Commit d4706dad authored by Park Changwan's avatar Park Changwan Committed by GitHub

op-e2e: Refactor for asterisc e2e (#10214)

* op-e2e: Expose fields for asterisc e2e

* op-e2e: Add Helper Initializer methods

* op-e2e: Apply initializer methods and exposed fields

* op-e2e: Expose methods for asterisc e2e
parent 1667124c
......@@ -40,6 +40,16 @@ type Helper struct {
chl cliapp.Lifecycle
}
func NewHelper(log log.Logger, t *testing.T, require *require.Assertions, dir string, chl cliapp.Lifecycle) *Helper {
return &Helper{
log: log,
t: t,
require: require,
dir: dir,
chl: chl,
}
}
type Option func(config2 *config.Config)
func WithFactoryAddress(addr common.Address) Option {
......@@ -66,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
......@@ -94,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"
......
......@@ -15,53 +15,53 @@ import (
type ClaimHelper struct {
require *require.Assertions
game *OutputGameHelper
index int64
parentIndex uint32
position types.Position
Index int64
ParentIndex uint32
Position types.Position
claim common.Hash
}
func newClaimHelper(game *OutputGameHelper, idx int64, claim ContractClaim) *ClaimHelper {
return &ClaimHelper{
require: game.require,
require: game.Require,
game: game,
index: idx,
parentIndex: claim.ParentIndex,
position: types.NewPositionFromGIndex(claim.Position),
Index: idx,
ParentIndex: claim.ParentIndex,
Position: types.NewPositionFromGIndex(claim.Position),
claim: claim.Claim,
}
}
func (c *ClaimHelper) AgreesWithOutputRoot() bool {
return c.position.Depth()%2 == 0
return c.Position.Depth()%2 == 0
}
func (c *ClaimHelper) IsRootClaim() bool {
return c.position.IsRootPosition()
return c.Position.IsRootPosition()
}
func (c *ClaimHelper) IsOutputRoot(ctx context.Context) bool {
splitDepth := c.game.SplitDepth(ctx)
return c.position.Depth() <= splitDepth
return c.Position.Depth() <= splitDepth
}
func (c *ClaimHelper) IsOutputRootLeaf(ctx context.Context) bool {
splitDepth := c.game.SplitDepth(ctx)
return c.position.Depth() == splitDepth
return c.Position.Depth() == splitDepth
}
func (c *ClaimHelper) IsBottomGameRoot(ctx context.Context) bool {
splitDepth := c.game.SplitDepth(ctx)
return c.position.Depth() == splitDepth+1
return c.Position.Depth() == splitDepth+1
}
func (c *ClaimHelper) IsMaxDepth(ctx context.Context) bool {
maxDepth := c.game.MaxDepth(ctx)
return c.position.Depth() == maxDepth
return c.Position.Depth() == maxDepth
}
func (c *ClaimHelper) Depth() types.Depth {
return c.position.Depth()
return c.Position.Depth()
}
// WaitForCounterClaim waits for the claim to be countered by another claim being posted.
......@@ -72,8 +72,8 @@ func (c *ClaimHelper) WaitForCounterClaim(ctx context.Context, ignoreClaims ...*
// This is the first claim we need to run cannon on, so give it more time
timeout = timeout * 2
}
counterIdx, counterClaim := c.game.waitForClaim(ctx, timeout, fmt.Sprintf("failed to find claim with parent idx %v", c.index), func(claimIdx int64, claim ContractClaim) bool {
return int64(claim.ParentIndex) == c.index && !containsClaim(claimIdx, ignoreClaims)
counterIdx, counterClaim := c.game.waitForClaim(ctx, timeout, fmt.Sprintf("failed to find claim with parent idx %v", c.Index), func(claimIdx int64, claim ContractClaim) bool {
return int64(claim.ParentIndex) == c.Index && !containsClaim(claimIdx, ignoreClaims)
})
return newClaimHelper(c.game, counterIdx, counterClaim)
}
......@@ -83,28 +83,28 @@ func (c *ClaimHelper) WaitForCountered(ctx context.Context) {
timedCtx, cancel := context.WithTimeout(ctx, defaultTimeout)
defer cancel()
err := wait.For(timedCtx, time.Second, func() (bool, error) {
latestData := c.game.getClaim(ctx, c.index)
latestData := c.game.getClaim(ctx, c.Index)
return latestData.CounteredBy != common.Address{}, nil
})
if err != nil { // Avoid waiting time capturing game data when there's no error
c.require.NoErrorf(err, "Claim %v was not countered\n%v", c.index, c.game.gameData(ctx))
c.require.NoErrorf(err, "Claim %v was not countered\n%v", c.Index, c.game.GameData(ctx))
}
}
func (c *ClaimHelper) RequireCorrectOutputRoot(ctx context.Context) {
c.require.True(c.IsOutputRoot(ctx), "Should not expect a valid output root in the bottom game")
expected, err := c.game.correctOutputProvider.Get(ctx, c.position)
expected, err := c.game.CorrectOutputProvider.Get(ctx, c.Position)
c.require.NoError(err, "Failed to get correct output root")
c.require.Equalf(expected, c.claim, "Should have correct output root in claim %v and position %v", c.index, c.position)
c.require.Equalf(expected, c.claim, "Should have correct output root in claim %v and position %v", c.Index, c.Position)
}
func (c *ClaimHelper) Attack(ctx context.Context, value common.Hash, opts ...MoveOpt) *ClaimHelper {
c.game.Attack(ctx, c.index, value, opts...)
c.game.Attack(ctx, c.Index, value, opts...)
return c.WaitForCounterClaim(ctx)
}
func (c *ClaimHelper) Defend(ctx context.Context, value common.Hash, opts ...MoveOpt) *ClaimHelper {
c.game.Defend(ctx, c.index, value, opts...)
c.game.Defend(ctx, c.Index, value, opts...)
return c.WaitForCounterClaim(ctx)
}
......@@ -115,19 +115,19 @@ func (c *ClaimHelper) RequireDifferentClaimValue(other *ClaimHelper) {
func (c *ClaimHelper) RequireOnlyCounteredBy(ctx context.Context, expected ...*ClaimHelper) {
claims := c.game.getAllClaims(ctx)
for idx, claim := range claims {
if int64(claim.ParentIndex) != c.index {
if int64(claim.ParentIndex) != c.Index {
// Doesn't counter this claim, so ignore
continue
}
if !containsClaim(int64(idx), expected) {
// Found a countering claim not in the expected list. Fail.
c.require.FailNowf("Found unexpected countering claim", "Parent claim index: %v Game state:\n%v", c.index, c.game.gameData(ctx))
c.require.FailNowf("Found unexpected countering claim", "Parent claim index: %v Game state:\n%v", c.Index, c.game.GameData(ctx))
}
}
}
func containsClaim(claimIdx int64, haystack []*ClaimHelper) bool {
return slices.ContainsFunc(haystack, func(candidate *ClaimHelper) bool {
return candidate.index == claimIdx
return candidate.Index == claimIdx
})
}
......@@ -39,7 +39,7 @@ func (d *DishonestHelper) ExhaustDishonestClaims(ctx context.Context, rootClaim
}
d.LogGameData(ctx)
d.OutputGameHelper.t.Logf("Dishonest moves against claimIndex %d", claimIndex)
d.OutputGameHelper.T.Logf("Dishonest moves against claimIndex %d", claimIndex)
agreeWithLevel := d.defender == (pos.Depth()%2 == 0)
if !agreeWithLevel {
d.OutputHonestHelper.Attack(ctx, claimIndex, WithIgnoreDuplicates())
......@@ -53,7 +53,7 @@ func (d *DishonestHelper) ExhaustDishonestClaims(ctx context.Context, rootClaim
}
}
numClaimsSeen := rootClaim.index
numClaimsSeen := rootClaim.Index
for {
// Use a short timeout since we don't know the challenger will respond,
// and this is only designed for the alphabet game where the response should be fast.
......@@ -63,7 +63,7 @@ func (d *DishonestHelper) ExhaustDishonestClaims(ctx context.Context, rootClaim
// There's nothing to respond to.
break
}
d.OutputGameHelper.require.NoError(err)
d.OutputGameHelper.Require.NoError(err)
for ; numClaimsSeen < newCount; numClaimsSeen++ {
claimData := d.getClaim(ctx, numClaimsSeen)
......
This diff is collapsed.
......@@ -24,37 +24,31 @@ func (g *OutputAlphabetGameHelper) StartChallenger(
options ...challenger.Option,
) *challenger.Helper {
opts := []challenger.Option{
challenger.WithAlphabet(g.system.RollupEndpoint(l2Node)),
challenger.WithFactoryAddress(g.factoryAddr),
challenger.WithGameAddress(g.addr),
challenger.WithAlphabet(g.System.RollupEndpoint(l2Node)),
challenger.WithFactoryAddress(g.FactoryAddr),
challenger.WithGameAddress(g.Addr),
}
opts = append(opts, options...)
c := challenger.NewChallenger(g.t, ctx, g.system, name, opts...)
g.t.Cleanup(func() {
c := challenger.NewChallenger(g.T, ctx, g.System, name, opts...)
g.T.Cleanup(func() {
_ = c.Close()
})
return c
}
func (g *OutputAlphabetGameHelper) CreateHonestActor(ctx context.Context, l2Node string) *OutputHonestHelper {
logger := testlog.Logger(g.t, log.LevelInfo).New("role", "HonestHelper", "game", g.addr)
caller := batching.NewMultiCaller(g.system.NodeClient("l1").Client(), batching.DefaultBatchSize)
contract := contracts.NewFaultDisputeGameContract(contractMetrics.NoopContractMetrics, g.addr, caller)
logger := testlog.Logger(g.T, log.LevelInfo).New("role", "HonestHelper", "game", g.Addr)
caller := batching.NewMultiCaller(g.System.NodeClient("l1").Client(), batching.DefaultBatchSize)
contract := contracts.NewFaultDisputeGameContract(contractMetrics.NoopContractMetrics, g.Addr, caller)
prestateBlock, poststateBlock, err := contract.GetBlockRange(ctx)
g.require.NoError(err, "Get block range")
g.Require.NoError(err, "Get block range")
splitDepth := g.SplitDepth(ctx)
l1Head := g.getL1Head(ctx)
rollupClient := g.system.RollupClient(l2Node)
l1Head := g.GetL1Head(ctx)
rollupClient := g.System.RollupClient(l2Node)
prestateProvider := outputs.NewPrestateProvider(rollupClient, prestateBlock)
correctTrace, err := outputs.NewOutputAlphabetTraceAccessor(logger, metrics.NoopMetrics, prestateProvider, rollupClient, l1Head, splitDepth, prestateBlock, poststateBlock)
g.require.NoError(err, "Create trace accessor")
return &OutputHonestHelper{
t: g.t,
require: g.require,
game: &g.OutputGameHelper,
contract: contract,
correctTrace: correctTrace,
}
g.Require.NoError(err, "Create trace accessor")
return NewOutputHonestHelper(g.T, g.Require, &g.OutputGameHelper, contract, correctTrace)
}
func (g *OutputAlphabetGameHelper) CreateDishonestHelper(ctx context.Context, l2Node string, defender bool) *DishonestHelper {
......
......@@ -21,8 +21,18 @@ type OutputHonestHelper struct {
correctTrace types.TraceAccessor
}
func NewOutputHonestHelper(t *testing.T, require *require.Assertions, game *OutputGameHelper, contract *contracts.FaultDisputeGameContract, correctTrace types.TraceAccessor) *OutputHonestHelper {
return &OutputHonestHelper{
t: t,
require: require,
game: game,
contract: contract,
correctTrace: correctTrace,
}
}
func (h *OutputHonestHelper) CounterClaim(ctx context.Context, claim *ClaimHelper, opts ...MoveOpt) *ClaimHelper {
game, target := h.loadState(ctx, claim.index)
game, target := h.loadState(ctx, claim.Index)
value, err := h.correctTrace.Get(ctx, game, target, target.Position)
h.require.NoErrorf(err, "Failed to determine correct claim at position %v with g index %v", target.Position, target.Position.ToGIndex())
if value == claim.claim {
......@@ -33,12 +43,12 @@ func (h *OutputHonestHelper) CounterClaim(ctx context.Context, claim *ClaimHelpe
}
func (h *OutputHonestHelper) AttackClaim(ctx context.Context, claim *ClaimHelper, opts ...MoveOpt) *ClaimHelper {
h.Attack(ctx, claim.index, opts...)
h.Attack(ctx, claim.Index, opts...)
return claim.WaitForCounterClaim(ctx)
}
func (h *OutputHonestHelper) DefendClaim(ctx context.Context, claim *ClaimHelper, opts ...MoveOpt) *ClaimHelper {
h.Defend(ctx, claim.index, opts...)
h.Defend(ctx, claim.Index, opts...)
return claim.WaitForCounterClaim(ctx)
}
......@@ -68,12 +78,12 @@ func (h *OutputHonestHelper) Defend(ctx context.Context, claimIdx int64, opts ..
game, claim := h.loadState(ctx, claimIdx)
defendPos := claim.Position.Defend()
value, err := h.correctTrace.Get(ctx, game, claim, defendPos)
h.game.require.NoErrorf(err, "Get correct claim at position %v with g index %v", defendPos, defendPos.ToGIndex())
h.game.Require.NoErrorf(err, "Get correct claim at position %v with g index %v", defendPos, defendPos.ToGIndex())
h.game.Defend(ctx, claimIdx, value, opts...)
}
func (h *OutputHonestHelper) StepClaimFails(ctx context.Context, claim *ClaimHelper, isAttack bool) {
h.StepFails(ctx, claim.index, isAttack)
h.StepFails(ctx, claim.Index, isAttack)
}
func (h *OutputHonestHelper) StepFails(ctx context.Context, claimIdx int64, isAttack bool) {
......
......@@ -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",
......
......@@ -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)
......
......@@ -18,7 +18,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)
......@@ -75,7 +75,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)
......@@ -83,7 +83,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
......@@ -105,7 +105,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.MaxClockDuration(ctx))
......@@ -130,13 +130,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)
......@@ -169,7 +169,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)
......@@ -234,7 +234,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())
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
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