Skip to content

Commit

Permalink
randomize localnet keys
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Jun 4, 2024
1 parent 7418e0f commit 41aff9f
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 38 deletions.
5 changes: 3 additions & 2 deletions cmd/zetae2e/config/local.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
zeta_chain_id: "athens_7001-1"
accounts:
deployer:
evm_address: "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC"
private_key: "d87baf7bf6dc560a252596678c12e41f7d1682837f05b29d411bc3f78ae2c263"
bech32_address: zeta1uhznv7uzyjq84s3q056suc8pkme85lkvhrz3dd
evm_address: 0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC
private_key: d87baf7bf6dc560a252596678c12e41f7d1682837f05b29d411bc3f78ae2c263
rpcs:
zevm: "http://0.0.0.0:9545"
evm: "http://0.0.0.0:8545"
Expand Down
40 changes: 24 additions & 16 deletions cmd/zetae2e/config/localnet.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
zeta_chain_id: "athens_101-1"
accounts:
deployer:
evm_address: "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC"
private_key: "d87baf7bf6dc560a252596678c12e41f7d1682837f05b29d411bc3f78ae2c263"
bech32_address: zeta1fxlsqfxvxtrnas4ac7spymcu9r3m4fen3sle3d
evm_address: 0x49bF0024Cc32C73ec2BDc7A0126f1c28E3baA733
private_key: e79da36bffce4258079404273284bf5c7e0ee744f8d537cc7d76e85f124259bb
additional_accounts:
user_erc20:
evm_address: "0x6F57D5E7c6DBb75e59F1524a3dE38Fc389ec5Fd6"
private_key: "fda3be1b1517bdf48615bdadacc1e6463d2865868dc8077d2cdcfa4709a16894"
bech32_address: zeta149uwgfqpcx0ac582ef2wwnqq6u8j5sfpjh9evc
evm_address: 0xa978E42401c19fdC50eAcA54E74c00d70f2A4121
private_key: b4ccebf1759b50fd9cc207e34d56a3483236d59b1fff3a113a5d8fecd8eed4f0
user_zeta_test:
evm_address: "0x5cC2fBb200A929B372e3016F1925DcF988E081fd"
private_key: "729a6cdc5c925242e7df92fdeeb94dadbf2d0b9950d4db8f034ab27a3b114ba7"
bech32_address: zeta1930fvyrh5d2tmjkd45vvhecqemsep5x3stpeg6
evm_address: 0x2c5E961077A354bdcaCdAd18cbe700CeE190d0d1
private_key: abc4bc5148bb53aba8497811a535d6fcafaaee192ef48ebc45b6b8f07b3c3176
user_zevm_mp_test:
evm_address: "0x8Ae229198eCE3c889C07DB648Ec7C30E6051592c"
private_key: "105460aebf71b10bfdb710ef5aa6d2932ee6ff6fc317ac9c24e0979903b10a5d"
bech32_address: zeta10dcylj5qwf2hhnctcx6hdxdlw7svts9wdgsvh4
evm_address: 0x7B704fcA8072557bCF0bc1B57699Bf77a0c5C0Ae
private_key: 32b356b6dc1e6e7c8c95ad60701498dcbe38201e5e3411b3f3896e6441e1efc9
user_bitcoin:
evm_address: "0x283d810090EdF4043E75247eAeBcE848806237fD"
private_key: "7bb523963ee2c78570fb6113d886a4184d42565e8847f1cb639f5f5e2ef5b37a"
bech32_address: zeta1yu27pntgex05gc0kqu2k7dtmp9zg8xqhpe0uc2
evm_address: 0x2715e0cD68c99F4461f607156f357B0944839817
private_key: 89233cf4ae1246d3818931791715a5445fc2e704463730e151c55a38df2479fc
user_ether:
evm_address: "0x8D47Db7390AC4D3D449Cc20D799ce4748F97619A"
private_key: "098e74a1c2261fa3c1b8cfca8ef2b4ff96c73ce36710d208d1f6535aef42545d"
bech32_address: zeta1uqmx23pxfm5626lhmrlqw4ud36vyptsdf8x20d
evm_address: 0xe0366544264EE9a56Bf7D8Fe07578d8e9840AE0d
private_key: b278b31e4add702f2462400fe9da2386908462a7ee69b81e3feeeb3f6679ac24
user_misc:
evm_address: "0x90126d02E41c9eB2a10cfc43aAb3BD3460523Cdf"
private_key: "853c0945b8035a501b1161df65a17a0a20fc848bda8975a8b4e9222cc6f84cd4"
bech32_address: zeta1peejc609gn74wn9xghc7tklsspkghhd3udmg05
evm_address: 0x0e732c69e544fd574cA645f1E5DbF0806C8bDdb1
private_key: 497c5d1abb1d08052c75b51d7854815a2e6382e0d1f423e70ec1f9873371d7e0
user_admin:
evm_address: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
private_key: "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
bech32_address: zeta1efqph3qvk68tj5vldy0acvnvgq7kpca4y22xen
evm_address: 0xcA401bC40CB68eb9519F691FdC326c403D60e3B5
private_key: 73871482c14868071fbbbdc83e56c9c2c4047a4649ada35658eb01dfca5502e9
rpcs:
zevm: "http://zetacore0:8545"
evm: "http://eth:8545"
Expand Down
40 changes: 24 additions & 16 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,44 @@ sleep 2
### Create the accounts and fund them with Ether on local Ethereum network

