Skip to content

Commit

Permalink
feat(e2e/cmd): add deploy bridge command
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhalliday committed Nov 4, 2024
1 parent b4a803e commit 889567c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
2 changes: 1 addition & 1 deletion e2e/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func Deploy(ctx context.Context, def Definition, cfg DeployConfig) (*pingpong.XD
}
}

if err := setupTokenBridge(ctx, def); err != nil {
if err := DeployBridge(ctx, def); err != nil {
return nil, errors.Wrap(err, "setup token bridge")
}

Expand Down
30 changes: 13 additions & 17 deletions e2e/app/tokenbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
)

// setupTokenBridge deploys the OmniBridgeL1 & OmniToken contracts (if necessary), and configures the OmniBridgeNative predeploy.
func setupTokenBridge(ctx context.Context, def Definition) error {
if def.Testnet.Network == netconf.Mainnet {
// mainnet bridge will be setup post network deployment
return nil
}

// DeployBridge deploys the OmniBridgeL1 & OmniToken contracts (if necessary), and configures the OmniBridgeNative predeploy.
func DeployBridge(ctx context.Context, def Definition) error {
networkID := def.Testnet.Network
l1, ok := def.Testnet.EthereumChain()
if !ok {
Expand Down Expand Up @@ -57,17 +52,18 @@ func setupTokenBridge(ctx context.Context, def Definition) error {
return errors.Wrap(err, "omni backend")
}

// Deploy the token

tokenAddr, receipt, err := omnitoken.DeployIfNeeded(ctx, networkID, l1Backend)
if err != nil {
return errors.Wrap(err, "deploy omni token")
}
// Only deploy the token for non-mainnet
if networkID != netconf.Mainnet {
_, receipt, err := omnitoken.DeployIfNeeded(ctx, networkID, l1Backend)
if err != nil {
return errors.Wrap(err, "deploy omni token")
}

if receipt != nil {
log.Info(ctx, "Deployed Omni Token", "chain", l1.Name, "addr", tokenAddr.Hex(), "block", receipt.BlockNumber)
} else if tokenAddr != networkID.Static().TokenAddress {
log.Warn(ctx, "Omni token already deployed, but not in network static", errors.New("missing static token addr"), "addr", tokenAddr.Hex())
if receipt != nil {
log.Info(ctx, "Deployed Omni Token", "chain", l1.Name, "addr", addrs.Token.Hex(), "block", receipt.BlockNumber)
} else if addrs.Token != networkID.Static().TokenAddress {
log.Warn(ctx, "Omni token already deployed, but not in network static", errors.New("missing static token addr"), "addr", addrs.Token.Hex())
}
}

// Deploy the bridge
Expand Down
17 changes: 17 additions & 0 deletions e2e/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func New() *cobra.Command {
newAdminCmd(&def),
newERC20FaucetCmd(&def),
newDeployGasAppCmd(&def),
newDeployBridgeCmd(&def),
fundAccounts(&def),
)

Expand Down Expand Up @@ -261,3 +262,19 @@ func newDeployGasAppCmd(def *app.Definition) *cobra.Command {

return cmd
}

func newDeployBridgeCmd(def *app.Definition) *cobra.Command {
cmd := &cobra.Command{
Use: "deploy-bridge",
Short: "Deploys l1 bridge, setups native bridge.",
RunE: func(cmd *cobra.Command, _ []string) error {
if def.Testnet.Network.IsEphemeral() {
return errors.New("only permanent networks")
}

return app.DeployBridge(cmd.Context(), *def)
},
}

return cmd
}
2 changes: 1 addition & 1 deletion lib/contracts/testdata/TestContractAddressReference.golden
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
"portal": "0xcb60a0451831e4865bc49f41f9c67665fc9b75c3",
"token": "0xd036c60f46ff51dd7fbf6a819b5b171c8a076b07"
}
}
}
6 changes: 6 additions & 0 deletions lib/netconf/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,12 @@ func (s Static) ConsensusRPC() string {
var (
omegaAVS = common.HexToAddress("0xa7b2e7830C51728832D33421670DbBE30299fD92")
omegaPortal = common.HexToAddress("0xcB60A0451831E4865bC49f41F9C67665Fc9b75C3")
omegaBridge = common.HexToAddress("0x084ef227534A6Ad2DE4C4e54dB19f1C457A57a27")
omegaToken = common.HexToAddress("0xD036C60f46FF51dd7Fbf6a819b5B171c8A076b07")
mainnetAVS = common.HexToAddress("0xed2f4d90b073128ae6769a9A8D51547B1Df766C8")
mainnetToken = common.HexToAddress("0x36e66fbbce51e4cd5bd3c62b637eb411b18949d4")
mainnetPortal = common.HexToAddress("0x5e9A8Aa213C912Bf54C86bf64aDB8ed6A79C04d1")
mainnetBridge = common.HexToAddress("0x5e9A8Aa213C912Bf54C86bf64aDB8ed6A79C04d1") // To be deployed

//go:embed omega/consensus-genesis.json
omegaConsensusGenesisJSON []byte
Expand Down Expand Up @@ -209,6 +212,8 @@ var statics = map[ID]Static{
AVSContractAddress: omegaAVS,
OmniExecutionChainID: evmchain.IDOmniOmega,
MaxValidators: maxValidators,
TokenAddress: omegaToken,
L1BridgeAddress: omegaBridge,
Portals: []Deployment{
{ChainID: evmchain.IDArbSepolia, Address: omegaPortal, DeployHeight: 71015563},
{ChainID: evmchain.IDBaseSepolia, Address: omegaPortal, DeployHeight: 13932203},
Expand All @@ -227,6 +232,7 @@ var statics = map[ID]Static{
OmniExecutionChainID: evmchain.IDOmniMainnet,
MaxValidators: maxValidators,
TokenAddress: mainnetToken,
L1BridgeAddress: mainnetBridge,
Portals: []Deployment{
{ChainID: evmchain.IDEthereum, Address: mainnetPortal, DeployHeight: 21029795},
{ChainID: evmchain.IDArbitrumOne, Address: mainnetPortal, DeployHeight: 266889621},
Expand Down

0 comments on commit 889567c

Please sign in to comment.