Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(e2e): merge portal deploy flow #2149

Merged
merged 1 commit into from
Oct 11, 2024
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
28 changes: 4 additions & 24 deletions e2e/app/create3.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,11 @@ func Create3Deploy(ctx context.Context, def Definition, cfg Create3DeployConfig)
return nil
}

func deployPrivateCreate3(ctx context.Context, def Definition) error {
for _, c := range def.Testnet.AnvilChains {
_, _, err := deployCreate3(ctx, def, c.Chain.ChainID)
func deployAllCreate3(ctx context.Context, def Definition) error {
for _, chain := range def.Testnet.EVMChains() {
_, _, err := deployCreate3(ctx, def, chain.ChainID)
if err != nil {
return errors.Wrap(err, "deploy create3")
}
}

// only deploy to omni evm once
if len(def.Testnet.OmniEVMs) > 0 {
c := def.Testnet.OmniEVMs[0]
_, _, err := deployCreate3(ctx, def, c.Chain.ChainID)
if err != nil {
return errors.Wrap(err, "deploy create3")
}
}

return nil
}

func deployPublicCreate3(ctx context.Context, def Definition) error {
for _, c := range def.Testnet.PublicChains {
_, _, err := deployCreate3(ctx, def, c.Chain().ChainID)
if err != nil {
return errors.Wrap(err, "deploy create3")
return errors.Wrap(err, "deploy create3", "chain", chain.Name)
}
}

Expand Down
15 changes: 10 additions & 5 deletions e2e/app/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,13 @@ func (d Definition) Netman() netman.Manager {
func (d Definition) DeployInfos() types.DeployInfos {
resp := make(types.DeployInfos)

for chainID, info := range d.Netman().DeployInfo() {
resp.Set(chainID, types.ContractPortal, info.PortalAddress, info.DeployHeight)
for chainID, portal := range d.Netman().Portals() {
resp.Set(
chainID,
types.ContractPortal,
portal.DeployInfo.PortalAddress,
portal.DeployInfo.DeployHeight,
)
}

return resp
Expand Down Expand Up @@ -512,15 +517,15 @@ func NetworkFromDef(def Definition) netconf.Network {
var chains []netconf.Chain

newChain := func(chain types.EVMChain) netconf.Chain {
depInfo := def.DeployInfos()[chain.ChainID]
portal := def.Netman().Portals()[chain.ChainID]
return netconf.Chain{
ID: chain.ChainID,
Name: chain.Name,
BlockPeriod: chain.BlockPeriod,
Shards: chain.Shards,
AttestInterval: chain.AttestInterval(def.Testnet.Network),
PortalAddress: depInfo[types.ContractPortal].Address,
DeployHeight: depInfo[types.ContractPortal].Height,
PortalAddress: portal.DeployInfo.PortalAddress,
DeployHeight: portal.DeployInfo.DeployHeight,
}
}

Expand Down
4 changes: 2 additions & 2 deletions e2e/app/fund.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func accountsToFund(network netconf.ID) []common.Address {
}
}

// fundAccounts funds the EOAs that need funding (just on anvil chains, for now).
func fundAccounts(ctx context.Context, def Definition) error {
// fundAnvilAccounts funds the EOAs on anvil that need funding.
func fundAnvilAccounts(ctx context.Context, def Definition) error {
accounts := accountsToFund(def.Testnet.Network)
eth100 := new(big.Int).Mul(big.NewInt(params.Ether), big.NewInt(100))
for _, chain := range def.Testnet.AnvilChains {
Expand Down
1 change: 1 addition & 0 deletions e2e/app/gaspump.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ var (
}
)

// TODO(corver): Move this to actual tests package.
func testGasPumps(ctx context.Context, def Definition) error {
networkID := def.Testnet.Network
network := NetworkFromDef(def)
Expand Down
9 changes: 4 additions & 5 deletions e2e/app/portalregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,12 @@ func evmChains(def Definition) ([]types.EVMChain, error) {

// toPortalDepls converts EVM chains to portal registry deployments.
func toPortalDepls(def Definition, chains []types.EVMChain) (map[uint64]bindings.PortalRegistryDeployment, error) {
infos := def.DeployInfos()
deps := make(map[uint64]bindings.PortalRegistryDeployment)

for _, chain := range chains {
info, ok := infos[chain.ChainID][types.ContractPortal]
portal, ok := def.Netman().Portals()[chain.ChainID]
if !ok {
return nil, errors.New("missing info", "chain", chain.ChainID)
return nil, errors.New("missing portal", "chain", chain.ChainID)
}

blockPeriodNs, err := umath.ToUint64(chain.BlockPeriod.Nanoseconds())
Expand All @@ -157,10 +156,10 @@ func toPortalDepls(def Definition, chains []types.EVMChain) (map[uint64]bindings
deps[chain.ChainID] = bindings.PortalRegistryDeployment{
Name: chain.Name,
ChainId: chain.ChainID,
Addr: info.Address,
Addr: portal.DeployInfo.PortalAddress,
BlockPeriodNs: blockPeriodNs,
AttestInterval: chain.AttestInterval(def.Testnet.Network),
DeployHeight: info.Height,
DeployHeight: portal.DeployInfo.DeployHeight,
Shards: chain.ShardsUint64(),
}
}
Expand Down
17 changes: 4 additions & 13 deletions e2e/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,30 +79,21 @@ func Deploy(ctx context.Context, def Definition, cfg DeployConfig) (*pingpong.XD
return nil, err
}

if err := waitForEVMs(ctx, NetworkFromDef(def), def.Backends()); err != nil {
if err := waitForEVMs(ctx, def.Testnet.EVMChains(), def.Backends()); err != nil {
return nil, err
}

contracts.UseStagingOmniRPC(def.Testnet.BroadcastOmniEVM().ExternalRPC)

if err := deployPublicCreate3(ctx, def); err != nil {
if err := fundAnvilAccounts(ctx, def); err != nil {
return nil, err
}

// Deploy public portals first so their addresses are available for setup.
if err := def.Netman().DeployPublicPortals(ctx, genesisValSetID, genesisVals); err != nil {
if err := deployAllCreate3(ctx, def); err != nil {
return nil, err
}

if err := fundAccounts(ctx, def); err != nil {
return nil, err
}

if err := deployPrivateCreate3(ctx, def); err != nil {
return nil, err
}

if err := def.Netman().DeployPrivatePortals(ctx, genesisValSetID, genesisVals); err != nil {
if err := def.Netman().DeployPortals(ctx, genesisValSetID, genesisVals); err != nil {
return nil, err
}
logRPCs(ctx, def)
Expand Down
8 changes: 4 additions & 4 deletions e2e/app/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"sync"
"time"

"github.com/omni-network/omni/e2e/types"
"github.com/omni-network/omni/lib/errors"
"github.com/omni-network/omni/lib/ethclient/ethbackend"
"github.com/omni-network/omni/lib/expbackoff"
"github.com/omni-network/omni/lib/log"
"github.com/omni-network/omni/lib/netconf"

e2e "github.com/cometbft/cometbft/test/e2e/pkg"
"github.com/cometbft/cometbft/test/e2e/pkg/infra"
Expand Down Expand Up @@ -176,9 +176,9 @@ func getSortedNodes(testnet *e2e.Testnet) ([]*e2e.Node, error) {
// waitForEVMs waits for EVMs to be available.
// This mitigates any issues if starting anvils or omni evms is slow.
// It also ensures the public RPCs are accessible.
func waitForEVMs(ctx context.Context, network netconf.Network, backends ethbackend.Backends) error {
for _, chain := range network.EVMChains() {
backend, err := backends.Backend(chain.ID)
func waitForEVMs(ctx context.Context, chains []types.EVMChain, backends ethbackend.Backends) error {
for _, chain := range chains {
backend, err := backends.Backend(chain.ChainID)
if err != nil {
return errors.Wrap(err, "backend")
}
Expand Down
1 change: 1 addition & 0 deletions e2e/app/tokenbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ var ToL1BridgeTests = []BridgeTest{

// testBridge bridges some tokens from L1 to OmniEVM, and some from OmniEVM to L1.
// Tokens must be bridged to OmniEVM first, before the native bridge contract will allow bridging back to L1.
// TODO(corver): Move this to actual tests package.
func testBridge(ctx context.Context, def Definition) error {
networkID := def.Testnet.Network
network := NetworkFromDef(def)
Expand Down
Loading
Loading