Skip to content

Commit

Permalink
Query rootchain block number before rootchain contracts deployment(#1742
Browse files Browse the repository at this point in the history
)
  • Loading branch information
rzmahmood committed Jul 31, 2023
1 parent f5393c1 commit 3070ee0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions command/rootchain/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,16 @@ func runCommand(cmd *cobra.Command, _ []string) {
}
}

// set event tracker start blocks for rootchain contract(s) of interest
// the block number should be queried before deploying contracts so that no events during deployment
// and initialization are missed
blockNum, err := client.Eth().BlockNumber()
if err != nil {
outputter.SetError(fmt.Errorf("failed to query rootchain latest block number: %w", err))

return
}

deploymentResultInfo, err := deployContracts(outputter, client,
chainConfig.Params.ChainID, consensusCfg.InitialValidatorSet, cmd.Context())
if err != nil {
Expand All @@ -363,14 +373,6 @@ func runCommand(cmd *cobra.Command, _ []string) {

consensusCfg.Bridge = bridgeConfig

// set event tracker start blocks for rootchain contract(s) of interest
blockNum, err := client.Eth().BlockNumber()
if err != nil {
outputter.SetError(fmt.Errorf("failed to query rootchain latest block number: %w", err))

return
}

consensusCfg.Bridge.EventTrackerStartBlocks = map[types.Address]uint64{
deploymentResultInfo.RootchainCfg.StateSenderAddress: blockNum,
}
Expand Down

0 comments on commit 3070ee0

Please sign in to comment.