Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/zeta-chain/node into avo…
Browse files Browse the repository at this point in the history
…id-btc-solana-inbound-endless-rescan-on-invalid-vote-msg
  • Loading branch information
ws4charlie committed Nov 22, 2024
2 parents c8b50eb + cad1b36 commit 33fd7d3
Show file tree
Hide file tree
Showing 33 changed files with 742 additions and 47 deletions.
57 changes: 56 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@

### Features

### Tests

### Refactor

### Fixes

* [3184](https://github.com/zeta-chain/node/pull/3184) - zetaclient should not retry if inbound vote message validation fails

## v23.0.0

### Features

* [2984](https://github.com/zeta-chain/node/pull/2984) - add Whitelist message ability to whitelist SPL tokens on Solana
* [3091](https://github.com/zeta-chain/node/pull/3091) - improve build reproducability. `make release{,-build-only}` checksums should now be stable.
* [3124](https://github.com/zeta-chain/node/pull/3124) - integrate SPL deposits
Expand All @@ -16,6 +28,7 @@
* [3105](https://github.com/zeta-chain/node/pull/3105) - split Bitcoin E2E tests into two runners for deposit and withdraw
* [3154](https://github.com/zeta-chain/node/pull/3154) - configure Solana gateway program id for E2E tests
* [3188](https://github.com/zeta-chain/node/pull/3188) - add e2e test for v2 deposit and call with swap
* [3151](https://github.com/zeta-chain/node/pull/3151) - add withdraw emissions to e2e tests

### Refactor

Expand All @@ -35,7 +48,49 @@
* [3155](https://github.com/zeta-chain/node/pull/3155) - fix potential panic in the Bitcoin inscription parsing
* [3162](https://github.com/zeta-chain/node/pull/3162) - skip depositor fee calculation if transaction does not involve TSS address
* [3179](https://github.com/zeta-chain/node/pull/3179) - support inbound trackers for v2 cctx
* [3184](https://github.com/zeta-chain/node/pull/3184) - zetaclient should not retry if inbound vote message validation fails
* [3192](https://github.com/zeta-chain/node/pull/3192) - fix incorrect zContext origin caused by the replacement of 'sender' with 'revertAddress'

## v22.1.2

## Fixes

- [3181](https://github.com/zeta-chain/node/pull/3181) - add lock around pingRTT to prevent crash

## v22.1.1

## Fixes

- [3171](https://github.com/zeta-chain/node/pull/3171) - infinite discovery address leak

## v22.1.0

## Features

- [3028](https://github.com/zeta-chain/node/pull/3028) - whitelist connection gater

## Fixes

- [3041](https://github.com/zeta-chain/node/pull/3041) - replace DHT with private peer discovery
- [3162](https://github.com/zeta-chain/node/pull/3162) - skip depositor fee calculation on irrelevant transactions

## v22.0.2

## Fixes

- [3144](https://github.com/zeta-chain/node/pull/3145) - out of gas on ZetaClient during `onRevert`

## v22.0.1

## Fixes

- [3140](https://github.com/zeta-chain/node/pull/3140) - allow BTC revert with dust amount

## v22.0.0

## Refactor

* [3073](https://github.com/zeta-chain/node/pull/3073) - improve ZETA deposit check with max supply check
>>>>>>> cad1b36d6fdd96b8ecfd48f0be32246338db513e
## v21.0.0

Expand Down
4 changes: 4 additions & 0 deletions cmd/zetae2e/config/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ additional_accounts:
bech32_address: "zeta1nry9yeg6njhjrp2ctppa8558vqxal9fxk69zxg"
evm_address: "0x98c852651A9CAF2185585843d3D287600Ddf9526"
private_key: "bf9456c679bb5a952a9a137fcfc920e0413efdb97c36de1e57455763084230cb"
user_emissions_withdraw:
bech32_address: "zeta1n9zhyn4unvaee3ey40k7x7f5nmj7zet6qr5kl7"
evm_address: "0x9945724EBc9B3B9cc724abedE379349EE5E1657a"
private_key: "9d524fe318c0eb5f80d8b246993a9f15f924db24d4b8b873839b13bc30040d03"
policy_accounts:
emergency_policy_account:
bech32_address: "zeta16m2cnrdwtgweq4njc6t470vl325gw4kp6s7tap"
Expand Down
4 changes: 4 additions & 0 deletions cmd/zetae2e/config/localnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ additional_accounts:
bech32_address: "zeta1nry9yeg6njhjrp2ctppa8558vqxal9fxk69zxg"
evm_address: "0x98c852651A9CAF2185585843d3D287600Ddf9526"
private_key: "bf9456c679bb5a952a9a137fcfc920e0413efdb97c36de1e57455763084230cb"
user_emissions_withdraw:
bech32_address: "zeta1n9zhyn4unvaee3ey40k7x7f5nmj7zet6qr5kl7"
evm_address: "0x9945724EBc9B3B9cc724abedE379349EE5E1657a"
private_key: "9d524fe318c0eb5f80d8b246993a9f15f924db24d4b8b873839b13bc30040d03"
policy_accounts:
emergency_policy_account:
bech32_address: "zeta16m2cnrdwtgweq4njc6t470vl325gw4kp6s7tap"
Expand Down
15 changes: 13 additions & 2 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
logger := runner.NewLogger(verbose, color.FgWhite, "setup")

testStartTime := time.Now()

logger.Print("starting E2E tests")

if testAdmin {
Expand Down Expand Up @@ -160,11 +161,17 @@ func localE2ETest(cmd *cobra.Command, _ []string) {

zetaTxServer, err := txserver.NewZetaTxServer(
conf.RPCs.ZetaCoreRPC,
[]string{utils.EmergencyPolicyName, utils.OperationalPolicyName, utils.AdminPolicyName},
[]string{
utils.EmergencyPolicyName,
utils.OperationalPolicyName,
utils.AdminPolicyName,
utils.UserEmissionsWithdrawName,
},
[]string{
conf.PolicyAccounts.EmergencyPolicyAccount.RawPrivateKey.String(),
conf.PolicyAccounts.OperationalPolicyAccount.RawPrivateKey.String(),
conf.PolicyAccounts.AdminPolicyAccount.RawPrivateKey.String(),
conf.AdditionalAccounts.UserEmissionsWithdraw.RawPrivateKey.String(),
},
conf.ZetaChainID,
)
Expand Down Expand Up @@ -323,14 +330,16 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
e2etests.TestBitcoinDepositName,
e2etests.TestBitcoinDepositAndCallName,
e2etests.TestBitcoinDepositAndCallRevertName,
e2etests.TestBitcoinDepositAndCallRevertWithDustName,
e2etests.TestBitcoinStdMemoDepositName,
e2etests.TestBitcoinStdMemoDepositAndCallName,
e2etests.TestBitcoinStdMemoDepositAndCallRevertName,
e2etests.TestBitcoinStdMemoDepositAndCallRevertOtherAddressName,
e2etests.TestBitcoinStdMemoInscribedDepositAndCallName,
e2etests.TestCrosschainSwapName,
}
bitcoinDepositTestsAdvanced := []string{
e2etests.TestBitcoinDepositAndCallRevertWithDustName,
}
bitcoinWithdrawTests := []string{
e2etests.TestBitcoinWithdrawSegWitName,
e2etests.TestBitcoinWithdrawInvalidAddressName,
Expand Down Expand Up @@ -375,6 +384,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
erc20Tests = append(erc20Tests, erc20AdvancedTests...)
zetaTests = append(zetaTests, zetaAdvancedTests...)
zevmMPTests = append(zevmMPTests, zevmMPAdvancedTests...)
bitcoinDepositTests = append(bitcoinDepositTests, bitcoinDepositTestsAdvanced...)
bitcoinWithdrawTests = append(bitcoinWithdrawTests, bitcoinWithdrawTestsAdvanced...)
ethereumTests = append(ethereumTests, ethereumAdvancedTests...)
}
Expand Down Expand Up @@ -488,6 +498,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
logger.Print("❌ e2e tests failed after %s", time.Since(testStartTime).String())
os.Exit(1)
}
noError(deployerRunner.WithdrawEmissions())

// if all tests pass, cancel txs priority monitoring and check if tx priority is not correct in some blocks
logger.Print("⏳ e2e tests passed, checking tx priority")
Expand Down
6 changes: 5 additions & 1 deletion contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ fund_eth_from_config '.additional_accounts.user_v2_ether_revert.evm_address' 100
# unlock v2 erc20 revert tests accounts
fund_eth_from_config '.additional_accounts.user_v2_erc20_revert.evm_address' 10000 "V2 ERC20 revert tester"

# unlock emissions withdraw tests accounts
fund_eth_from_config '.additional_accounts.user_emissions_withdraw.evm_address' 10000 "emissions withdraw tester"

# unlock local solana relayer accounts
if host solana > /dev/null; then
solana_url=$(config_str '.rpcs.solana')
Expand Down Expand Up @@ -222,7 +225,8 @@ if [ "$LOCALNET_MODE" == "upgrade" ]; then
echo "running E2E command to setup the networks and populate the state..."

# Use light flag to ensure tests can complete before the upgrade height
zetae2e local $E2E_ARGS --skip-setup --config "$deployed_config_path" --light --skip-precompiles ${COMMON_ARGS}
# skip-bitcoin-dust-withdraw flag can be removed after v23 is released
zetae2e local $E2E_ARGS --skip-setup --config "$deployed_config_path" --light --skip-precompiles ${COMMON_ARGS}
if [ $? -ne 0 ]; then
echo "first e2e failed"
exit 1
Expand Down
58 changes: 58 additions & 0 deletions contrib/localnet/scripts/start-zetacored.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,55 @@ add_v17_message_authorizations() {
' $json_file > temp.json && mv temp.json $json_file
}


add_emissions_withdraw_authorizations() {

config_file="/root/config.yml"
json_file="/root/.zetacored/config/genesis.json"

# Check if config file exists
if [[ ! -f "$config_file" ]]; then
echo "Error: Config file not found at $config_file"
return 1
fi
# Address to add emissions withdraw authorizations
address=$(yq -r '.additional_accounts.user_emissions_withdraw.bech32_address' "$config_file")

# Check if genesis file exists
if [[ ! -f "$json_file" ]]; then
echo "Error: Genesis file not found at $json_file"
return 1
fi

echo "Adding emissions withdraw authorizations for address: $address"


# Using jq to parse JSON, create new entries, and append them to the authorization array
if ! jq --arg address "$address" '
# Store the nodeAccountList array
.app_state.observer.nodeAccountList as $list |
# Iterate over the stored list to construct new objects and append to the authorization array
.app_state.authz.authorization += [
$list[] |
{
"granter": .operator,
"grantee": $address,
"authorization": {
"@type": "/cosmos.authz.v1beta1.GenericAuthorization",
"msg": "/zetachain.zetacore.emissions.MsgWithdrawEmission"
},
"expiration": null
}
]
' "$json_file" > temp.json; then
echo "Error: Failed to update genesis file"
return 1
fi
mv temp.json "$json_file"
}



# create keys
CHAINID="athens_101-1"
KEYRING="test"
Expand Down Expand Up @@ -191,6 +240,12 @@ then
zetacored collect-observer-info
zetacored add-observer-list --keygen-block 25

# Add emissions withdraw authorizations
if ! add_emissions_withdraw_authorizations; then
echo "Error: Failed to add emissions withdraw authorizations"
exit 1
fi

# Check for the existence of "AddToOutTxTracker" string in the genesis file
# If this message is found in the genesis, it means add-observer-list has been run with the v16 binary for upgrade tests
# In this case, we need to add authorizations for the new v17 messages to the genesis file
Expand Down Expand Up @@ -272,6 +327,9 @@ then
# v2 erc20 revert tester
address=$(yq -r '.additional_accounts.user_v2_erc20_revert.bech32_address' /root/config.yml)
zetacored add-genesis-account "$address" 100000000000000000000000000azeta
# emissions withdraw tester
address=$(yq -r '.additional_accounts.user_emissions_withdraw.bech32_address' /root/config.yml)
zetacored add-genesis-account "$address" 100000000000000000000000000azeta

# 3. Copy the genesis.json to all the nodes .And use it to create a gentx for every node
zetacored gentx operator 1000000000000000000000azeta --chain-id=$CHAINID --keyring-backend=$KEYRING --gas-prices 20000000000azeta
Expand Down
6 changes: 3 additions & 3 deletions docs/openapi/openapi.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
<link
rel="stylesheet"
type="text/css"
href="https://unpkg.com/swagger-ui-dist@4.18.1/swagger-ui.css"
href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.18.2/swagger-ui.min.css"
/>
<link
rel="icon"
type="image/png"
href="https://unpkg.com/swagger-ui-dist@4.18.1/favicon-16x16.png"
href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.18.2/favicon-16x16.png"
/>
</head>
<body>
<div id="swagger-ui"></div>

<script src="https://unpkg.com/swagger-ui-dist@4.18.1/swagger-ui-bundle.js"></script>
<script src="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.18.2/swagger-ui-bundle.min.js"></script>
<script>
window.onload = function() {
window.ui = SwaggerUIBundle({
Expand Down
36 changes: 21 additions & 15 deletions e2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,22 @@ type Account struct {

// AdditionalAccounts are extra accounts required to run specific tests
type AdditionalAccounts struct {
UserERC20 Account `yaml:"user_erc20"`
UserZetaTest Account `yaml:"user_zeta_test"`
UserZEVMMPTest Account `yaml:"user_zevm_mp_test"`
UserBitcoinDeposit Account `yaml:"user_bitcoin_deposit"`
UserBitcoinWithdraw Account `yaml:"user_bitcoin_withdraw"`
UserSolana Account `yaml:"user_solana"`
UserEther Account `yaml:"user_ether"`
UserMisc Account `yaml:"user_misc"`
UserAdmin Account `yaml:"user_admin"`
UserMigration Account `yaml:"user_migration"` // used for TSS migration, TODO: rename (https://github.com/zeta-chain/node/issues/2780)
UserPrecompile Account `yaml:"user_precompile"`
UserV2Ether Account `yaml:"user_v2_ether"`
UserV2ERC20 Account `yaml:"user_v2_erc20"`
UserV2EtherRevert Account `yaml:"user_v2_ether_revert"`
UserV2ERC20Revert Account `yaml:"user_v2_erc20_revert"`
UserERC20 Account `yaml:"user_erc20"`
UserZetaTest Account `yaml:"user_zeta_test"`
UserZEVMMPTest Account `yaml:"user_zevm_mp_test"`
UserBitcoinDeposit Account `yaml:"user_bitcoin_deposit"`
UserBitcoinWithdraw Account `yaml:"user_bitcoin_withdraw"`
UserSolana Account `yaml:"user_solana"`
UserEther Account `yaml:"user_ether"`
UserMisc Account `yaml:"user_misc"`
UserAdmin Account `yaml:"user_admin"`
UserMigration Account `yaml:"user_migration"` // used for TSS migration, TODO: rename (https://github.com/zeta-chain/node/issues/2780)
UserPrecompile Account `yaml:"user_precompile"`
UserV2Ether Account `yaml:"user_v2_ether"`
UserV2ERC20 Account `yaml:"user_v2_erc20"`
UserV2EtherRevert Account `yaml:"user_v2_ether_revert"`
UserV2ERC20Revert Account `yaml:"user_v2_erc20_revert"`
UserEmissionsWithdraw Account `yaml:"user_emissions_withdraw"`
}

type PolicyAccounts struct {
Expand Down Expand Up @@ -248,6 +249,7 @@ func (a AdditionalAccounts) AsSlice() []Account {
a.UserV2ERC20,
a.UserV2EtherRevert,
a.UserV2ERC20Revert,
a.UserEmissionsWithdraw,
}
}

Expand Down Expand Up @@ -364,6 +366,10 @@ func (c *Config) GenerateKeys() error {
if err != nil {
return err
}
c.AdditionalAccounts.UserEmissionsWithdraw, err = generateAccount()
if err != nil {
return err
}

c.PolicyAccounts.EmergencyPolicyAccount, err = generateAccount()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ func TestBitcoinDepositAndCallRevertWithDust(r *runner.E2ERunner, args []string)

// ASSERT
// Now we want to make sure the cctx is aborted with expected error message

// cctx status would be pending revert if using v21 or before
cctx := utils.WaitCctxAbortedByInboundHash(r.Ctx, r, txHash.String(), r.CctxClient)

require.True(r, cctx.GetCurrentOutboundParam().Amount.Uint64() < constant.BTCWithdrawalDustAmount)
require.True(r, strings.Contains(cctx.CctxStatus.ErrorMessage, crosschaintypes.ErrInvalidWithdrawalAmount.Error()))
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func TestBitcoinStdMemoDepositAndCallRevertOtherAddress(r *runner.E2ERunner, arg
// Now we want to make sure revert TX is completed.
cctx := utils.WaitCctxRevertedByInboundHash(r.Ctx, r, txHash.String(), r.CctxClient)

// Make sure inbound sender and revert address are correct
assert.Equal(r, cctx.InboundParams.Sender, r.BTCDeployerAddress.EncodeAddress())
assert.Equal(r, cctx.GetCurrentOutboundParam().Receiver, revertAddress)

// Check revert tx receiver address and amount
receiver, value := r.QueryOutboundReceiverAndAmount(cctx.OutboundParams[1].Hash)
assert.Equal(r, revertAddress, receiver)
Expand Down
2 changes: 1 addition & 1 deletion e2e/e2etests/test_crosschain_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestCrosschainSwap(r *runner.E2ERunner, _ []string) {
// if the tx fails due to already initialized, it will be ignored
_, err := r.UniswapV2Factory.CreatePair(r.ZEVMAuth, r.ERC20ZRC20Addr, r.BTCZRC20Addr)
if err != nil {
r.Logger.Print("ℹ️ create pair error")
r.Logger.Print("ℹ️ create pair error %s", err.Error())
}

txERC20ZRC20Approve, err := r.ERC20ZRC20.Approve(r.ZEVMAuth, r.UniswapV2RouterAddr, big.NewInt(1e18))
Expand Down
7 changes: 5 additions & 2 deletions e2e/e2etests/test_v2_deposit_and_call_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ import (
func TestV2DepositAndCallSwap(r *runner.E2ERunner, _ []string) {
// create tokens pair (erc20 and eth)
tx, err := r.UniswapV2Factory.CreatePair(r.ZEVMAuth, r.ERC20ZRC20Addr, r.ETHZRC20Addr)
require.NoError(r, err)
utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
if err != nil {
r.Logger.Print("ℹ️ create pair error %s", err.Error())
} else {
utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
}

// approve router to spend tokens being swapped
tx, err = r.ERC20ZRC20.Approve(r.ZEVMAuth, r.UniswapV2RouterAddr, big.NewInt(1e18))
Expand Down
2 changes: 1 addition & 1 deletion e2e/e2etests/test_zrc20_swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestZRC20Swap(r *runner.E2ERunner, _ []string) {
// if the tx fails due to already initialized, it will be ignored
tx, err := r.UniswapV2Factory.CreatePair(r.ZEVMAuth, r.ERC20ZRC20Addr, r.ETHZRC20Addr)
if err != nil {
r.Logger.Print("ℹ️ create pair error")
r.Logger.Print("ℹ️ create pair error %s", err.Error())
} else {
utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
}
Expand Down
Loading

0 comments on commit 33fd7d3

Please sign in to comment.