Skip to content

Commit

Permalink
Merge branch 'develop' into feat/ton/e2e-testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
swift1337 committed Feb 28, 2025
2 parents 953c800 + 1eff305 commit 123a89d
Show file tree
Hide file tree
Showing 44 changed files with 834 additions and 224 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/zetachain-sec-checks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: "CodeQL - ZetaChain Custom checks "

on: [push, pull_request]
on:
push:
branches:
- develop
- release/*
pull_request:

jobs:
analyze:
Expand Down
13 changes: 7 additions & 6 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
ethante "github.com/zeta-chain/ethermint/app/ante"
ethermint "github.com/zeta-chain/ethermint/types"
evmtypes "github.com/zeta-chain/ethermint/x/evm/types"
Expand All @@ -37,9 +35,10 @@ import (
)

type HandlerOptions struct {
AccountKeeper evmtypes.AccountKeeper
BankKeeper evmtypes.BankKeeper
IBCKeeper *ibckeeper.Keeper
AccountKeeper evmtypes.AccountKeeper
BankKeeper evmtypes.BankKeeper
// TODO: enable back IBC
// IBCKeeper *ibckeeper.Keeper
FeeMarketKeeper FeeMarketKeeper
EvmKeeper EVMKeeper
FeegrantKeeper ante.FeegrantKeeper
Expand Down Expand Up @@ -76,7 +75,9 @@ func NewLegacyCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
// Note: signature verification uses EIP instead of the cosmos signature validator
ethante.NewLegacyEip712SigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
// TODO: enable back IBC
// check if this ante handler is needed in non legacy cosmos ante handlers
// ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
ethante.NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper),
)
}
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* [3548](https://github.com/zeta-chain/node/pull/3548) - ensure cctx list is sorted by creation time
* [3562](https://github.com/zeta-chain/node/pull/3562) - add Sui withdrawals
* [3600](https://github.com/zeta-chain/node/pull/3600) - add dedicated zetaclient restricted addresses config. This file will be automatically reloaded when it changes without needing to restart zetaclient.
* [3578](https://github.com/zeta-chain/node/pull/3578) - Add disable_tss_block_scan parameter. This parameter will be used to disable expensive block scanning actions on non-ethereum EVM Chains.

### Refactor

Expand All @@ -45,6 +46,7 @@
* [3503](https://github.com/zeta-chain/node/pull/3503) - add check in e2e test to ensure deletion of stale ballots
* [3536](https://github.com/zeta-chain/node/pull/3536) - add e2e test for upgrading solana gateway program
* [3560](https://github.com/zeta-chain/node/pull/3560) - initialize Sui E2E deposit tests
* [3591](https://github.com/zeta-chain/node/pull/3591) - add a runner for gov proposals in the e2e test.

## v28.0.0

Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/local/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func adminTestRoutine(

// depositing the necessary tokens on ZetaChain
txZetaDeposit := adminRunner.LegacyDepositZeta()
txEtherDeposit := adminRunner.LegacyDepositEther()
txERC20Deposit := adminRunner.LegacyDepositERC20()
txEtherDeposit := adminRunner.DepositEtherDeployer()
txERC20Deposit := adminRunner.DepositERC20Deployer()
adminRunner.WaitForMinedCCTX(txZetaDeposit)
adminRunner.WaitForMinedCCTX(txEtherDeposit)
adminRunner.WaitForMinedCCTX(txERC20Deposit)
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/local/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ func initBitcoinRunner(
runner.WaitForTxReceiptOnEVM(txERC20Send)

// deposit ETH and ERC20 tokens on ZetaChain
txEtherDeposit := runner.LegacyDepositEther()
txERC20Deposit := runner.LegacyDepositERC20()
txEtherDeposit := runner.DepositEtherDeployer()
txERC20Deposit := runner.DepositERC20Deployer()

runner.WaitForMinedCCTX(txEtherDeposit)
runner.WaitForMinedCCTX(txERC20Deposit)
Expand Down
10 changes: 9 additions & 1 deletion cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
startTime := time.Now()

//setup protocol contracts v1 as they are still supported for now
deployerRunner.LegacySetupEVM(contractsDeployed)
deployerRunner.LegacySetupEVM(contractsDeployed, testLegacy)

// setup protocol contracts on the connected EVM chain
deployerRunner.SetupEVM()
Expand Down Expand Up @@ -298,6 +298,11 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
// always mint ERC20 before every test execution
deployerRunner.MintERC20OnEVM(1e10)

// Run the proposals under the start sequence(proposals_e2e_start folder)
if !skipRegular {
noError(deployerRunner.CreateGovProposals(runner.StartOfE2E))
}

// run tests
var eg errgroup.Group

Expand Down Expand Up @@ -508,6 +513,9 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
logger.Print("❌ e2e tests failed after %s", time.Since(testStartTime).String())
os.Exit(1)
}
if !skipRegular {
noError(deployerRunner.CreateGovProposals(runner.EndOfE2E))
}

logger.Print("✅ e2e tests completed in %s", time.Since(testStartTime).String())

Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/local/performance.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func ethereumWithdrawPerformanceRoutine(
startTime := time.Now()

// depositing the necessary tokens on ZetaChain
txEtherDeposit := r.LegacyDepositEther()
txEtherDeposit := r.DepositEtherDeployer()
r.WaitForMinedCCTX(txEtherDeposit)

tests, err := r.GetE2ETestsToRunByName(
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetae2e/stress.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func StressTest(cmd *cobra.Command, _ []string) {

// setup TSS addresses
noError(e2eTest.SetTSSAddresses())
e2eTest.LegacySetupEVM(stressTestArgs.contractsDeployed)
e2eTest.LegacySetupEVM(stressTestArgs.contractsDeployed, false)

// If stress test is running on local docker environment
switch stressTestArgs.network {
Expand All @@ -142,7 +142,7 @@ func StressTest(cmd *cobra.Command, _ []string) {
})

// deposit on ZetaChain
e2eTest.LegacyDepositEther()
e2eTest.DepositEtherDeployer()
e2eTest.LegacyDepositZeta()
case "TESTNET":
ethZRC20Addr := must(e2eTest.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(5)))
Expand Down
2 changes: 2 additions & 0 deletions contrib/localnet/orchestrator/Dockerfile.fastbuild
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ COPY --from=geth /usr/local/bin/geth /usr/local/bin/
COPY --from=solana /usr/bin/solana /usr/local/bin/

COPY contrib/localnet/orchestrator/start-zetae2e.sh /work/
COPY contrib/localnet/orchestrator/proposals_e2e_start/ /work/proposals_e2e_start/
COPY contrib/localnet/orchestrator/proposals_e2e_end/ /work/proposals_e2e_end/
COPY contrib/localnet/scripts/wait-for-ton.sh /work/
COPY cmd/zetae2e/config/localnet.yml /work/config.yml
RUN chmod +x /work/*.sh
Expand Down
26 changes: 26 additions & 0 deletions contrib/localnet/orchestrator/proposals_e2e_end/max_gas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"messages": [
{
"@type": "/cosmos.consensus.v1.MsgUpdateParams",
"authority": "zeta10d07y265gmmuvt4z0w9aw880jnsr700jvxasvr",
"block": {
"max_bytes": "22020096",
"max_gas": "150000000"
},
"evidence": {
"max_age_num_blocks": "100000",
"max_age_duration": "172800s",
"max_bytes": "1048576"
},
"validator": {
"pub_key_types": [
"ed25519"
]
}
}
],
"metadata": "",
"deposit": "1000000000000000000azeta",
"title": "Update Max Gas Limit to 150M",
"summary": "Update Max Gas Limit to 150M ZetaChain Athens Testnet."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"messages": [
{
"@type": "/zetachain.zetacore.emissions.MsgUpdateParams",
"params": {
"validatorEmissionPercentage": "0.50",
"observerEmissionPercentage": "0.25",
"tssSignerEmissionPercentage": "0.25",
"observerSlashAmount": "100000000000000000",
"ballotMaturityBlocks": 101,
"blockRewardAmount": "9620949074074074074.074070733466756687"
},
"authority": "zeta10d07y265gmmuvt4z0w9aw880jnsr700jvxasvr"
}
],
"metadata": "test proposal",
"deposit": "100000000azeta",
"title": "emissions param change",
"summary": "emissions param change"
}
14 changes: 14 additions & 0 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ fund_eth_from_config '.additional_accounts.user_erc20_revert.evm_address' 10000
# unlock emissions withdraw tests accounts
fund_eth_from_config '.additional_accounts.user_emissions_withdraw.evm_address' 10000 "emissions withdraw tester"

mkdir -p /root/.zetacored/keyring-test/
for i in 0 1; do
ssh root@zetacore$i "test -d /root/.zetacored/keyring-test/" && \
(echo "Source directory found in zetacore$i, copying operator keys" && \
mkdir -p /root/zetacore$i/ && \

scp -r root@zetacore$i:/root/.zetacored/keyring-test/ /root/zetacore$i/keyring-test/ && \
echo "Files copied successfully from zetacore$i") || \
echo "Error: keyring-test directory not found in zetacore$i container"

zetacored keys rename operator operator$i --home=/root/zetacore$i/ --keyring-backend=test --yes
cp -r /root/zetacore$i/keyring-test/* /root/.zetacored/keyring-test/
done

# unlock local solana relayer accounts
if host solana > /dev/null; then
solana_url=$(config_str '.rpcs.solana')
Expand Down
4 changes: 2 additions & 2 deletions contrib/localnet/scripts/start-zetacored.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ then

# Update governance and other chain parameters for localnet
jq '
.app_state.gov.params.voting_period="100s" |
.app_state.gov.params.voting_period="30s" |
.app_state.gov.params.quorum="0.1" |
.app_state.gov.params.threshold="0.1" |
.app_state.gov.params.expedited_voting_period = "50s" |
.app_state.gov.params.expedited_voting_period = "10s" |
.app_state.gov.deposit_params.min_deposit[0].denom = "azeta" |
.app_state.gov.params.min_deposit[0].denom = "azeta" |
.app_state.staking.params.bond_denom = "azeta" |
Expand Down
5 changes: 5 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58469,6 +58469,11 @@ definitions:
confirmationParams:
$ref: '#/definitions/zetachain.zetacore.observer.ConfirmationParams'
title: Advanced confirmation parameters for chain to support fast observation
disableTssBlockScan:
type: boolean
description: |-
Skip actions that require scanning the contents of each block.
The main thing this disables is transfers directly to the TSS address.
zetachain.zetacore.observer.ChainParamsList:
type: object
properties:
Expand Down
1 change: 1 addition & 0 deletions docs/spec/observer/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ message MsgUpdateOperationalChainParams {
int64 outbound_schedule_interval = 7;
int64 outbound_schedule_lookahead = 8;
ConfirmationParams confirmation_params = 9;
bool disable_tss_block_scan = 10;
}
```

6 changes: 6 additions & 0 deletions e2e/TESTING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,9 @@ Arbitrary calls feature is an experimental and niche use case for now, these tes
```
eth_withdraw_and_arbitrary_call:1000 erc20_withdraw_and_arbitrary_call:1000
```

## Gov proposal

Any governace proposals can be executed in the E2E tests. There are two options for the sequence of the proposal execution.
1. Start of E2E tests: The proposal json needs to be placed in the `contrib/localnet/orchestrator/proposal_e2e_start` directory.All proposals in this directory will be executed before running the e2e tests
2. End of E2E tests: The proposal json needs to be placed in the `contrib/localnet/orchestrator/proposal_e2e_end` directory.All proposals in this directory will be executed after running the e2e tests
22 changes: 16 additions & 6 deletions e2e/e2etests/test_eth_deposit_liquidity_cap.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"cosmossdk.io/math"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/stretchr/testify/require"
"github.com/zeta-chain/protocol-contracts/pkg/gatewayevm.sol"

"github.com/zeta-chain/node/e2e/runner"
"github.com/zeta-chain/node/e2e/utils"
Expand Down Expand Up @@ -35,8 +36,11 @@ func TestDepositEtherLiquidityCap(r *runner.E2ERunner, args []string) {
r.Logger.Info("set liquidity cap tx hash: %s", res.TxHash)
r.Logger.Info("Depositing more than liquidity cap should make cctx reverted")

signedTx, err := r.LegacySendEther(r.TSSAddress, amountMoreThanCap, nil)
require.NoError(r, err)
signedTx := r.ETHDeposit(
r.EVMAddress(),
amountMoreThanCap,
gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)},
)

receipt := utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, signedTx, r.Logger, r.ReceiptTimeout)
utils.RequireTxSuccessful(r, receipt)
Expand All @@ -50,8 +54,11 @@ func TestDepositEtherLiquidityCap(r *runner.E2ERunner, args []string) {
initialBal, err := r.ETHZRC20.BalanceOf(&bind.CallOpts{}, r.EVMAddress())
require.NoError(r, err)

signedTx, err = r.LegacySendEther(r.TSSAddress, amountLessThanCap, nil)
require.NoError(r, err)
signedTx = r.ETHDeposit(
r.EVMAddress(),
amountLessThanCap,
gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)},
)

receipt = utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, signedTx, r.Logger, r.ReceiptTimeout)
utils.RequireTxSuccessful(r, receipt)
Expand Down Expand Up @@ -82,8 +89,11 @@ func TestDepositEtherLiquidityCap(r *runner.E2ERunner, args []string) {
initialBal, err = r.ETHZRC20.BalanceOf(&bind.CallOpts{}, r.EVMAddress())
require.NoError(r, err)

signedTx, err = r.LegacySendEther(r.TSSAddress, amountMoreThanCap, nil)
require.NoError(r, err)
signedTx = r.ETHDeposit(
r.EVMAddress(),
amountMoreThanCap,
gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)},
)

receipt = utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, signedTx, r.Logger, r.ReceiptTimeout)
utils.RequireTxSuccessful(r, receipt)
Expand Down
4 changes: 2 additions & 2 deletions e2e/e2etests/test_migrate_chain_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) {
newRunner, err := configureEVM2(r)
require.NoError(r, err)

newRunner.LegacySetupEVM(false)
newRunner.LegacySetupEVM(false, false)

// mint some ERC20
newRunner.MintERC20OnEVM(10000)
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) {
newRunner.ERC20ZRC20 = erc20ZRC20

// deposit ERC20 on ZetaChain
txERC20Deposit := newRunner.LegacyDepositERC20()
txERC20Deposit := newRunner.DepositERC20Deployer()
newRunner.WaitForMinedCCTX(txERC20Deposit)

// stop mining
Expand Down
8 changes: 2 additions & 6 deletions e2e/e2etests/test_pause_zrc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,9 @@ func TestPauseZRC20(r *runner.E2ERunner, _ []string) {
utils.RequireTxSuccessful(r, receipt)

// Check deposit revert when paused
signedTx, err := r.LegacySendEther(r.TSSAddress, big.NewInt(1e17), nil)
require.NoError(r, err)

receipt = utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, signedTx, r.Logger, r.ReceiptTimeout)
utils.RequireTxSuccessful(r, receipt)
depositHash := r.DepositEtherDeployer()

cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, signedTx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout)
cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, depositHash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout)
utils.RequireCCTXStatus(r, cctx, types.CctxStatus_Reverted)

r.Logger.Info("CCTX has been reverted")
Expand Down
5 changes: 4 additions & 1 deletion e2e/e2etests/test_stress_eth_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package e2etests

import (
"fmt"
"math/big"
"time"

ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
"github.com/zeta-chain/protocol-contracts/pkg/gatewayevm.sol"
"golang.org/x/sync/errgroup"

"github.com/zeta-chain/node/e2e/runner"
Expand All @@ -29,7 +31,8 @@ func TestStressEtherDeposit(r *runner.E2ERunner, args []string) {
// send the deposits
for i := 0; i < numDeposits; i++ {
i := i
hash := r.LegacyDepositEtherWithAmount(depositAmount)
tx := r.ETHDeposit(r.EVMAddress(), depositAmount, gatewayevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)})
hash := tx.Hash()
r.Logger.Print("index %d: starting deposit, tx hash: %s", i, hash.Hex())

eg.Go(func() error { return monitorEtherDeposit(r, hash, i, time.Now()) })
Expand Down
Loading

0 comments on commit 123a89d

Please sign in to comment.