Skip to content

Commit

Permalink
Merge branch 'develop' into feat/vote-priority-fee
Browse files Browse the repository at this point in the history
  • Loading branch information
swift1337 committed Jul 24, 2024
2 parents ccc3598 + 960da02 commit b6305d4
Show file tree
Hide file tree
Showing 75 changed files with 1,598 additions and 559 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/reusable-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
if: ${{ inputs.run }}
runs-on: ${{ inputs.runs-on }}
timeout-minutes: ${{ inputs.timeout-minutes }}
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@ start-solana-test: zetanode solana
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/v17' .
$(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime-source --build-arg OLD_VERSION='release/v18' .
.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/ci-testing-node/releases/download/v17.0.1-internal' .
$(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime --build-arg OLD_VERSION='https://github.com/zeta-chain/node/releases/download/v18.0.0' .
.PHONY: zetanode-upgrade
endif

Expand Down
2 changes: 2 additions & 0 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"
emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types"
ibccrosschaintypes "github.com/zeta-chain/zetacore/x/ibccrosschain/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

func SetupHandlers(app *App) {
Expand Down Expand Up @@ -68,6 +69,7 @@ func SetupHandlers(app *App) {
crisistypes.ModuleName,
emissionstypes.ModuleName,
authoritytypes.ModuleName,
observertypes.ModuleName,
}
allUpgrades := upgradeTracker{
upgrades: []upgradeTrackerItem{
Expand Down
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
* [2395](https://github.com/zeta-chain/node/pull/2395) - converge AppContext with ZetaCoreContext in zetaclient
* [2428](https://github.com/zeta-chain/node/pull/2428) - propagate context across codebase & refactor zetacore client
* [2464](https://github.com/zeta-chain/node/pull/2464) - move common voting logic to voting.go and add new function VoteOnBallot
* [2515](https://github.com/zeta-chain/node/pull/2515) - replace chainName by chainID for ChainNonces indexing

### Tests

Expand All @@ -85,7 +86,7 @@
* [2549](https://github.com/zeta-chain/node/pull/2459) - add separate accounts for each policy in e2e tests
* [2415](https://github.com/zeta-chain/node/pull/2415) - add e2e test for upgrade and test admin functionalities
* [2440](https://github.com/zeta-chain/node/pull/2440) - Add e2e test for TSS migration

* [2473](https://github.com/zeta-chain/node/pull/2473) - add e2e tests for most used admin transactions

### Fixes

Expand Down
4 changes: 2 additions & 2 deletions cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ func start(_ *cobra.Command, _ []string) error {
startLogger.Debug().Msgf("CreateAuthzSigner is ready")

// Initialize core parameters from zetacore
err = zetacoreClient.UpdateZetacoreContext(ctx, appContext, true, startLogger)
err = zetacoreClient.UpdateAppContext(ctx, appContext, true, startLogger)
if err != nil {
startLogger.Error().Err(err).Msg("Error getting core parameters")
return err
}
startLogger.Info().Msgf("Config is updated from zetacore %s", maskCfg(cfg))

go zetacoreClient.UpdateZetacoreContextWorker(ctx, appContext)
go zetacoreClient.UpdateAppContextWorker(ctx, appContext)

// Generate TSS address . The Tss address is generated through Keygen ceremony. The TSS key is used to sign all outbound transactions .
// The hotkeyPk is private key for the Hotkey. The Hotkey is used to sign all inbound transactions
Expand Down
4 changes: 3 additions & 1 deletion cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package local

import (
"context"
"errors"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -296,6 +297,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
e2etests.TestUpdateBytecodeZRC20Name,
e2etests.TestUpdateBytecodeConnectorName,
e2etests.TestDepositEtherLiquidityCapName,
e2etests.TestCriticalAdminTransactionsName,

// 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
Expand Down Expand Up @@ -331,7 +333,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
// 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")
monitorPriorityCancel()
if err := <-txPriorityErrCh; err != nil {
if err := <-txPriorityErrCh; err != nil && errors.Is(err, errWrongTxPriority) {
logger.Print("❌ %v", err)
logger.Print("❌ e2e tests failed after %s", time.Since(testStartTime).String())
os.Exit(1)
Expand Down
4 changes: 3 additions & 1 deletion cmd/zetae2e/local/monitor_priority_txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"github.com/zeta-chain/zetacore/e2e/config"
)

var errWrongTxPriority = errors.New("wrong tx priority, system tx not on top")

// monitorTxPriorityInBlocks checks for transaction priorities in blocks and reports errors
func monitorTxPriorityInBlocks(ctx context.Context, conf config.Config, errCh chan error) {
rpcClient, err := rpchttp.New(conf.RPCs.ZetaCoreRPC, "/websocket")
Expand Down Expand Up @@ -71,7 +73,7 @@ func processTx(txResult *coretypes.ResultTx, nonSystemTxFound *bool, errCh chan
if isMsgTypeURLSystemTx(attr) {
// a non system tx has been found in the block before a system tx
if *nonSystemTxFound {
errCh <- errors.New("wrong tx priority, system tx not on top")
errCh <- errWrongTxPriority
return
}
} else {
Expand Down
1 change: 1 addition & 0 deletions docs/cli/zetacored/zetacored_query_crosschain.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ zetacored query crosschain [flags]
* [zetacored query crosschain show-cctx](zetacored_query_crosschain_show-cctx.md) - shows a CCTX
* [zetacored query crosschain show-gas-price](zetacored_query_crosschain_show-gas-price.md) - shows a gasPrice
* [zetacored query crosschain show-inbound-hash-to-cctx](zetacored_query_crosschain_show-inbound-hash-to-cctx.md) - shows a inboundHashToCctx
* [zetacored query crosschain show-inbound-tracker](zetacored_query_crosschain_show-inbound-tracker.md) - shows an inbound tracker by chainID and txHash
* [zetacored query crosschain show-outbound-tracker](zetacored_query_crosschain_show-outbound-tracker.md) - shows an outbound tracker
* [zetacored query crosschain show-rate-limiter-flags](zetacored_query_crosschain_show-rate-limiter-flags.md) - shows the rate limiter flags

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# query crosschain show-inbound-tracker

shows an inbound tracker by chainID and txHash

```
zetacored query crosschain show-inbound-tracker [chainID] [txHash] [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 show-inbound-tracker
--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 crosschain](zetacored_query_crosschain.md) - Querying commands for the crosschain module

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
shows a chainNonces

```
zetacored query observer show-chain-nonces [index] [flags]
zetacored query observer show-chain-nonces [chain-id] [flags]
```

### Options
Expand Down
35 changes: 33 additions & 2 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28846,6 +28846,30 @@ paths:
type: string
tags:
- Query
/zeta-chain/crosschain/inboundTracker/{chain_id}/{tx_hash}:
get:
operationId: Query_InboundTracker
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/crosschainQueryInboundTrackerResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: chain_id
in: path
required: true
type: string
format: int64
- name: tx_hash
in: path
required: true
type: string
tags:
- Query
/zeta-chain/crosschain/inboundTrackerByChain/{chain_id}:
get:
operationId: Query_InboundTrackerAllByChain
Expand Down Expand Up @@ -30077,7 +30101,7 @@ paths:
type: boolean
tags:
- Query
/zeta-chain/observer/chainNonces/{index}:
/zeta-chain/observer/chainNonces/{chain_id}:
get:
summary: Queries a chainNonces by index.
operationId: Query_ChainNonces
Expand All @@ -30091,10 +30115,11 @@ paths:
schema:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: index
- name: chain_id
in: path
required: true
type: string
format: int64
tags:
- Query
/zeta-chain/observer/crosschain_flags:
Expand Down Expand Up @@ -57406,6 +57431,11 @@ definitions:
items:
type: object
$ref: '#/definitions/crosschainCrossChainTx'
crosschainQueryInboundTrackerResponse:
type: object
properties:
inbound_tracker:
$ref: '#/definitions/crosschainInboundTracker'
crosschainQueryLastZetaHeightResponse:
type: object
properties:
Expand Down Expand Up @@ -57795,6 +57825,7 @@ definitions:
type: string
index:
type: string
title: 'deprecated(v19): index has been replaced by chain_id for unique identifier'
chain_id:
type: string
format: int64
Expand Down
19 changes: 13 additions & 6 deletions e2e/e2etests/e2etests.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ const (
Admin tests
Test admin functionalities
*/
TestDepositEtherLiquidityCapName = "deposit_eth_liquidity_cap"
TestMigrateChainSupportName = "migrate_chain_support"
TestPauseZRC20Name = "pause_zrc20"
TestUpdateBytecodeZRC20Name = "update_bytecode_zrc20"
TestUpdateBytecodeConnectorName = "update_bytecode_connector"
TestRateLimiterName = "rate_limiter"
TestDepositEtherLiquidityCapName = "deposit_eth_liquidity_cap"
TestMigrateChainSupportName = "migrate_chain_support"
TestPauseZRC20Name = "pause_zrc20"
TestUpdateBytecodeZRC20Name = "update_bytecode_zrc20"
TestUpdateBytecodeConnectorName = "update_bytecode_connector"
TestRateLimiterName = "rate_limiter"
TestCriticalAdminTransactionsName = "critical_admin_transactions"

TestMigrateTSSName = "migrate_TSS"

Expand Down Expand Up @@ -549,6 +550,12 @@ var AllE2ETests = []runner.E2ETest{
[]runner.ArgDefinition{},
TestRateLimiter,
),
runner.NewE2ETest(
TestCriticalAdminTransactionsName,
"test critical admin transactions",
[]runner.ArgDefinition{},
TestCriticalAdminTransactions,
),
/*
Special tests
*/
Expand Down
105 changes: 105 additions & 0 deletions e2e/e2etests/test_admin_transactions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package e2etests

import (
"github.com/stretchr/testify/require"

"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/coin"
"github.com/zeta-chain/zetacore/testutil/sample"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

// TestCriticalAdminTransactions tests critical admin transactions that are the most used on mainnet .
// The complete list is
// MsgUpdateChainParams
// MsgRefundAbortedCCTX
// MsgEnableCCTX
// MsgDisableCCTX
// MsgUpdateGasPriceIncreaseFlags
// MsgAddInboundTracker
// MsgUpdateZRC20LiquidityCap
// MsgDeploySystemContracts
// MsgWhitelistERC20
// MsgPauseZRC20
// MsgMigrateTssFunds
// MsgUpdateTssAddress
//
// However, the transactions other than `AddToInboundTracker` and `UpdateGasPriceIncreaseFlags` have already been used in other tests.
func TestCriticalAdminTransactions(r *runner.E2ERunner, _ []string) {
TestAddToInboundTracker(r)
TestUpdateGasPriceIncreaseFlags(r)
}

func TestUpdateGasPriceIncreaseFlags(r *runner.E2ERunner) {
// Set default flags on zetacore
defaultFlags := observertypes.DefaultGasPriceIncreaseFlags
msgGasPriceFlags := observertypes.NewMsgUpdateGasPriceIncreaseFlags(
r.ZetaTxServer.MustGetAccountAddressFromName(utils.OperationalPolicyName),
defaultFlags,
)
_, err := r.ZetaTxServer.BroadcastTx(utils.OperationalPolicyName, msgGasPriceFlags)
require.NoError(r, err)

// create a new set of flag values by incrementing the epoch length by 1
defaultFlagsUpdated := defaultFlags
defaultFlagsUpdated.EpochLength = defaultFlags.EpochLength + 1

// Update the flags on zetacore with the new values
msgGasPriceFlags = observertypes.NewMsgUpdateGasPriceIncreaseFlags(
r.ZetaTxServer.MustGetAccountAddressFromName(utils.OperationalPolicyName),
defaultFlagsUpdated,
)
_, err = r.ZetaTxServer.BroadcastTx(utils.OperationalPolicyName, msgGasPriceFlags)
require.NoError(r, err)

r.WaitForBlocks(1)

// Verify that the flags have been updated
flags, err := r.ObserverClient.CrosschainFlags(r.Ctx, &observertypes.QueryGetCrosschainFlagsRequest{})
require.NoError(r, err)
require.Equal(r, defaultFlagsUpdated.EpochLength, flags.CrosschainFlags.GasPriceIncreaseFlags.EpochLength)
}

func TestAddToInboundTracker(r *runner.E2ERunner) {
chainEth := chains.GoerliLocalnet
chainBtc := chains.BitcoinRegtest
msgEth := crosschaintypes.NewMsgAddInboundTracker(
r.ZetaTxServer.MustGetAccountAddressFromName(utils.EmergencyPolicyName),
chainEth.ChainId,
coin.CoinType_Gas,
sample.Hash().Hex(),
)
_, err := r.ZetaTxServer.BroadcastTx(utils.EmergencyPolicyName, msgEth)
require.NoError(r, err)

msgBtc := crosschaintypes.NewMsgAddInboundTracker(
r.ZetaTxServer.MustGetAccountAddressFromName(utils.EmergencyPolicyName),
chainBtc.ChainId,
coin.CoinType_Gas,
sample.BtcHash().String(),
)

_, err = r.ZetaTxServer.BroadcastTx(utils.EmergencyPolicyName, msgBtc)
require.NoError(r, err)

r.WaitForBlocks(1)

tracker, err := r.CctxClient.InboundTracker(r.Ctx, &crosschaintypes.QueryInboundTrackerRequest{
ChainId: msgEth.ChainId,
TxHash: msgEth.TxHash,
})
require.NoError(r, err)
require.NotNil(r, tracker)
require.Equal(r, msgEth.TxHash, tracker.InboundTracker.TxHash)

tracker, err = r.CctxClient.InboundTracker(r.Ctx, &crosschaintypes.QueryInboundTrackerRequest{
ChainId: msgBtc.ChainId,
TxHash: msgBtc.TxHash,
})
require.NoError(r, err)
require.NotNil(r, tracker)
require.Equal(r, msgBtc.TxHash, tracker.InboundTracker.TxHash)
}
7 changes: 2 additions & 5 deletions e2e/e2etests/test_erc20_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ import (
func TestERC20Withdraw(r *runner.E2ERunner, args []string) {
require.Len(r, args, 1)

approvedAmount := big.NewInt(1e18)

withdrawalAmount, ok := new(big.Int).SetString(args[0], 10)
require.True(r, ok, "Invalid withdrawal amount specified for TestERC20Withdraw.")
require.Equal(r, -1, withdrawalAmount.Cmp(approvedAmount))

// approve
tx, err := r.ETHZRC20.Approve(r.ZEVMAuth, r.ERC20ZRC20Addr, approvedAmount)
// approve 1 unit of the gas token to cover the gas fee
tx, err := r.ETHZRC20.Approve(r.ZEVMAuth, r.ERC20ZRC20Addr, big.NewInt(1e18))
require.NoError(r, err)

receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
Expand Down
Loading

0 comments on commit b6305d4

Please sign in to comment.