Skip to content

Commit

Permalink
load addresses from yaml, fix ssh host keygen
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Jun 18, 2024
1 parent 3fdd0aa commit edc6111
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 160 deletions.
10 changes: 6 additions & 4 deletions Dockerfile-localnet
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN go install cosmossdk.io/tools/cosmovisor/cmd/[email protected]
FROM golang:1.20.14-bookworm AS base-runtime

RUN apt update && \
apt install -yq jq curl tmux python3 openssh-server iputils-ping iproute2 && \
apt install -yq jq yq curl tmux python3 openssh-server iputils-ping iproute2 && \
rm -rf /var/lib/apt/lists/*

RUN ssh-keygen -A && \
Expand All @@ -45,13 +45,15 @@ ENV PATH /root/.zetacored/cosmovisor/current/bin/:/root/.zetaclientd/upgrades/cu

COPY contrib/localnet/scripts /root
COPY contrib/localnet/preparams /root/preparams
COPY contrib/localnet/ssh_config /root/.ssh/config
COPY contrib/localnet/ssh_config /etc/ssh/ssh_config.d/localnet
COPY contrib/localnet/zetacored /root/zetacored
COPY contrib/localnet/tss /root/tss
COPY cmd/zetae2e/config/localnet.yml /root/config.yml

RUN chmod 755 /root/*.sh
RUN chmod 755 /root/*.sh && \
chmod 744 /etc/ssh/ssh_config.d/localnet

WORKDIR /usr/local/bin
WORKDIR /root
EXPOSE 22

FROM base-runtime AS latest-runtime
Expand Down
32 changes: 16 additions & 16 deletions cmd/zetae2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,23 @@ func RunnerFromConfig(
// ExportContractsFromRunner export contracts from the runner to config using a source config
func ExportContractsFromRunner(r *runner.E2ERunner, conf config.Config) config.Config {
// copy contracts from deployer runner
conf.Contracts.EVM.ZetaEthAddress = r.ZetaEthAddr.Hex()
conf.Contracts.EVM.ConnectorEthAddr = r.ConnectorEthAddr.Hex()
conf.Contracts.EVM.CustodyAddr = r.ERC20CustodyAddr.Hex()
conf.Contracts.EVM.ERC20 = r.ERC20Addr.Hex()
conf.Contracts.EVM.TestDappAddr = r.EvmTestDAppAddr.Hex()
conf.Contracts.EVM.ZetaEthAddress = config.DoubleQuotedString(r.ZetaEthAddr.Hex())
conf.Contracts.EVM.ConnectorEthAddr = config.DoubleQuotedString(r.ConnectorEthAddr.Hex())
conf.Contracts.EVM.CustodyAddr = config.DoubleQuotedString(r.ERC20CustodyAddr.Hex())
conf.Contracts.EVM.ERC20 = config.DoubleQuotedString(r.ERC20Addr.Hex())
conf.Contracts.EVM.TestDappAddr = config.DoubleQuotedString(r.EvmTestDAppAddr.Hex())

conf.Contracts.ZEVM.SystemContractAddr = r.SystemContractAddr.Hex()
conf.Contracts.ZEVM.ETHZRC20Addr = r.ETHZRC20Addr.Hex()
conf.Contracts.ZEVM.ERC20ZRC20Addr = r.ERC20ZRC20Addr.Hex()
conf.Contracts.ZEVM.BTCZRC20Addr = r.BTCZRC20Addr.Hex()
conf.Contracts.ZEVM.UniswapFactoryAddr = r.UniswapV2FactoryAddr.Hex()
conf.Contracts.ZEVM.UniswapRouterAddr = r.UniswapV2RouterAddr.Hex()
conf.Contracts.ZEVM.ConnectorZEVMAddr = r.ConnectorZEVMAddr.Hex()
conf.Contracts.ZEVM.WZetaAddr = r.WZetaAddr.Hex()
conf.Contracts.ZEVM.ZEVMSwapAppAddr = r.ZEVMSwapAppAddr.Hex()
conf.Contracts.ZEVM.ContextAppAddr = r.ContextAppAddr.Hex()
conf.Contracts.ZEVM.TestDappAddr = r.ZevmTestDAppAddr.Hex()
conf.Contracts.ZEVM.SystemContractAddr = config.DoubleQuotedString(r.SystemContractAddr.Hex())
conf.Contracts.ZEVM.ETHZRC20Addr = config.DoubleQuotedString(r.ETHZRC20Addr.Hex())
conf.Contracts.ZEVM.ERC20ZRC20Addr = config.DoubleQuotedString(r.ERC20ZRC20Addr.Hex())
conf.Contracts.ZEVM.BTCZRC20Addr = config.DoubleQuotedString(r.BTCZRC20Addr.Hex())
conf.Contracts.ZEVM.UniswapFactoryAddr = config.DoubleQuotedString(r.UniswapV2FactoryAddr.Hex())
conf.Contracts.ZEVM.UniswapRouterAddr = config.DoubleQuotedString(r.UniswapV2RouterAddr.Hex())
conf.Contracts.ZEVM.ConnectorZEVMAddr = config.DoubleQuotedString(r.ConnectorZEVMAddr.Hex())
conf.Contracts.ZEVM.WZetaAddr = config.DoubleQuotedString(r.WZetaAddr.Hex())
conf.Contracts.ZEVM.ZEVMSwapAppAddr = config.DoubleQuotedString(r.ZEVMSwapAppAddr.Hex())
conf.Contracts.ZEVM.ContextAppAddr = config.DoubleQuotedString(r.ContextAppAddr.Hex())
conf.Contracts.ZEVM.TestDappAddr = config.DoubleQuotedString(r.ZevmTestDAppAddr.Hex())

return conf
}
123 changes: 63 additions & 60 deletions cmd/zetae2e/config/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package config
import (
"fmt"

ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/erc20custody.sol"
zetaeth "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zeta.eth.sol"
zetaconnectoreth "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zetaconnector.eth.sol"
Expand All @@ -27,168 +26,172 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {

// set EVM contracts
if c := conf.Contracts.EVM.ZetaEthAddress; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid ZetaEthAddress: %s", c)
r.ZetaEthAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid ZetaEthAddress: %w", err)
}
r.ZetaEthAddr = ethcommon.HexToAddress(c)
r.ZetaEth, err = zetaeth.NewZetaEth(r.ZetaEthAddr, r.EVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.EVM.ConnectorEthAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid ConnectorEthAddr: %s", c)
r.ConnectorEthAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid ConnectorEthAddr: %w", err)
}
r.ConnectorEthAddr = ethcommon.HexToAddress(c)
r.ConnectorEth, err = zetaconnectoreth.NewZetaConnectorEth(r.ConnectorEthAddr, r.EVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.EVM.CustodyAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid CustodyAddr: %s", c)
r.ERC20CustodyAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid CustodyAddr: %w", err)
}
r.ERC20CustodyAddr = ethcommon.HexToAddress(c)
r.ERC20Custody, err = erc20custody.NewERC20Custody(r.ERC20CustodyAddr, r.EVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.EVM.ERC20; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid ERC20: %s", c)
r.ERC20Addr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid ERC20: %w", err)
}
r.ERC20Addr = ethcommon.HexToAddress(c)
r.ERC20, err = erc20.NewERC20(r.ERC20Addr, r.EVMClient)
if err != nil {
return err
}
}

// set Zevm contracts
// set ZEVM contracts
if c := conf.Contracts.ZEVM.SystemContractAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid SystemContractAddr: %s", c)
r.SystemContractAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid SystemContractAddr: %w", err)
}
r.SystemContractAddr = ethcommon.HexToAddress(c)
r.SystemContract, err = systemcontract.NewSystemContract(r.SystemContractAddr, r.ZEVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.ZEVM.ETHZRC20Addr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid ETHZRC20Addr: %s", c)
r.ETHZRC20Addr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid ETHZRC20Addr: %w", err)
}
r.ETHZRC20Addr = ethcommon.HexToAddress(c)
r.ETHZRC20, err = zrc20.NewZRC20(r.ETHZRC20Addr, r.ZEVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.ZEVM.ERC20ZRC20Addr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid ERC20ZRC20Addr: %s", c)
r.ERC20ZRC20Addr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid ERC20ZRC20Addr: %w", err)
}
r.ERC20ZRC20Addr = ethcommon.HexToAddress(c)
r.ERC20ZRC20, err = zrc20.NewZRC20(r.ERC20ZRC20Addr, r.ZEVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.ZEVM.BTCZRC20Addr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid BTCZRC20Addr: %s", c)
}
r.BTCZRC20Addr = ethcommon.HexToAddress(c)
r.BTCZRC20, err = zrc20.NewZRC20(r.BTCZRC20Addr, r.ZEVMClient)
r.BTCZRC20Addr, err = c.AsEVMAddress()
if err != nil {
return err
}
}
if c := conf.Contracts.ZEVM.ERC20ZRC20Addr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid ERC20ZRC20Addr: %s", c)
return fmt.Errorf("invalid BTCZRC20Addr: %w", err)
}
r.ERC20ZRC20Addr = ethcommon.HexToAddress(c)
r.ERC20ZRC20, err = zrc20.NewZRC20(r.ERC20ZRC20Addr, r.ZEVMClient)
r.BTCZRC20, err = zrc20.NewZRC20(r.BTCZRC20Addr, r.ZEVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.ZEVM.UniswapFactoryAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid UniswapFactoryAddr: %s", c)
r.UniswapV2FactoryAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid UniswapFactoryAddr: %w", err)
}
r.UniswapV2FactoryAddr = ethcommon.HexToAddress(c)
r.UniswapV2Factory, err = uniswapv2factory.NewUniswapV2Factory(r.UniswapV2FactoryAddr, r.ZEVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.ZEVM.UniswapRouterAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid UniswapRouterAddr: %s", c)
r.UniswapV2RouterAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid UniswapRouterAddr: %w", err)
}
r.UniswapV2RouterAddr = ethcommon.HexToAddress(c)
r.UniswapV2Router, err = uniswapv2router.NewUniswapV2Router02(r.UniswapV2RouterAddr, r.ZEVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.ZEVM.ConnectorZEVMAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid ConnectorZEVMAddr: %s", c)
r.ConnectorZEVMAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid ConnectorZEVMAddr: %w", err)
}
r.ConnectorZEVMAddr = ethcommon.HexToAddress(c)
r.ConnectorZEVM, err = connectorzevm.NewZetaConnectorZEVM(r.ConnectorZEVMAddr, r.ZEVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.ZEVM.WZetaAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid WZetaAddr: %s", c)
r.WZetaAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid WZetaAddr: %w", err)
}
r.WZetaAddr = ethcommon.HexToAddress(c)
r.WZeta, err = wzeta.NewWETH9(r.WZetaAddr, r.ZEVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.ZEVM.ZEVMSwapAppAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid ZEVMSwapAppAddr: %s", c)
r.ZEVMSwapAppAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid ZEVMSwapAppAddr: %w", err)
}
r.ZEVMSwapAppAddr = ethcommon.HexToAddress(c)
r.ZEVMSwapApp, err = zevmswap.NewZEVMSwapApp(r.ZEVMSwapAppAddr, r.ZEVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.ZEVM.ContextAppAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid ContextAppAddr: %s", c)
r.ContextAppAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid ContextAppAddr: %w", err)
}
r.ContextAppAddr = ethcommon.HexToAddress(c)
r.ContextApp, err = contextapp.NewContextApp(r.ContextAppAddr, r.ZEVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.ZEVM.TestDappAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid ZevmTestDappAddr: %s", c)
r.ZevmTestDAppAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid ZevmTestDappAddr: %w", err)
}
r.ZevmTestDAppAddr = ethcommon.HexToAddress(c)
}

if c := conf.Contracts.EVM.TestDappAddr; c != "" {
if !ethcommon.IsHexAddress(c) {
return fmt.Errorf("invalid EvmTestDappAddr: %s", c)
r.EvmTestDAppAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid EvmTestDappAddr: %w", err)
}
r.EvmTestDAppAddr = ethcommon.HexToAddress(c)
}

return nil
Expand Down
50 changes: 25 additions & 25 deletions cmd/zetae2e/config/localnet.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
zeta_chain_id: "athens_101-1"
accounts:
deployer:
bech32_address: zeta1fxlsqfxvxtrnas4ac7spymcu9r3m4fen3sle3d
evm_address: 0x49bF0024Cc32C73ec2BDc7A0126f1c28E3baA733
private_key: e79da36bffce4258079404273284bf5c7e0ee744f8d537cc7d76e85f124259bb
bech32_address: "zeta1n8tfvy6s4glmp8r4steuja5zrgfalvr0nfr99q"
evm_address: "0x99d6961350aA3fb09C7582F3C976821A13DFb06f"
private_key: "263c595c5b703631d8e489ca95b6dad8a460e710df6b47d31b2e00abbbbeed53"
additional_accounts:
user_erc20:
bech32_address: zeta149uwgfqpcx0ac582ef2wwnqq6u8j5sfpjh9evc
evm_address: 0xa978E42401c19fdC50eAcA54E74c00d70f2A4121
private_key: b4ccebf1759b50fd9cc207e34d56a3483236d59b1fff3a113a5d8fecd8eed4f0
bech32_address: "zeta1m2kcpr459cwgzv4hv2vak6rz89umh5humxme6a"
evm_address: "0xdaAd808eB42E1C8132b76299DB68623979bBd2FC"
private_key: "73c026bf56ed085c8dbd3e0f3c0ae0daedd8d688d82b716aff75b53d281ad5d7"
user_zeta_test:
bech32_address: zeta1930fvyrh5d2tmjkd45vvhecqemsep5x3stpeg6
evm_address: 0x2c5E961077A354bdcaCdAd18cbe700CeE190d0d1
private_key: abc4bc5148bb53aba8497811a535d6fcafaaee192ef48ebc45b6b8f07b3c3176
bech32_address: "zeta12ztczzt6j4znwf32tvqcqspah5s3qg8fkwx2wx"
evm_address: "0x509781097A954537262a5B0180403dbd211020e9"
private_key: "eea9972997087dfc1a024ba066777f7a40348a6c1f0fb901d409f5846ef44fdf"
user_zevm_mp_test:
bech32_address: zeta10dcylj5qwf2hhnctcx6hdxdlw7svts9wdgsvh4
evm_address: 0x7B704fcA8072557bCF0bc1B57699Bf77a0c5C0Ae
private_key: 32b356b6dc1e6e7c8c95ad60701498dcbe38201e5e3411b3f3896e6441e1efc9
bech32_address: "zeta1wlutj5p2hr23p6z4vhp7jnt7cxxkd8rnfczrvc"
evm_address: "0x77f8b9502Ab8D510E85565c3E94D7ec18D669c73"
private_key: "93e4c38cd1689c6be87f9d5011cdd231ab968472bb1483ecbca5fb1db8a0e4af"
user_bitcoin:
bech32_address: zeta1yu27pntgex05gc0kqu2k7dtmp9zg8xqhpe0uc2
evm_address: 0x2715e0cD68c99F4461f607156f357B0944839817
private_key: 89233cf4ae1246d3818931791715a5445fc2e704463730e151c55a38df2479fc
bech32_address: "zeta1fltrg8z7k9wt7dygu68680le9vh96kzvxcpqfn"
evm_address: "0x4fD6341C5eB15CbF3488e68FA3bFf92b2E5d584C"
private_key: "0be8b14808b52c3ca85113b5472fe76eb2566bddcaf900de453218cc4e7fa182"
user_ether:
bech32_address: zeta1uqmx23pxfm5626lhmrlqw4ud36vyptsdf8x20d
evm_address: 0xe0366544264EE9a56Bf7D8Fe07578d8e9840AE0d
private_key: b278b31e4add702f2462400fe9da2386908462a7ee69b81e3feeeb3f6679ac24
bech32_address: "zeta1vprcujr05nx5jywv24a5vpnlxly84crlxzngdh"
evm_address: "0x60478e486Fa4Cd4911CC557b46067f37c87Ae07f"
private_key: "916d769389df042d7b8fabe3487fc762e7ac0cbf57e3b5d6a8c9d97b763e2adc"
user_misc:
bech32_address: zeta1peejc609gn74wn9xghc7tklsspkghhd3udmg05
evm_address: 0x0e732c69e544fd574cA645f1E5DbF0806C8bDdb1
private_key: 497c5d1abb1d08052c75b51d7854815a2e6382e0d1f423e70ec1f9873371d7e0
bech32_address: "zeta16mq0g7r27pevqnwx6qc6zvvd69sxfhfn08easj"
evm_address: "0xd6c0f4786Af072c04dc6d031a1318dd16064dD33"
private_key: "cb84dcec621aecde27c9f3187eb86bb8f600da9d3df4c7dcbe0db8d3091e4f10"
user_admin:
bech32_address: zeta1efqph3qvk68tj5vldy0acvnvgq7kpca4y22xen
evm_address: 0xcA401bC40CB68eb9519F691FdC326c403D60e3B5
private_key: 73871482c14868071fbbbdc83e56c9c2c4047a4649ada35658eb01dfca5502e9
bech32_address: "zeta1rpnxskyhppzwrn3awhqu3wxfey2kd5mnelgkuv"
evm_address: "0x18666858970844e1ce3D75C1C8B8C9c91566D373"
private_key: "4eb834f11c6ad5038e79756f82f74b83a0c8dee7c1cfbb16878ecabeae5efbab"
rpcs:
zevm: "http://zetacore0:8545"
evm: "http://eth:8545"
Expand Down Expand Up @@ -61,4 +61,4 @@ contracts:
connector_eth: "0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca"
custody: "0xff3135df4F2775f4091b81f4c7B6359CfA07862a"
erc20: "0xbD1e64A22B9F92D9Ce81aA9B4b0fFacd80215564"
fungible_admin_mnemonic: "snow grace federal cupboard arrive fancy gym lady uniform rotate exercise either leave alien grass"
fungible_admin_mnemonic: "raccoon foot earn can napkin parade verb bench mind deal crunch gorilla"
8 changes: 5 additions & 3 deletions contrib/localnet/orchestrator/Dockerfile.fastbuild
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
FROM zetanode:latest as zeta
FROM ethereum/client-go:v1.10.26 as geth
FROM golang:1.20.14-bookworm as orchestrator
FROM golang:1.20.14-bookworm as orchestrator

RUN apt update && \
apt install -yq jq curl tmux python3 openssh-server iputils-ping iproute2 && \
apt install -yq jq yq curl tmux python3 openssh-server iputils-ping iproute2 && \
rm -rf /var/lib/apt/lists/*

COPY --from=geth /usr/local/bin/geth /usr/local/bin/
COPY --from=zeta /usr/local/bin/zetacored /usr/local/bin/zetaclientd /usr/local/bin/zetae2e /usr/local/bin/

COPY contrib/localnet/orchestrator/start-zetae2e.sh /work/
COPY cmd/zetae2e/config/localnet.yml /work/config.yml
RUN chmod +x /work/*.sh
COPY contrib/localnet/ssh_config /etc/ssh/ssh_config.d/localnet
RUN chmod +x /work/*.sh && \
chmod 744 /etc/ssh/ssh_config.d/localnet

WORKDIR /work
Loading

0 comments on commit edc6111

Please sign in to comment.