Skip to content

Commit

Permalink
populate l1chainID with l2chainID
Browse files Browse the repository at this point in the history
  • Loading branch information
rachit77 committed Jan 14, 2025
1 parent ff9ce60 commit abe8bf7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions aggoracle/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,11 @@ type Config struct {
// BlockFinality indicates the status of the blocks that will be queried in order to sync
BlockFinality string `jsonschema:"enum=LatestBlock, enum=SafeBlock, enum=PendingBlock, enum=FinalizedBlock, enum=EarliestBlock" mapstructure:"BlockFinality"` //nolint:lll
WaitPeriodNextGER types.Duration `mapstructure:"WaitPeriodNextGER"`
L2ChainID uint64 `mapstructure:"L2ChainID"`
EVMSender chaingersender.EVMConfig `mapstructure:"EVMSender"`
}

// ApplyL2ChainID copies L2ChainID to the L1ChainID in the Etherman config
func (c *Config) ApplyL2ChainID(l2ChainID uint64) {
c.EVMSender.EthTxManager.Etherman.L1ChainID = l2ChainID
}
10 changes: 10 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,16 @@ func createAggoracle(
syncer *l1infotreesync.L1InfoTreeSync,
) *aggoracle.AggOracle {
logger := log.WithFields("module", cdkcommon.AGGORACLE)
ethermanClient, err := etherman.NewClient(cfg.Etherman, cfg.NetworkConfig.L1Config, cfg.Common)
if err != nil {
logger.Fatal(err)
}
l2ChainID, err := ethermanClient.GetL2ChainID()
if err != nil {
logger.Fatal(err)
}
cfg.AggOracle.ApplyL2ChainID(l2ChainID)

var sender aggoracle.ChainSender
switch cfg.AggOracle.TargetChainType {
case aggoracle.EVMChain:
Expand Down
3 changes: 2 additions & 1 deletion config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ TargetChainType="EVM"
URLRPCL1="{{L1URL}}"
BlockFinality="FinalizedBlock"
WaitPeriodNextGER="100ms"
# L2ChainID is populated on runtime
L2ChainID=0
[AggOracle.EVMSender]
GlobalExitRootL2="{{L2Config.GlobalExitRootAddr}}"
URLRPCL2="{{L2URL}}"
Expand All @@ -246,7 +248,6 @@ WaitPeriodNextGER="100ms"
[AggOracle.EVMSender.EthTxManager.Etherman]
URL = "{{L2URL}}"
MultiGasProvider = false
L1ChainID = {{NetworkConfig.L1.L1ChainID}}
HTTPHeaders = []
[RPC]
Expand Down

0 comments on commit abe8bf7

Please sign in to comment.