From ead440efe6a5ce7d3ad8738a37be9d2254f29589 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 26 Jun 2024 14:29:10 -0700 Subject: [PATCH] s/deployer/default_account/ --- cmd/zetae2e/README.md | 14 ++++++-------- cmd/zetae2e/balances.go | 2 +- cmd/zetae2e/bitcoin_address.go | 2 +- cmd/zetae2e/config/config_test.go | 4 ++-- cmd/zetae2e/config/example.yml | 4 ++-- cmd/zetae2e/config/local.yml | 9 ++++----- cmd/zetae2e/config/localnet.yml | 9 ++++----- cmd/zetae2e/local/local.go | 2 +- cmd/zetae2e/run.go | 2 +- cmd/zetae2e/setup_bitcoin.go | 2 +- cmd/zetae2e/show_tss.go | 2 +- cmd/zetae2e/stress.go | 4 ++-- contrib/localnet/orchestrator/start-zetae2e.sh | 4 ++-- contrib/localnet/scripts/start-zetacored.sh | 4 ++-- e2e/config/config.go | 12 ++++-------- e2e/config/config_test.go | 8 +++----- 16 files changed, 37 insertions(+), 47 deletions(-) diff --git a/cmd/zetae2e/README.md b/cmd/zetae2e/README.md index 729b60a9b4..bdc043f7d2 100644 --- a/cmd/zetae2e/README.md +++ b/cmd/zetae2e/README.md @@ -24,10 +24,9 @@ This is an example of config for interaction with Athens3: ```go zeta_chain_id: "athens_7001-1" -accounts: - deployer - evm_address: "" - private_key: "" +default_account: + evm_address: "" + private_key: "" rpcs: zevm: ", generally using port 8545" evm: ", generally using port 8545" @@ -102,10 +101,9 @@ Testing a gas token requires the following values to be defined in the config: ```go zeta_chain_id -accounts: - deployer: - evm_address - private_key +default_account: + evm_address + private_key rpcs: zevm evm diff --git a/cmd/zetae2e/balances.go b/cmd/zetae2e/balances.go index f151e31ca0..13df89430a 100644 --- a/cmd/zetae2e/balances.go +++ b/cmd/zetae2e/balances.go @@ -58,7 +58,7 @@ func runBalances(cmd *cobra.Command, args []string) error { "e2e", cancel, conf, - conf.Accounts.Deployer, + conf.DefaultAccount, logger, ) if err != nil { diff --git a/cmd/zetae2e/bitcoin_address.go b/cmd/zetae2e/bitcoin_address.go index 6704b474f7..6c9c5c3f4a 100644 --- a/cmd/zetae2e/bitcoin_address.go +++ b/cmd/zetae2e/bitcoin_address.go @@ -58,7 +58,7 @@ func runBitcoinAddress(cmd *cobra.Command, args []string) error { "e2e", cancel, conf, - conf.Accounts.Deployer, + conf.DefaultAccount, logger, ) if err != nil { diff --git a/cmd/zetae2e/config/config_test.go b/cmd/zetae2e/config/config_test.go index 6b0cf9cdf6..f8eb98a01e 100644 --- a/cmd/zetae2e/config/config_test.go +++ b/cmd/zetae2e/config/config_test.go @@ -33,8 +33,8 @@ func TestReadConfig(t *testing.T) { t.Run(tt.name, func(t *testing.T) { conf, err := config.ReadConfig(tt.filePath) require.NoError(t, err) - require.NotEmpty(t, conf.Accounts.Deployer.RawEVMAddress) - require.NotEmpty(t, conf.Accounts.Deployer.RawPrivateKey) + require.NotEmpty(t, conf.DefaultAccount.RawEVMAddress) + require.NotEmpty(t, conf.DefaultAccount.RawPrivateKey) }) } } diff --git a/cmd/zetae2e/config/example.yml b/cmd/zetae2e/config/example.yml index be692b9d4c..21cdd6de36 100644 --- a/cmd/zetae2e/config/example.yml +++ b/cmd/zetae2e/config/example.yml @@ -1,7 +1,7 @@ zeta_chain_id: "athens_7001-1" -accounts: +default_account: evm_address: "" - evm_priv_key: "" + private_key: "" rpcs: zevm: ", generally using port 8545" evm: ", generally using port 8545" diff --git a/cmd/zetae2e/config/local.yml b/cmd/zetae2e/config/local.yml index aee3d0312c..ee5e171ccc 100644 --- a/cmd/zetae2e/config/local.yml +++ b/cmd/zetae2e/config/local.yml @@ -1,9 +1,8 @@ zeta_chain_id: "athens_7001-1" -accounts: - deployer: - bech32_address: zeta1uhznv7uzyjq84s3q056suc8pkme85lkvhrz3dd - evm_address: "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC" - private_key: "d87baf7bf6dc560a252596678c12e41f7d1682837f05b29d411bc3f78ae2c263" +default_account: + bech32_address: zeta1uhznv7uzyjq84s3q056suc8pkme85lkvhrz3dd + evm_address: "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC" + private_key: "d87baf7bf6dc560a252596678c12e41f7d1682837f05b29d411bc3f78ae2c263" rpcs: zevm: "http://0.0.0.0:9545" evm: "http://0.0.0.0:8545" diff --git a/cmd/zetae2e/config/localnet.yml b/cmd/zetae2e/config/localnet.yml index 6029569987..abb780db39 100644 --- a/cmd/zetae2e/config/localnet.yml +++ b/cmd/zetae2e/config/localnet.yml @@ -1,9 +1,8 @@ zeta_chain_id: "athens_101-1" -accounts: - deployer: - bech32_address: "zeta1uhznv7uzyjq84s3q056suc8pkme85lkvhrz3dd" - evm_address: "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC" - private_key: "d87baf7bf6dc560a252596678c12e41f7d1682837f05b29d411bc3f78ae2c263" +default_account: + bech32_address: "zeta1uhznv7uzyjq84s3q056suc8pkme85lkvhrz3dd" + evm_address: "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC" + private_key: "d87baf7bf6dc560a252596678c12e41f7d1682837f05b29d411bc3f78ae2c263" additional_accounts: user_erc20: bech32_address: "zeta1datate7xmwm4uk032f9rmcu0cwy7ch7kg6y6zv" diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index e166ff80ad..7e00f9ba5b 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -138,7 +138,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) { "deployer", cancel, conf, - conf.Accounts.Deployer, + conf.DefaultAccount, logger, runner.WithZetaTxServer(zetaTxServer), ) diff --git a/cmd/zetae2e/run.go b/cmd/zetae2e/run.go index 99cb58c3dd..9c36d8e3d2 100644 --- a/cmd/zetae2e/run.go +++ b/cmd/zetae2e/run.go @@ -80,7 +80,7 @@ func runE2ETest(cmd *cobra.Command, args []string) error { "e2e", cancel, conf, - conf.Accounts.Deployer, + conf.DefaultAccount, logger, ) if err != nil { diff --git a/cmd/zetae2e/setup_bitcoin.go b/cmd/zetae2e/setup_bitcoin.go index cc6049dd0f..99a5365adc 100644 --- a/cmd/zetae2e/setup_bitcoin.go +++ b/cmd/zetae2e/setup_bitcoin.go @@ -46,7 +46,7 @@ func runSetupBitcoin(_ *cobra.Command, args []string) error { "e2e", cancel, conf, - conf.Accounts.Deployer, + conf.DefaultAccount, logger, ) if err != nil { diff --git a/cmd/zetae2e/show_tss.go b/cmd/zetae2e/show_tss.go index eeb1128409..01b61317a1 100644 --- a/cmd/zetae2e/show_tss.go +++ b/cmd/zetae2e/show_tss.go @@ -46,7 +46,7 @@ func runShowTSS(_ *cobra.Command, args []string) error { "tss", cancel, conf, - conf.Accounts.Deployer, + conf.DefaultAccount, logger, ) if err != nil { diff --git a/cmd/zetae2e/stress.go b/cmd/zetae2e/stress.go index 240240e853..30b2faf924 100644 --- a/cmd/zetae2e/stress.go +++ b/cmd/zetae2e/stress.go @@ -84,7 +84,7 @@ func StressTest(cmd *cobra.Command, _ []string) { // initialize E2E tests config conf := must(local.GetConfig(cmd)) - deployerAccount := conf.Accounts.Deployer + deployerAccount := conf.DefaultAccount // Initialize clients ---------------------------------------------------------------- evmClient := must(ethclient.Dial(conf.RPCs.EVM)) @@ -129,7 +129,7 @@ func StressTest(cmd *cobra.Command, _ []string) { "deployer", cancel, conf, - conf.Accounts.Deployer, + conf.DefaultAccount, logger, )) diff --git a/contrib/localnet/orchestrator/start-zetae2e.sh b/contrib/localnet/orchestrator/start-zetae2e.sh index 3844db4efb..676d55e26e 100644 --- a/contrib/localnet/orchestrator/start-zetae2e.sh +++ b/contrib/localnet/orchestrator/start-zetae2e.sh @@ -37,8 +37,8 @@ sleep 2 ### Create the accounts and fund them with Ether on local Ethereum network -# unlock the deployer account -address=$(yq -r '.accounts.deployer.evm_address' config.yml) +# unlock the default account account +address=$(yq -r '.default_account.evm_address' config.yml) echo "funding deployer address ${address} with 10000 Ether" geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545 diff --git a/contrib/localnet/scripts/start-zetacored.sh b/contrib/localnet/scripts/start-zetacored.sh index 5f68377d7b..aba9538c5e 100755 --- a/contrib/localnet/scripts/start-zetacored.sh +++ b/contrib/localnet/scripts/start-zetacored.sh @@ -222,8 +222,8 @@ then cat $HOME/.zetacored/config/genesis.json | jq --arg address "$address" '.app_state["authority"]["policies"]["items"][2]["address"] = $address' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json # give balance to runner accounts to deploy contracts directly on zEVM -# deployer - address=$(yq -r '.accounts.deployer.bech32_address' /root/config.yml) +# default account + address=$(yq -r '.default_account.bech32_address' /root/config.yml) zetacored add-genesis-account "$address" 100000000000000000000000000azeta # erc20 tester address=$(yq -r '.additional_accounts.user_erc20.bech32_address' /root/config.yml) diff --git a/e2e/config/config.go b/e2e/config/config.go index acbebbde08..3b33fee697 100644 --- a/e2e/config/config.go +++ b/e2e/config/config.go @@ -39,7 +39,8 @@ func (s DoubleQuotedString) AsEVMAddress() (ethcommon.Address, error) { // Config contains the configuration for the e2e test type Config struct { - Accounts Accounts `yaml:"accounts"` + // Default account to use when running tests and running setup + DefaultAccount Account `yaml:"default_account"` AdditionalAccounts AdditionalAccounts `yaml:"additional_accounts"` RPCs RPCs `yaml:"rpcs"` Contracts Contracts `yaml:"contracts"` @@ -53,11 +54,6 @@ type Account struct { RawPrivateKey DoubleQuotedString `yaml:"private_key"` } -// Accounts are the required accounts to run any e2e test -type Accounts struct { - Deployer Account `yaml:"deployer"` -} - // AdditionalAccounts are extra accounts required to run specific tests type AdditionalAccounts struct { UserERC20 Account `yaml:"user_erc20"` @@ -207,7 +203,7 @@ func (c Config) Validate() error { return errors.New("invalid bitcoin params") } - err := c.Accounts.Deployer.Validate() + err := c.DefaultAccount.Validate() if err != nil { return fmt.Errorf("validating deployer account: %w", err) } @@ -228,7 +224,7 @@ func (c Config) Validate() error { // GenerateKeys generates new key pairs for all accounts func (c *Config) GenerateKeys() error { var err error - c.Accounts.Deployer, err = generateAccount() + c.DefaultAccount, err = generateAccount() if err != nil { return err } diff --git a/e2e/config/config_test.go b/e2e/config/config_test.go index 7c0afc135a..033efb81b6 100644 --- a/e2e/config/config_test.go +++ b/e2e/config/config_test.go @@ -29,11 +29,9 @@ func TestConfigAdditionalAccountsSliceSynced(t *testing.T) { func TestConfigInvalidAccount(t *testing.T) { conf := Config{ - Accounts: Accounts{ - Deployer: Account{ - RawEVMAddress: "asdf", - RawPrivateKey: "asdf", - }, + DefaultAccount: Account{ + RawEVMAddress: "asdf", + RawPrivateKey: "asdf", }, } err := conf.Validate()