Skip to content

Commit

Permalink
feat(e2e): solve devnet (#2434)
Browse files Browse the repository at this point in the history
Add devnet manifest for deploying solve inbox / outbox contracts.

issue: #2355
  • Loading branch information
kevinhalliday authored Nov 11, 2024
1 parent 9d4f7ae commit 3100781
Show file tree
Hide file tree
Showing 11 changed files with 507 additions and 19 deletions.
3 changes: 3 additions & 0 deletions e2e/app/eoa/eoa.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const (
RoleTester Role = "tester"
// RoleXCaller is used for testing xcalls on a network.
RoleXCaller Role = "xcaller"
// RolveSolver is the allowed solver for solve inbox / outboxes.
RoleSolver Role = "solver"
)

func AllRoles() []Role {
Expand All @@ -57,6 +59,7 @@ func AllRoles() []Role {
RoleUpgrader,
RoleTester,
RoleXCaller,
// RoleSolver TODO: omitting solver for now. It is just used in devnet and not set for other networks.
}
}

Expand Down
1 change: 1 addition & 0 deletions e2e/app/eoa/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var statics = map[netconf.ID][]Account{
wellKnown(anvil.DevPrivateKey8(), RoleHot),
wellKnown(anvil.DevPrivateKey9(), RoleCold),
wellKnown(anvil.DevPrivateKey10(), RoleXCaller),
wellKnown(anvil.DevPrivateKey4(), RoleSolver),
),
netconf.Staging: flatten(
remote("0x64Bf40F5E6C4DE0dfe8fE6837F6339455657A2F5", RoleCold), // we use shared-cold
Expand Down
7 changes: 7 additions & 0 deletions e2e/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/omni-network/omni/e2e/app/eoa"
"github.com/omni-network/omni/e2e/netman"
"github.com/omni-network/omni/e2e/netman/pingpong"
"github.com/omni-network/omni/e2e/solve"
"github.com/omni-network/omni/e2e/types"
"github.com/omni-network/omni/halo/genutil/evm/predeploys"
"github.com/omni-network/omni/lib/contracts"
Expand Down Expand Up @@ -121,6 +122,12 @@ func Deploy(ctx context.Context, def Definition, cfg DeployConfig) (*pingpong.XD
return nil, err
}

if def.Manifest.DeploySolve {
if err := solve.DeployContracts(ctx, NetworkFromDef(def), def.Backends()); err != nil {
return nil, errors.Wrap(err, "deploy solve contracts")
}
}

err = waitForSupportedChains(ctx, def)
if err != nil {
return nil, err
Expand Down
11 changes: 11 additions & 0 deletions e2e/manifests/devnetsolve.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# DevnetSolve is a simple devnet with solve contracts deployed
network = "devnet"
anvil_chains = ["mock_l1", "mock_l2"]
deploy_solve = true

prometheus = true

[node.validator01]

[node.fullnode01]
mode="archive"
45 changes: 45 additions & 0 deletions e2e/solve/deploy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package solve

import (
"context"

"github.com/omni-network/omni/lib/contracts/solveinbox"
"github.com/omni-network/omni/lib/contracts/solveoutbox"
"github.com/omni-network/omni/lib/errors"
"github.com/omni-network/omni/lib/ethclient/ethbackend"
"github.com/omni-network/omni/lib/log"
"github.com/omni-network/omni/lib/netconf"
)

// DeployContracts deploys solve inbox / outbox contracts.
func DeployContracts(ctx context.Context, network netconf.Network, backends ethbackend.Backends) error {
if network.ID != netconf.Devnet {
log.Warn(ctx, "Skipping solve deploy", nil)
return nil
}

log.Info(ctx, "Deploying solve contracts")

for _, chain := range network.EVMChains() {
backend, err := backends.Backend(chain.ID)
if err != nil {
return errors.Wrap(err, "get backend", "chain", chain.Name)
}

addr, _, err := solveinbox.DeployIfNeeded(ctx, network.ID, backend)
if err != nil {
return errors.Wrap(err, "deploy solve inbox")
}

log.Info(ctx, "SolveInbox deployed", "addr", addr.Hex(), "chain", chain.Name)

addr, _, err = solveoutbox.DeployIfNeeded(ctx, network.ID, backend)
if err != nil {
return errors.Wrap(err, "deploy solve outbox")
}

log.Info(ctx, "SolveOutbox deployed", "addr", addr.Hex(), "chain", chain.Name)
}

return nil
}
3 changes: 3 additions & 0 deletions e2e/types/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ type Manifest struct {
// PingPongN defines the number of ping pong messages to send. Defaults 3 if 0.
PingPongN uint64 `toml:"pingpong_n"`

// DeploySolve defines whether to deploy the solve contracts
DeploySolve bool `toml:"deploy_solve"`

// Keys contains long-lived private keys (address by type) by node name.
Keys map[string]map[key.Type]string `toml:"keys"`

Expand Down
48 changes: 36 additions & 12 deletions lib/contracts/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,19 @@ type Addresses struct {
L1Bridge common.Address
Portal common.Address
Token common.Address
SolveOutbox common.Address
SolveInbox common.Address
}

type Salts struct {
AVS string
GasPump string
GasStation string
L1Bridge string
Portal string
Token string
AVS string
GasPump string
GasStation string
L1Bridge string
Portal string
Token string
SolveOutbox string
SolveInbox string
}

type cache[T any] struct {
Expand Down Expand Up @@ -135,6 +139,8 @@ func GetAddresses(ctx context.Context, network netconf.ID) (Addresses, error) {
Token: token(network, ver),
GasPump: gasPump(network, ver),
GasStation: gasStation(network, ver),
SolveInbox: solveInbox(network, ver),
SolveOutbox: solveOutbox(network, ver),
}

addrsCache.cache[network] = addrs
Expand All @@ -158,12 +164,14 @@ func GetSalts(ctx context.Context, network netconf.ID) (Salts, error) {
}

salts = Salts{
AVS: avsSalt(network),
Portal: portalSalt(network, ver),
L1Bridge: l1BridgeSalt(network, ver),
Token: tokenSalt(network, ver),
GasPump: gasPumpSalt(network, ver),
GasStation: gasStationSalt(network, ver),
AVS: avsSalt(network),
Portal: portalSalt(network, ver),
L1Bridge: l1BridgeSalt(network, ver),
Token: tokenSalt(network, ver),
GasPump: gasPumpSalt(network, ver),
GasStation: gasStationSalt(network, ver),
SolveInbox: solveInboxSalt(network, ver),
SolveOutbox: solveOutboxSalt(network, ver),
}

saltsCache.cache[network] = salts
Expand Down Expand Up @@ -216,6 +224,14 @@ func gasStation(network netconf.ID, version string) common.Address {
return create3.Address(create3Factory(network), gasStationSalt(network, version), eoa.MustAddress(network, eoa.RoleDeployer))
}

func solveInbox(network netconf.ID, version string) common.Address {
return create3.Address(create3Factory(network), solveInboxSalt(network, version), eoa.MustAddress(network, eoa.RoleDeployer))
}

func solveOutbox(network netconf.ID, version string) common.Address {
return create3.Address(create3Factory(network), solveOutboxSalt(network, version), eoa.MustAddress(network, eoa.RoleDeployer))
}

//
// Salts.
//
Expand Down Expand Up @@ -245,6 +261,14 @@ func gasStationSalt(network netconf.ID, version string) string {
return salt(network, "gas-station-"+version)
}

func solveInboxSalt(network netconf.ID, version string) string {
return salt(network, "solve-inbox-"+version)
}

func solveOutboxSalt(network netconf.ID, version string) string {
return salt(network, "solve-outbox-"+version)
}

//
// Utils.
//
Expand Down
16 changes: 9 additions & 7 deletions lib/contracts/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ func TestContractAddressReference(t *testing.T) {
require.NoError(t, err)

addrsJSON := map[string]common.Address{
"create3": addrs.Create3Factory,
"portal": addrs.Portal,
"avs": addrs.AVS,
"l1bridge": addrs.L1Bridge,
"token": addrs.Token,
"gaspump": addrs.GasPump,
"gasstation": addrs.GasStation,
"create3": addrs.Create3Factory,
"portal": addrs.Portal,
"avs": addrs.AVS,
"l1bridge": addrs.L1Bridge,
"token": addrs.Token,
"gaspump": addrs.GasPump,
"gasstation": addrs.GasStation,
"solveinbox": addrs.SolveInbox,
"solveoutbox": addrs.SolveOutbox,
}

for name, addr := range addrsJSON {
Expand Down
Loading

0 comments on commit 3100781

Please sign in to comment.