# unlock the deployer account
echo "funding deployer address 0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC", value: web3.toWei(10000,"ether")})' attach http://eth:8545
address=$(yq -r '.accounts.deployer.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

# unlock erc20 tester accounts
echo "funding deployer address 0x6F57D5E7c6DBb75e59F1524a3dE38Fc389ec5Fd6 with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x6F57D5E7c6DBb75e59F1524a3dE38Fc389ec5Fd6", value: web3.toWei(10000,"ether")})' attach http://eth:8545
address=$(yq -r '.additional_accounts.user_erc20.evm_address' config.yml)
echo "funding erc20 address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545

# unlock zeta tester accounts
echo "funding deployer address 0x5cC2fBb200A929B372e3016F1925DcF988E081fd with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x5cC2fBb200A929B372e3016F1925DcF988E081fd", value: web3.toWei(10000,"ether")})' attach http://eth:8545
address=$(yq -r '.additional_accounts.user_zeta_test.evm_address' config.yml)
echo "funding zeta tester address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545

# unlock zevm message passing tester accounts
echo "funding deployer address 0x8Ae229198eCE3c889C07DB648Ec7C30E6051592c with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x8Ae229198eCE3c889C07DB648Ec7C30E6051592c", value: web3.toWei(10000,"ether")})' attach http://eth:8545
address=$(yq -r '.additional_accounts.zevm_mp_test.evm_address' config.yml)
echo "funding zevm mp tester address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545

# unlock bitcoin tester accounts
echo "funding deployer address 0x283d810090EdF4043E75247eAeBcE848806237fD with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x283d810090EdF4043E75247eAeBcE848806237fD", value: web3.toWei(10000,"ether")})' attach http://eth:8545
address=$(yq -r '.additional_accounts.user_bitcoin.evm_address' config.yml)
echo "funding bitcoin tester address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545

# unlock ethers tester accounts
echo "funding deployer address 0x8D47Db7390AC4D3D449Cc20D799ce4748F97619A with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x8D47Db7390AC4D3D449Cc20D799ce4748F97619A", value: web3.toWei(10000,"ether")})' attach http://eth:8545
address=$(yq -r '.additional_accounts.user_ether.evm_address' config.yml)
echo "funding ether tester address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545

# unlock miscellaneous tests accounts
echo "funding deployer address 0x90126d02E41c9eB2a10cfc43aAb3BD3460523Cdf with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x90126d02E41c9eB2a10cfc43aAb3BD3460523Cdf", value: web3.toWei(10000,"ether")})' attach http://eth:8545
address=$(yq -r '.additional_accounts.user_misc.evm_address' config.yml)
echo "funding misc tester address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545

# unlock admin erc20 tests accounts
echo "funding deployer address 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 with 10000 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", value: web3.toWei(10000,"ether")})' attach http://eth:8545
address=$(yq -r '.additional_accounts.admin.evm_address' config.yml)
echo "funding admin tester address ${address} with 10000 Ether"
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545

# unlock the TSS account
echo "funding TSS address 0xF421292cb0d3c97b90EEEADfcD660B893592c6A2 with 10000 Ether"
Expand Down
24 changes: 20 additions & 4 deletions e2e/config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"bytes"
"crypto/ecdsa"
"errors"
"fmt"
Expand All @@ -27,8 +28,12 @@ type Config struct {
// Account contains configuration for an account
type Account struct {
RawBech32Address string `yaml:"bech32_address"`
RawEVMAddress string `yaml:"evm_address"`
RawPrivateKey string `yaml:"private_key"`
// hex encoded EVM style address
//
// WARN: this will not be double quoted because of https://github.com/go-yaml/yaml/issues/847
// and you may run into issues loading it in non-golang applications
RawEVMAddress string `yaml:"evm_address"`
RawPrivateKey string `yaml:"private_key"`
}

// Accounts are the required accounts to run any e2e test
Expand Down Expand Up @@ -254,14 +259,25 @@ func (a Account) Validate() error {
if err != nil {
return fmt.Errorf("invalid private key: %w", err)

Check warning on line 260 in e2e/config/config.go

View check run for this annotation

Codecov / codecov/patch

e2e/config/config.go#L260

Added line #L260 was not covered by tests
}
privateKeyAddress := crypto.PubkeyToAddress(privateKey.PublicKey).Hex()
if a.RawEVMAddress != privateKeyAddress {
privateKeyAddress := crypto.PubkeyToAddress(privateKey.PublicKey)
if a.RawEVMAddress != privateKeyAddress.Hex() {
return fmt.Errorf(
"address derived from private key (%s) does not match configured address (%s)",
privateKeyAddress,
a.RawEVMAddress,
)

Check warning on line 268 in e2e/config/config.go

View check run for this annotation

Codecov / codecov/patch

e2e/config/config.go#L264-L268

Added lines #L264 - L268 were not covered by tests
}
_, bech32Data, err := bech32.DecodeAndConvert(a.RawBech32Address)
if err != nil {
return fmt.Errorf("decoding bech32 address: %w", err)

Check warning on line 272 in e2e/config/config.go

View check run for this annotation

Codecov / codecov/patch

e2e/config/config.go#L272

Added line #L272 was not covered by tests
}
if !bytes.Equal(privateKeyAddress.Bytes(), bech32Data) {
return fmt.Errorf(
"address derived from private key (%s) does not match configured address (%s)",
privateKeyAddress,
a.RawBech32Address,
)

Check warning on line 279 in e2e/config/config.go

View check run for this annotation

Codecov / codecov/patch

e2e/config/config.go#L275-L279

Added lines #L275 - L279 were not covered by tests
}
return nil
}

Expand Down

0 comments on commit 41aff9f

Please sign in to comment.