Skip to content

Commit

Permalink
Adds odyssey support (#302)
Browse files Browse the repository at this point in the history
* Adds odyssey support

* Adds docs
  • Loading branch information
nitaliano authored Dec 16, 2024
1 parent ed519bb commit b27245e
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 5 deletions.
4 changes: 4 additions & 0 deletions anvil/anvil.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func (a *Anvil) Start(ctx context.Context) error {
"--max-persisted-states", "5",
}

if a.cfg.OdysseyEnabled {
args = append(args, "--odyssey")
}

if a.cfg.L2Config != nil {
args = append(args, "--optimism")
}
Expand Down
3 changes: 3 additions & 0 deletions config/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ type ChainConfig struct {

// Optional
LogsDirectory string

// Optional
OdysseyEnabled bool
}

type NetworkConfig struct {
Expand Down
14 changes: 14 additions & 0 deletions config/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const (
InteropEnabledFlagName = "interop.enabled"
InteropAutoRelayFlagName = "interop.autorelay"
InteropDelayFlagName = "interop.delay"

OdysseyEnabledFlagName = "odyssey.enabled"
)

var documentationLinks = []struct {
Expand Down Expand Up @@ -95,6 +97,12 @@ func BaseCLIFlags(envPrefix string) []cli.Flag {
Usage: "Delay before relaying messages sent to the L2ToL2CrossDomainMessenger",
EnvVars: opservice.PrefixEnvVar(envPrefix, "INTEROP_DELAY"),
},
&cli.BoolFlag{
Name: OdysseyEnabledFlagName,
Value: false, // disabled by default
Usage: "Enable odyssey experimental features",
EnvVars: opservice.PrefixEnvVar(envPrefix, "ODYSSEY_ENABLED"),
},
}
}

Expand Down Expand Up @@ -135,6 +143,7 @@ type ForkCLIConfig struct {
Chains []string

InteropEnabled bool
OdysseyEnabled bool
}

type CLIConfig struct {
Expand All @@ -146,6 +155,8 @@ type CLIConfig struct {
InteropAutoRelay bool
InteropDelay uint64

OdysseyEnabled bool

LogsDirectory string

ForkConfig *ForkCLIConfig
Expand All @@ -166,6 +177,8 @@ func ReadCLIConfig(ctx *cli.Context) (*CLIConfig, error) {

LogsDirectory: ctx.String(LogsDirectoryFlagName),

OdysseyEnabled: ctx.Bool(OdysseyEnabledFlagName),

L1Host: ctx.String(L1HostFlagName),
L2Host: ctx.String(L2HostFlagName),
}
Expand All @@ -177,6 +190,7 @@ func ReadCLIConfig(ctx *cli.Context) (*CLIConfig, error) {
Chains: ctx.StringSlice(ChainsFlagName),

InteropEnabled: ctx.Bool(InteropEnabledFlagName),
OdysseyEnabled: ctx.Bool(OdysseyEnabledFlagName),
}
}

Expand Down
3 changes: 3 additions & 0 deletions docs/src/reference/supersim-fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ OPTIONS:
--log.pid (default: false) ($SUPERSIM_LOG_PID)
Show pid in the log
--odyssey.enabled (default: false) ($SUPERSIM_ODYSSEY_ENABLED)
Enable odyssey experimental features
--help, -h (default: false)
show help
```
Expand Down
3 changes: 3 additions & 0 deletions docs/src/reference/supersim.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ GLOBAL OPTIONS:
--logs.directory value ($SUPERSIM_LOGS_DIRECTORY)
Directory to store logs
--odyssey.enabled (default: false) ($SUPERSIM_ODYSSEY_ENABLED)
Enable odyssey experimental features
MISC
Expand Down
2 changes: 2 additions & 0 deletions orchestrator/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func NetworkConfigFromForkCLIConfig(log log.Logger, envPrefix string, cliConfig
RPCUrl: l1RpcUrl,
BlockNumber: l1Header.Number.Uint64(),
},
OdysseyEnabled: cliConfig.OdysseyEnabled,
}

// L2s
Expand Down Expand Up @@ -106,6 +107,7 @@ func NetworkConfigFromForkCLIConfig(log log.Logger, envPrefix string, cliConfig
L1ChainID: superchain.Config.L1.ChainID,
L1Addresses: registry.Addresses[chainCfg.ChainID],
},
OdysseyEnabled: cliConfig.OdysseyEnabled,
}

if forkConfig.InteropEnabled {
Expand Down
14 changes: 11 additions & 3 deletions orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,24 @@ type Orchestrator struct {
AdminServer *admin.AdminServer
}

func NewOrchestrator(log log.Logger, closeApp context.CancelCauseFunc, networkConfig *config.NetworkConfig, adminPort uint64) (*Orchestrator, error) {
func NewOrchestrator(log log.Logger, closeApp context.CancelCauseFunc, cliConfig *config.CLIConfig, networkConfig *config.NetworkConfig, adminPort uint64) (*Orchestrator, error) {
// Spin up L1 anvil instance
l1Anvil := anvil.New(log, closeApp, &networkConfig.L1Config)
l1Cfg := networkConfig.L1Config
if cliConfig != nil {
l1Cfg.OdysseyEnabled = cliConfig.OdysseyEnabled
}
l1Anvil := anvil.New(log, closeApp, &l1Cfg)

// Spin up L2 anvil instances
nextL2Port := networkConfig.L2StartingPort
l2Anvils, l2OpSims := make(map[uint64]config.Chain), make(map[uint64]*opsimulator.OpSimulator)
for i := range networkConfig.L2Configs {
cfg := networkConfig.L2Configs[i]

if cliConfig != nil {
cfg.OdysseyEnabled = cliConfig.OdysseyEnabled
}

cfg.Port = 0 // explicitly set to zero as this anvil sits behind a proxy

l2Anvil := anvil.New(log, closeApp, &cfg)
Expand All @@ -52,7 +61,6 @@ func NewOrchestrator(log log.Logger, closeApp context.CancelCauseFunc, networkCo
// Spin up OpSim to front the L2 instances
for i := range networkConfig.L2Configs {
cfg := networkConfig.L2Configs[i]

l2OpSims[cfg.ChainID] = opsimulator.New(log, closeApp, nextL2Port, cfg.Host, l1Anvil, l2Anvils[cfg.ChainID], l2Anvils, networkConfig.InteropDelay)

// only increment expected port if it has been specified
Expand Down
2 changes: 1 addition & 1 deletion orchestrator/orchestrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func createTestSuite(t *testing.T, networkConfig *config.NetworkConfig) *TestSui
testlog := testlog.Logger(t, log.LevelInfo)

ctx, closeApp := context.WithCancelCause(context.Background())
orchestrator, _ := NewOrchestrator(testlog, closeApp, networkConfig, 0)
orchestrator, _ := NewOrchestrator(testlog, closeApp, &config.CLIConfig{}, networkConfig, 0)

t.Cleanup(func() {
closeApp(nil)
Expand Down
2 changes: 1 addition & 1 deletion supersim.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewSupersim(log log.Logger, envPrefix string, closeApp context.CancelCauseF
networkConfig.InteropAutoRelay = cliConfig.InteropAutoRelay
networkConfig.InteropDelay = cliConfig.InteropDelay

o, err := orchestrator.NewOrchestrator(log, closeApp, &networkConfig, cliConfig.AdminPort)
o, err := orchestrator.NewOrchestrator(log, closeApp, cliConfig, &networkConfig, cliConfig.AdminPort)
if err != nil {
return nil, fmt.Errorf("failed to create orchestrator")
}
Expand Down

0 comments on commit b27245e

Please sign in to comment.