Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): add gateway upgrade in upgrade test #2923

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8a93aa3
e2e tests and modifications for authenticated call
skosito Sep 20, 2024
af8d86c
extend test with sender check and revert case
skosito Sep 20, 2024
0cd7cb2
separate tests into separate files
skosito Sep 20, 2024
914d151
cleanup
skosito Sep 20, 2024
9d1471f
withdraw and call support and tests
skosito Sep 20, 2024
10ea638
bump protocol contracts
skosito Sep 20, 2024
d6786dc
split tests into separate files
skosito Sep 20, 2024
6b711dc
small cleanup
skosito Sep 20, 2024
614df83
fmt
skosito Sep 20, 2024
fbb0c21
Merge branch 'develop' into authenticated-call-sc-support
skosito Sep 20, 2024
9557a57
generate
skosito Sep 20, 2024
07a83a1
lint
skosito Sep 20, 2024
3610f17
changelog
skosito Sep 20, 2024
7bd42dc
Merge branch 'develop' into authenticated-call-sc-support
skosito Sep 23, 2024
bd80fb2
PR comments
skosito Sep 23, 2024
86367b0
fix case in proto
skosito Sep 24, 2024
e850ae6
bump vote inbound gas limit in zetaclient
skosito Sep 24, 2024
4d6f363
fix test
skosito Sep 24, 2024
d5b5c11
generate
skosito Sep 24, 2024
c93142b
fixing tests
skosito Sep 24, 2024
80ca59e
call options non empty
skosito Sep 24, 2024
1692d98
generate
skosito Sep 24, 2024
5daa3ee
test fix
skosito Sep 24, 2024
e89c759
rename gateway caller
skosito Sep 24, 2024
04f432a
pr comments rename tests
skosito Sep 24, 2024
470a90e
PR comment
skosito Sep 24, 2024
5ad665d
generate
skosito Sep 24, 2024
8c96cea
tests
skosito Sep 24, 2024
3c02247
Merge branch 'develop' into authenticated-call-sc-support
skosito Sep 24, 2024
d6e9b5c
some improvement
lumtis Sep 25, 2024
b389626
upgrade function
lumtis Sep 25, 2024
d778157
add upgrade call
lumtis Sep 25, 2024
5faf0cb
add docs back
lumtis Sep 26, 2024
4a2b4d6
change base
lumtis Sep 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ start-v2-test: zetanode
ifdef UPGRADE_TEST_FROM_SOURCE
zetanode-upgrade: zetanode
@echo "Building zetanode-upgrade from source"
$(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime-source --build-arg OLD_VERSION='release/v19' .
$(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime-source --build-arg OLD_VERSION='release/v20' .
.PHONY: zetanode-upgrade
else
zetanode-upgrade: zetanode
@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/v19.1.1' .
$(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime --build-arg OLD_VERSION='https://github.com/zeta-chain/node/releases/download/v20.0.2' .
.PHONY: zetanode-upgrade
endif

Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* [2870](https://github.com/zeta-chain/node/pull/2870) - support for multiple Bitcoin chains in the zetaclient
* [2883](https://github.com/zeta-chain/node/pull/2883) - add chain static information for btc signet testnet
* [2907](https://github.com/zeta-chain/node/pull/2907) - derive Bitcoin tss address by chain id and added more Signet static info
* [2904](https://github.com/zeta-chain/node/pull/2904) - integrate authenticated calls smart contract functionality into protocol

### Refactor

Expand Down
8 changes: 8 additions & 0 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const (
flagTestV2Migration = "test-v2-migration"
flagSkipTrackerCheck = "skip-tracker-check"
flagSkipPrecompiles = "skip-precompiles"
flagUpgradeGateways = "upgrade-gateways"
)

var (
Expand Down Expand Up @@ -83,6 +84,7 @@ func NewLocalCmd() *cobra.Command {
cmd.Flags().Bool(flagTestV2Migration, false, "set to true to run tests for v2 contracts migration test")
cmd.Flags().Bool(flagSkipTrackerCheck, false, "set to true to skip tracker check at the end of the tests")
cmd.Flags().Bool(flagSkipPrecompiles, false, "set to true to skip stateful precompiled contracts test")
cmd.Flags().Bool(flagUpgradeGateways, false, "set to true to upgrade gateways during setup for ZEVM and EVM")

return cmd
}
Expand Down Expand Up @@ -112,6 +114,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
testV2 = must(cmd.Flags().GetBool(flagTestV2))
testV2Migration = must(cmd.Flags().GetBool(flagTestV2Migration))
skipPrecompiles = must(cmd.Flags().GetBool(flagSkipPrecompiles))
upgradeGateways = must(cmd.Flags().GetBool(flagUpgradeGateways))
)

logger := runner.NewLogger(verbose, color.FgWhite, "setup")
Expand Down Expand Up @@ -407,6 +410,11 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
deployerRunner.UpdateChainParamsV2Contracts()
}

// upgrade gateways
if upgradeGateways {
deployerRunner.UpgradeGateways()
}

if testV2 || testV2Migration {
startV2Tests(&eg, conf, deployerRunner, verbose)
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/zetae2e/local/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ func startV2Tests(eg *errgroup.Group, conf config.Config, deployerRunner *runner
e2etests.TestV2ETHDepositName,
e2etests.TestV2ETHDepositAndCallName,
e2etests.TestV2ETHWithdrawName,
e2etests.TestV2ETHWithdrawAndArbitraryCallName,
e2etests.TestV2ETHWithdrawAndCallName,
e2etests.TestV2ETHWithdrawAndCallThroughContractName,
e2etests.TestV2ZEVMToEVMArbitraryCallName,
e2etests.TestV2ZEVMToEVMCallName,
e2etests.TestV2ZEVMToEVMCallThroughContractName,
e2etests.TestV2EVMToZEVMCallName,
))

Expand Down
4 changes: 2 additions & 2 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ if [ "$LOCALNET_MODE" == "upgrade" ]; then
# When the upgrade height is greater than 100 for upgrade test, the Bitcoin tests have been run once, therefore the Bitcoin wallet is already set up
# Use light flag to skip advanced tests
if [ "$UPGRADE_HEIGHT" -lt 100 ]; then
zetae2e local $E2E_ARGS --skip-setup --config "$deployed_config_path" --light ${COMMON_ARGS}
zetae2e local $E2E_ARGS --skip-setup --config "$deployed_config_path" --light --upgrade-gateways ${COMMON_ARGS}
else
zetae2e local $E2E_ARGS --skip-setup --config "$deployed_config_path" --skip-bitcoin-setup --light ${COMMON_ARGS}
zetae2e local $E2E_ARGS --skip-setup --config "$deployed_config_path" --skip-bitcoin-setup --light --test-v2 --upgrade-gateways ${COMMON_ARGS}
fi

ZETAE2E_EXIT_CODE=$?
Expand Down
89 changes: 35 additions & 54 deletions docs/cli/zetacored/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -3345,10 +3345,45 @@ zetacored query emissions [flags]
### SEE ALSO

* [zetacored query](#zetacored-query) - Querying subcommands
* [zetacored query emissions get-emmisons-factors](#zetacored-query-emissions-get-emmisons-factors) - Query GetEmmisonsFactors
* [zetacored query emissions list-pool-addresses](#zetacored-query-emissions-list-pool-addresses) - Query list-pool-addresses
* [zetacored query emissions params](#zetacored-query-emissions-params) - shows the parameters of the module
* [zetacored query emissions show-available-emissions](#zetacored-query-emissions-show-available-emissions) - Query show-available-emissions

## zetacored query emissions get-emmisons-factors

Query GetEmmisonsFactors

```
zetacored query emissions get-emmisons-factors [flags]
```

### Options

```
--grpc-addr string the gRPC endpoint to use for this chain
--grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS
--height int Use a specific height to query state at (this can error if the node is pruning state)
-h, --help help for get-emmisons-factors
--node string [host]:[port] to Tendermint RPC interface for this chain
-o, --output string Output format (text|json)
```

### Options inherited from parent commands

```
--chain-id string The network chain ID
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--log_no_color Disable colored logs
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored query emissions](#zetacored-query-emissions) - Querying commands for the emissions module

## zetacored query emissions list-pool-addresses

Query list-pool-addresses
Expand Down Expand Up @@ -8174,7 +8209,6 @@ zetacored tx authority [flags]
* [zetacored tx](#zetacored-tx) - Transactions subcommands
* [zetacored tx authority add-authorization](#zetacored-tx-authority-add-authorization) - Add a new authorization or update the policy of an existing authorization. Policy type can be 0 for groupEmergency, 1 for groupOperational, 2 for groupAdmin.
* [zetacored tx authority remove-authorization](#zetacored-tx-authority-remove-authorization) - removes an existing authorization
* [zetacored tx authority remove-chain-info](#zetacored-tx-authority-remove-chain-info) - Remove the chain info for the specified chain id
* [zetacored tx authority update-chain-info](#zetacored-tx-authority-update-chain-info) - Update the chain info
* [zetacored tx authority update-policies](#zetacored-tx-authority-update-policies) - Update policies to values provided in the JSON file.

Expand Down Expand Up @@ -8284,59 +8318,6 @@ zetacored tx authority remove-authorization [msg-url] [flags]

* [zetacored tx authority](#zetacored-tx-authority) - authority transactions subcommands

## zetacored tx authority remove-chain-info

Remove the chain info for the specified chain id

```
zetacored tx authority remove-chain-info [chain-id] [flags]
```

### Options

```
-a, --account-number uint The account number of the signing account (offline mode only)
--aux Generate aux signer data instead of sending a tx
-b, --broadcast-mode string Transaction broadcasting mode (sync|async)
--chain-id string The network chain ID
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible)
--fee-granter string Fee granter grants fees for the transaction
--fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000)
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name)
-h, --help help for remove-chain-info
--keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory)
--keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used
--ledger Use a connected Ledger device
--node string [host]:[port] to tendermint rpc interface for this chain
--note string Note to add a description to the transaction (previously --memo)
--offline Offline mode (does not allow any online functionality)
-o, --output string Output format (text|json)
-s, --sequence uint The sequence number of the signing account (offline mode only)
--sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature
--timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height
--tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator
-y, --yes Skip tx broadcasting prompt confirmation
```

### Options inherited from parent commands

```
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--log_no_color Disable colored logs
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored tx authority](#zetacored-tx-authority) - authority transactions subcommands

## zetacored tx authority update-chain-info

Update the chain info
Expand Down
13 changes: 10 additions & 3 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57067,6 +57067,14 @@ definitions:
- ERC20: ERC20 token
- Cmd: no asset, used for admin command
- NoAssetCall: no asset, used for contract call
crosschainCallOptions:
type: object
properties:
gas_limit:
type: string
format: uint64
is_arbitrary_call:
type: boolean
crosschainCctxStatus:
type: string
enum:
Expand Down Expand Up @@ -57274,9 +57282,8 @@ definitions:
tss_nonce:
type: string
format: uint64
gas_limit:
type: string
format: uint64
call_options:
$ref: '#/definitions/crosschainCallOptions'
gas_price:
type: string
gas_priority_fee:
Expand Down
2 changes: 1 addition & 1 deletion docs/spec/crosschain/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ message MsgVoteInbound {
string message = 8;
string inbound_hash = 9;
uint64 inbound_block_height = 10;
uint64 gas_limit = 11;
CallOptions call_options = 11;
pkg.coin.CoinType coin_type = 12;
string tx_origin = 13;
string asset = 14;
Expand Down
34 changes: 33 additions & 1 deletion e2e/e2etests/e2etests.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ const (
TestV2ETHDepositAndCallRevertName = "v2_eth_deposit_and_call_revert"
TestV2ETHDepositAndCallRevertWithCallName = "v2_eth_deposit_and_call_revert_with_call"
TestV2ETHWithdrawName = "v2_eth_withdraw"
TestV2ETHWithdrawAndArbitraryCallName = "v2_eth_withdraw_and_arbitrary_call"
TestV2ETHWithdrawAndCallName = "v2_eth_withdraw_and_call"
TestV2ETHWithdrawAndCallThroughContractName = "v2_eth_withdraw_and_call_through_contract"
TestV2ETHWithdrawAndCallRevertName = "v2_eth_withdraw_and_call_revert"
TestV2ETHWithdrawAndCallRevertWithCallName = "v2_eth_withdraw_and_call_revert_with_call"
TestV2ERC20DepositName = "v2_erc20_deposit"
Expand All @@ -142,7 +144,9 @@ const (
TestV2ERC20WithdrawAndCallName = "v2_erc20_withdraw_and_call"
TestV2ERC20WithdrawAndCallRevertName = "v2_erc20_withdraw_and_call_revert"
TestV2ERC20WithdrawAndCallRevertWithCallName = "v2_erc20_withdraw_and_call_revert_with_call"
TestV2ZEVMToEVMArbitraryCallName = "v2_zevm_to_evm_arbitrary_call"
TestV2ZEVMToEVMCallName = "v2_zevm_to_evm_call"
TestV2ZEVMToEVMCallThroughContractName = "v2_zevm_to_evm_call_through_contract"
TestV2EVMToZEVMCallName = "v2_evm_to_zevm_call"

/*
Expand Down Expand Up @@ -731,13 +735,29 @@ var AllE2ETests = []runner.E2ETest{
TestV2ETHWithdraw,
),
runner.NewE2ETest(
TestV2ETHWithdrawAndCallName,
TestV2ETHWithdrawAndArbitraryCallName,
"withdraw Ether from ZEVM and call a contract using V2 contract",
[]runner.ArgDefinition{
{Description: "amount in wei", DefaultValue: "100000"},
},
TestV2ETHWithdrawAndArbitraryCall,
),
runner.NewE2ETest(
TestV2ETHWithdrawAndCallName,
"withdraw Ether from ZEVM call a contract using V2 contract",
[]runner.ArgDefinition{
{Description: "amount in wei", DefaultValue: "100000"},
},
TestV2ETHWithdrawAndCall,
),
runner.NewE2ETest(
TestV2ETHWithdrawAndCallThroughContractName,
"withdraw Ether from ZEVM call a contract using V2 contract through intermediary contract",
[]runner.ArgDefinition{
{Description: "amount in wei", DefaultValue: "100000"},
},
TestV2ETHWithdrawAndCallThroughContract,
),
runner.NewE2ETest(
TestV2ETHWithdrawAndCallRevertName,
"withdraw Ether from ZEVM and call a contract using V2 contract that reverts",
Expand Down Expand Up @@ -818,12 +838,24 @@ var AllE2ETests = []runner.E2ETest{
},
TestV2ERC20WithdrawAndCallRevertWithCall,
),
runner.NewE2ETest(
TestV2ZEVMToEVMArbitraryCallName,
"zevm -> evm call using V2 contract",
[]runner.ArgDefinition{},
TestV2ZEVMToEVMArbitraryCall,
),
runner.NewE2ETest(
TestV2ZEVMToEVMCallName,
"zevm -> evm call using V2 contract",
[]runner.ArgDefinition{},
TestV2ZEVMToEVMCall,
),
runner.NewE2ETest(
TestV2ZEVMToEVMCallThroughContractName,
"zevm -> evm call using V2 contract through intermediary contract",
[]runner.ArgDefinition{},
TestV2ZEVMToEVMCallThroughContract,
),
runner.NewE2ETest(
TestV2EVMToZEVMCallName,
"evm -> zevm call using V2 contract",
Expand Down
40 changes: 40 additions & 0 deletions e2e/e2etests/test_v2_eth_withdraw_and_arbitrary_call.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package e2etests

import (
"math/big"

"github.com/stretchr/testify/require"
"github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayzevm.sol"

"github.com/zeta-chain/node/e2e/runner"
"github.com/zeta-chain/node/e2e/utils"
crosschaintypes "github.com/zeta-chain/node/x/crosschain/types"
)

const payloadMessageWithdrawETH = "this is a test ETH withdraw and call payload"

func TestV2ETHWithdrawAndArbitraryCall(r *runner.E2ERunner, args []string) {
require.Len(r, args, 1)

amount, ok := big.NewInt(0).SetString(args[0], 10)
require.True(r, ok, "Invalid amount specified for TestV2ETHWithdrawAndCall")

r.AssertTestDAppEVMCalled(false, payloadMessageWithdrawETH, amount)

r.ApproveETHZRC20(r.GatewayZEVMAddr)

// perform the withdraw
tx := r.V2ETHWithdrawAndCall(
r.TestDAppV2EVMAddr,
amount,
r.EncodeGasCall(payloadMessageWithdrawETH),
gatewayzevm.RevertOptions{OnRevertGasLimit: big.NewInt(0)},
)

// wait for the cctx to be mined
cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, tx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout)
r.Logger.CCTX(*cctx, "withdraw")
require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctx.CctxStatus.Status)

r.AssertTestDAppEVMCalled(true, payloadMessageWithdrawETH, amount)
}
Loading
Loading