Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/improve-start-cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
swift1337 authored Dec 12, 2024
2 parents 6f43ea0 + 462fcea commit ef9fb5a
Show file tree
Hide file tree
Showing 70 changed files with 2,282 additions and 362 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ ifdef UPGRADE_TEST_FROM_SOURCE
zetanode-upgrade: e2e-images
@echo "Building zetanode-upgrade from source"
$(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime-source \
--build-arg OLD_VERSION='release/v22' \
--build-arg OLD_VERSION='release/v23' \
--build-arg NODE_VERSION=$(NODE_VERSION) \
--build-arg NODE_COMMIT=$(NODE_COMMIT)
.
Expand All @@ -336,7 +336,7 @@ else
zetanode-upgrade: e2e-images
@echo "Building zetanode-upgrade from binaries"
$(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime \
--build-arg OLD_VERSION='https://github.com/zeta-chain/node/releases/download/v22.1.1' \
--build-arg OLD_VERSION='https://github.com/zeta-chain/node/releases/download/v23.1.5' \
--build-arg NODE_VERSION=$(NODE_VERSION) \
--build-arg NODE_COMMIT=$(NODE_COMMIT) \
.
Expand Down Expand Up @@ -409,7 +409,7 @@ test-sim-fullappsimulation:
$(call run-sim-test,"TestFullAppSimulation",TestFullAppSimulation,100,200,30m)

test-sim-import-export:
$(call run-sim-test,"test-import-export",TestAppImportExport,100,200,30m)
$(call run-sim-test,"test-import-export",TestAppImportExport,50,100,30m)

test-sim-after-import:
$(call run-sim-test,"test-sim-after-import",TestAppSimulationAfterImport,100,200,30m)
Expand Down
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,8 @@ func New(
app.SlashingKeeper,
app.AuthorityKeeper,
app.LightclientKeeper,
app.BankKeeper,
app.AccountKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

Expand Down
3 changes: 3 additions & 0 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,8 @@ func simulationModules(
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, app.GetSubspace(evmtypes.ModuleName)),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
crosschainmodule.NewAppModule(appCodec, app.CrosschainKeeper),
observermodule.NewAppModule(appCodec, *app.ObserverKeeper),
fungiblemodule.NewAppModule(appCodec, app.FungibleKeeper),
}
}
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

* [3205](https://github.com/zeta-chain/node/issues/3205) - move Bitcoin revert address test to advanced group to avoid upgrade test failure
* [3254](https://github.com/zeta-chain/node/pull/3254) - rename v2 E2E tests as evm tests and rename old evm tests as legacy
* [3095](https://github.com/zeta-chain/node/pull/3095) - initialize simulation tests for custom zetachain modules

## Refactor

Expand All @@ -23,6 +24,7 @@
* [3225](https://github.com/zeta-chain/node/pull/3225) - use separate database file names for btc signet and testnet4
* [3242](https://github.com/zeta-chain/node/pull/3242) - set the `Receiver` of `MsgVoteInbound` to the address pulled from solana memo
* [3253](https://github.com/zeta-chain/node/pull/3253) - fix solana inbound version 0 queries and move tss keysign prior to relayer key checking
* [3278](https://github.com/zeta-chain/node/pull/3278) - enforce checksum format for asset address in ZRC20

## v23.0.0

Expand Down
104 changes: 104 additions & 0 deletions cmd/zetae2e/local/get_zetaclient_bootstrap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package local

import (
"fmt"
"net"
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/spf13/cobra"
"gitlab.com/thorchain/tss/go-tss/conversion"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"github.com/zeta-chain/node/pkg/rpc"
"github.com/zeta-chain/node/pkg/sdkconfig"
observertypes "github.com/zeta-chain/node/x/observer/types"
)

const grpcURLFlag = "grpc-url"

func NewGetZetaclientBootstrap() *cobra.Command {
var cmd = &cobra.Command{
Use: "get-zetaclient-bootstrap",
Short: "get bootstrap address book entries for zetaclient",
RunE: getZetaclientBootstrap,
}

cmd.Flags().
String(grpcURLFlag, "zetacore0:9090", "--grpc-url zetacore0:9090")

return cmd
}

func getZetaclientBootstrap(cmd *cobra.Command, _ []string) error {
sdkconfig.SetDefault(true)
grpcURL, _ := cmd.Flags().GetString(grpcURLFlag)
rpcClient, err := rpc.NewGRPCClients(
grpcURL,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock(),
)
if err != nil {
return fmt.Errorf("get zetacore rpc client: %w", err)
}
var res *observertypes.QueryAllNodeAccountResponse
for {
res, err = rpcClient.Observer.NodeAccountAll(cmd.Context(), &observertypes.QueryAllNodeAccountRequest{})
if err != nil {
return fmt.Errorf("get all node accounts: %w", err)
}
if len(res.NodeAccount) > 1 {
break
}
fmt.Fprintln(cmd.OutOrStderr(), "waiting for node accounts")
}

// note that we deliberately do not filter ourselfs/localhost
// to mirror the production configuration
for _, account := range res.NodeAccount {
accAddr, err := sdk.AccAddressFromBech32(account.Operator)
if err != nil {
return err
}
valAddr := sdk.ValAddress(accAddr).String()
validatorRes, err := rpcClient.Staking.Validator(cmd.Context(), &stakingtypes.QueryValidatorRequest{
ValidatorAddr: valAddr,
})
if err != nil {
return fmt.Errorf("getting validator info for %s: %w", account.Operator, err)
}
// in localnet, moniker is also the hostname
moniker := validatorRes.Validator.Description.Moniker

peerID, err := conversion.Bech32PubkeyToPeerID(account.GranteePubkey.Secp256k1.String())
if err != nil {
return fmt.Errorf("converting pubkey to peerID: %w", err)
}
zetaclientHostname := strings.ReplaceAll(moniker, "zetacore", "zetaclient")

// resolve the hostname
// something in libp2p/go-tss requires /ip4/<ip> and doesn't tolerate /dns4/<hostname>
ipAddresses, err := net.LookupIP(zetaclientHostname)
if err != nil {
return fmt.Errorf("failed to resolve hostname %s: %w", zetaclientHostname, err)
}
if len(ipAddresses) == 0 {
return fmt.Errorf("no IP addresses found for hostname %s", zetaclientHostname)
}
ipv4Address := ""
for _, ip := range ipAddresses {
if ip.To4() != nil {
ipv4Address = ip.String()
break
}
}
if ipv4Address == "" {
return fmt.Errorf("no IPv4 address found for hostname %s", zetaclientHostname)
}
fmt.Printf("/ip4/%s/tcp/6668/p2p/%s\n", ipv4Address, peerID.String())
}

return nil
}
2 changes: 2 additions & 0 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ func NewLocalCmd() *cobra.Command {
cmd.Flags().
Bool(flagUpgradeContracts, false, "set to true to upgrade Gateways and ERC20Custody contracts during setup for ZEVM and EVM")

cmd.AddCommand(NewGetZetaclientBootstrap())

return cmd
}

Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ignore:
- "x/**/events.go"
- "x/**/migrator.go"
- "x/**/module_simulation.go"
- "x/**/simulation/**/*"
- "x/**/simulation/*.go"
- "**/*.proto"
- "**/*.md"
- "**/*.yml"
Expand Down
2 changes: 1 addition & 1 deletion contrib/docker-scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,4 @@ else

logt "Start Network"
start_network
fi
fi
14 changes: 6 additions & 8 deletions contrib/localnet/scripts/start-zetaclientd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ echo "operatorAddress: $operatorAddress"
RELAYER_KEY_PATH="$HOME/.zetacored/relayer-keys"
mkdir -p "${RELAYER_KEY_PATH}"

mkdir -p "$HOME/.tss/"
zetae2e local get-zetaclient-bootstrap > "$HOME/.tss/address_book.seed"

MYIP=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)

echo "Start zetaclientd"
# skip initialization if the config file already exists (zetaclientd init has already been run)
if [[ $HOSTNAME == "zetaclient0" && ! -f ~/.zetacored/config/zetaclient_config.json ]]
then
MYIP=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
zetaclientd init --zetacore-url zetacore0 --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --keyring-backend "$BACKEND" --pre-params "$PREPARAMS_PATH"

# import relayer private key for zetaclient0
Expand All @@ -90,13 +94,7 @@ if [[ $HOSTNAME != "zetaclient0" && ! -f ~/.zetacored/config/zetaclient_config.j
then
num=$(echo $HOSTNAME | tr -dc '0-9')
node="zetacore$num"
MYIP=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
SEED=""
while [ -z "$SEED" ]
do
SEED=$(curl --retry 30 --retry-delay 1 --max-time 1 --retry-connrefused -s zetaclient0:8123/p2p)
done
zetaclientd init --peer "/ip4/172.20.0.21/tcp/6668/p2p/${SEED}" --zetacore-url "$node" --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --log-level 1 --keyring-backend "$BACKEND" --pre-params "$PREPARAMS_PATH"
zetaclientd init --zetacore-url "$node" --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --log-level 1 --keyring-backend "$BACKEND" --pre-params "$PREPARAMS_PATH"

# import relayer private key for zetaclient{$num}
import_relayer_key "${num}"
Expand Down
92 changes: 92 additions & 0 deletions e2e/TESTING_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Regular E2E tests

This page lists the regular E2E tests to run when testing the network, in case of upgrade, etc..
These snippets are aimed to be copy-pasted in the input in the E2E CI tool.

## Inbounds and outbounds observation

When we only want to verify the network correctly observe cross-chain transactions, simple deposits and withdraws are sufficient.

The amount provided represent `0.0001` unit for coin with 18 decimals.

```
eth_deposit:100000000000000 eth_withdraw:100000000000000
```

## ERC20 observation

When we want to verify the network correctly observe cross-chain transactions for ERC20 tokens.

The amount is set to a small value so it can be used for most ERC20s regardless of the decimals.

```
erc20_deposit:1000 erc20_withdraw:1000
```

## Gateway basic workflow

When we want to verify the gateway basic workflow, the happy path where cross-chain calls succeed.

The amount is arbitrarily set to a small value, currently the tokens sent to the test contracts are lost.

```
eth_deposit_and_call:1000 eth_withdraw_and_call:1000 erc20_deposit_and_call:1000 erc20_withdraw_and_call:1000 zevm_to_evm_call evm_to_zevm_call
```

## Solana

When it is necessary to test the Solana workflows, SOL and SPL tokens.

```
solana_deposit:1000 solana_withdraw:1000 solana_deposit_and_call:1000 spl_deposit:1000 spl_withdraw:1000 spl_deposit_and_call:1000 solana_deposit_and_call_revert:20000
```

## Gateway revert workflow

When we want to verify the gateway revert workflow, the unhappy path where cross-chain calls fail

### WithdrawAndCall

The `withdrawAndCall` tests doesn't depend on the provided amount, this list can be used across all networks

```
eth_withdraw_and_call_revert:1000 eth_withdraw_and_call_revert_with_call:1000 erc20_withdraw_and_call_revert:1000 erc20_withdraw_and_call_revert_with_call:1000
```

### DepositAndCall

The amount for reverting `depositAndCall` must depend on the chain as the value in the CCTX is used to pay for the revert fee.

Note: these are estimated required values for mainnet based on the current gas price, the actual value might be different and fine-tuned. The values for ERC20 tests are set for USDC token.

Ethereum: `0.0007ETH` and `3USDC`

```
eth_deposit_and_call_revert:700000000000000 eth_deposit_and_call_revert_with_call:700000000000000 erc20_deposit_and_call_revert:3000000 erc20_deposit_and_call_revert_with_call:3000000
```

BSC: `0.0008BNB` and `0.5USDC`

```
eth_deposit_and_call_revert:800000000000000 eth_deposit_and_call_revert_with_call:800000000000000 erc20_deposit_and_call_revert:500000 erc20_deposit_and_call_revert_with_call:500000
```

Polygon: `0.008POL` and `0.01USDC`

```
eth_deposit_and_call_revert:8000000000000000 eth_deposit_and_call_revert_with_call:8000000000000000 erc20_deposit_and_call_revert:10000 erc20_deposit_and_call_revert_with_call:10000
```

Base: `0.000005ETH` and `0.02USDC`

```
eth_deposit_and_call_revert:5000000000000 eth_deposit_and_call_revert_with_call:5000000000000 erc20_deposit_and_call_revert:20000 erc20_deposit_and_call_revert_with_call:20000
```

## Gateway arbitrary calls

Arbitrary calls feature is an experimental and niche use case for now, these tests are not necessary for regular testing.

```
eth_withdraw_and_arbitrary_call:1000 erc20_withdraw_and_arbitrary_call:1000
```
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.22.8

require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
cosmossdk.io/math v1.4.0
cosmossdk.io/tools/rosetta v0.2.1 // indirect
github.com/99designs/keyring v1.2.1
github.com/btcsuite/btcd v0.24.2
Expand Down Expand Up @@ -59,10 +59,10 @@ require (
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c
gitlab.com/thorchain/tss/go-tss v1.6.5
go.nhat.io/grpcmock v0.25.0
golang.org/x/crypto v0.23.0
golang.org/x/crypto v0.31.0
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
golang.org/x/net v0.25.0
golang.org/x/sync v0.7.0
golang.org/x/sync v0.10.0
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.33.0
Expand Down Expand Up @@ -297,9 +297,9 @@ require (
go.uber.org/zap v1.24.0 // indirect
golang.org/x/mod v0.17.0
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.20.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/api v0.155.0 // indirect
Expand Down
Loading

0 comments on commit ef9fb5a

Please sign in to comment.