Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,15 @@ ifdef UPGRADE_TEST_FROM_SOURCE
zetanode-upgrade: e2e-images
@echo "Building zetanode-upgrade from source"
$(DOCKER) build -t zetanode:old -f Dockerfile-localnet --target old-runtime-source \
--build-arg OLD_VERSION='release/v35' \
--build-arg OLD_VERSION='release/v36' \
--build-arg NODE_VERSION=$(NODE_VERSION) \
--build-arg NODE_COMMIT=$(NODE_COMMIT) \
.
else
zetanode-upgrade: e2e-images
@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/v35.0.0' \
--build-arg OLD_VERSION='https://github.com/zeta-chain/node/releases/download/v36.0.1' \
--build-arg NODE_VERSION=$(NODE_VERSION) \
--build-arg NODE_COMMIT=$(NODE_COMMIT) \
.
Expand All @@ -379,13 +379,15 @@ start-upgrade-test: zetanode-upgrade solana
@echo "--> Starting upgrade test"
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=240 && \
export USE_ZETAE2E_ANTE=true && \
export E2E_ARGS="--test-solana --test-sui" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade --profile solana --profile sui -f docker-compose-upgrade.yml up -d

start-upgrade-test-light: zetanode-upgrade
@echo "--> Starting light upgrade test (no ZetaChain state populating before upgrade)"
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=60 && \
export USE_ZETAE2E_ANTE=true && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose-upgrade.yml up -d

start-upgrade-test-admin: zetanode-upgrade
Expand Down
11 changes: 11 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@
* EVM inbounds support multiple calls inside same tx. EVM Gateway contracts must be upgraded before node upgrade, and an additional action fee should be set,
by calling `updateAdditionalActionFee` admin function.

### Zetaclient Config

* Feature flags are introduced, this section should be added to Zetaclient Config after EVM Gateway contracts are upgraded, to enable multiple EVM calls in Zetaclient:

```
"FeatureFlags": {
"EnableMultipleCalls": true
}
```

### Features

