Skip to content

Commit

Permalink
Merge branch 'develop' into test-fungible-module
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito authored Apr 4, 2024
2 parents 4526113 + 9eb55e7 commit 03cfc24
Show file tree
Hide file tree
Showing 83 changed files with 5,125 additions and 1,274 deletions.
9 changes: 0 additions & 9 deletions Dockerfile-localnet
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,12 @@ RUN ssh-keygen -b 2048 -t rsa -f /root/.ssh/localtest.pem -q -N ""
WORKDIR /go/delivery/zeta-node
COPY go.mod .
COPY go.sum .
#RUN --mount=type=cache,target=/root/.cache/go-build \
# go mod download
RUN go mod download
COPY . .

#RUN --mount=type=cache,target=/root/.cache/go-build \
# make install
#RUN --mount=type=cache,target=/root/.cache/go-build \
# make install-zetae2e
RUN make install
RUN make install-zetae2e
#
#FROM golang:1.20-alpine

#RUN apk --no-cache add openssh jq tmux vim curl bash
RUN ssh-keygen -A
WORKDIR /root

Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* [1755](https://github.com/zeta-chain/node/issues/1755) - use evm JSON RPC for inbound tx (including blob tx) observation.
* [1815](https://github.com/zeta-chain/node/pull/1815) - add authority module for authorized actions
* [1884](https://github.com/zeta-chain/node/pull/1884) - added zetatool cmd, added subcommand to filter deposits
* [1942](https://github.com/zeta-chain/node/pull/1982) - support Bitcoin P2TR, P2WSH, P2SH, P2PKH addresses
* [1935](https://github.com/zeta-chain/node/pull/1935) - add an operational authority group
* [1954](https://github.com/zeta-chain/node/pull/1954) - add metric for concurrent keysigns

Expand All @@ -50,6 +51,7 @@
* [1805](https://github.com/zeta-chain/node/pull/1805) - add admin and performance test and fix upgrade test
* [1879](https://github.com/zeta-chain/node/pull/1879) - full coverage for messages in types packages
* [1899](https://github.com/zeta-chain/node/pull/1899) - add empty test files so packages are included in coverage
* [1900](https://github.com/zeta-chain/node/pull/1900) - add testing for external chain migration
* [1903](https://github.com/zeta-chain/node/pull/1903) - common package tests
* [1961](https://github.com/zeta-chain/node/pull/1961) - improve observer module coverage
* [1967](https://github.com/zeta-chain/node/pull/1967) - improve crosschain module coverage
Expand All @@ -59,6 +61,7 @@

* [1861](https://github.com/zeta-chain/node/pull/1861) - fix `ObserverSlashAmount` invalid read
* [1880](https://github.com/zeta-chain/node/issues/1880) - lower the gas price multiplier for EVM chains.
* [1883](https://github.com/zeta-chain/node/issues/1883) - zetaclient should check 'IsSupported' flag to pause/unpause a specific chain
* [1633](https://github.com/zeta-chain/node/issues/1633) - zetaclient should be able to pick up new connector and erc20Custody addresses
* [1944](https://github.com/zeta-chain/node/pull/1944) - fix evm signer unit tests

Expand Down Expand Up @@ -175,6 +178,7 @@
* [1675](https://github.com/zeta-chain/node/issues/1675) - use chain param ConfirmationCount for bitcoin confirmation

## Chores

* [1694](https://github.com/zeta-chain/node/pull/1694) - remove standalone network, use require testing package for the entire node folder

## Version: v12.1.0
Expand All @@ -187,6 +191,7 @@
* [1658](https://github.com/zeta-chain/node/pull/1658) - modify emission distribution to use fixed block rewards

### Fixes

* [1535](https://github.com/zeta-chain/node/issues/1535) - Avoid voting on wrong ballots due to false blockNumber in EVM tx receipt
* [1588](https://github.com/zeta-chain/node/pull/1588) - fix chain params comparison logic
* [1650](https://github.com/zeta-chain/node/pull/1605) - exempt (discounted) *system txs* from min gas price check and gas fee deduction
Expand Down
8 changes: 1 addition & 7 deletions cmd/zetaclientd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ func CreateSignerMap(
loggers.Std.Error().Msgf("ChainParam not found for chain %s", evmConfig.Chain.String())
continue
}
if !evmChainParams.IsSupported {
continue
}
mpiAddress := ethcommon.HexToAddress(evmChainParams.ConnectorContractAddress)
erc20CustodyAddress := ethcommon.HexToAddress(evmChainParams.Erc20CustodyContractAddress)
signer, err := evm.NewEVMSigner(
Expand Down Expand Up @@ -117,14 +114,11 @@ func CreateChainClientMap(
if evmConfig.Chain.IsZetaChain() {
continue
}
evmChainParams, found := appContext.ZetaCoreContext().GetEVMChainParams(evmConfig.Chain.ChainId)
_, found := appContext.ZetaCoreContext().GetEVMChainParams(evmConfig.Chain.ChainId)
if !found {
loggers.Std.Error().Msgf("ChainParam not found for chain %s", evmConfig.Chain.String())
continue
}
if !evmChainParams.IsSupported {
continue
}
co, err := evm.NewEVMChainClient(appContext, bridge, tss, dbpath, loggers, evmConfig, ts)
if err != nil {
loggers.Std.Error().Err(err).Msgf("NewEVMChainClient error for chain %s", evmConfig.Chain.String())
Expand Down
5 changes: 3 additions & 2 deletions cmd/zetae2e/local/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ var (
UserMiscPrivateKey = "853c0945b8035a501b1161df65a17a0a20fc848bda8975a8b4e9222cc6f84cd4" // #nosec G101 - used for testing

// UserAdminAddress is the address of the account for testing admin function features
UserAdminAddress = ethcommon.HexToAddress("0xcC8487562AAc220ea4406196Ee902C7c076966af")
UserAdminPrivateKey = "95409f1f0e974871cc26ba98ffd31f613aa1287d40c0aea6a87475fc3521d083" // #nosec G101 - used for testing
// NOTE: this is the default account using Anvil
UserAdminAddress = ethcommon.HexToAddress("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266")
UserAdminPrivateKey = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" // #nosec G101 - used for testing

FungibleAdminMnemonic = "snow grace federal cupboard arrive fancy gym lady uniform rotate exercise either leave alien grass" // #nosec G101 - used for testing
)
5 changes: 3 additions & 2 deletions cmd/zetae2e/local/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func adminTestRoutine(
deployerRunner,
UserAdminAddress,
UserAdminPrivateKey,
runner.NewLogger(verbose, color.FgGreen, "admin"),
runner.NewLogger(verbose, color.FgHiGreen, "admin"),
)
if err != nil {
return err
Expand All @@ -48,7 +48,8 @@ func adminTestRoutine(
startTime := time.Now()

// funding the account
txZetaSend := deployerRunner.SendZetaOnEvm(UserAdminAddress, 1000)
// we transfer around the total supply of Zeta to the admin for the chain migration test
txZetaSend := deployerRunner.SendZetaOnEvm(UserAdminAddress, 20_500_000_000)
txERC20Send := deployerRunner.SendERC20OnEvm(UserAdminAddress, 1000)
adminRunner.WaitForTxReceiptOnEvm(txZetaSend)
adminRunner.WaitForTxReceiptOnEvm(txERC20Send)
Expand Down
14 changes: 12 additions & 2 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
if !skipSetup {
logger.Print("⚙️ setting up networks")
startTime := time.Now()
deployerRunner.SetupEVM(contractsDeployed)
deployerRunner.SetupEVM(contractsDeployed, true)
deployerRunner.SetZEVMContracts()

// NOTE: this method return an error so we handle it and panic if it occurs unlike other method that panics directly
Expand Down Expand Up @@ -250,7 +250,11 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
e2etests.TestZetaDepositRestrictedName,
}
bitcoinTests := []string{
e2etests.TestBitcoinWithdrawName,
e2etests.TestBitcoinWithdrawSegWitName,
e2etests.TestBitcoinWithdrawTaprootName,
e2etests.TestBitcoinWithdrawLegacyName,
e2etests.TestBitcoinWithdrawP2SHName,
e2etests.TestBitcoinWithdrawP2WSHName,
e2etests.TestBitcoinWithdrawInvalidAddressName,
e2etests.TestZetaWithdrawBTCRevertName,
e2etests.TestCrosschainSwapName,
Expand Down Expand Up @@ -285,6 +289,12 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
e2etests.TestPauseZRC20Name,
e2etests.TestUpdateBytecodeName,
e2etests.TestDepositEtherLiquidityCapName,

// TestMigrateChainSupportName tests EVM chain migration. Currently this test doesn't work with Anvil because pre-EIP1559 txs are not supported
// See issue below for details
// TODO: renenable this test as per the issue below
// https://github.com/zeta-chain/node/issues/1980
// e2etests.TestMigrateChainSupportName,
))
}
if testPerformance {
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/stress.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func StressTest(cmd *cobra.Command, _ []string) {
panic(err)
}

e2eTest.SetupEVM(stressTestArgs.contractsDeployed)
e2eTest.SetupEVM(stressTestArgs.contractsDeployed, true)

// If stress test is running on local docker environment
if stressTestArgs.network == "LOCAL" {
Expand Down
11 changes: 11 additions & 0 deletions contrib/localnet/anvil/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This Dockerfile is used to build a Docker image for Anvil, a localnet for testing purposes.
# Currently we directly set the chain ID to 11155111 and expose the default Anvil port specifically for the chain migration test.

# Start from the latest Rust image as Anvil is built with Rust
FROM ghcr.io/foundry-rs/foundry:latest

# Expose the default Anvil port
EXPOSE 8545

# Run Anvil with specified chain ID and a prefunded account when the container starts
ENTRYPOINT ["anvil", "--host", "0.0.0.0", "--chain-id", "11155111"]
17 changes: 17 additions & 0 deletions contrib/localnet/docker-compose-admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@ version: "3"

# This docker-compose file overrides the orchestrator service to specify the flag to test the admin functions
# and skip the regular tests
# it also adds another local Ethereum network to test EVM chain migration and use the additional-evm flag

services:
orchestrator:
entrypoint: ["/work/start-zetae2e.sh", "local --skip-regular --test-admin"]

eth2:
build:
context: ./anvil
container_name: eth2
hostname: eth2
ports:
- "8546:8545"
networks:
mynetwork:
ipv4_address: 172.20.0.102

zetaclient0:
entrypoint: [ "/root/start-zetaclientd.sh", "additional-evm" ]

zetaclient1:
entrypoint: [ "/root/start-zetaclientd.sh", "additional-evm" ]
1 change: 1 addition & 0 deletions contrib/localnet/orchestrator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ COPY --from=zeta /root/.ssh/localtest.pem /root/.ssh/localtest.pem

COPY contrib/localnet/orchestrator/start-zetae2e.sh /work/
COPY contrib/localnet/orchestrator/restart-zetaclientd.sh /work/
COPY contrib/localnet/orchestrator/restart-zetaclientd-at-upgrade.sh /work/
RUN chmod +x /work/*.sh

ENV GOPATH /go
Expand Down
1 change: 1 addition & 0 deletions contrib/localnet/orchestrator/Dockerfile.fastbuild
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ COPY --from=zeta /root/.ssh/localtest.pem /root/.ssh/localtest.pem

COPY contrib/localnet/orchestrator/start-zetae2e.sh /work/
COPY contrib/localnet/orchestrator/restart-zetaclientd.sh /work/
COPY contrib/localnet/orchestrator/restart-zetaclientd-at-upgrade.sh /work/
RUN chmod +x /work/*.sh

COPY --from=zeta /usr/local/bin/zetae2e /usr/local/bin/
Expand Down
50 changes: 50 additions & 0 deletions contrib/localnet/orchestrator/restart-zetaclientd-at-upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# This script is used to restart zetaclientd after an upgrade
# It waits for the upgrade height to be reached and then restarts the zetaclientd on all nodes in the network
# It interacts with the network using the zetaclientd binary

clibuilder()
{
echo ""
echo "Usage: $0 -u UPGRADE_HEIGHT"
echo -e "\t-u Height of upgrade, should match governance proposal"
echo -e "\t-n Number of clients in the network"
exit 1 # Exit script after printing help
}

while getopts "u:n:" opt
do
case "$opt" in
u ) UPGRADE_HEIGHT="$OPTARG" ;;
n ) NUM_OF_NODES="$OPTARG" ;;
? ) clibuilder ;; # Print cliBuilder in case parameter is non-existent
esac
done

# generate client list
START=0
END=$((NUM_OF_NODES-1))
CLIENT_LIST=()
for i in $(eval echo "{$START..$END}")
do
CLIENT_LIST+=("zetaclient$i")
done

echo "$UPGRADE_HEIGHT"

CURRENT_HEIGHT=0

while [[ $CURRENT_HEIGHT -lt $UPGRADE_HEIGHT ]]
do
CURRENT_HEIGHT=$(curl -s zetacore0:26657/status | jq '.result.sync_info.latest_block_height' | tr -d '"')
echo current height is "$CURRENT_HEIGHT", waiting for "$UPGRADE_HEIGHT"
sleep 5
done

echo upgrade height reached, restarting zetaclients

for NODE in "${CLIENT_LIST[@]}"; do
ssh -o "StrictHostKeyChecking no" "$NODE" -i ~/.ssh/localtest.pem killall zetaclientd
ssh -o "StrictHostKeyChecking no" "$NODE" -i ~/.ssh/localtest.pem "$GOPATH/bin/new/zetaclientd start < /root/password.file > $HOME/zetaclient.log 2>&1 &"
done
51 changes: 6 additions & 45 deletions contrib/localnet/orchestrator/restart-zetaclientd.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,11 @@
#!/bin/bash

# This script is used to restart zetaclientd after an upgrade
# It waits for the upgrade height to be reached and then restarts the zetaclientd on all nodes in the network
# It interacts with the network using the zetaclientd binary
# This script immediately restarts the zetaclientd on zetaclient0 and zetaclient1 containers in the network

clibuilder()
{
echo ""
echo "Usage: $0 -u UPGRADE_HEIGHT"
echo -e "\t-u Height of upgrade, should match governance proposal"
echo -e "\t-n Number of clients in the network"
exit 1 # Exit script after printing help
}
echo restarting zetaclients

while getopts "u:n:" opt
do
case "$opt" in
u ) UPGRADE_HEIGHT="$OPTARG" ;;
n ) NUM_OF_NODES="$OPTARG" ;;
? ) clibuilder ;; # Print cliBuilder in case parameter is non-existent
esac
done
ssh -o "StrictHostKeyChecking no" "zetaclient0" -i ~/.ssh/localtest.pem killall zetaclientd
ssh -o "StrictHostKeyChecking no" "zetaclient1" -i ~/.ssh/localtest.pem killall zetaclientd
ssh -o "StrictHostKeyChecking no" "zetaclient0" -i ~/.ssh/localtest.pem "/usr/local/bin/zetaclientd start < /root/password.file > $HOME/zetaclient.log 2>&1 &"
ssh -o "StrictHostKeyChecking no" "zetaclient1" -i ~/.ssh/localtest.pem "/usr/local/bin/zetaclientd start < /root/password.file > $HOME/zetaclient.log 2>&1 &"

# generate client list
START=0
END=$((NUM_OF_NODES-1))
CLIENT_LIST=()
for i in $(eval echo "{$START..$END}")
do
CLIENT_LIST+=("zetaclient$i")
done

echo "$UPGRADE_HEIGHT"

CURRENT_HEIGHT=0

while [[ $CURRENT_HEIGHT -lt $UPGRADE_HEIGHT ]]
do
CURRENT_HEIGHT=$(curl -s zetacore0:26657/status | jq '.result.sync_info.latest_block_height' | tr -d '"')
echo current height is "$CURRENT_HEIGHT", waiting for "$UPGRADE_HEIGHT"
sleep 5
done

echo upgrade height reached, restarting zetaclients

for NODE in "${CLIENT_LIST[@]}"; do
ssh -o "StrictHostKeyChecking no" "$NODE" -i ~/.ssh/localtest.pem killall zetaclientd
ssh -o "StrictHostKeyChecking no" "$NODE" -i ~/.ssh/localtest.pem "$GOPATH/bin/new/zetaclientd start < /root/password.file > $HOME/zetaclient.log 2>&1 &"
done
8 changes: 4 additions & 4 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x8D47Db7390AC4D3D449
echo "funding deployer address 0x90126d02E41c9eB2a10cfc43aAb3BD3460523Cdf with 100 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x90126d02E41c9eB2a10cfc43aAb3BD3460523Cdf", value: web3.toWei(100,"ether")})' attach http://eth:8545

# unlock advanced erc20 tests accounts
echo "funding deployer address 0xcC8487562AAc220ea4406196Ee902C7c076966af with 100 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xcC8487562AAc220ea4406196Ee902C7c076966af", value: web3.toWei(100,"ether")})' attach http://eth:8545
# unlock admin erc20 tests accounts
echo "funding deployer address 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 with 100 Ether"
geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", value: web3.toWei(100,"ether")})' attach http://eth:8545

# unlock the TSS account
echo "funding TSS address 0xF421292cb0d3c97b90EEEADfcD660B893592c6A2 with 100 Ether"
Expand Down Expand Up @@ -74,7 +74,7 @@ if [ "$OPTION" == "upgrade" ]; then
echo "E2E setup passed, waiting for upgrade height..."

# Restart zetaclients at upgrade height
/work/restart-zetaclientd.sh -u "$UPGRADE_HEIGHT" -n 2
/work/restart-zetaclientd-at-upgrade.sh -u "$UPGRADE_HEIGHT" -n 2

echo "waiting 10 seconds for node to restart..."

Expand Down
24 changes: 23 additions & 1 deletion contrib/localnet/scripts/start-zetaclientd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
HOSTNAME=$(hostname)
OPTION=$1

# sepolia is used in chain migration tests, this functions set the sepolia endpoint in the zetaclient_config.json
set_sepolia_endpoint() {
jq '.EVMChainConfigs."11155111".Endpoint = "http://eth2:8545"' /root/.zetacored/config/zetaclient_config.json > tmp.json && mv tmp.json /root/.zetacored/config/zetaclient_config.json
}

# read HOTKEY_BACKEND env var for hotkey keyring backend and set default to test
BACKEND="test"
if [ "$HOTKEY_BACKEND" == "file" ]; then
Expand All @@ -30,6 +35,14 @@ then
rm ~/.tss/*
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"

# check if the option is additional-evm
# in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545)
# in /root/.zetacored/config/zetaclient_config.json
if [ "$OPTION" == "additional-evm" ]; then
set_sepolia_endpoint
fi

zetaclientd start < /root/password.file
else
num=$(echo $HOSTNAME | tr -dc '0-9')
Expand All @@ -42,11 +55,20 @@ else
done
rm ~/.tss/*
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"

# check if the option is additional-evm
# in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545)
# in /root/.zetacored/config/zetaclient_config.json
if [ "$OPTION" == "additional-evm" ]; then
set_sepolia_endpoint
fi

zetaclientd start < /root/password.file
fi

# check if the option is background
# in this case, we tail the zetaclientd log file
if [ "$OPTION" == "background" ]; then
sleep 3
tail -f $HOME/zetaclient.log
fi

Loading

0 comments on commit 03cfc24

Please sign in to comment.