Commit 1a1ab6ec authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

op-e2e: Expose context in supersystem op-e2e (#13135)

When any of the setup transactions in `TestInterop_EmitLogs` fail to be mined, the test hangs until it times out. See [here](https://app.circleci.com/pipelines/github/ethereum-optimism/optimism/73118/workflows/b48debaa-55bc-4138-a419-a87c236cbc58/jobs/2994655/artifacts) for an example. This PR updates the SuperSystem API to take a context from the test itself to allow for timeouts.
parent 8f31e601
...@@ -121,7 +121,9 @@ func TestInterop_EmitLogs(t *testing.T) { ...@@ -121,7 +121,9 @@ func TestInterop_EmitLogs(t *testing.T) {
var emitParallel sync.WaitGroup var emitParallel sync.WaitGroup
emitOn := func(chainID string) { emitOn := func(chainID string) {
for i := 0; i < numEmits; i++ { for i := 0; i < numEmits; i++ {
s2.EmitData(chainID, "Alice", payload1) ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
s2.EmitData(ctx, chainID, "Alice", payload1)
cancel()
} }
emitParallel.Done() emitParallel.Done()
} }
...@@ -218,7 +220,9 @@ func TestInteropBlockBuilding(t *testing.T) { ...@@ -218,7 +220,9 @@ func TestInteropBlockBuilding(t *testing.T) {
// Add chain A as dependency to chain B, // Add chain A as dependency to chain B,
// such that we can execute a message on B that was initiated on A. // such that we can execute a message on B that was initiated on A.
depRec := s2.AddDependency(chainB, s2.ChainID(chainA)) ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
depRec := s2.AddDependency(ctx, chainB, s2.ChainID(chainA))
cancel()
t.Logf("Dependency set in L1 block %d", depRec.BlockNumber) t.Logf("Dependency set in L1 block %d", depRec.BlockNumber)
rollupClA, err := dial.DialRollupClientWithTimeout(context.Background(), time.Second*15, logger, s2.OpNode(chainA).UserRPC().RPC()) rollupClA, err := dial.DialRollupClientWithTimeout(context.Background(), time.Second*15, logger, s2.OpNode(chainA).UserRPC().RPC())
...@@ -233,7 +237,9 @@ func TestInteropBlockBuilding(t *testing.T) { ...@@ -233,7 +237,9 @@ func TestInteropBlockBuilding(t *testing.T) {
t.Log("Dependency information has been processed in L2 block") t.Log("Dependency information has been processed in L2 block")
// emit log on chain A // emit log on chain A
emitRec := s2.EmitData(chainA, "Alice", "hello world") ctx, cancel = context.WithTimeout(context.Background(), 30*time.Second)
emitRec := s2.EmitData(ctx, chainA, "Alice", "hello world")
cancel()
t.Logf("Emitted a log event in block %d", emitRec.BlockNumber.Uint64()) t.Logf("Emitted a log event in block %d", emitRec.BlockNumber.Uint64())
// Wait for initiating side to become cross-unsafe // Wait for initiating side to become cross-unsafe
......
...@@ -103,9 +103,9 @@ type SuperSystem interface { ...@@ -103,9 +103,9 @@ type SuperSystem interface {
// Deploy the Emitter Contract, which emits Event Logs // Deploy the Emitter Contract, which emits Event Logs
DeployEmitterContract(network string, username string) common.Address DeployEmitterContract(network string, username string) common.Address
// Use the Emitter Contract to emit an Event Log // Use the Emitter Contract to emit an Event Log
EmitData(network string, username string, data string) *types.Receipt EmitData(ctx context.Context, network string, username string, data string) *types.Receipt
// AddDependency adds a dependency (by chain ID) to the given chain // AddDependency adds a dependency (by chain ID) to the given chain
AddDependency(network string, dep *big.Int) *types.Receipt AddDependency(ctx context.Context, network string, dep *big.Int) *types.Receipt
// ExecuteMessage calls the CrossL2Inbox executeMessage function // ExecuteMessage calls the CrossL2Inbox executeMessage function
ExecuteMessage( ExecuteMessage(
ctx context.Context, ctx context.Context,
...@@ -767,7 +767,7 @@ func (s *interopE2ESystem) ExecuteMessage( ...@@ -767,7 +767,7 @@ func (s *interopE2ESystem) ExecuteMessage(
return bind.WaitMined(ctx, s.L2GethClient(id), tx) return bind.WaitMined(ctx, s.L2GethClient(id), tx)
} }
func (s *interopE2ESystem) AddDependency(id string, dep *big.Int) *types.Receipt { func (s *interopE2ESystem) AddDependency(ctx context.Context, id string, dep *big.Int) *types.Receipt {
// There is a note in OPContractsManagerInterop that the proxy-admin is used for now, // There is a note in OPContractsManagerInterop that the proxy-admin is used for now,
// even though it should be a separate dependency-set-manager address. // even though it should be a separate dependency-set-manager address.
secret, err := s.hdWallet.Secret(devkeys.ChainOperatorKey{ secret, err := s.hdWallet.Secret(devkeys.ChainOperatorKey{
...@@ -779,7 +779,7 @@ func (s *interopE2ESystem) AddDependency(id string, dep *big.Int) *types.Receipt ...@@ -779,7 +779,7 @@ func (s *interopE2ESystem) AddDependency(id string, dep *big.Int) *types.Receipt
auth, err := bind.NewKeyedTransactorWithChainID(secret, s.worldOutput.L1.Genesis.Config.ChainID) auth, err := bind.NewKeyedTransactorWithChainID(secret, s.worldOutput.L1.Genesis.Config.ChainID)
require.NoError(s.t, err) require.NoError(s.t, err)
balance, err := s.l1GethClient.BalanceAt(context.Background(), crypto.PubkeyToAddress(secret.PublicKey), nil) balance, err := s.l1GethClient.BalanceAt(ctx, crypto.PubkeyToAddress(secret.PublicKey), nil)
require.NoError(s.t, err) require.NoError(s.t, err)
require.False(s.t, balance.Sign() == 0, "system config owner needs a balance") require.False(s.t, balance.Sign() == 0, "system config owner needs a balance")
...@@ -790,7 +790,7 @@ func (s *interopE2ESystem) AddDependency(id string, dep *big.Int) *types.Receipt ...@@ -790,7 +790,7 @@ func (s *interopE2ESystem) AddDependency(id string, dep *big.Int) *types.Receipt
tx, err := contract.SystemconfigTransactor.AddDependency(auth, dep) tx, err := contract.SystemconfigTransactor.AddDependency(auth, dep)
require.NoError(s.t, err) require.NoError(s.t, err)
receipt, err := wait.ForReceiptOK(context.Background(), s.L1GethClient(), tx.Hash()) receipt, err := wait.ForReceiptOK(ctx, s.L1GethClient(), tx.Hash())
require.NoError(s.t, err) require.NoError(s.t, err)
return receipt return receipt
} }
...@@ -813,6 +813,7 @@ func (s *interopE2ESystem) DeployEmitterContract( ...@@ -813,6 +813,7 @@ func (s *interopE2ESystem) DeployEmitterContract(
} }
func (s *interopE2ESystem) EmitData( func (s *interopE2ESystem) EmitData(
ctx context.Context,
id string, id string,
sender string, sender string,
data string, data string,
...@@ -828,7 +829,7 @@ func (s *interopE2ESystem) EmitData( ...@@ -828,7 +829,7 @@ func (s *interopE2ESystem) EmitData(
contract := s.Contract(id, "emitter").(*emit.Emit) contract := s.Contract(id, "emitter").(*emit.Emit)
tx, err := contract.EmitTransactor.EmitData(auth, []byte(data)) tx, err := contract.EmitTransactor.EmitData(auth, []byte(data))
require.NoError(s.t, err) require.NoError(s.t, err)
receipt, err := bind.WaitMined(context.Background(), s.L2GethClient(id), tx) receipt, err := bind.WaitMined(ctx, s.L2GethClient(id), tx)
require.NoError(s.t, err) require.NoError(s.t, err)
return receipt return receipt
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment