Commit 39877f60 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

op-e2e: Fix Cannon tests (#13395)

* op-e2e: Fix anchor roots

* use correct prestate

* Run FP tests on develop only again
parent 6823d676
...@@ -329,10 +329,6 @@ jobs: ...@@ -329,10 +329,6 @@ jobs:
environment: environment:
FOUNDRY_PROFILE: <<parameters.profile>> FOUNDRY_PROFILE: <<parameters.profile>>
working_directory: packages/contracts-bedrock working_directory: packages/contracts-bedrock
- run:
name: Generate allocs
command: |
make devnet-allocs
- persist_to_workspace: - persist_to_workspace:
root: "." root: "."
paths: paths:
...@@ -341,12 +337,6 @@ jobs: ...@@ -341,12 +337,6 @@ jobs:
- "packages/contracts-bedrock/forge-artifacts" - "packages/contracts-bedrock/forge-artifacts"
- "packages/contracts-bedrock/deploy-config/devnetL1.json" - "packages/contracts-bedrock/deploy-config/devnetL1.json"
- "packages/contracts-bedrock/deployments/devnetL1" - "packages/contracts-bedrock/deployments/devnetL1"
- ".devnet"
- ".devnet-standard"
- ".devnet-l2oo"
- ".devnet-alt-da"
- ".devnet-alt-da-generic"
- ".devnet-mt-cannon"
- notify-failures-on-develop - notify-failures-on-develop
check-kontrol-build: check-kontrol-build:
...@@ -928,9 +918,8 @@ jobs: ...@@ -928,9 +918,8 @@ jobs:
- persist_to_workspace: - persist_to_workspace:
root: . root: .
paths: paths:
- "op-program/bin/prestate.bin.gz" - "op-program/bin"
- "op-program/bin/meta.json" - "cannon/bin"
- "op-program/bin/prestate-proof.json"
preimage-reproducibility: preimage-reproducibility:
docker: docker:
...@@ -1493,6 +1482,9 @@ workflows: ...@@ -1493,6 +1482,9 @@ workflows:
op-e2e/faultproofs op-e2e/faultproofs
context: context:
- slack - slack
requires:
- contracts-bedrock-build
- cannon-prestate
develop-kontrol-tests: develop-kontrol-tests:
when: when:
......
...@@ -115,7 +115,7 @@ func makeDCIV160(intent *state.Intent, thisIntent *state.ChainIntent, chainID co ...@@ -115,7 +115,7 @@ func makeDCIV160(intent *state.Intent, thisIntent *state.ChainIntent, chainID co
for _, game := range thisIntent.AdditionalDisputeGames { for _, game := range thisIntent.AdditionalDisputeGames {
anchorRoots = append(anchorRoots, opcm.StartingAnchorRoot{ anchorRoots = append(anchorRoots, opcm.StartingAnchorRoot{
GameType: game.DisputeGameType, GameType: game.DisputeGameType,
Root: game.DisputeAbsolutePrestate, Root: game.StartingAnchorRoot,
L2BlockNumber: common.Big0, L2BlockNumber: common.Big0,
}) })
} }
......
...@@ -33,6 +33,7 @@ type AdditionalDisputeGame struct { ...@@ -33,6 +33,7 @@ type AdditionalDisputeGame struct {
OracleMinProposalSize uint64 OracleMinProposalSize uint64
OracleChallengePeriodSeconds uint64 OracleChallengePeriodSeconds uint64
MakeRespected bool MakeRespected bool
StartingAnchorRoot common.Hash
} }
type ChainIntent struct { type ChainIntent struct {
......
...@@ -48,7 +48,7 @@ devnet-allocs: pre-test-cannon ...@@ -48,7 +48,7 @@ devnet-allocs: pre-test-cannon
make -C .. devnet-allocs make -C .. devnet-allocs
.PHONY: devnet-allocs .PHONY: devnet-allocs
pre-test: pre-test-cannon pre-test-allocs pre-test: pre-test-cannon
.PHONY: pre-test .PHONY: pre-test
pre-test-cannon: pre-test-cannon:
......
...@@ -267,7 +267,7 @@ func initAllocType(root string, allocType AllocType) { ...@@ -267,7 +267,7 @@ func initAllocType(root string, allocType AllocType) {
go func(mode genesis.L2AllocsMode) { go func(mode genesis.L2AllocsMode) {
defer wg.Done() defer wg.Done()
intent := defaultIntent(root, loc, deployerAddr) intent := defaultIntent(root, loc, deployerAddr, allocType)
if allocType == AllocTypeAltDA { if allocType == AllocTypeAltDA {
intent.Chains[0].DangerousAltDAConfig = genesis.AltDADeployConfig{ intent.Chains[0].DangerousAltDAConfig = genesis.AltDADeployConfig{
UseAltDA: true, UseAltDA: true,
...@@ -356,7 +356,9 @@ func initAllocType(root string, allocType AllocType) { ...@@ -356,7 +356,9 @@ func initAllocType(root string, allocType AllocType) {
l2AllocsByType[allocType] = l2Alloc l2AllocsByType[allocType] = l2Alloc
} }
func defaultIntent(root string, loc *artifacts.Locator, deployer common.Address) *state.Intent { func defaultIntent(root string, loc *artifacts.Locator, deployer common.Address, allocType AllocType) *state.Intent {
defaultPrestate := common.HexToHash("0x03c7ae758795765c6664a5d39bf63841c71ff191e9189522bad8ebff5d4eca98")
genesisOutputRoot := common.HexToHash("0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF")
return &state.Intent{ return &state.Intent{
ConfigType: state.IntentConfigTypeCustom, ConfigType: state.IntentConfigTypeCustom,
DeploymentStrategy: state.DeploymentStrategyGenesis, DeploymentStrategy: state.DeploymentStrategyGenesis,
...@@ -392,12 +394,12 @@ func defaultIntent(root string, loc *artifacts.Locator, deployer common.Address) ...@@ -392,12 +394,12 @@ func defaultIntent(root string, loc *artifacts.Locator, deployer common.Address)
"gasPriceOracleBaseFeeScalar": 1368, "gasPriceOracleBaseFeeScalar": 1368,
"gasPriceOracleBlobBaseFeeScalar": 810949, "gasPriceOracleBlobBaseFeeScalar": 810949,
"l1CancunTimeOffset": "0x0", "l1CancunTimeOffset": "0x0",
"faultGameAbsolutePrestate": "0x03c7ae758795765c6664a5d39bf63841c71ff191e9189522bad8ebff5d4eca98", "faultGameAbsolutePrestate": defaultPrestate.Hex(),
"faultGameMaxDepth": 50, "faultGameMaxDepth": 50,
"faultGameClockExtension": 0, "faultGameClockExtension": 0,
"faultGameMaxClockDuration": 1200, "faultGameMaxClockDuration": 1200,
"faultGameGenesisBlock": 0, "faultGameGenesisBlock": 0,
"faultGameGenesisOutputRoot": "0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF", "faultGameGenesisOutputRoot": genesisOutputRoot.Hex(),
"faultGameSplitDepth": 14, "faultGameSplitDepth": 14,
"faultGameWithdrawalDelay": 604800, "faultGameWithdrawalDelay": 604800,
"preimageOracleMinProposalSize": 10000, "preimageOracleMinProposalSize": 10000,
...@@ -429,7 +431,7 @@ func defaultIntent(root string, loc *artifacts.Locator, deployer common.Address) ...@@ -429,7 +431,7 @@ func defaultIntent(root string, loc *artifacts.Locator, deployer common.Address)
ChainProofParams: state.ChainProofParams{ ChainProofParams: state.ChainProofParams{
// Fast game // Fast game
DisputeGameType: 254, DisputeGameType: 254,
DisputeAbsolutePrestate: common.HexToHash("0x03c7ae758795765c6664a5d39bf63841c71ff191e9189522bad8ebff5d4eca98"), DisputeAbsolutePrestate: defaultPrestate,
DisputeMaxGameDepth: 14 + 3 + 1, DisputeMaxGameDepth: 14 + 3 + 1,
DisputeSplitDepth: 14, DisputeSplitDepth: 14,
DisputeClockExtension: 0, DisputeClockExtension: 0,
...@@ -440,29 +442,32 @@ func defaultIntent(root string, loc *artifacts.Locator, deployer common.Address) ...@@ -440,29 +442,32 @@ func defaultIntent(root string, loc *artifacts.Locator, deployer common.Address)
OracleMinProposalSize: 10000, OracleMinProposalSize: 10000,
OracleChallengePeriodSeconds: 0, OracleChallengePeriodSeconds: 0,
MakeRespected: true, MakeRespected: true,
StartingAnchorRoot: genesisOutputRoot,
}, },
{ {
ChainProofParams: state.ChainProofParams{ ChainProofParams: state.ChainProofParams{
// Alphabet game // Alphabet game
DisputeGameType: 255, DisputeGameType: 255,
DisputeAbsolutePrestate: common.HexToHash("0x03c7ae758795765c6664a5d39bf63841c71ff191e9189522bad8ebff5d4eca98"), DisputeAbsolutePrestate: defaultPrestate,
DisputeMaxGameDepth: 14 + 3 + 1, DisputeMaxGameDepth: 14 + 3 + 1,
DisputeSplitDepth: 14, DisputeSplitDepth: 14,
DisputeClockExtension: 0, DisputeClockExtension: 0,
DisputeMaxClockDuration: 1200, DisputeMaxClockDuration: 1200,
}, },
VMType: state.VMTypeAlphabet, VMType: state.VMTypeAlphabet,
StartingAnchorRoot: genesisOutputRoot,
}, },
{ {
ChainProofParams: state.ChainProofParams{ ChainProofParams: state.ChainProofParams{
DisputeGameType: 0, DisputeGameType: 0,
DisputeAbsolutePrestate: cannonPrestate(root), DisputeAbsolutePrestate: cannonPrestate(root, allocType),
DisputeMaxGameDepth: 50, DisputeMaxGameDepth: 50,
DisputeSplitDepth: 14, DisputeSplitDepth: 14,
DisputeClockExtension: 0, DisputeClockExtension: 0,
DisputeMaxClockDuration: 1200, DisputeMaxClockDuration: 1200,
}, },
VMType: cannonVMType(), VMType: cannonVMType(allocType),
StartingAnchorRoot: genesisOutputRoot,
}, },
}, },
}, },
...@@ -498,8 +503,8 @@ func decompressGzipJSON(p string, thing any) { ...@@ -498,8 +503,8 @@ func decompressGzipJSON(p string, thing any) {
} }
} }
func cannonVMType() state.VMType { func cannonVMType(allocType AllocType) state.VMType {
if os.Getenv("USE_MT_CANNON") == "true" { if allocType == AllocTypeMTCannon {
return state.VMTypeCannon2 return state.VMTypeCannon2
} }
return state.VMTypeCannon1 return state.VMTypeCannon1
...@@ -509,19 +514,27 @@ type prestateFile struct { ...@@ -509,19 +514,27 @@ type prestateFile struct {
Pre string `json:"pre"` Pre string `json:"pre"`
} }
var cannonPrestateCache common.Hash var cannonPrestateMT common.Hash
var cannonPrestateOnce sync.Once var cannonPrestateST common.Hash
var cannonPrestateMTOnce sync.Once
var cannonPrestateSTOnce sync.Once
func cannonPrestate(monorepoRoot string) common.Hash { func cannonPrestate(monorepoRoot string, allocType AllocType) common.Hash {
var filename string var filename string
if cannonVMType() == state.VMTypeCannon1 { var once *sync.Once
filename = "prestate-proof-st.json" var cacheVar *common.Hash
if cannonVMType(allocType) == state.VMTypeCannon1 {
filename = "prestate-proof.json"
once = &cannonPrestateSTOnce
cacheVar = &cannonPrestateST
} else { } else {
filename = "prestate-proof-mt.json" filename = "prestate-proof-mt.json"
once = &cannonPrestateMTOnce
cacheVar = &cannonPrestateMT
} }
cannonPrestateOnce.Do(func() { once.Do(func() {
f, err := os.Open(path.Join(monorepoRoot, "op-program", "bin", filename)) f, err := os.Open(path.Join(monorepoRoot, "op-program", "bin", filename))
if err != nil { if err != nil {
log.Warn("error opening prestate file", "err", err) log.Warn("error opening prestate file", "err", err)
...@@ -536,8 +549,8 @@ func cannonPrestate(monorepoRoot string) common.Hash { ...@@ -536,8 +549,8 @@ func cannonPrestate(monorepoRoot string) common.Hash {
return return
} }
cannonPrestateCache = common.HexToHash(prestate.Pre) *cacheVar = common.HexToHash(prestate.Pre)
}) })
return cannonPrestateCache return *cacheVar
} }
...@@ -89,8 +89,7 @@ func testPrecompiles(t *testing.T, allocType e2e_config.AllocType) { ...@@ -89,8 +89,7 @@ func testPrecompiles(t *testing.T, allocType e2e_config.AllocType) {
op_e2e.InitParallel(t, op_e2e.UsesCannon) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
genesisTime := hexutil.Uint64(0) genesisTime := hexutil.Uint64(0)
cfg := e2esys.EcotoneSystemConfig(t, &genesisTime) cfg := e2esys.EcotoneSystemConfig(t, &genesisTime, e2esys.WithAllocType(allocType))
cfg.AllocType = allocType
// We don't need a verifier - just the sequencer is enough // We don't need a verifier - just the sequencer is enough
delete(cfg.Nodes, "verifier") delete(cfg.Nodes, "verifier")
...@@ -194,8 +193,7 @@ func testGranitePrecompiles(t *testing.T, allocType e2e_config.AllocType) { ...@@ -194,8 +193,7 @@ func testGranitePrecompiles(t *testing.T, allocType e2e_config.AllocType) {
op_e2e.InitParallel(t, op_e2e.UsesCannon) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
genesisTime := hexutil.Uint64(0) genesisTime := hexutil.Uint64(0)
cfg := e2esys.GraniteSystemConfig(t, &genesisTime) cfg := e2esys.GraniteSystemConfig(t, &genesisTime, e2esys.WithAllocType(allocType))
cfg.AllocType = allocType
// We don't need a verifier - just the sequencer is enough // We don't need a verifier - just the sequencer is enough
delete(cfg.Nodes, "verifier") delete(cfg.Nodes, "verifier")
......
...@@ -16,48 +16,66 @@ import ( ...@@ -16,48 +16,66 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
type faultDisputeConfigOpts func(cfg *e2esys.SystemConfig) type faultDisputeConfig struct {
sysOpts []e2esys.SystemConfigOpt
cfgModifiers []func(cfg *e2esys.SystemConfig)
}
type faultDisputeConfigOpts func(cfg *faultDisputeConfig)
func WithBatcherStopped() faultDisputeConfigOpts { func WithBatcherStopped() faultDisputeConfigOpts {
return func(cfg *e2esys.SystemConfig) { return func(fdc *faultDisputeConfig) {
cfg.DisableBatcher = true fdc.cfgModifiers = append(fdc.cfgModifiers, func(cfg *e2esys.SystemConfig) {
cfg.DisableBatcher = true
})
} }
} }
func WithBlobBatches() faultDisputeConfigOpts { func WithBlobBatches() faultDisputeConfigOpts {
return func(cfg *e2esys.SystemConfig) { return func(fdc *faultDisputeConfig) {
cfg.DataAvailabilityType = batcherFlags.BlobsType fdc.cfgModifiers = append(fdc.cfgModifiers, func(cfg *e2esys.SystemConfig) {
cfg.DataAvailabilityType = batcherFlags.BlobsType
genesisActivation := hexutil.Uint64(0) genesisActivation := hexutil.Uint64(0)
cfg.DeployConfig.L1CancunTimeOffset = &genesisActivation cfg.DeployConfig.L1CancunTimeOffset = &genesisActivation
cfg.DeployConfig.L2GenesisDeltaTimeOffset = &genesisActivation cfg.DeployConfig.L2GenesisDeltaTimeOffset = &genesisActivation
cfg.DeployConfig.L2GenesisEcotoneTimeOffset = &genesisActivation cfg.DeployConfig.L2GenesisEcotoneTimeOffset = &genesisActivation
})
} }
} }
func WithEcotone() faultDisputeConfigOpts { func WithEcotone() faultDisputeConfigOpts {
return func(cfg *e2esys.SystemConfig) { return func(fdc *faultDisputeConfig) {
genesisActivation := hexutil.Uint64(0) fdc.cfgModifiers = append(fdc.cfgModifiers, func(cfg *e2esys.SystemConfig) {
cfg.DeployConfig.L1CancunTimeOffset = &genesisActivation genesisActivation := hexutil.Uint64(0)
cfg.DeployConfig.L2GenesisDeltaTimeOffset = &genesisActivation cfg.DeployConfig.L1CancunTimeOffset = &genesisActivation
cfg.DeployConfig.L2GenesisEcotoneTimeOffset = &genesisActivation cfg.DeployConfig.L2GenesisDeltaTimeOffset = &genesisActivation
cfg.DeployConfig.L2GenesisEcotoneTimeOffset = &genesisActivation
})
} }
} }
func WithSequencerWindowSize(size uint64) faultDisputeConfigOpts { func WithSequencerWindowSize(size uint64) faultDisputeConfigOpts {
return func(cfg *e2esys.SystemConfig) { return func(fdc *faultDisputeConfig) {
cfg.DeployConfig.SequencerWindowSize = size fdc.cfgModifiers = append(fdc.cfgModifiers, func(cfg *e2esys.SystemConfig) {
cfg.DeployConfig.SequencerWindowSize = size
})
} }
} }
func WithAllocType(allocType config.AllocType) faultDisputeConfigOpts { func WithAllocType(allocType config.AllocType) faultDisputeConfigOpts {
return func(cfg *e2esys.SystemConfig) { return func(fdc *faultDisputeConfig) {
cfg.AllocType = allocType fdc.sysOpts = append(fdc.sysOpts, e2esys.WithAllocType(allocType))
} }
} }
func StartFaultDisputeSystem(t *testing.T, opts ...faultDisputeConfigOpts) (*e2esys.System, *ethclient.Client) { func StartFaultDisputeSystem(t *testing.T, opts ...faultDisputeConfigOpts) (*e2esys.System, *ethclient.Client) {
cfg := e2esys.DefaultSystemConfig(t) fdc := new(faultDisputeConfig)
for _, opt := range opts {
opt(fdc)
}
cfg := e2esys.DefaultSystemConfig(t, fdc.sysOpts...)
delete(cfg.Nodes, "verifier") delete(cfg.Nodes, "verifier")
cfg.Nodes["sequencer"].SafeDBPath = t.TempDir() cfg.Nodes["sequencer"].SafeDBPath = t.TempDir()
cfg.DeployConfig.SequencerWindowSize = 30 cfg.DeployConfig.SequencerWindowSize = 30
...@@ -65,9 +83,10 @@ func StartFaultDisputeSystem(t *testing.T, opts ...faultDisputeConfigOpts) (*e2e ...@@ -65,9 +83,10 @@ func StartFaultDisputeSystem(t *testing.T, opts ...faultDisputeConfigOpts) (*e2e
cfg.SupportL1TimeTravel = true cfg.SupportL1TimeTravel = true
// Disable proposer creating fast games automatically - required games are manually created // Disable proposer creating fast games automatically - required games are manually created
cfg.DisableProposer = true cfg.DisableProposer = true
for _, opt := range opts { for _, opt := range fdc.cfgModifiers {
opt(&cfg) opt(&cfg)
} }
sys, err := cfg.Start(t) sys, err := cfg.Start(t)
require.Nil(t, err, "Error starting up system") require.Nil(t, err, "Error starting up system")
return sys, sys.NodeClient("l1") return sys, sys.NodeClient("l1")
......
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