Skip to content

Commit

Permalink
fix(e2e): update chain params if deployer account changes (#2612)
Browse files Browse the repository at this point in the history
* fix(e2e): update chain params if deployer account changes

* unconditionally update
  • Loading branch information
gartnera authored Aug 7, 2024
1 parent a01a2e8 commit d8a23e3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
13 changes: 1 addition & 12 deletions contrib/localnet/scripts/start-zetacored.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@ then
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
zetacored add-genesis-account "$emergency_policy" 100000000000000000000000000azeta
zetacored add-genesis-account "$admin_policy" 100000000000000000000000000azeta
zetacored add-genesis-account "$operational_policy" 100000000000000000000000000azeta
Expand All @@ -252,16 +250,7 @@ then
zetacored add-genesis-account "$address" 100000000000000000000000000azeta
# 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
zetacored add-genesis-account "$address" 100000000000000000000000000azeta
# migration tester
address=$(yq -r '.additional_accounts.user_migration.bech32_address' /root/config.yml)
zetacored add-genesis-account "$address" 100000000000000000000000000azeta
Expand Down
25 changes: 25 additions & 0 deletions e2e/runner/setup_evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import (
"github.com/zeta-chain/zetacore/e2e/contracts/erc20"
"github.com/zeta-chain/zetacore/e2e/contracts/testdapp"
"github.com/zeta-chain/zetacore/e2e/utils"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/constant"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

const (
Expand Down Expand Up @@ -167,4 +169,27 @@ func (r *E2ERunner) SetupEVM(contractsDeployed bool, whitelistERC20 bool) {
// We use this config to be consistent with the old implementation
// https://github.com/zeta-chain/node-private/issues/41
require.NoError(r, config.WriteConfig(ContractsConfigFile, conf))

// chain params will need to be updated if they do not match the default params
// this be required if the deployer account changes
currentChainParamsRes, err := r.ObserverClient.GetChainParamsForChain(
r.Ctx,
&observertypes.QueryGetChainParamsForChainRequest{
ChainId: chains.GoerliLocalnet.ChainId,
},
)
require.NoError(r, err, "failed to get chain params for chain %d", chains.GoerliLocalnet.ChainId)

chainParams := currentChainParamsRes.ChainParams
chainParams.Erc20CustodyContractAddress = r.ERC20CustodyAddr.Hex()
chainParams.ConnectorContractAddress = r.ConnectorEthAddr.Hex()
chainParams.ZetaTokenContractAddress = r.ZetaEthAddr.Hex()

_, err = r.ZetaTxServer.BroadcastTx(utils.OperationalPolicyName, observertypes.NewMsgUpdateChainParams(
r.ZetaTxServer.MustGetAccountAddressFromName(utils.OperationalPolicyName),
chainParams,
))

require.NoError(r, err, "failed to update chain params")
r.Logger.Print("🔄 updated chain params")
}

0 comments on commit d8a23e3

Please sign in to comment.