From 0b5a310139c0107af3a908d70e69f72b559bfd37 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Wed, 10 Jul 2024 10:19:25 -0400 Subject: [PATCH] add policy accounts --- cmd/zetae2e/config/localnet.yml | 13 ++++++++++ contrib/localnet/scripts/start-zetacored.sh | 24 +++++++++++++++--- e2e/config/config.go | 28 +++++++++++++++++++++ 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/cmd/zetae2e/config/localnet.yml b/cmd/zetae2e/config/localnet.yml index abb780db39..8026e67219 100644 --- a/cmd/zetae2e/config/localnet.yml +++ b/cmd/zetae2e/config/localnet.yml @@ -36,6 +36,19 @@ additional_accounts: bech32_address: "zeta1svzuz982w09vf2y08xsh8qplj36phyz466krj3" evm_address: "0x8305C114Ea73cAc4A88f39A173803F94741b9055" private_key: "d88d09a7d6849c15a36eb6931f9dd616091a63e9849a2cc86f309ba11fb8fec5" +policy_accounts: + emergency_policy_account: + bech32_address: "zeta16m2cnrdwtgweq4njc6t470vl325gw4kp6s7tap" + evm_address: "0xd6d5898dAE5A1D905672c6975F3d9f8aA88756C1" + private_key: "88BE93D11624B794F4BCC77BEA7385AF7EAD0B183B913485C74F0A803ABBC3F0" + operational_policy_account: + bech32_address: "zeta1pgx85vzx4fzh5zzyjqgs6a6cmaujd0xs8efrkc" + evm_address: "0x0A0c7a3046AA457A084490110d7758Df7926bcd0" + private_key: "59D1B982BD446545A1740ABD01F1ED9C162B72ACC1522B9B71B6DB5A9C37FA7D" + admin_policy_account: + bech32_address: "zeta142ds9x7raljv2qz9euys93e64gjmgdfnc47dwq" + evm_address: "0xAa9b029BC3EFe4c50045Cf0902c73aAa25b43533" + private_key: "0595CB0CD9BF5264A85A603EC8E43C30ADBB5FD2D9E2EF84C374EA4A65BB616C" rpcs: zevm: "http://zetacore0:8545" evm: "http://eth:8545" diff --git a/contrib/localnet/scripts/start-zetacored.sh b/contrib/localnet/scripts/start-zetacored.sh index 64779d2a39..5e4b7e72b6 100755 --- a/contrib/localnet/scripts/start-zetacored.sh +++ b/contrib/localnet/scripts/start-zetacored.sh @@ -221,10 +221,19 @@ then zetacored add-genesis-account zeta1n0rn6sne54hv7w2uu93fl48ncyqz97d3kty6sh 100000000000000000000000000azeta # Funds the localnet_gov_admin account address=$(yq -r '.additional_accounts.user_fungible_admin.bech32_address' /root/config.yml) + emergency_policy=$(yq -r '.policy_accounts.emergency_policy_account.bech32_address' /root/config.yml) + admin_policy=$(yq -r '.policy_accounts.admin_policy_account.bech32_address' /root/config.yml) + operational_policy=$(yq -r '.policy_accounts.operational_policy_account.bech32_address' /root/config.yml) + + zetacored add-genesis-account "$address" 100000000000000000000000000azeta - cat $HOME/.zetacored/config/genesis.json | jq --arg address "$address" '.app_state["authority"]["policies"]["items"][0]["address"] = $address' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json - cat $HOME/.zetacored/config/genesis.json | jq --arg address "$address" '.app_state["authority"]["policies"]["items"][1]["address"] = $address' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json - 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 + zetacored add-genesis-account "$emergency_policy" 100000000000000000000000000azeta + zetacored add-genesis-account "$admin_policy" 100000000000000000000000000azeta + zetacored add-genesis-account "$operational_policy" 100000000000000000000000000azeta + + cat $HOME/.zetacored/config/genesis.json | jq --arg address "$emergency_policy" '.app_state["authority"]["policies"]["items"][0]["address"] = $address' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json + cat $HOME/.zetacored/config/genesis.json | jq --arg address "$operational_policy" '.app_state["authority"]["policies"]["items"][1]["address"] = $address' > $HOME/.zetacored/config/tmp_genesis.json && mv $HOME/.zetacored/config/tmp_genesis.json $HOME/.zetacored/config/genesis.json + cat $HOME/.zetacored/config/genesis.json | jq --arg address "$admin_policy" '.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 # default account @@ -242,6 +251,15 @@ then # ethers tester address=$(yq -r '.additional_accounts.user_ether.bech32_address' /root/config.yml) zetacored add-genesis-account "$address" 100000000000000000000000000azeta +# emergency policy account + address=$(yq -r '.policy_accounts.emergency_policy_account.bech32_address' /root/config.yml) + zetacored add-genesis-account "$address" 100000000000000000000000000azeta +# admin policy account + address=$(yq -r '.policy_accounts.admin_policy_account.bech32_address' /root/config.yml) + zetacored add-genesis-account "$address" 100000000000000000000000000azeta +# operational policy account + address=$(yq -r '.policy_accounts.operational_policy_account.bech32_address' /root/config.yml) + zetacored add-genesis-account "$address" 100000000000000000000000000azeta # 3. Copy the genesis.json to all the nodes .And use it to create a gentx for every node zetacored gentx operator 1000000000000000000000azeta --chain-id=$CHAINID --keyring-backend=$KEYRING --gas-prices 20000000000azeta diff --git a/e2e/config/config.go b/e2e/config/config.go index 66409ee339..235b7cb568 100644 --- a/e2e/config/config.go +++ b/e2e/config/config.go @@ -43,6 +43,7 @@ type Config struct { // Default account to use when running tests and running setup DefaultAccount Account `yaml:"default_account"` AdditionalAccounts AdditionalAccounts `yaml:"additional_accounts"` + PolicyAccounts PolicyAccounts `yaml:"policy_accounts"` RPCs RPCs `yaml:"rpcs"` Contracts Contracts `yaml:"contracts"` ZetaChainID string `yaml:"zeta_chain_id"` @@ -67,6 +68,12 @@ type AdditionalAccounts struct { UserFungibleAdmin Account `yaml:"user_fungible_admin"` } +type PolicyAccounts struct { + EmergencyPolicyAccount Account `yaml:"emergency_policy_account"` + OperationalPolicyAccount Account `yaml:"operational_policy_account"` + AdminPolicyAccount Account `yaml:"admin_policy_account"` +} + // RPCs contains the configuration for the RPC endpoints type RPCs struct { Zevm string `yaml:"zevm"` @@ -196,6 +203,15 @@ func (a AdditionalAccounts) AsSlice() []Account { } } +func (a PolicyAccounts) AsSlice() []Account { + return []Account{ + a.EmergencyPolicyAccount, + a.OperationalPolicyAccount, + a.AdminPolicyAccount, + } + +} + // Validate validates the config func (c Config) Validate() error { if c.RPCs.Bitcoin.Params != Mainnet && @@ -261,6 +277,18 @@ func (c *Config) GenerateKeys() error { if err != nil { return err } + c.PolicyAccounts.EmergencyPolicyAccount, err = generateAccount() + if err != nil { + return err + } + c.PolicyAccounts.OperationalPolicyAccount, err = generateAccount() + if err != nil { + return err + } + c.PolicyAccounts.AdminPolicyAccount, err = generateAccount() + if err != nil { + return err + } return nil }