Commit b1d119fc authored by Adrian Sutton's avatar Adrian Sutton Committed by GitHub

op-e2e: Retrieve AllocType from System instead of env (#12221)

* op-e2e: Retrieve AllocType from System instead of env

* Remove more uses of env.

* op-e2e: Run mt-cannon as an allocType without needing special env vars.
parent e7dbd848
...@@ -908,9 +908,6 @@ jobs: ...@@ -908,9 +908,6 @@ jobs:
go-e2e-test: go-e2e-test:
parameters: parameters:
variant:
type: string
default: ''
module: module:
description: Go Module Name description: Go Module Name
type: string type: string
...@@ -935,13 +932,6 @@ jobs: ...@@ -935,13 +932,6 @@ jobs:
parallelism: <<parameters.parallelism>> parallelism: <<parameters.parallelism>>
steps: steps:
- checkout - checkout
- when:
condition:
equal: ['-mt-cannon', <<parameters.variant>>]
steps:
- run:
name: Set OP_E2E_ALLOC_TYPE = mt-cannon
command: echo 'export OP_E2E_ALLOC_TYPE=mt-cannon' >> $BASH_ENV
- check-changed: - check-changed:
patterns: op-(.+),cannon,contracts-bedrock patterns: op-(.+),cannon,contracts-bedrock
- run: - run:
...@@ -979,7 +969,7 @@ jobs: ...@@ -979,7 +969,7 @@ jobs:
# want it to. # want it to.
export OP_E2E_CANNON_ENABLED="false" export OP_E2E_CANNON_ENABLED="false"
# Note: We don't use circle CI test splits because we need to split by test name, not by package. There is an additional # Note: We don't use circle CI test splits because we need to split by test name, not by package. There is an additional
# constraint that gotestsum does not currently (nor likely will) accept files from different pacakges when building. # constraint that gotestsum does not currently (nor likely will) accept files from different packages when building.
JUNIT_FILE=/tmp/test-results/<<parameters.module>>_<<parameters.target>>.xml JSON_LOG_FILE=/testlogs/test.log make <<parameters.target>> JUNIT_FILE=/tmp/test-results/<<parameters.module>>_<<parameters.target>>.xml JSON_LOG_FILE=/testlogs/test.log make <<parameters.target>>
working_directory: <<parameters.module>> working_directory: <<parameters.module>>
- store_artifacts: - store_artifacts:
...@@ -1685,13 +1675,10 @@ workflows: ...@@ -1685,13 +1675,10 @@ workflows:
context: context:
- slack - slack
- go-e2e-test: - go-e2e-test:
name: op-e2e-cannon-tests<< matrix.variant >> name: op-e2e-cannon-tests
matrix:
parameters:
variant: ["", "-mt-cannon"]
module: op-e2e module: op-e2e
target: test-cannon target: test-cannon
parallelism: 4 parallelism: 8
notify: true notify: true
mentions: "@proofs-squad" mentions: "@proofs-squad"
requires: requires:
......
...@@ -212,15 +212,3 @@ func initAllocType(root string, allocType AllocType) { ...@@ -212,15 +212,3 @@ func initAllocType(root string, allocType AllocType) {
dc.SetDeployments(l1Deployments) dc.SetDeployments(l1Deployments)
deployConfigsByType[allocType] = dc deployConfigsByType[allocType] = dc
} }
func AllocTypeFromEnv() AllocType {
allocType := os.Getenv("OP_E2E_ALLOC_TYPE")
if allocType == "" {
return DefaultAllocType
}
out := AllocType(allocType)
if err := out.Check(); err != nil {
panic(err)
}
return out
}
...@@ -12,7 +12,6 @@ import ( ...@@ -12,7 +12,6 @@ import (
"time" "time"
e2econfig "github.com/ethereum-optimism/optimism/op-e2e/config" e2econfig "github.com/ethereum-optimism/optimism/op-e2e/config"
"github.com/ethereum-optimism/optimism/op-service/crypto" "github.com/ethereum-optimism/optimism/op-service/crypto"
"github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethclient"
...@@ -39,6 +38,11 @@ type EndpointProvider interface { ...@@ -39,6 +38,11 @@ type EndpointProvider interface {
L1BeaconEndpoint() endpoint.RestHTTP L1BeaconEndpoint() endpoint.RestHTTP
} }
type System interface {
RollupCfg() *rollup.Config
L2Genesis() *core.Genesis
AllocType() e2econfig.AllocType
}
type Helper struct { type Helper struct {
log log.Logger log log.Logger
t *testing.T t *testing.T
...@@ -142,17 +146,17 @@ func applyCannonConfig(c *config.Config, t *testing.T, rollupCfg *rollup.Config, ...@@ -142,17 +146,17 @@ func applyCannonConfig(c *config.Config, t *testing.T, rollupCfg *rollup.Config,
c.Cannon.RollupConfigPath = rollupFile c.Cannon.RollupConfigPath = rollupFile
} }
func WithCannon(t *testing.T, rollupCfg *rollup.Config, l2Genesis *core.Genesis, allocType e2econfig.AllocType) Option { func WithCannon(t *testing.T, system System) Option {
return func(c *config.Config) { return func(c *config.Config) {
c.TraceTypes = append(c.TraceTypes, types.TraceTypeCannon) c.TraceTypes = append(c.TraceTypes, types.TraceTypeCannon)
applyCannonConfig(c, t, rollupCfg, l2Genesis, allocType) applyCannonConfig(c, t, system.RollupCfg(), system.L2Genesis(), system.AllocType())
} }
} }
func WithPermissioned(t *testing.T, rollupCfg *rollup.Config, l2Genesis *core.Genesis, allocType e2econfig.AllocType) Option { func WithPermissioned(t *testing.T, system System) Option {
return func(c *config.Config) { return func(c *config.Config) {
c.TraceTypes = append(c.TraceTypes, types.TraceTypePermissioned) c.TraceTypes = append(c.TraceTypes, types.TraceTypePermissioned)
applyCannonConfig(c, t, rollupCfg, l2Genesis, allocType) applyCannonConfig(c, t, system.RollupCfg(), system.L2Genesis(), system.AllocType())
} }
} }
......
...@@ -83,6 +83,7 @@ type DisputeSystem interface { ...@@ -83,6 +83,7 @@ type DisputeSystem interface {
L1Deployments() *genesis.L1Deployments L1Deployments() *genesis.L1Deployments
RollupCfg() *rollup.Config RollupCfg() *rollup.Config
L2Genesis() *core.Genesis L2Genesis() *core.Genesis
AllocType() config.AllocType
AdvanceTime(time.Duration) AdvanceTime(time.Duration)
} }
...@@ -117,7 +118,7 @@ func NewFactoryHelper(t *testing.T, ctx context.Context, system DisputeSystem, o ...@@ -117,7 +118,7 @@ func NewFactoryHelper(t *testing.T, ctx context.Context, system DisputeSystem, o
chainID, err := client.ChainID(ctx) chainID, err := client.ChainID(ctx)
require.NoError(err) require.NoError(err)
allocType := config.AllocTypeFromEnv() allocType := system.AllocType()
require.True(allocType.UsesProofs(), "AllocType %v does not support proofs", allocType) require.True(allocType.UsesProofs(), "AllocType %v does not support proofs", allocType)
factoryCfg := &FactoryCfg{PrivKey: TestKey} factoryCfg := &FactoryCfg{PrivKey: TestKey}
......
...@@ -35,7 +35,7 @@ type OutputCannonGameHelper struct { ...@@ -35,7 +35,7 @@ type OutputCannonGameHelper struct {
func (g *OutputCannonGameHelper) StartChallenger(ctx context.Context, name string, options ...challenger.Option) *challenger.Helper { func (g *OutputCannonGameHelper) StartChallenger(ctx context.Context, name string, options ...challenger.Option) *challenger.Helper {
opts := []challenger.Option{ opts := []challenger.Option{
challenger.WithCannon(g.T, g.System.RollupCfg(), g.System.L2Genesis(), g.AllocType), challenger.WithCannon(g.T, g.System),
challenger.WithFactoryAddress(g.FactoryAddr), challenger.WithFactoryAddress(g.FactoryAddr),
challenger.WithGameAddress(g.Addr), challenger.WithGameAddress(g.Addr),
} }
...@@ -331,7 +331,7 @@ func (g *OutputCannonGameHelper) createCannonTraceProvider(ctx context.Context, ...@@ -331,7 +331,7 @@ func (g *OutputCannonGameHelper) createCannonTraceProvider(ctx context.Context,
func (g *OutputCannonGameHelper) defaultChallengerOptions() []challenger.Option { func (g *OutputCannonGameHelper) defaultChallengerOptions() []challenger.Option {
return []challenger.Option{ return []challenger.Option{
challenger.WithCannon(g.T, g.System.RollupCfg(), g.System.L2Genesis(), g.AllocType), challenger.WithCannon(g.T, g.System),
challenger.WithFactoryAddress(g.FactoryAddr), challenger.WithFactoryAddress(g.FactoryAddr),
challenger.WithGameAddress(g.Addr), challenger.WithGameAddress(g.Addr),
} }
......
...@@ -42,7 +42,6 @@ type OutputGameHelper struct { ...@@ -42,7 +42,6 @@ type OutputGameHelper struct {
Addr common.Address Addr common.Address
CorrectOutputProvider *outputs.OutputTraceProvider CorrectOutputProvider *outputs.OutputTraceProvider
System DisputeSystem System DisputeSystem
AllocType config.AllocType
} }
func NewOutputGameHelper(t *testing.T, require *require.Assertions, client *ethclient.Client, opts *bind.TransactOpts, privKey *ecdsa.PrivateKey, func NewOutputGameHelper(t *testing.T, require *require.Assertions, client *ethclient.Client, opts *bind.TransactOpts, privKey *ecdsa.PrivateKey,
...@@ -58,7 +57,6 @@ func NewOutputGameHelper(t *testing.T, require *require.Assertions, client *ethc ...@@ -58,7 +57,6 @@ func NewOutputGameHelper(t *testing.T, require *require.Assertions, client *ethc
Addr: addr, Addr: addr,
CorrectOutputProvider: correctOutputProvider, CorrectOutputProvider: correctOutputProvider,
System: system, System: system,
AllocType: allocType,
} }
} }
......
...@@ -33,12 +33,20 @@ import ( ...@@ -33,12 +33,20 @@ import (
"github.com/ethereum-optimism/optimism/op-service/testlog" "github.com/ethereum-optimism/optimism/op-service/testlog"
) )
func TestBenchmarkCannon_FPP(t *testing.T) { func TestBenchmarkCannonFPP_Standard(t *testing.T) {
testBenchmarkCannonFPP(t, config.AllocTypeStandard)
}
func TestBenchmarkCannonFPP_Multithreaded(t *testing.T) {
testBenchmarkCannonFPP(t, config.AllocTypeMTCannon)
}
func testBenchmarkCannonFPP(t *testing.T, allocType config.AllocType) {
t.Skip("TODO(client-pod#906): Compare total witness size for assertions against pages allocated by the VM") t.Skip("TODO(client-pod#906): Compare total witness size for assertions against pages allocated by the VM")
op_e2e.InitParallel(t, op_e2e.UsesCannon) op_e2e.InitParallel(t, op_e2e.UsesCannon)
ctx := context.Background() ctx := context.Background()
cfg := e2esys.DefaultSystemConfig(t, e2esys.WithAllocType(config.AllocTypeFromEnv())) cfg := e2esys.DefaultSystemConfig(t, e2esys.WithAllocType(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")
// Use a small sequencer window size to avoid test timeout while waiting for empty blocks // Use a small sequencer window size to avoid test timeout while waiting for empty blocks
......
...@@ -4,8 +4,6 @@ import ( ...@@ -4,8 +4,6 @@ import (
"context" "context"
"testing" "testing"
"github.com/ethereum-optimism/optimism/op-e2e/config"
op_e2e "github.com/ethereum-optimism/optimism/op-e2e" op_e2e "github.com/ethereum-optimism/optimism/op-e2e"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
...@@ -29,7 +27,7 @@ func TestMultipleGameTypes(t *testing.T) { ...@@ -29,7 +27,7 @@ func TestMultipleGameTypes(t *testing.T) {
// Start a challenger with both cannon and alphabet support // Start a challenger with both cannon and alphabet support
gameFactory.StartChallenger(ctx, "TowerDefense", gameFactory.StartChallenger(ctx, "TowerDefense",
challenger.WithCannon(t, sys.RollupConfig, sys.L2GenesisCfg, config.AllocTypeFromEnv()), challenger.WithCannon(t, sys),
challenger.WithAlphabet(), challenger.WithAlphabet(),
challenger.WithPrivKey(sys.Cfg.Secrets.Alice), challenger.WithPrivKey(sys.Cfg.Secrets.Alice),
) )
......
This diff is collapsed.
...@@ -4,8 +4,6 @@ import ( ...@@ -4,8 +4,6 @@ import (
"context" "context"
"testing" "testing"
"github.com/ethereum-optimism/optimism/op-e2e/config"
op_e2e "github.com/ethereum-optimism/optimism/op-e2e" op_e2e "github.com/ethereum-optimism/optimism/op-e2e"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/challenger"
...@@ -28,7 +26,7 @@ func TestPermissionedGameType(t *testing.T) { ...@@ -28,7 +26,7 @@ func TestPermissionedGameType(t *testing.T) {
gameFactory.StartChallenger(ctx, "TowerDefense", gameFactory.StartChallenger(ctx, "TowerDefense",
challenger.WithValidPrestateRequired(), challenger.WithValidPrestateRequired(),
challenger.WithInvalidCannonPrestate(), challenger.WithInvalidCannonPrestate(),
challenger.WithPermissioned(t, sys.RollupConfig, sys.L2GenesisCfg, config.AllocTypeFromEnv()), challenger.WithPermissioned(t, sys),
challenger.WithPrivKey(sys.Cfg.Secrets.Alice), challenger.WithPrivKey(sys.Cfg.Secrets.Alice),
) )
......
...@@ -7,9 +7,8 @@ import ( ...@@ -7,9 +7,8 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
e2econfig "github.com/ethereum-optimism/optimism/op-e2e/config"
op_e2e "github.com/ethereum-optimism/optimism/op-e2e" op_e2e "github.com/ethereum-optimism/optimism/op-e2e"
e2e_config "github.com/ethereum-optimism/optimism/op-e2e/config"
"github.com/ethereum-optimism/optimism/op-e2e/system/e2esys" "github.com/ethereum-optimism/optimism/op-e2e/system/e2esys"
"github.com/ethereum-optimism/optimism/op-e2e/system/helpers" "github.com/ethereum-optimism/optimism/op-e2e/system/helpers"
...@@ -31,7 +30,15 @@ import ( ...@@ -31,7 +30,15 @@ import (
"github.com/ethereum-optimism/optimism/op-service/testlog" "github.com/ethereum-optimism/optimism/op-service/testlog"
) )
func TestPrecompiles(t *testing.T) { func TestPrecompiles_Standard(t *testing.T) {
testPrecompiles(t, e2e_config.AllocTypeStandard)
}
func TestPrecompiles_Multithreaded(t *testing.T) {
testPrecompiles(t, e2e_config.AllocTypeMTCannon)
}
func testPrecompiles(t *testing.T, allocType e2e_config.AllocType) {
op_e2e.InitParallel(t, op_e2e.UsesCannon) op_e2e.InitParallel(t, op_e2e.UsesCannon)
// precompile test vectors copied from go-ethereum // precompile test vectors copied from go-ethereum
tests := []struct { tests := []struct {
...@@ -81,6 +88,7 @@ func TestPrecompiles(t *testing.T) { ...@@ -81,6 +88,7 @@ func TestPrecompiles(t *testing.T) {
ctx := context.Background() ctx := context.Background()
genesisTime := hexutil.Uint64(0) genesisTime := hexutil.Uint64(0)
cfg := e2esys.EcotoneSystemConfig(t, &genesisTime) cfg := e2esys.EcotoneSystemConfig(t, &genesisTime)
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")
// Use a small sequencer window size to avoid test timeout while waiting for empty blocks // Use a small sequencer window size to avoid test timeout while waiting for empty blocks
...@@ -141,7 +149,7 @@ func TestPrecompiles(t *testing.T) { ...@@ -141,7 +149,7 @@ func TestPrecompiles(t *testing.T) {
t.Skipf("%v is not accelerated so no preimgae to upload", test.name) t.Skipf("%v is not accelerated so no preimgae to upload", test.name)
} }
ctx := context.Background() ctx := context.Background()
sys, _ := StartFaultDisputeSystem(t, WithBlobBatches()) sys, _ := StartFaultDisputeSystem(t, WithBlobBatches(), WithAllocType(allocType))
l2Seq := sys.NodeClient("sequencer") l2Seq := sys.NodeClient("sequencer")
aliceKey := sys.Cfg.Secrets.Alice aliceKey := sys.Cfg.Secrets.Alice
...@@ -175,11 +183,20 @@ func TestPrecompiles(t *testing.T) { ...@@ -175,11 +183,20 @@ func TestPrecompiles(t *testing.T) {
} }
} }
func TestGranitePrecompiles(t *testing.T) { func TestGranitePrecompiles_Standard(t *testing.T) {
testGranitePrecompiles(t, e2e_config.AllocTypeStandard)
}
func TestGranitePrecompiles_Multithreaded(t *testing.T) {
testGranitePrecompiles(t, e2e_config.AllocTypeMTCannon)
}
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)
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")
// Use a small sequencer window size to avoid test timeout while waiting for empty blocks // Use a small sequencer window size to avoid test timeout while waiting for empty blocks
...@@ -252,7 +269,7 @@ func runCannon(t *testing.T, ctx context.Context, sys *e2esys.System, inputs uti ...@@ -252,7 +269,7 @@ func runCannon(t *testing.T, ctx context.Context, sys *e2esys.System, inputs uti
l1Beacon := sys.L1BeaconEndpoint().RestHTTP() l1Beacon := sys.L1BeaconEndpoint().RestHTTP()
rollupEndpoint := sys.RollupEndpoint("sequencer").RPC() rollupEndpoint := sys.RollupEndpoint("sequencer").RPC()
l2Endpoint := sys.NodeEndpoint("sequencer").RPC() l2Endpoint := sys.NodeEndpoint("sequencer").RPC()
cannonOpts := challenger.WithCannon(t, sys.RollupCfg(), sys.L2Genesis(), e2econfig.AllocTypeFromEnv()) cannonOpts := challenger.WithCannon(t, sys)
dir := t.TempDir() dir := t.TempDir()
proofsDir := filepath.Join(dir, "cannon-proofs") proofsDir := filepath.Join(dir, "cannon-proofs")
cfg := config.NewConfig(common.Address{}, l1Endpoint, l1Beacon, rollupEndpoint, l2Endpoint, dir) cfg := config.NewConfig(common.Address{}, l1Endpoint, l1Beacon, rollupEndpoint, l2Endpoint, dir)
......
...@@ -50,8 +50,14 @@ func WithSequencerWindowSize(size uint64) faultDisputeConfigOpts { ...@@ -50,8 +50,14 @@ func WithSequencerWindowSize(size uint64) faultDisputeConfigOpts {
} }
} }
func WithAllocType(allocType config.AllocType) faultDisputeConfigOpts {
return func(cfg *e2esys.SystemConfig) {
cfg.AllocType = 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, e2esys.WithAllocType(config.AllocTypeFromEnv())) cfg := e2esys.DefaultSystemConfig(t)
delete(cfg.Nodes, "verifier") delete(cfg.Nodes, "verifier")
cfg.Nodes["sequencer"].SafeDBPath = t.TempDir() cfg.Nodes["sequencer"].SafeDBPath = t.TempDir()
cfg.DeployConfig.SequencerWindowSize = 4 cfg.DeployConfig.SequencerWindowSize = 4
......
...@@ -404,6 +404,10 @@ func (sys *System) L2Genesis() *core.Genesis { ...@@ -404,6 +404,10 @@ func (sys *System) L2Genesis() *core.Genesis {
return sys.L2GenesisCfg return sys.L2GenesisCfg
} }
func (sys *System) AllocType() config.AllocType {
return sys.Cfg.AllocType
}
func (sys *System) L1Slot(l1Timestamp uint64) uint64 { func (sys *System) L1Slot(l1Timestamp uint64) uint64 {
return (l1Timestamp - uint64(sys.Cfg.DeployConfig.L1GenesisBlockTimestamp)) / return (l1Timestamp - uint64(sys.Cfg.DeployConfig.L1GenesisBlockTimestamp)) /
sys.Cfg.DeployConfig.L1BlockTime sys.Cfg.DeployConfig.L1BlockTime
......
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