Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -120,4 +120,4 @@ workflows:
- build
- run-hive-sim:
requires: ["build"]
context: slack
context: slack
12 changes: 11 additions & 1 deletion clients/op-geth/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -52,5 +62,5 @@ geth \
--password="$GETH_DATA_DIR"/password \
--allow-insecure-unlock \
--gcmode=archive \
--rollup.disabletxpoolgossip=true \
$EXTRA_FLAGS \
"$@"
80 changes: 80 additions & 0 deletions simulators/optimism/p2p/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down