From 1bc41f2162c7151f09af9f16bcdd8687f3010b73 Mon Sep 17 00:00:00 2001 From: pcw109550 Date: Thu, 18 Apr 2024 16:03:50 -0600 Subject: [PATCH] op-e2e: Expose methods for asterisc e2e --- op-e2e/e2eutils/challenger/helper.go | 6 ++-- op-e2e/faultproofs/challenge_preimage_test.go | 6 ++-- op-e2e/faultproofs/multi_test.go | 2 +- op-e2e/faultproofs/output_alphabet_test.go | 16 +++++----- op-e2e/faultproofs/output_cannon_test.go | 32 +++++++++---------- op-e2e/faultproofs/preimages_test.go | 2 +- op-e2e/faultproofs/util.go | 12 +++---- 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/op-e2e/e2eutils/challenger/helper.go b/op-e2e/e2eutils/challenger/helper.go index 92851a75cf24e..39dbeda65589e 100644 --- a/op-e2e/e2eutils/challenger/helper.go +++ b/op-e2e/e2eutils/challenger/helper.go @@ -76,9 +76,9 @@ func WithPollInterval(pollInterval time.Duration) Option { } } -// findMonorepoRoot finds the relative path to the monorepo root +// FindMonorepoRoot finds the relative path to the monorepo root // Different tests might be nested in subdirectories of the op-e2e dir. -func findMonorepoRoot(t *testing.T) string { +func FindMonorepoRoot(t *testing.T) string { path := "./" // Only search up 5 directories // Avoids infinite recursion if the root isn't found for some reason @@ -104,7 +104,7 @@ func applyCannonConfig( ) { require := require.New(t) c.L2Rpc = l2Endpoint - root := findMonorepoRoot(t) + root := FindMonorepoRoot(t) c.CannonBin = root + "cannon/bin/cannon" c.CannonServer = root + "op-program/bin/op-program" c.CannonAbsolutePreState = root + "op-program/bin/prestate.json" diff --git a/op-e2e/faultproofs/challenge_preimage_test.go b/op-e2e/faultproofs/challenge_preimage_test.go index f071580b51aee..445bcf50c8077 100644 --- a/op-e2e/faultproofs/challenge_preimage_test.go +++ b/op-e2e/faultproofs/challenge_preimage_test.go @@ -15,7 +15,7 @@ import ( func TestChallengeLargePreimages_ChallengeFirst(t *testing.T) { op_e2e.InitParallel(t) ctx := context.Background() - sys, _ := startFaultDisputeSystem(t) + sys, _ := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -34,7 +34,7 @@ func TestChallengeLargePreimages_ChallengeFirst(t *testing.T) { func TestChallengeLargePreimages_ChallengeMiddle(t *testing.T) { op_e2e.InitParallel(t) ctx := context.Background() - sys, _ := startFaultDisputeSystem(t) + sys, _ := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) disputeGameFactory.StartChallenger(ctx, "Challenger", @@ -52,7 +52,7 @@ func TestChallengeLargePreimages_ChallengeMiddle(t *testing.T) { func TestChallengeLargePreimages_ChallengeLast(t *testing.T) { op_e2e.InitParallel(t) ctx := context.Background() - sys, _ := startFaultDisputeSystem(t) + sys, _ := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) disputeGameFactory.StartChallenger(ctx, "Challenger", diff --git a/op-e2e/faultproofs/multi_test.go b/op-e2e/faultproofs/multi_test.go index 0db4167cf4923..a2a171adc875c 100644 --- a/op-e2e/faultproofs/multi_test.go +++ b/op-e2e/faultproofs/multi_test.go @@ -14,7 +14,7 @@ func TestMultipleGameTypes(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, _ := startFaultDisputeSystem(t) + sys, _ := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) gameFactory := disputegame.NewFactoryHelper(t, ctx, sys) diff --git a/op-e2e/faultproofs/output_alphabet_test.go b/op-e2e/faultproofs/output_alphabet_test.go index e87049b9c2e95..8aa89426ed6d6 100644 --- a/op-e2e/faultproofs/output_alphabet_test.go +++ b/op-e2e/faultproofs/output_alphabet_test.go @@ -19,7 +19,7 @@ import ( func TestOutputAlphabetGame_ChallengerWins(t *testing.T) { op_e2e.InitParallel(t) ctx := context.Background() - sys, l1Client := startFaultDisputeSystem(t) + sys, l1Client := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -76,7 +76,7 @@ func TestOutputAlphabetGame_ChallengerWins(t *testing.T) { func TestOutputAlphabetGame_ReclaimBond(t *testing.T) { op_e2e.InitParallel(t) ctx := context.Background() - sys, l1Client := startFaultDisputeSystem(t) + sys, l1Client := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -84,7 +84,7 @@ func TestOutputAlphabetGame_ReclaimBond(t *testing.T) { game.LogGameData(ctx) // The dispute game should have a zero balance - balance := game.WethBalance(ctx, game.Addr()) + balance := game.WethBalance(ctx, game.Addr) require.Zero(t, balance.Uint64()) alice := sys.Cfg.Secrets.Addresses().Alice @@ -106,7 +106,7 @@ func TestOutputAlphabetGame_ReclaimBond(t *testing.T) { _ = claim.WaitForCounterClaim(ctx) // Expect posted claims so the game balance is non-zero - balance = game.WethBalance(ctx, game.Addr()) + balance = game.WethBalance(ctx, game.Addr) require.Truef(t, balance.Cmp(big.NewInt(0)) > 0, "Expected game balance to be above zero") sys.TimeTravelClock.AdvanceTime(game.GameDuration(ctx)) @@ -131,13 +131,13 @@ func TestOutputAlphabetGame_ReclaimBond(t *testing.T) { game.WaitForNoAvailableCredit(ctx, alice) // The dispute game delayed weth balance should be zero since it's all claimed - require.True(t, game.WethBalance(ctx, game.Addr()).Cmp(big.NewInt(0)) == 0) + require.True(t, game.WethBalance(ctx, game.Addr).Cmp(big.NewInt(0)) == 0) } func TestOutputAlphabetGame_ValidOutputRoot(t *testing.T) { op_e2e.InitParallel(t) ctx := context.Background() - sys, l1Client := startFaultDisputeSystem(t) + sys, l1Client := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -170,7 +170,7 @@ func TestChallengerCompleteExhaustiveDisputeGame(t *testing.T) { testCase := func(t *testing.T, isRootCorrect bool) { ctx := context.Background() - sys, l1Client := startFaultDisputeSystem(t) + sys, l1Client := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -235,7 +235,7 @@ func TestChallengerCompleteExhaustiveDisputeGame(t *testing.T) { func TestOutputAlphabetGame_FreeloaderEarnsNothing(t *testing.T) { op_e2e.InitParallel(t) ctx := context.Background() - sys, l1Client := startFaultDisputeSystem(t) + sys, l1Client := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) freeloaderOpts, err := bind.NewKeyedTransactorWithChainID(sys.Cfg.Secrets.Mallory, sys.Cfg.L1ChainIDBig()) diff --git a/op-e2e/faultproofs/output_cannon_test.go b/op-e2e/faultproofs/output_cannon_test.go index 5ec43611956be..183eea1b79812 100644 --- a/op-e2e/faultproofs/output_cannon_test.go +++ b/op-e2e/faultproofs/output_cannon_test.go @@ -21,7 +21,7 @@ import ( func TestOutputCannonGame(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, l1Client := startFaultDisputeSystem(t) + sys, l1Client := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -77,7 +77,7 @@ func TestOutputCannon_ChallengeAllZeroClaim(t *testing.T) { // The dishonest actor always posts claims with all zeros. op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, l1Client := startFaultDisputeSystem(t) + sys, l1Client := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -116,7 +116,7 @@ func TestOutputCannon_PublishCannonRootClaim(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, _ := startFaultDisputeSystem(t) + sys, _ := StartFaultDisputeSystem(t) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) game := disputeGameFactory.StartOutputCannonGame(ctx, "sequencer", test.disputeL2BlockNumber, common.Hash{0x01}) @@ -147,7 +147,7 @@ func TestOutputCannonDisputeGame(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, l1Client := startFaultDisputeSystem(t) + sys, l1Client := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -184,7 +184,7 @@ func TestOutputCannonDefendStep(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, l1Client := startFaultDisputeSystem(t) + sys, l1Client := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -220,7 +220,7 @@ func TestOutputCannonStepWithLargePreimage(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, _ := startFaultDisputeSystem(t, withBatcherStopped()) + sys, _ := StartFaultDisputeSystem(t, WithBatcherStopped()) t.Cleanup(sys.Close) // Manually send a tx from the correct batcher key to the batcher input with very large (invalid) data @@ -263,7 +263,7 @@ func TestOutputCannonStepWithPreimage(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, _ := startFaultDisputeSystem(t, withBlobBatches()) + sys, _ := StartFaultDisputeSystem(t, WithBlobBatches()) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -306,7 +306,7 @@ func TestOutputCannonStepWithKZGPointEvaluation(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, _ := startFaultDisputeSystem(t, withEcotone()) + sys, _ := StartFaultDisputeSystem(t, WithEcotone()) t.Cleanup(sys.Close) // NOTE: Flake prevention @@ -315,7 +315,7 @@ func TestOutputCannonStepWithKZGPointEvaluation(t *testing.T) { require.NoError(t, err) require.NoError(t, wait.ForSafeBlock(ctx, sys.RollupClient("sequencer"), safeBlock.NumberU64()+3)) - receipt := sendKZGPointEvaluationTx(t, sys, "sequencer", sys.Cfg.Secrets.Alice) + receipt := SendKZGPointEvaluationTx(t, sys, "sequencer", sys.Cfg.Secrets.Alice) precompileBlock := receipt.BlockNumber t.Logf("KZG Point Evaluation block number: %d", precompileBlock) @@ -406,7 +406,7 @@ func TestOutputCannonProposedOutputRootValid(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, l1Client := startFaultDisputeSystem(t) + sys, l1Client := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -440,7 +440,7 @@ func TestOutputCannonPoisonedPostState(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, l1Client := startFaultDisputeSystem(t) + sys, l1Client := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -504,7 +504,7 @@ func TestDisputeOutputRootBeyondProposedBlock_ValidOutputRoot(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, l1Client := startFaultDisputeSystem(t) + sys, l1Client := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -554,7 +554,7 @@ func TestDisputeOutputRootBeyondProposedBlock_InvalidOutputRoot(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, l1Client := startFaultDisputeSystem(t) + sys, l1Client := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -605,7 +605,7 @@ func TestDisputeOutputRoot_ChangeClaimedOutputRoot(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, l1Client := startFaultDisputeSystem(t) + sys, l1Client := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) @@ -693,7 +693,7 @@ func TestInvalidateUnsafeProposal(t *testing.T) { test := test t.Run(test.name, func(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) - sys, l1Client := startFaultDisputeSystem(t, withSequencerWindowSize(100000), withBatcherStopped()) + sys, l1Client := StartFaultDisputeSystem(t, WithSequencerWindowSize(100000), WithBatcherStopped()) t.Cleanup(sys.Close) blockNum := uint64(1) @@ -755,7 +755,7 @@ func TestInvalidateProposalForFutureBlock(t *testing.T) { test := test t.Run(test.name, func(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) - sys, l1Client := startFaultDisputeSystem(t, withSequencerWindowSize(100000)) + sys, l1Client := StartFaultDisputeSystem(t, WithSequencerWindowSize(100000)) t.Cleanup(sys.Close) farFutureBlockNum := uint64(10_000_000) diff --git a/op-e2e/faultproofs/preimages_test.go b/op-e2e/faultproofs/preimages_test.go index fd6032b83fa1b..03acf824daf36 100644 --- a/op-e2e/faultproofs/preimages_test.go +++ b/op-e2e/faultproofs/preimages_test.go @@ -32,7 +32,7 @@ func TestLocalPreimages(t *testing.T) { op_e2e.InitParallel(t, op_e2e.UsesCannon) ctx := context.Background() - sys, _ := startFaultDisputeSystem(t) + sys, _ := StartFaultDisputeSystem(t) t.Cleanup(sys.Close) disputeGameFactory := disputegame.NewFactoryHelper(t, ctx, sys) diff --git a/op-e2e/faultproofs/util.go b/op-e2e/faultproofs/util.go index 804c8f307a02c..df3a81131c775 100644 --- a/op-e2e/faultproofs/util.go +++ b/op-e2e/faultproofs/util.go @@ -15,13 +15,13 @@ import ( type faultDisputeConfigOpts func(cfg *op_e2e.SystemConfig) -func withBatcherStopped() faultDisputeConfigOpts { +func WithBatcherStopped() faultDisputeConfigOpts { return func(cfg *op_e2e.SystemConfig) { cfg.DisableBatcher = true } } -func withBlobBatches() faultDisputeConfigOpts { +func WithBlobBatches() faultDisputeConfigOpts { return func(cfg *op_e2e.SystemConfig) { cfg.DataAvailabilityType = batcherFlags.BlobsType @@ -32,7 +32,7 @@ func withBlobBatches() faultDisputeConfigOpts { } } -func withEcotone() faultDisputeConfigOpts { +func WithEcotone() faultDisputeConfigOpts { return func(cfg *op_e2e.SystemConfig) { genesisActivation := hexutil.Uint64(0) cfg.DeployConfig.L1CancunTimeOffset = &genesisActivation @@ -41,13 +41,13 @@ func withEcotone() faultDisputeConfigOpts { } } -func withSequencerWindowSize(size uint64) faultDisputeConfigOpts { +func WithSequencerWindowSize(size uint64) faultDisputeConfigOpts { return func(cfg *op_e2e.SystemConfig) { cfg.DeployConfig.SequencerWindowSize = size } } -func startFaultDisputeSystem(t *testing.T, opts ...faultDisputeConfigOpts) (*op_e2e.System, *ethclient.Client) { +func StartFaultDisputeSystem(t *testing.T, opts ...faultDisputeConfigOpts) (*op_e2e.System, *ethclient.Client) { cfg := op_e2e.DefaultSystemConfig(t) delete(cfg.Nodes, "verifier") for _, opt := range opts { @@ -64,7 +64,7 @@ func startFaultDisputeSystem(t *testing.T, opts ...faultDisputeConfigOpts) (*op_ return sys, sys.Clients["l1"] } -func sendKZGPointEvaluationTx(t *testing.T, sys *op_e2e.System, l2Node string, privateKey *ecdsa.PrivateKey) *types.Receipt { +func SendKZGPointEvaluationTx(t *testing.T, sys *op_e2e.System, l2Node string, privateKey *ecdsa.PrivateKey) *types.Receipt { return op_e2e.SendL2Tx(t, sys.Cfg, sys.Clients[l2Node], privateKey, func(opts *op_e2e.TxOpts) { precompile := common.BytesToAddress([]byte{0x0a}) opts.Gas = 100_000