Skip to content

Commit

Permalink
Merge pull request #2059 from OffchainLabs/fix-node-interface
Browse files Browse the repository at this point in the history
Fix broken NodeInterface methods
  • Loading branch information
PlasmaPower authored Dec 27, 2023
2 parents 66d00da + 966a172 commit 2f9c34d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion execution/gethexec/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func CreateExecutionNode(
}

func (n *ExecutionNode) Initialize(ctx context.Context, arbnode interface{}, sync arbitrum.SyncProgressBackend) error {
n.ArbInterface.Initialize(n)
n.ArbInterface.Initialize(arbnode)
err := n.Backend.Start()
if err != nil {
return fmt.Errorf("error starting geth backend: %w", err)
Expand Down
37 changes: 37 additions & 0 deletions system_tests/nodeinterface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/offchainlabs/nitro/arbos/util"
"github.com/offchainlabs/nitro/solgen/go/node_interfacegen"
Expand Down Expand Up @@ -73,3 +74,39 @@ func TestL2BlockRangeForL1(t *testing.T) {
t.Fatalf("GetL2BlockRangeForL1 didn't fail for an invalid input")
}
}

func TestGetL1Confirmations(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

builder := NewNodeBuilder(ctx).DefaultConfig(t, true)
cleanup := builder.Build(t)
defer cleanup()

nodeInterface, err := node_interfacegen.NewNodeInterface(types.NodeInterfaceAddress, builder.L2.Client)
Require(t, err)

genesisBlock, err := builder.L2.Client.BlockByNumber(ctx, big.NewInt(0))
Require(t, err)
l1Confs, err := nodeInterface.GetL1Confirmations(&bind.CallOpts{}, genesisBlock.Hash())
Require(t, err)

numTransactions := 200

if l1Confs >= uint64(numTransactions) {
t.Fatalf("L1Confirmations for latest block %v is already %v (over %v)", genesisBlock.Number(), l1Confs, numTransactions)
}

for i := 0; i < numTransactions; i++ {
builder.L1.TransferBalance(t, "User", "User", common.Big0, builder.L1Info)
}

l1Confs, err = nodeInterface.GetL1Confirmations(&bind.CallOpts{}, genesisBlock.Hash())
Require(t, err)

// Allow a gap of 10 for asynchronicity, just in case
if l1Confs+10 < uint64(numTransactions) {
t.Fatalf("L1Confirmations for latest block %v is only %v (did not hit expected %v)", genesisBlock.Number(), l1Confs, numTransactions)
}
}

0 comments on commit 2f9c34d

Please sign in to comment.