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
5 changes: 3 additions & 2 deletions op-e2e/e2eutils/challenger/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type EndpointProvider interface {
L2NodeEndpoints() []endpoint.RPC
RollupEndpoint(name string) endpoint.RPC
L1BeaconEndpoint() endpoint.RestHTTP
SupervisorEndpoint() endpoint.RPC
SupernodeEndpoint() endpoint.RPC
IsSupersystem() bool
}

Expand Down Expand Up @@ -197,7 +197,8 @@ func NewChallengerConfig(t *testing.T, sys EndpointProvider, l2NodeName string,
for _, l2Node := range sys.L2NodeEndpoints() {
l2Endpoints = append(l2Endpoints, l2Node.RPC())
}
cfg = config.NewInteropConfig(common.Address{}, l1Endpoint, l1Beacon, sys.SupervisorEndpoint().RPC(), l2Endpoints, t.TempDir())
cfg = config.NewInteropConfig(common.Address{}, l1Endpoint, l1Beacon, sys.SupernodeEndpoint().RPC(), l2Endpoints, t.TempDir())
cfg.UseSuperNode = true
} else {
cfg = config.NewConfig(common.Address{}, l1Endpoint, l1Beacon, sys.RollupEndpoint(l2NodeName).RPC(), sys.NodeEndpoint(l2NodeName).RPC(), t.TempDir())
}
Expand Down
58 changes: 35 additions & 23 deletions op-e2e/e2eutils/disputegame/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/ethereum-optimism/optimism/op-supervisor/supervisor/backend/depset"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
Expand Down Expand Up @@ -94,12 +93,12 @@ func WithSuper(super eth.Super) GameOpt {

type DisputeSystem interface {
L1BeaconEndpoint() endpoint.RestHTTP
SupervisorClient() *sources.SupervisorClient
SupernodeClient() *sources.SuperNodeClient
NodeEndpoint(name string) endpoint.RPC
L2NodeEndpoints() []endpoint.RPC
NodeClient(name string) *ethclient.Client
RollupEndpoint(name string) endpoint.RPC
SupervisorEndpoint() endpoint.RPC
SupernodeEndpoint() endpoint.RPC
RollupClient(name string) *sources.RollupClient
IsSupersystem() bool
DisputeGameFactoryAddr() common.Address
Expand Down Expand Up @@ -269,12 +268,12 @@ func (h *FactoryHelper) StartSuperCannonGameAtTimestamp(ctx context.Context, tim
func (h *FactoryHelper) startSuperCannonGameOfType(ctx context.Context, timestamp uint64, gameType uint32, opts ...GameOpt) *SuperCannonGameHelper {
cfg := NewGameCfg(opts...)
logger := testlog.Logger(h.T, log.LevelInfo).New("role", "CannonGameHelper")
rootProvider := h.System.SupervisorClient()
rootProvider := h.System.SupernodeClient()

extraData := h.createSuperGameExtraData(ctx, rootProvider, timestamp, cfg)
rootClaim := crypto.Keccak256Hash(extraData)

ctx, cancel := context.WithTimeout(ctx, 1*time.Minute)
timedCtx, cancel := context.WithTimeout(ctx, 1*time.Minute)
defer cancel()

bond, err := h.Factory.InitBonds(nil, gameType)
Expand All @@ -286,24 +285,23 @@ func (h *FactoryHelper) startSuperCannonGameOfType(ctx context.Context, timestam
return h.Factory.Create(opts, gameType, rootClaim, extraData)
})
h.Require.NoErrorf(err, "create fault dispute game at timestamp %v. extraData: %x", timestamp, extraData)
rcpt, err := wait.ForReceiptOK(ctx, h.Client, tx.Hash())
rcpt, err := wait.ForReceiptOK(timedCtx, h.Client, tx.Hash())
h.Require.NoError(err, "wait for create fault dispute game receipt to be OK")
h.Require.Len(rcpt.Logs, 2, "should have emitted a single DisputeGameCreated event")
createdEvent, err := h.Factory.ParseDisputeGameCreated(*rcpt.Logs[1])
h.Require.NoError(err)
game, err := contracts.NewFaultDisputeGameContract(ctx, metrics.NoopContractMetrics, createdEvent.DisputeProxy, batching.NewMultiCaller(h.Client.Client(), batching.DefaultBatchSize))
game, err := contracts.NewFaultDisputeGameContract(timedCtx, metrics.NoopContractMetrics, createdEvent.DisputeProxy, batching.NewMultiCaller(h.Client.Client(), batching.DefaultBatchSize))
h.Require.NoError(err)

prestateTimestamp, poststateTimestamp, err := game.GetGameRange(ctx)
prestateTimestamp, poststateTimestamp, err := game.GetGameRange(timedCtx)
h.Require.NoError(err, "Failed to load starting block number")
splitDepth, err := game.GetSplitDepth(ctx)
splitDepth, err := game.GetSplitDepth(timedCtx)
h.Require.NoError(err, "Failed to load split depth")
l1Head := h.GetL1Head(ctx, game)
l1Head := h.GetL1Head(timedCtx, game)
h.waitForSupernodePastL1(ctx, l1Head)

prestateProvider := super.NewSuperRootPrestateProvider(rootProvider, prestateTimestamp)
rollupCfgs, err := super.NewRollupConfigsFromParsed(h.System.RollupCfgs()...)
require.NoError(h.T, err, "failed to create rollup configs")
provider := super.NewSupervisorSuperTraceProvider(logger, rollupCfgs, prestateProvider, rootProvider, l1Head, splitDepth, prestateTimestamp, poststateTimestamp)
prestateProvider := super.NewSuperNodePrestateProvider(rootProvider, prestateTimestamp)
provider := super.NewSuperNodeTraceProvider(logger, prestateProvider, rootProvider, l1Head, splitDepth, prestateTimestamp, poststateTimestamp)

return NewSuperCannonGameHelper(h.T, h.Client, h.Opts, h.PrivKey, game, h.FactoryAddr, createdEvent.DisputeProxy, provider, h.System)
}
Expand All @@ -313,8 +311,22 @@ func (h *FactoryHelper) GetL1Head(ctx context.Context, game contracts.FaultDispu
h.Require.NoError(err, "Failed to load L1 head")
l1Header, err := h.Client.HeaderByHash(ctx, l1HeadHash)
h.Require.NoError(err, "Failed to load L1 header")
l1Head := eth.HeaderBlockID(l1Header)
return l1Head
return eth.HeaderBlockID(l1Header)
}

// waitForSupernodePastL1 blocks until the supernode's CurrentL1 has advanced past l1Head, so
// the trace provider can return data instead of ErrNotInSync.
func (h *FactoryHelper) waitForSupernodePastL1(ctx context.Context, l1Head eth.BlockID) {
timedCtx, cancel := context.WithTimeout(ctx, 2*time.Minute)
Comment thread
ajsutton marked this conversation as resolved.
defer cancel()
err := wait.For(timedCtx, 500*time.Millisecond, func() (bool, error) {
status, statusErr := h.System.SupernodeClient().SyncStatus(ctx)
if statusErr != nil {
return false, statusErr
}
return status.CurrentL1.Number > l1Head.Number, nil
})
h.Require.NoErrorf(err, "supernode did not advance past game L1 head %d", l1Head.Number)
}

func (h *FactoryHelper) StartOutputAlphabetGameWithCorrectRoot(ctx context.Context, l2Node string, l2BlockNumber uint64, opts ...GameOpt) *OutputAlphabetGameHelper {
Expand Down Expand Up @@ -370,12 +382,12 @@ func (h *FactoryHelper) CreateBisectionGameExtraData(l2Node string, l2BlockNumbe
return extraData
}

func (h *FactoryHelper) createSuperGameExtraData(ctx context.Context, supervisor *sources.SupervisorClient, timestamp uint64, cfg *GameCfg) []byte {
func (h *FactoryHelper) createSuperGameExtraData(ctx context.Context, sn *sources.SuperNodeClient, timestamp uint64, cfg *GameCfg) []byte {
if !cfg.allowFuture {
timedCtx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
err := wait.For(timedCtx, time.Second, func() (bool, error) {
status, err := supervisor.SyncStatus(ctx)
status, err := sn.SyncStatus(ctx)
if err != nil {
return false, err
}
Expand All @@ -387,10 +399,10 @@ func (h *FactoryHelper) createSuperGameExtraData(ctx context.Context, supervisor
super := cfg.super
if super == nil {
h.T.Logf("Creating game with l2 timestamp: %v", timestamp)
superResponse, err := h.System.SupervisorClient().SuperRootAtTimestamp(ctx, hexutil.Uint64(timestamp))
superResponse, err := h.System.SupernodeClient().SuperRootAtTimestamp(ctx, uint64(timestamp))
h.Require.NoErrorf(err, "Failed to get super root at timestamp %v", timestamp)
super, err = superResponse.ToSuper()
h.Require.NoErrorf(err, "Failed to parse super at timestamp %v", timestamp)
h.Require.NotNilf(superResponse.Data, "supernode returned no super root data at timestamp %v", timestamp)
super = superResponse.Data.Super
}

superV1, ok := super.(*eth.SuperV1)
Expand Down Expand Up @@ -427,7 +439,7 @@ func (h *FactoryHelper) WaitForSuperTimestamp(l2Timestamp uint64, cfg *GameCfg)
return
}

client := h.System.SupervisorClient()
client := h.System.SupernodeClient()
absoluteTimeout := 5 * time.Minute
ctx, cancel := context.WithTimeout(context.Background(), absoluteTimeout)
defer cancel()
Expand All @@ -444,7 +456,7 @@ func (h *FactoryHelper) WaitForSuperTimestamp(l2Timestamp uint64, cfg *GameCfg)
if cfg.allowUnsafe {
localUnsafeAtTimestamp := true
for _, chain := range status.Chains {
if chain.LocalUnsafe.Time < l2Timestamp {
if chain.UnsafeL2.Time < l2Timestamp {
localUnsafeAtTimestamp = false
break
}
Expand Down
16 changes: 7 additions & 9 deletions op-e2e/e2eutils/disputegame/super_cannon_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (g *SuperCannonGameHelper) CreateHonestActor(ctx context.Context, options .
realPrestateBlock, realPostStateBlock, err := g.Game.GetGameRange(ctx)
g.Require.NoError(err, "Failed to load block range")
splitDepth := g.SplitDepth(ctx)
supervisorClient := g.System.SupervisorClient()
supernodeClient := g.System.SupernodeClient()
actorCfg := &HonestActorConfig{
PrestateSequenceNumber: realPrestateBlock,
PoststateSequenceNumber: realPostStateBlock,
Expand All @@ -67,17 +67,17 @@ func (g *SuperCannonGameHelper) CreateHonestActor(ctx context.Context, options .

cfg := challenger.NewChallengerConfig(g.T, g.System, "", actorCfg.ChallengerOpts...)
dir := filepath.Join(cfg.Datadir, "honest")
prestateProvider := super.NewSuperRootPrestateProvider(supervisorClient, actorCfg.PrestateSequenceNumber)
prestateProvider := super.NewSuperNodePrestateProvider(supernodeClient, actorCfg.PrestateSequenceNumber)
l1Head := g.GetL1Head(ctx)
accessor, err := super.NewSuperCannonTraceAccessor(
logger,
metrics.NoopMetrics,
cfg.CannonKona,
vm.NewKonaSuperExecutor(),
prestateProvider,
supervisorClient,
nil,
false,
supernodeClient,
true,
cfg.CannonKonaAbsolutePreState,
dir,
l1Head,
Expand Down Expand Up @@ -194,15 +194,13 @@ func (g *SuperCannonGameHelper) createSuperCannonTraceProvider(ctx context.Conte

func (g *SuperCannonGameHelper) createSuperTraceProvider(ctx context.Context) super.SuperTraceProvider {
logger := testlog.Logger(g.t, log.LevelInfo).New("role", "superTraceProvider", "game", g.splitGame.Addr)
rootProvider := g.System.SupervisorClient()
rootProvider := g.System.SupernodeClient()
splitDepth := g.splitGame.SplitDepth(ctx)
l1Head := g.GetL1Head(ctx)
prestateTimestamp, poststateTimestamp, err := g.Game.GetGameRange(ctx)
g.require.NoError(err, "Failed to load block range")
prestateProvider := super.NewSuperRootPrestateProvider(rootProvider, prestateTimestamp)
rollupCfgs, err := super.NewRollupConfigsFromParsed(g.System.RollupCfgs()...)
require.NoError(g.T, err, "failed to create rollup configs")
return super.NewSupervisorSuperTraceProvider(logger, rollupCfgs, prestateProvider, rootProvider, l1Head, splitDepth, prestateTimestamp, poststateTimestamp)
prestateProvider := super.NewSuperNodePrestateProvider(rootProvider, prestateTimestamp)
return super.NewSuperNodeTraceProvider(logger, prestateProvider, rootProvider, l1Head, splitDepth, prestateTimestamp, poststateTimestamp)
}

// InitFirstDerivationGame builds a top-level game whose deepest node (at splitDepth) asserts the first
Expand Down
8 changes: 4 additions & 4 deletions op-e2e/e2eutils/disputegame/super_dispute_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ type SuperDisputeSystem struct {
opts *e2esys.SystemConfigOpts
}

func (s *SuperDisputeSystem) SupervisorClient() *sources.SupervisorClient {
return s.sys.SupervisorClient()
func (s *SuperDisputeSystem) SupernodeClient() *sources.SuperNodeClient {
return s.sys.SupernodeClient()
}

func NewSuperDisputeSystem(sys interop.SuperSystem, opts *e2esys.SystemConfigOpts) *SuperDisputeSystem {
Expand Down Expand Up @@ -60,8 +60,8 @@ func (s *SuperDisputeSystem) L2NodeEndpoints() []endpoint.RPC {
return endpoints
}

func (s *SuperDisputeSystem) SupervisorEndpoint() endpoint.RPC {
return endpoint.URL(s.sys.Supervisor().RPC())
func (s *SuperDisputeSystem) SupernodeEndpoint() endpoint.RPC {
return s.sys.SupernodeEndpoint()
}

func (s *SuperDisputeSystem) NodeClient(name string) *ethclient.Client {
Expand Down
6 changes: 3 additions & 3 deletions op-e2e/faultproofs/arenas.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/ethereum-optimism/optimism/op-e2e/interop"
"github.com/ethereum-optimism/optimism/op-e2e/system/e2esys"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -74,9 +73,10 @@ func (s *superGameArena) L1Client() *ethclient.Client {
}

func (s *superGameArena) GetProposalRoot(ctx context.Context, l2SequenceNumber uint64) common.Hash {
output, err := s.sys.SupervisorClient().SuperRootAtTimestamp(ctx, hexutil.Uint64(l2SequenceNumber))
output, err := s.sys.SupernodeClient().SuperRootAtTimestamp(ctx, l2SequenceNumber)
require.NoError(s.t, err)
return common.Hash(output.SuperRoot)
require.NotNil(s.t, output.Data, "supernode returned no super root data at timestamp %v", l2SequenceNumber)
return common.Hash(output.Data.SuperRoot)
}

func (s *superGameArena) CreateChallenger(ctx context.Context) {
Expand Down
23 changes: 12 additions & 11 deletions op-e2e/faultproofs/super_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/sources/batching/rpcblock"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -253,7 +252,7 @@ func testSuperPreimageStep(t *testing.T, preimageType utils.PreimageOpt, preload
ctx := context.Background()
sys, disputeGameFactory, _ := StartInteropFaultDisputeSystem(t, WithBlobBatches(), WithAllocType(allocType))

status, err := sys.SupervisorClient().SyncStatus(ctx)
status, err := sys.SupernodeClient().SyncStatus(ctx)
require.NoError(t, err)
l2Timestamp := status.SafeTimestamp + 40

Expand Down Expand Up @@ -365,7 +364,7 @@ func TestSuperInvalidateUnsafeProposal(t *testing.T) {
RunTestsAcrossVmTypes(t, tests, func(t *testing.T, allocType config.AllocType, test TestCase) {
sys, disputeGameFactory, _ := StartInteropFaultDisputeSystem(t, WithAllocType(allocType))

client := sys.SupervisorClient()
client := sys.SupernodeClient()
status, err := client.SyncStatus(ctx)
require.NoError(t, err, "Failed to get sync status")
// Ensure that the superchain has progressed a bit past the genesis timestamp
Expand Down Expand Up @@ -421,7 +420,7 @@ func TestSuperInalidateUnsafeProposal_SecondChainIsUnsafe(t *testing.T) {
RunTestAcrossVmTypes(t, func(t *testing.T, allocType config.AllocType) {
sys, disputeGameFactory, _ := StartInteropFaultDisputeSystem(t, WithAllocType(allocType))

client := sys.SupervisorClient()
client := sys.SupernodeClient()
status, err := client.SyncStatus(ctx)
require.NoError(t, err, "Failed to get sync status")
// Ensure that the superchain has progressed a bit past the genesis timestamp
Expand Down Expand Up @@ -561,14 +560,16 @@ func TestSuperInvalidateCorrectProposalFutureBlock(t *testing.T) {

RunTestsAcrossVmTypes(t, tests, func(t *testing.T, allocType config.AllocType, test TestCase) {
sys, disputeGameFactory, _ := StartInteropFaultDisputeSystem(t, WithAllocType(allocType))
client := sys.SupervisorClient()
client := sys.SupernodeClient()

status, err := client.SyncStatus(ctx)
require.NoError(t, err, "Failed to get sync status")
superRoot, err := client.SuperRootAtTimestamp(ctx, hexutil.Uint64(status.SafeTimestamp))
superRoot, err := client.SuperRootAtTimestamp(ctx, status.SafeTimestamp)
require.NoError(t, err, "Failed to get super root at safe timestamp")
super, err := superRoot.ToSuper()
require.NoError(t, err, "Failed to parse super root")
require.NotNil(t, superRoot.Data, "supernode returned no super root data at timestamp %v", status.SafeTimestamp)
super := superRoot.Data.Super
superV1, ok := super.(*eth.SuperV1)
require.Truef(t, ok, "Unsupported super type %T", super)

// Stop the batcher so the safe head doesn't advance
for _, id := range sys.L2IDs() {
Expand All @@ -577,7 +578,7 @@ func TestSuperInvalidateCorrectProposalFutureBlock(t *testing.T) {

// Create a dispute game with a proposal that is valid at `superRoot.Timestamp`, but that claims to correspond to timestamp
// `superRoot.Timestamp + 100000`. This is dishonest, because the superchain hasn't reached this timestamp yet.
game := disputeGameFactory.StartSuperCannonGameAtTimestamp(ctx, superRoot.Timestamp+100_000, disputegame.WithSuper(super), disputegame.WithFutureProposal())
game := disputeGameFactory.StartSuperCannonGameAtTimestamp(ctx, superV1.Timestamp+100_000, disputegame.WithSuper(super), disputegame.WithFutureProposal())

game.StartChallenger(ctx, "Challenger", challenger.WithPrivKey(aliceKey(t)), challenger.WithDepset(t, sys.DependencySet()))

Expand Down Expand Up @@ -613,7 +614,7 @@ func TestSuperCannonHonestSafeTraceExtensionValidRoot(t *testing.T) {
ctx := context.Background()

sys, disputeGameFactory, _ := StartInteropFaultDisputeSystem(t, WithAllocType(allocType))
client := sys.SupervisorClient()
client := sys.SupernodeClient()
// Wait for there to be there are safe L2 blocks past the claimed safe timestamp that have data available on L1 within
// the commitment stored in the dispute game.
status, err := client.SyncStatus(ctx)
Expand Down Expand Up @@ -666,7 +667,7 @@ func TestSuperCannonHonestSafeTraceExtensionInvalidRoot(t *testing.T) {
ctx := context.Background()

sys, disputeGameFactory, _ := StartInteropFaultDisputeSystem(t, WithAllocType(allocType))
client := sys.SupervisorClient()
client := sys.SupernodeClient()
// Wait for there to be there are safe L2 blocks past the claimed safe timestamp that have data available on L1 within
// the commitment stored in the dispute game.
status, err := client.SyncStatus(ctx)
Expand Down
6 changes: 3 additions & 3 deletions op-e2e/faultproofs/util_interop.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ func StartInteropFaultDisputeSystem(t *testing.T, opts ...faultDisputeConfigOpts
// Also ensures the L1 has advanced past genesis which can otherwise cause gas estimation problems
var lastError error
err = wait.For(ctx, 1*time.Minute, func() (bool, error) {
status, err := s2.SupervisorClient().SyncStatus(ctx)
status, err := s2.SupernodeClient().SyncStatus(ctx)
if err != nil {
lastError = err
return false, nil
}
return status.SafeTimestamp > recipe.GenesisTimestamp && status.MinSyncedL1.Number > 0, nil
return status.SafeTimestamp > recipe.GenesisTimestamp && status.CurrentL1.Number > 0, nil
})
require.NoErrorf(t, err, "failed to wait for supervisor to sync genesis: %v", lastError)
require.NoErrorf(t, err, "failed to wait for supernode to sync genesis: %v", lastError)

return s2, factory, s2.L1GethClient()
}
Expand Down
Loading
Loading