diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index a7dc7f26f9..47fafba2e2 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -774,7 +774,7 @@ func applyChainParameters(ctx context.Context, k *koanf.Koanf, chainId uint64, c if chainInfo.ParentChainIsArbitrum != nil { parentChainIsArbitrum = *chainInfo.ParentChainIsArbitrum } else { - log.Warn("Chain information parentChainIsArbitrum field missing, in the future this will be required", "chainId", chainId, "parentChainId", chainInfo.ParentChainId) + log.Warn("Chain information parentChainIsArbitrum field missing, in the future this will be required", "chainId", chainInfo.ChainConfig.ChainID, "parentChainId", chainInfo.ParentChainId) _, err := chaininfo.ProcessChainInfo(chainInfo.ParentChainId, "", combinedL2ChainInfoFiles, "") if err == nil { parentChainIsArbitrum = true diff --git a/go-ethereum b/go-ethereum index 3f2e789b38..45efc8230c 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 3f2e789b3857ccdd647c319e16f1a00805d1d6bd +Subproject commit 45efc8230c2561cf56652dabccdd670101f75b0c diff --git a/nodeInterface/NodeInterface.go b/nodeInterface/NodeInterface.go index 6984255393..f13f8ce6c0 100644 --- a/nodeInterface/NodeInterface.go +++ b/nodeInterface/NodeInterface.go @@ -598,6 +598,9 @@ func (n NodeInterface) BlockL1Num(c ctx, evm mech, l2BlockNum uint64) (uint64, e if err != nil { return 0, err } + if blockHeader == nil { + return 0, fmt.Errorf("nil header for l2 block: %d", l2BlockNum) + } blockL1Num := types.DeserializeHeaderExtraInformation(blockHeader).L1BlockNumber return blockL1Num, nil } diff --git a/system_tests/nodeinterface_test.go b/system_tests/nodeinterface_test.go index 63b3d7bb7b..167f2204cd 100644 --- a/system_tests/nodeinterface_test.go +++ b/system_tests/nodeinterface_test.go @@ -30,40 +30,46 @@ func TestL2BlockRangeForL1(t *testing.T) { } nodeInterface, err := node_interfacegen.NewNodeInterface(types.NodeInterfaceAddress, l2client) - Require(t, err) + if err != nil { + t.Fatalf("Error creating node interface: %v", err) + } l1BlockNums := map[uint64]*[2]uint64{} latestL2, err := l2client.BlockNumber(ctx) - Require(t, err) + if err != nil { + t.Fatalf("Error querying most recent l2 block: %v", err) + } for l2BlockNum := uint64(0); l2BlockNum <= latestL2; l2BlockNum++ { l1BlockNum, err := nodeInterface.BlockL1Num(&bind.CallOpts{}, l2BlockNum) - Require(t, err) + if err != nil { + t.Fatalf("Error quering l1 block number for l2 block: %d, error: %v", l2BlockNum, err) + } if _, ok := l1BlockNums[l1BlockNum]; !ok { l1BlockNums[l1BlockNum] = &[2]uint64{l2BlockNum, l2BlockNum} - } else { - l1BlockNums[l1BlockNum][1] = l2BlockNum } + l1BlockNums[l1BlockNum][1] = l2BlockNum } - // Test success + // Test success. for l1BlockNum := range l1BlockNums { rng, err := nodeInterface.L2BlockRangeForL1(&bind.CallOpts{}, l1BlockNum) - Require(t, err) + if err != nil { + t.Fatalf("Error getting l2 block range for l1 block: %d, error: %v", l1BlockNum, err) + } expected := l1BlockNums[l1BlockNum] if rng.FirstBlock != expected[0] || rng.LastBlock != expected[1] { unexpectedL1BlockNum, err := nodeInterface.BlockL1Num(&bind.CallOpts{}, rng.LastBlock) - Require(t, err) + if err != nil { + t.Fatalf("Error quering l1 block number for l2 block: %d, error: %v", rng.LastBlock, err) + } // Handle the edge case when new l2 blocks are produced between latestL2 was last calculated and now. if unexpectedL1BlockNum != l1BlockNum || rng.LastBlock < expected[1] || rng.FirstBlock != expected[0] { t.Errorf("L2BlockRangeForL1(%d) = (%d %d) want (%d %d)", l1BlockNum, rng.FirstBlock, rng.LastBlock, expected[0], expected[1]) } } } - // Test invalid case - finalValidL1BlockNumber, err := nodeInterface.BlockL1Num(&bind.CallOpts{}, latestL2) - Require(t, err) - if _, err := nodeInterface.L2BlockRangeForL1(&bind.CallOpts{}, finalValidL1BlockNumber+1); err == nil { + // Test invalid case. + if _, err := nodeInterface.L2BlockRangeForL1(&bind.CallOpts{}, 1e5); err == nil { t.Fatalf("GetL2BlockRangeForL1 didn't fail for an invalid input") } - }