diff --git a/.circleci/config.yml b/.circleci/config.yml index 61c4d247fd..1b15c54a05 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ jobs: # This job builds the hive executable and stores it in the workspace. build: docker: - - image: cimg/go:1.18 + - image: cimg/go:1.19 steps: # Build it. - checkout @@ -25,7 +25,7 @@ jobs: # to be able to talk to the docker containers it creates. run-hive-sim: machine: - image: ubuntu-2004:202201-02 + image: ubuntu-2204:2022.07.1 docker_layer_caching: true parameters: sim: @@ -63,7 +63,7 @@ jobs: # This job runs the go unit tests. go-test: docker: - - image: cimg/go:1.18 + - image: cimg/go:1.19 steps: # Get the source. - checkout @@ -120,4 +120,4 @@ workflows: - build - run-hive-sim: requires: ["build"] - context: slack \ No newline at end of file + context: slack diff --git a/clients/op-geth/entrypoint.sh b/clients/op-geth/entrypoint.sh index 8fcbbf8718..94cca4f5d9 100644 --- a/clients/op-geth/entrypoint.sh +++ b/clients/op-geth/entrypoint.sh @@ -24,6 +24,16 @@ fi GAS_LIMIT_HEX=$(jq -r .gasLimit < /genesis.json | sed s/0x//i | tr '[:lower:]' '[:upper:]') GAS_LIMIT=$(echo "obase=10; ibase=16; $GAS_LIMIT_HEX" | bc) + +EXTRA_FLAGS="--rollup.disabletxpoolgossip=true" + +# We check for env variables that may not be bound so we need to disable `set -u` for this section. +set +u +if [ "$HIVE_OP_GETH_SEQUENCER_HTTP" != "" ]; then + EXTRA_FLAGS="$EXTRA_FLAGS --rollup.sequencerhttp $HIVE_OP_GETH_SEQUENCER_HTTP" +fi +set -u + # Warning: Archive mode is required, otherwise old trie nodes will be # pruned within minutes of starting the devnet. @@ -52,5 +62,5 @@ geth \ --password="$GETH_DATA_DIR"/password \ --allow-insecure-unlock \ --gcmode=archive \ - --rollup.disabletxpoolgossip=true \ + $EXTRA_FLAGS \ "$@" diff --git a/simulators/optimism/p2p/main.go b/simulators/optimism/p2p/main.go index 21643fc5eb..8e5d5e01b8 100644 --- a/simulators/optimism/p2p/main.go +++ b/simulators/optimism/p2p/main.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum-optimism/optimism/op-node/eth" "github.com/ethereum-optimism/optimism/op-node/rollup/driver" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" "github.com/stretchr/testify/require" @@ -32,11 +33,90 @@ func main() { Description: `This suite runs the a testnet with P2P set up`, Run: func(t *hivesim.T) { runP2PTests(t) }, }) + suite.Add(&hivesim.TestSpec{ + Name: "tx forwarding", + Description: `This test verifies that tx forwarding works`, + Run: func(t *hivesim.T) { txForwardingTest(t) }, + }) sim := hivesim.New() hivesim.MustRunSuite(sim, suite) } +// txForwardingTest verifies that a transaction submitted to a replica with tx forwarding enabled shows up on the sequencer. +// TODO: The transaction shows up with `getTransaction`, but it remains pending and is not mined for some reason. +// This is weird, but fine because it still shows that the transaction is received by the sequencer. +func txForwardingTest(t *hivesim.T) { + d := optimism.NewDevnet(t) + sender := d.L2Vault.GenerateKey() + receiver := d.L2Vault.GenerateKey() + d.InitChain(30, 4, 30, core.GenesisAlloc{sender: {Balance: big.NewInt(params.Ether)}}) + d.AddEth1() + d.WaitUpEth1(0, time.Second*10) + + d.AddOpL2() + d.AddOpNode(0, 0, true) + seqNode := d.GetOpL2Engine(0) + seqClient := d.GetOpL2Engine(0).EthClient() + + d.AddOpL2(hivesim.Params{"HIVE_OP_GETH_SEQUENCER_HTTP": seqNode.HttpRpcEndpoint()}) + d.AddOpNode(0, 1, false) + + d.AddOpBatcher(0, 0, 0, optimism.HiveUnpackParams{}.Params()) + d.AddOpProposer(0, 0, 0) + + var wg sync.WaitGroup + wg.Add(2) + + go func() { + d.WaitUpOpL2Engine(0, time.Second*10) + wg.Done() + }() + go func() { + d.WaitUpOpL2Engine(1, time.Second*10) + wg.Done() + }() + + t.Log("waiting for nodes to come up") + wg.Wait() + + verifClient := d.GetOpL2Engine(1).EthClient() + + baseTx := types.NewTx(&types.DynamicFeeTx{ + ChainID: optimism.L2ChainIDBig, + Nonce: 0, + To: &receiver, + Gas: 75000, + GasTipCap: big.NewInt(1), + GasFeeCap: big.NewInt(2), + Value: big.NewInt(0.0001 * params.Ether), + }) + + tx, err := d.L2Vault.SignTransaction(sender, baseTx) + require.Nil(t, err) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + require.NoError(t, verifClient.SendTransaction(ctx, tx)) + t.Log("sent tx to verifier, waiting for propagation") + + <-time.After(10 * time.Second) + + ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + _, isPending, err := seqClient.TransactionByHash(ctx, tx.Hash()) + if err != nil { + t.Fatal("transaction did not propagate") + } + t.Logf("found transaction on sequencer, isPending: %v", isPending) + + // TODO: The transaction is not getting mined on the sequencer + // At least it did show up on the sequencer. + // ctx, cancel = context.WithTimeout(context.Background(), 20*time.Second) + // defer cancel() + // _, err = optimism.WaitReceiptOK(ctx, seqClient, tx.Hash()) + // require.Nil(t, err) // tx should show up on the sequencer +} + // runP2PTests runs the P2P tests between the sequencer and verifier. func runP2PTests(t *hivesim.T) { d := optimism.NewDevnet(t)