Skip to content

Commit

Permalink
add policy accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Jul 10, 2024
1 parent b249faa commit 0b5a310
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
13 changes: 13 additions & 0 deletions cmd/zetae2e/config/localnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 21 additions & 3 deletions contrib/localnet/scripts/start-zetacored.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
28 changes: 28 additions & 0 deletions e2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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"`
Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 0b5a310

Please sign in to comment.