* [4274](https://github.com/zeta-chain/node/pull/4274) - multiple evm calls in single tx
* [4288](https://github.com/zeta-chain/node/pull/4288) - zetaclient config feature flag for multiple evm calls

## v36.0.0

Expand Down
1 change: 1 addition & 0 deletions cmd/zetaclientd/initconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func InitializeConfig(_ *cobra.Command, _ []string) error {
configData.KeyringBackend = config.KeyringBackend(initializeConfigOpts.KeyringBackend)
configData.RelayerKeyPath = opts.RelayerKeyPath
configData.ComplianceConfig = sample.ComplianceConfig()
configData.FeatureFlags = sample.FeatureFlags()

// Save config file
return config.Save(&configData, globalOpts.ZetacoreHome)
Expand Down
11 changes: 2 additions & 9 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,18 +307,11 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
logger.Print("✅ setup completed in %s", time.Since(startTime))
}

deployerRunner.AddPostUpgradeHandler(previousVersion, func() {
deployerRunner.Logger.Print(fmt.Sprintf("Running post-upgrade setup for %s", previousVersion))
deployerRunner.AddPostUpgradeHandler(runner.V36Version, func() {
deployerRunner.Logger.Print("Running post-upgrade setup for %s", runner.V36Version)
err = OverwriteAccountData(cmd, &conf)
require.NoError(deployerRunner, err, "Failed to override account data from the config file")
deployerRunner.RunSetup(testLegacy || testAdmin)
if !testSui || deployerRunner.IsRunningTssMigration() {
return
}

balance, err := deployerRunner.SUIZRC20.BalanceOf(&bind.CallOpts{}, fungibletypes.GasStabilityPoolAddressEVM())
require.NoError(deployerRunner, err, "Failed to get SUI ZRC20 balance")
require.True(deployerRunner, balance.Cmp(big.NewInt(0)) == 0, "SUI ZRC20 balance should be zero")
})

// if a config output is specified, write the config
Expand Down
10 changes: 10 additions & 0 deletions contrib/localnet/scripts/start-zetaclientd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ 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
}

enable_multiple_calls() {
jq '.FeatureFlags = {"EnableMultipleCalls": true}' \
/root/.zetacored/config/zetaclient_config.json > tmp.json && \
mv tmp.json /root/.zetacored/config/zetaclient_config.json
}

# import a relayer private key (e.g. Solana relayer key)
import_relayer_key() {
local num="$1"
Expand Down Expand Up @@ -86,6 +92,8 @@ if [[ $HOSTNAME == "zetaclient0" && ! -f ~/.zetacored/config/zetaclient_config.j

# import relayer private key for zetaclient0
import_relayer_key 0
# add feature flags to existing config
enable_multiple_calls

# if eth2 is enabled, set the endpoint in the zetaclient_config.json
# 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)
Expand All @@ -108,6 +116,8 @@ if [[ $HOSTNAME != "zetaclient0" && ! -f ~/.zetacored/config/zetaclient_config.j

# import relayer private key for zetaclient{$num}
import_relayer_key "${num}"
# add feature flags to existing config
enable_multiple_calls

# 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)
Expand Down
2 changes: 1 addition & 1 deletion e2e/contracts/testdappv2/TestDAppV2.bin

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion e2e/contracts/testdappv2/TestDAppV2.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion e2e/contracts/testdappv2/TestDAppV2.json

Large diffs are not rendered by default.

29 changes: 19 additions & 10 deletions e2e/contracts/testdappv2/TestDAppV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,21 @@ contract TestDAppV2 {
function gatewayMultipleDeposits(address dst, bytes calldata payload) external payable {
require(!isZetaChain);
uint256 additionalFee = IGatewayEVM(gateway).additionalActionFeeWei();
// substract 2 fees from msg.value
uint256 amount = msg.value - additionalFee * 2;
// substract 5 fees from msg.value
uint256 amount = msg.value - additionalFee * 5;

// initial free deposit
IGatewayEVM(gateway).deposit{value: amount / 2 }(dst, amount / 2, RevertOptions(msg.sender, false, address(0), "", 0));
IGatewayEVM(gateway).deposit{value: amount / 4 }(dst, amount / 4, RevertOptions(msg.sender, false, address(0), "", 0));

// eth deposit with additional fee
IGatewayEVM(gateway).deposit{value: amount / 4 + additionalFee }(dst, amount / 4, RevertOptions(msg.sender, false, address(0), "", 0));

// eth deposit and call with additional fee
IGatewayEVM(gateway).depositAndCall{value: amount / 2 + additionalFee }(dst, amount / 2, payload, RevertOptions(msg.sender, false, address(0), "", 0));
// 2 eth deposit and call with additional fee
IGatewayEVM(gateway).depositAndCall{value: amount / 4 + additionalFee }(dst, amount / 4, payload, RevertOptions(msg.sender, false, address(0), "", 0));
IGatewayEVM(gateway).depositAndCall{value: amount / 4 + additionalFee }(dst, amount / 4, payload, RevertOptions(msg.sender, false, address(0), "", 0));

// call with additional fee
// 2 calls with additional fee
IGatewayEVM(gateway).call{value: additionalFee}(dst, payload, RevertOptions(msg.sender, false, address(0), "", 0));
IGatewayEVM(gateway).call{value: additionalFee}(dst, payload, RevertOptions(msg.sender, false, address(0), "", 0));
}

Expand All @@ -288,10 +293,14 @@ contract TestDAppV2 {
IZRC20(asset).approve(gateway, assetAmount);

// initial free deposit
IGatewayEVM(gateway).deposit(dst, assetAmount / 2, asset, RevertOptions(msg.sender, false, address(0), "", 0));

// erc20 deposits with additional fee
IGatewayEVM(gateway).depositAndCall{ value: additionalFee }(dst, assetAmount / 2, asset, payload, RevertOptions(msg.sender, false, address(0), "", 0));
IGatewayEVM(gateway).deposit(dst, assetAmount / 4, asset, RevertOptions(msg.sender, false, address(0), "", 0));

// deposit with additional fee
IGatewayEVM(gateway).deposit{ value: additionalFee }(dst, assetAmount / 4, asset, RevertOptions(msg.sender, false, address(0), "", 0));

// 2 erc20 deposits with additional fee
IGatewayEVM(gateway).depositAndCall{ value: additionalFee }(dst, assetAmount / 4, asset, payload, RevertOptions(msg.sender, false, address(0), "", 0));
IGatewayEVM(gateway).depositAndCall{ value: additionalFee }(dst, assetAmount / 4, asset, payload, RevertOptions(msg.sender, false, address(0), "", 0));
}

function gatewayMultipleDepositsLegacy(address dst, uint256 fee) external payable {
Expand Down
14 changes: 10 additions & 4 deletions e2e/e2etests/test_erc20_multiple_deposits.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package e2etests

import (
"math/big"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -29,8 +31,8 @@ func TestERC20MultipleDeposits(r *runner.E2ERunner, args []string) {
fee, err := r.GatewayEVM.AdditionalActionFeeWei(nil)
require.NoError(r, err)

// use 1 fee as amount to pay for 2 inbounds (1st one is free)
r.EVMAuth.Value = fee
// use 3 * fee as amount to pay for 4 inbounds (1st one is free)
r.EVMAuth.Value = new(big.Int).Mul(fee, big.NewInt(3))
defer func() {
r.EVMAuth.Value = previousValue
}()
Expand All @@ -47,12 +49,16 @@ func TestERC20MultipleDeposits(r *runner.E2ERunner, args []string) {
r.WaitForTxReceiptOnEVM(tx)

// wait for the cctxs to be mined
cctxs := utils.WaitCctxsMinedByInboundHash(r.Ctx, tx.Hash().Hex(), r.CctxClient, 2, r.Logger, r.CctxTimeout)
cctxs := utils.WaitCctxsMinedByInboundHash(r.Ctx, tx.Hash().Hex(), r.CctxClient, 4, r.Logger, r.CctxTimeout)
r.Logger.CCTX(*cctxs[0], "deposit erc20")
r.Logger.CCTX(*cctxs[1], "deposit erc20 and call")
r.Logger.CCTX(*cctxs[1], "deposit erc20 2")
r.Logger.CCTX(*cctxs[2], "deposit erc20 and call")
r.Logger.CCTX(*cctxs[3], "deposit erc20 and call 2")

require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctxs[0].CctxStatus.Status)
require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctxs[1].CctxStatus.Status)
require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctxs[2].CctxStatus.Status)
require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctxs[3].CctxStatus.Status)

// wait for the zrc20 balance to be updated
change := utils.NewExactChange(amount)
Expand Down
16 changes: 11 additions & 5 deletions e2e/e2etests/test_eth_multiple_deposits.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func TestETHMultipleDeposits(r *runner.E2ERunner, args []string) {
previousValue := r.EVMAuth.Value
fee, err := r.GatewayEVM.AdditionalActionFeeWei(nil)
require.NoError(r, err)
// add 2 fees to provided amount to pay for 3 inbounds (1st one is free)
r.EVMAuth.Value = new(big.Int).Add(amount, new(big.Int).Mul(fee, big.NewInt(2)))
// add 5 fees to provided amount to pay for 6 inbounds (1st one is free)
r.EVMAuth.Value = new(big.Int).Add(amount, new(big.Int).Mul(fee, big.NewInt(5)))
defer func() {
r.EVMAuth.Value = previousValue
}()
Expand All @@ -37,14 +37,20 @@ func TestETHMultipleDeposits(r *runner.E2ERunner, args []string) {
r.WaitForTxReceiptOnEVM(tx)

// wait for the cctxs to be mined
cctxs := utils.WaitCctxsMinedByInboundHash(r.Ctx, tx.Hash().Hex(), r.CctxClient, 3, r.Logger, r.CctxTimeout)
cctxs := utils.WaitCctxsMinedByInboundHash(r.Ctx, tx.Hash().Hex(), r.CctxClient, 6, r.Logger, r.CctxTimeout)
r.Logger.CCTX(*cctxs[0], "deposit eth")
r.Logger.CCTX(*cctxs[1], "deposit and call eth")
r.Logger.CCTX(*cctxs[2], "call")
r.Logger.CCTX(*cctxs[1], "deposit eth 2")
r.Logger.CCTX(*cctxs[2], "deposit and call eth")
r.Logger.CCTX(*cctxs[3], "deposit and call eth 2")
r.Logger.CCTX(*cctxs[4], "call")
r.Logger.CCTX(*cctxs[5], "call 2")

require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctxs[0].CctxStatus.Status)
require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctxs[1].CctxStatus.Status)
require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctxs[2].CctxStatus.Status)
require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctxs[3].CctxStatus.Status)
require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctxs[4].CctxStatus.Status)
require.Equal(r, crosschaintypes.CctxStatus_OutboundMined, cctxs[5].CctxStatus.Status)

// wait for the zrc20 balance to be updated
change := utils.NewExactChange(amount)
Expand Down
14 changes: 7 additions & 7 deletions e2e/e2etests/test_inbound_trackers.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,15 @@ func TestInboundTrackers(r *runner.E2ERunner, args []string) {
previousValue := r.EVMAuth.Value
fee, err := r.GatewayEVM.AdditionalActionFeeWei(nil)
require.NoError(r, err)
// add 2 fees to provided amount to pay for 3 inbounds (1st one is free)
r.EVMAuth.Value = new(big.Int).Add(amount, new(big.Int).Mul(fee, big.NewInt(2)))

// add 5 fees to provided amount to pay for 6 inbounds (1st one is free)
r.EVMAuth.Value = new(big.Int).Add(amount, new(big.Int).Mul(fee, big.NewInt(5)))

// send multiple deposit through contract
r.Logger.Print("🏃test multiple deposits through contract")
tx, err = r.TestDAppV2EVM.GatewayMultipleDeposits(r.EVMAuth, r.TestDAppV2ZEVMAddr, []byte(randomPayload(r)))
require.NoError(r, err)
addTrackerAndWaitForCCTXs(coin.CoinType_Gas, tx.Hash().Hex(), 3)
addTrackerAndWaitForCCTXs(coin.CoinType_Gas, tx.Hash().Hex(), 6)
r.Logger.Print("🍾 multiple deposits through contract observed")

// reset the value of the payable transactions
Expand All @@ -140,9 +141,8 @@ func TestInboundTrackers(r *runner.E2ERunner, args []string) {
require.NoError(r, err)
r.WaitForTxReceiptOnEVM(tx)

// set value of the payable transactions
// use 1 fee as amount to pay for 2 inbounds (1st one is free)
r.EVMAuth.Value = fee
// use 3 * fee as amount to pay for 4 inbounds (1st one is free)
r.EVMAuth.Value = new(big.Int).Mul(fee, big.NewInt(3))

// send multiple deposit through contract
r.Logger.Print("🏃test multiple erc20 deposits through contract")
Expand All @@ -154,6 +154,6 @@ func TestInboundTrackers(r *runner.E2ERunner, args []string) {
[]byte(randomPayload(r)),
)
require.NoError(r, err)
addTrackerAndWaitForCCTXs(coin.CoinType_ERC20, tx.Hash().Hex(), 2)
addTrackerAndWaitForCCTXs(coin.CoinType_ERC20, tx.Hash().Hex(), 4)
r.Logger.Print("🍾 multiple erc20 deposits through contract observed")
}
26 changes: 26 additions & 0 deletions e2e/runner/setup_evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,29 @@ func (r *E2ERunner) DeployZetaConnectorNative(ensureTxReceipt func(tx *ethtypes.
txZetaConnectorNativeHash.Hash().Hex(),
)
}

// DeployTestDAppV2EVM deploys the test DApp V2 contract for EVM
func (r *E2ERunner) DeployTestDAppV2EVM() {
ensureTxReceipt := func(tx *ethtypes.Transaction, failMessage string) {
receipt := utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout)
r.requireTxSuccessful(receipt, failMessage)
}

testDAppV2Addr, txTestDAppV2, _, err := testdappv2.DeployTestDAppV2(
r.EVMAuth,
r.EVMClient,
false,
r.GatewayEVMAddr,
)
require.NoError(r, err)
ensureTxReceipt(txTestDAppV2, "TestDAppV2 deployment failed")

// Initialize the test dapp contract instance
r.TestDAppV2EVMAddr = testDAppV2Addr
r.TestDAppV2EVM, err = testdappv2.NewTestDAppV2(testDAppV2Addr, r.EVMClient)
require.NoError(r, err)

isZetaChain, err := r.TestDAppV2EVM.IsZetaChain(&bind.CallOpts{})
require.NoError(r, err)
require.False(r, isZetaChain)
}
25 changes: 25 additions & 0 deletions e2e/runner/setup_zevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,28 @@ func (r *E2ERunner) UpdateProtocolContractsInChainParams(testLegacy bool) {
err = r.ZetaTxServer.UpdateChainParams(chainParams)
require.NoError(r, err)
}

// DeployTestDAppV2ZEVM deploys the test DApp V2 contract
func (r *E2ERunner) DeployTestDAppV2ZEVM() {
ensureTxReceipt := func(tx *ethtypes.Transaction, failMessage string) {
receipt := e2eutils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
r.requireTxSuccessful(receipt, failMessage+" tx hash: "+tx.Hash().Hex())
}

testDAppV2Addr, txTestDAppV2, _, err := testdappv2.DeployTestDAppV2(
r.ZEVMAuth,
r.ZEVMClient,
true,
r.GatewayEVMAddr,
)
require.NoError(r, err)
ensureTxReceipt(txTestDAppV2, "TestDAppV2 deployment failed")

r.TestDAppV2ZEVMAddr = testDAppV2Addr
r.TestDAppV2ZEVM, err = testdappv2.NewTestDAppV2(testDAppV2Addr, r.ZEVMClient)
require.NoError(r, err)

isZetaChain, err := r.TestDAppV2ZEVM.IsZetaChain(&bind.CallOpts{})
require.NoError(r, err)
require.True(r, isZetaChain)
}
41 changes: 0 additions & 41 deletions e2e/runner/upgrade_v33.go

This file was deleted.

Loading