diff --git a/cmd/importcombinedjson.go b/cmd/importcombinedjson.go index 08b6b48..afd2bc9 100644 --- a/cmd/importcombinedjson.go +++ b/cmd/importcombinedjson.go @@ -44,7 +44,7 @@ type CombinedJSON struct { RollupGasTokenAddress common.Address `json:"gasTokenAddress"` DACAddress common.Address `json:"polygonDataCommitteeAddress"` BatchL2Data string `json:"batchL2Data,omitempty"` - LastGlobalExitRoot common.Hash `json:"globalExitRoot,omitempty"` + RollupGlobalExitRoot common.Hash `json:"globalExitRoot,omitempty"` } func importCombinedJson(cliCtx *cli.Context) error { @@ -77,9 +77,9 @@ func importCombinedJson(cliCtx *cli.Context) error { } var ( - dacAddr common.Address - batchL2Data string - lastGlobalExitRoot common.Hash + dacAddr common.Address + batchL2Data string + rollupGlobalExitRoot common.Hash ) switch rollupMetadata.VerifierType { @@ -94,7 +94,7 @@ func importCombinedJson(cliCtx *cli.Context) error { return fmt.Errorf("failed to retrieve batch l2 data %w", err) } - lastGlobalExitRoot, err = r.GetLastGlobalExitRoot(rollupManager, client) + rollupGlobalExitRoot, err = r.GetRollupGlobalExitRoot(rollupManager, client) if err != nil { return fmt.Errorf("failed to retrieve batch l2 data %w", err) } @@ -128,7 +128,7 @@ func importCombinedJson(cliCtx *cli.Context) error { RollupGasTokenAddress: rollupMetadata.GasToken, DACAddress: dacAddr, BatchL2Data: batchL2Data, - LastGlobalExitRoot: lastGlobalExitRoot, + RollupGlobalExitRoot: rollupGlobalExitRoot, } raw, err := json.MarshalIndent(combinedJson, "", " ") diff --git a/rollup/rollup_pessimistic_proofs.go b/rollup/rollup_pessimistic_proofs.go index a8f44a9..71ea0d3 100644 --- a/rollup/rollup_pessimistic_proofs.go +++ b/rollup/rollup_pessimistic_proofs.go @@ -116,8 +116,8 @@ func (r *RollupPessimisticProofs) GetBatchL2Data(client bind.ContractBackend) (s return hexutil.Encode(rawTxWithSignature), nil } -// GetLastGlobalExitRoot retrieves the last global exit root from global exit root manager -func (r *RollupPessimisticProofs) GetLastGlobalExitRoot(rm *rollupmanager.RollupManager, client bind.ContractBackend) (common.Hash, error) { +// GetRollupGlobalExitRoot retrieves the actual global exit root at the rollup creation time +func (r *RollupPessimisticProofs) GetRollupGlobalExitRoot(rm *rollupmanager.RollupManager, client bind.ContractBackend) (common.Hash, error) { gerContract, err := polygonzkevmglobalexitrootv2.NewPolygonzkevmglobalexitrootv2(rm.GERAddr, client) if err != nil { return common.Hash{}, err @@ -128,12 +128,17 @@ func (r *RollupPessimisticProofs) GetLastGlobalExitRoot(rm *rollupmanager.Rollup } endBlock := r.CreationBlock - 1 - iter, err := gerContract.FilterUpdateL1InfoTree( - &bind.FilterOpts{ - Start: rm.UpdateToULxLyBlock, - End: &endBlock, - }, nil, nil) + if endBlock < rm.UpdateToULxLyBlock { + return common.Hash{}, fmt.Errorf("end block (%d) is less than starting block (%d) in UpdateL1InfoTree filter", + rm.UpdateToULxLyBlock, endBlock) + } + + filter := &bind.FilterOpts{ + Start: rm.UpdateToULxLyBlock, + End: &endBlock, + } + iter, err := gerContract.FilterUpdateL1InfoTree(filter, nil, nil) if err != nil { return common.Hash{}, err }