Skip to content

Commit

Permalink
chore(e2e/eoa): add new role RoleXCaller (#2379)
Browse files Browse the repository at this point in the history
This PR adds a new role RoleXCaller that will be used to send xmsgs on
differen't networks and source chain/dest chain combinations. We will
create a github action that will periodically send xmsgs and it will use
this account.

issue: #2275
  • Loading branch information
kc1116 authored Nov 5, 2024
1 parent 4771e84 commit 83a5745
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 83 deletions.
3 changes: 3 additions & 0 deletions e2e/app/eoa/eoa.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const (
RoleUpgrader Role = "upgrader"
// RoleTester is used for general tasks and testing in non-mainnet networks.
RoleTester Role = "tester"
// RoleXCaller is used for testing xcalls on a network.
RoleXCaller Role = "xcaller"
)

func AllRoles() []Role {
Expand All @@ -54,6 +56,7 @@ func AllRoles() []Role {
RoleManager,
RoleUpgrader,
RoleTester,
RoleXCaller,
}
}

Expand Down
9 changes: 8 additions & 1 deletion e2e/app/eoa/fund.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ var (
targetGwei: gwei(0.01),
}

// thresholdSmall is used for EOAs which are used sometimes, mostly to make small test transactions per network.
thresholdSmall = FundThresholds{
minGwei: gwei(0.02),
targetGwei: gwei(.2),
}

// thresholdMedium is used by EOAs that regularly perform actions and need enough balance
// to last a weekend without topping up even if fees are spiking.
thresholdMedium = FundThresholds{
Expand All @@ -58,12 +64,13 @@ var (
RoleUpgrader: thresholdTiny, // Rarely used
RoleDeployer: thresholdTiny, // Protected chains are only deployed once
RoleTester: thresholdLarge, // Tester funds pingpongs, validator updates, etc, on non-mainnet.
RoleXCaller: thresholdSmall, // XCaller funds used for sending xmsgs across networks.
}

dynamicThresholdsByRole = map[Role]dynamicThreshold{
RoleHot: {
Multiplier: hotDynamicMultiplier,
Roles: []Role{RoleRelayer, RoleMonitor, RoleCreate3Deployer, RoleManager, RoleUpgrader, RoleDeployer, RoleTester},
Roles: []Role{RoleRelayer, RoleMonitor, RoleCreate3Deployer, RoleManager, RoleUpgrader, RoleDeployer, RoleTester, RoleXCaller},
},
RoleCold: {
Multiplier: coldDynamicMultiplier,
Expand Down
4 changes: 4 additions & 0 deletions e2e/app/eoa/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var statics = map[netconf.ID][]Account{
wellKnown(anvil.DevPrivateKey7(), RoleTester),
wellKnown(anvil.DevPrivateKey8(), RoleHot),
wellKnown(anvil.DevPrivateKey9(), RoleCold),
wellKnown(anvil.DevPrivateKey10(), RoleXCaller),
),
netconf.Staging: flatten(
remote("0x64Bf40F5E6C4DE0dfe8fE6837F6339455657A2F5", RoleCold), // we use shared-cold
Expand All @@ -25,6 +26,7 @@ var statics = map[netconf.ID][]Account{
remote("0x7a6cF389082dc698285474976d7C75CAdE08ab7e", RoleTester), // reused shared-test with omega. Concurrent usage will result in nonce clashes.
secret("0xfE921e06Ed0a22c035b4aCFF0A5D3a434A330c96", RoleRelayer),
secret("0x0De553555Fa19d787Af4273B18bDB77282D618c4", RoleMonitor),
secret("0xbC0F36A57B666922CF7C01003a01a613D44e993C", RoleXCaller),
),
netconf.Omega: flatten(
remote("0x64Bf40F5E6C4DE0dfe8fE6837F6339455657A2F5", RoleCold), // we use shared-cold
Expand All @@ -36,6 +38,7 @@ var statics = map[netconf.ID][]Account{
remote("0x7a6cF389082dc698285474976d7C75CAdE08ab7e", RoleTester), // reused shared-test with staging. Concurrent usage will result in nonce clashes.
secret("0x37AD6f7267454cac494C177127aC017750c8A7DB", RoleRelayer),
secret("0xcef2a2c477Ec8473E4DeB9a8c2DF1D0585ea1040", RoleMonitor),
secret("0x01A1A1C3Fe5369bc4DF3B5a5bbC10639a14113ab", RoleXCaller),
),
netconf.Mainnet: flatten(
remote("0x8b6b217572582C57616262F9cE02A951A1D1b951", RoleCold),
Expand All @@ -46,5 +49,6 @@ var statics = map[netconf.ID][]Account{
remote("0x9496Bf1Bd2Fa5BCba72062cC781cC97eA6930A13", RoleDeployer),
secret("0xfD62020Cee216Dc543E29752058Ee9f60f7D9Ff9", RoleMonitor),
secret("0x6191442101086253A636aecBCC870e4778490AaB", RoleRelayer),
secret("0x835c36774B28563b9a1d1ae83dD6F671F51DCb5c", RoleXCaller),
),
}
47 changes: 27 additions & 20 deletions e2e/app/eoa/static_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ func TestThresholdReference(t *testing.T) {
for _, token := range []tokens.Token{tokens.ETH, tokens.OMNI} {
resp[network][token] = make(map[eoa.Role]map[string]string)
for _, role := range eoa.AllRoles() {
if !shouldExist(role, network) {
continue
}

resp[network][token][role] = make(map[string]string)

thresholds, ok := eoa.GetFundThresholds(token, network, role)
if network == netconf.Mainnet && role == eoa.RoleTester {
require.False(t, ok, "account should not exist: %s %s %s", network, role, token)
continue
}
require.True(t, ok, "thresholds not found: %s %s %s", network, role, token)

resp[network][token][role]["target"] = etherStr(thresholds.TargetBalance())
Expand All @@ -51,26 +51,24 @@ func TestStatic(t *testing.T) {
for _, chain := range evmchain.All() {
for _, network := range []netconf.ID{netconf.Devnet, netconf.Staging, netconf.Omega, netconf.Mainnet} {
for _, role := range eoa.AllRoles() {
shouldExist := role != eoa.RoleTester || network != netconf.Mainnet // skip tester on mainnet
if !shouldExist(role, network) {
continue
}

acc, ok := eoa.AccountForRole(network, role)
require.Equal(t, shouldExist, ok, "account not found: %s %s", network, role)
if shouldExist {
require.NotZero(t, acc.Address)
require.True(t, common.IsHexAddress(acc.Address.Hex()))
}
require.True(t, ok, "account not found: %s %s", network, role)
require.NotZero(t, acc.Address)
require.True(t, common.IsHexAddress(acc.Address.Hex()))

thresholds, ok := eoa.GetFundThresholds(chain.NativeToken, network, acc.Role)
require.Equal(t, shouldExist, ok, "thresholds not found")

if shouldExist {
require.NotPanics(t, func() {
mini := thresholds.MinBalance()
target := thresholds.TargetBalance()
t.Logf("Thresholds: network=%s, role=%s, min=%s, target=%s",
network, acc.Role, etherStr(mini), etherStr(target))
})
}
require.True(t, ok, "thresholds not found")

require.NotPanics(t, func() {
mini := thresholds.MinBalance()
target := thresholds.TargetBalance()
t.Logf("Thresholds: network=%s, role=%s, min=%s, target=%s",
network, acc.Role, etherStr(mini), etherStr(target))
})
}
}
}
Expand Down Expand Up @@ -102,3 +100,12 @@ func etherStr(amount *big.Int) string {

return fmt.Sprintf("%.4f", b)
}

func shouldExist(role eoa.Role, id netconf.ID) bool {
switch {
case role == eoa.RoleTester && id == netconf.Mainnet: // RoleTester not supported on mainnet
return false
default:
return true
}
}
74 changes: 48 additions & 26 deletions e2e/app/eoa/testdata/threshold_reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"mainnet": {
"ETH": {
"cold": {
"min": "2.0080",
"target": "8.0800"
"min": "2.0480",
"target": "8.4800"
},
"create3-deployer": {
"min": "0.0010",
Expand All @@ -14,8 +14,8 @@
"target": "0.0100"
},
"hot": {
"min": "2.0080",
"target": "8.0800"
"min": "2.0480",
"target": "8.4800"
},
"manager": {
"min": "0.0010",
Expand All @@ -29,16 +29,19 @@
"min": "0.5000",
"target": "2.0000"
},
"tester": {},
"upgrader": {
"min": "0.0010",
"target": "0.0100"
},
"xcaller": {
"min": "0.0200",
"target": "0.2000"
}
},
"OMNI": {
"cold": {
"min": "1004.0000",
"target": "4040.0000"
"min": "1024.0000",
"target": "4240.0000"
},
"create3-deployer": {
"min": "0.5000",
Expand All @@ -49,8 +52,8 @@
"target": "5.0000"
},
"hot": {
"min": "1004.0000",
"target": "4040.0000"
"min": "1024.0000",
"target": "4240.0000"
},
"manager": {
"min": "0.5000",
Expand All @@ -64,18 +67,21 @@
"min": "250.0000",
"target": "1000.0000"
},
"tester": {},
"upgrader": {
"min": "0.5000",
"target": "5.0000"
},
"xcaller": {
"min": "10.0000",
"target": "100.0000"
}
}
},
"omega": {
"ETH": {
"cold": {
"min": "22.0080",
"target": "108.0800"
"min": "22.0480",
"target": "108.4800"
},
"create3-deployer": {
"min": "0.0010",
Expand All @@ -86,8 +92,8 @@
"target": "0.0100"
},
"hot": {
"min": "22.0080",
"target": "108.0800"
"min": "22.0480",
"target": "108.4800"
},
"manager": {
"min": "0.0010",
Expand All @@ -108,12 +114,16 @@
"upgrader": {
"min": "0.0010",
"target": "0.0100"
},
"xcaller": {
"min": "0.0200",
"target": "0.2000"
}
},
"OMNI": {
"cold": {
"min": "11004.0000",
"target": "54040.0000"
"min": "11024.0000",
"target": "54240.0000"
},
"create3-deployer": {
"min": "0.5000",
Expand All @@ -124,8 +134,8 @@
"target": "5.0000"
},
"hot": {
"min": "11004.0000",
"target": "54040.0000"
"min": "11024.0000",
"target": "54240.0000"
},
"manager": {
"min": "0.5000",
Expand All @@ -146,14 +156,18 @@
"upgrader": {
"min": "0.5000",
"target": "5.0000"
},
"xcaller": {
"min": "10.0000",
"target": "100.0000"
}
}
},
"staging": {
"ETH": {
"cold": {
"min": "23.0060",
"target": "112.0600"
"min": "23.0460",
"target": "112.4600"
},
"create3-deployer": {
"min": "0.0010",
Expand All @@ -164,8 +178,8 @@
"target": "2.0000"
},
"hot": {
"min": "23.0060",
"target": "112.0600"
"min": "23.0460",
"target": "112.4600"
},
"manager": {
"min": "0.0010",
Expand All @@ -186,12 +200,16 @@
"upgrader": {
"min": "0.0010",
"target": "0.0100"
},
"xcaller": {
"min": "0.0200",
"target": "0.2000"
}
},
"OMNI": {
"cold": {
"min": "11503.0000",
"target": "56030.0000"
"min": "11523.0000",
"target": "56230.0000"
},
"create3-deployer": {
"min": "0.5000",
Expand All @@ -202,8 +220,8 @@
"target": "1000.0000"
},
"hot": {
"min": "11503.0000",
"target": "56030.0000"
"min": "11523.0000",
"target": "56230.0000"
},
"manager": {
"min": "0.5000",
Expand All @@ -224,6 +242,10 @@
"upgrader": {
"min": "0.5000",
"target": "5.0000"
},
"xcaller": {
"min": "10.0000",
"target": "100.0000"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions e2e/app/fund.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"github.com/ethereum/go-ethereum/params"
)

const saneMaxETH = 112 // Maximum amount of ETH to fund (in ether).
const saneMaxOmni = 56030 // Maximum amount of OMNI to fund (in ether OMNI).
const saneMaxETH = 113 // Maximum amount of ETH to fund (in ether).
const saneMaxOmni = 56630 // Maximum amount of OMNI to fund (in ether OMNI).

// noAnvilDev returns a list of accounts that are not dev anvil accounts.
func noAnvilDev(accounts []common.Address) []common.Address {
Expand Down
2 changes: 1 addition & 1 deletion e2e/cmd/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func verifyKeyNodeType(def app.Definition, cfg key.UploadConfig) error {

account, ok := eoa.AccountForRole(def.Testnet.Network, eoaRole)
if !ok {
return errors.New("eoa account not found")
return errors.New("eoa account not found add new account with empty string")
}

if account.Type != eoa.TypeSecret {
Expand Down
21 changes: 11 additions & 10 deletions halo/genutil/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,17 @@ func PrefundAlloc(network netconf.ID) (types.GenesisAlloc, error) {
func ephemeralPrefundAlloc() types.GenesisAlloc {
allocs := types.GenesisAlloc{
// anvil pre-funded accounts
anvil.DevAccount0(): {Balance: eth1m},
anvil.DevAccount1(): {Balance: eth1m},
anvil.DevAccount2(): {Balance: eth1m},
anvil.DevAccount3(): {Balance: eth1m},
anvil.DevAccount4(): {Balance: eth1m},
anvil.DevAccount5(): {Balance: eth1m},
anvil.DevAccount6(): {Balance: eth1m},
anvil.DevAccount7(): {Balance: eth1m},
anvil.DevAccount8(): {Balance: eth1m},
anvil.DevAccount9(): {Balance: eth1m},
anvil.DevAccount0(): {Balance: eth1m},
anvil.DevAccount1(): {Balance: eth1m},
anvil.DevAccount2(): {Balance: eth1m},
anvil.DevAccount3(): {Balance: eth1m},
anvil.DevAccount4(): {Balance: eth1m},
anvil.DevAccount5(): {Balance: eth1m},
anvil.DevAccount6(): {Balance: eth1m},
anvil.DevAccount7(): {Balance: eth1m},
anvil.DevAccount8(): {Balance: eth1m},
anvil.DevAccount9(): {Balance: eth1m},
anvil.DevAccount10(): {Balance: eth1m},

// team ops accounts
common.HexToAddress("0xfE921e06Ed0a22c035b4aCFF0A5D3a434A330c96"): {Balance: eth1m}, // dev relayer (local)
Expand Down
Loading

0 comments on commit 83a5745

Please sign in to comment.