Skip to content
Closed
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: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ start-e2e-test: e2e-images
@echo "--> Starting e2e test"
cd contrib/localnet/ && $(DOCKER_COMPOSE) up -d

start-e2e-v2ZETA-test: e2e-images
@echo "--> Starting e2e test with V2 ZETA flows enabled"
export E2E_ARGS="${E2E_ARGS} --v2-zeta-flows" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) up -d

start-skip-consensus-overwrite-test: e2e-images
@echo "--> Starting e2e test but skip overwriting the consensus timeout params on zetacore0"
cd contrib/localnet/ && SKIP_CONSENSUS_VALUES_OVERWRITE=true $(DOCKER_COMPOSE) up -d
Expand Down Expand Up @@ -431,6 +436,7 @@ start-connector-migration-test: zetanode-upgrade
@echo "--> Starting migration test for v2 connector contracts"
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=90 && \
export USE_ZETAE2E_ANTE=true && \
export E2E_ARGS="${E2E_ARGS} --skip-regular --test-connector-migration --test-legacy" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose-upgrade.yml up -d

Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ by calling `updateAdditionalActionFee` admin function.
* [4211](https://github.com/zeta-chain/node/pull/4211) - provide error information in cctx when Bitcoin deposit fail
* [4218](https://github.com/zeta-chain/node/pull/4218) - enable NoAssetCall from Bitcoin chain
* [3834](https://github.com/zeta-chain/node/pull/3734) - refund a portion of remaining unused tokens to user
* [4486](https://github.com/zeta-chain/node/pull/4486) - add a flag to toggle V2ZETA flows on and off

### Refactor

Expand Down
7 changes: 7 additions & 0 deletions cmd/zetae2e/config/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,13 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
}
}

if c := conf.Contracts.ZEVM.TestDappAddr; c != "" {
r.ZevmTestDAppAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid ZevmTestDappAddr: %w", err)
}
}

if c := conf.Contracts.EVM.TestDAppV2Addr; c != "" {
r.TestDAppV2EVMAddr, err = c.AsEVMAddress()
if err != nil {
Expand Down
7 changes: 5 additions & 2 deletions cmd/zetae2e/local/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ func adminTestRoutine(
adminRunner.WaitForTxReceiptOnEVM(txERC20Send)

// depositing the necessary tokens on ZetaChain to the deployer account
txZetaDeposit := adminRunner.DepositZETAToDeployer()
// only deposit ZETA if V2 ZETA flows are enabled (gateway deposits don't work otherwise)
if adminRunner.IsV2ZETAEnabled() {
txZetaDeposit := adminRunner.DepositZETAToDeployer()
adminRunner.WaitForMinedCCTX(txZetaDeposit.Hash())
}
txEtherDeposit := adminRunner.DepositEtherToDeployer()
txERC20Deposit := adminRunner.DepositERC20ToDeployer()
adminRunner.WaitForMinedCCTX(txZetaDeposit.Hash())
adminRunner.WaitForMinedCCTX(txEtherDeposit)
adminRunner.WaitForMinedCCTX(txERC20Deposit)

Expand Down
7 changes: 7 additions & 0 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const (
flagTestStaking = "test-staking"
flagTestConnectorMigration = "test-connector-migration"
flagAccountConfig = "account-config" // Use this flag to override the account data in base config file
flagV2ZETAFlows = "v2-zeta-flows"
)

var (
Expand Down Expand Up @@ -109,6 +110,7 @@ func NewLocalCmd() *cobra.Command {
cmd.Flags().Bool(flagTestConnectorMigration, false, "set to true to run v2 connector migration tests")
cmd.Flags().
String(flagAccountConfig, "", "path to the account config file to override the accounts in the base config file")
cmd.Flags().Bool(flagV2ZETAFlows, false, "set to true to enable V2 ZETA gateway flows")

cmd.AddCommand(NewGetZetaclientBootstrap())

Expand Down Expand Up @@ -148,6 +150,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
testFilterStr = must(cmd.Flags().GetString(flagTestFilter))
testStaking = must(cmd.Flags().GetBool(flagTestStaking))
testConnectorMigration = must(cmd.Flags().GetBool(flagTestConnectorMigration))
v2ZETAFlows = must(cmd.Flags().GetBool(flagV2ZETAFlows))

testStress = testEthStress || testSolanaStress || testSuiStress
shouldSetupSolana = setupSolana || testSolana || testStress
Expand Down Expand Up @@ -260,6 +263,10 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
}))
}

if v2ZETAFlows {
noError(deployerRunner.EnableV2ZETAFlows())
}

// setting up the networks
if !skipSetup {
logger.Print("⚙️ setting up networks")
Expand Down
4 changes: 4 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55194,6 +55194,8 @@ definitions:
type: boolean
gasPriceIncreaseFlags:
$ref: '#/definitions/zetachain.zetacore.observer.GasPriceIncreaseFlags'
isV2ZetaEnabled:
type: boolean
zetachain.zetacore.observer.GasPriceIncreaseFlags:
type: object
properties:
Expand Down Expand Up @@ -55274,6 +55276,8 @@ definitions:
type: object
zetachain.zetacore.observer.MsgUpdateOperationalFlagsResponse:
type: object
zetachain.zetacore.observer.MsgUpdateV2ZetaFlowsResponse:
type: object
zetachain.zetacore.observer.MsgVoteBlameResponse:
type: object
zetachain.zetacore.observer.MsgVoteBlockHeaderResponse:
Expand Down
11 changes: 11 additions & 0 deletions docs/spec/generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -982,3 +982,14 @@ message MsgUpdateOperationalChainParams {
}
```

#### MsgUpdateV2ZetaFlows

UpdateV2ZetaFlows updates the V2 ZETA gateway flows flag.

```proto
message MsgUpdateV2ZetaFlows {
string creator = 1;
bool isV2ZetaEnabled = 2;
}
```

2 changes: 0 additions & 2 deletions e2e/e2etests/legacy/test_zeta_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,4 @@ func TestZetaDeposit(r *runner.E2ERunner, args []string) {
// wait for the cctx to be mined
cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, hash.Hex(), r.CctxClient, r.Logger, r.CctxTimeout)
r.Logger.CCTX(*cctx, "deposit")

r.Logger.Print("Zeta deposit cctx: %s", cctx.Index)
}
15 changes: 15 additions & 0 deletions e2e/e2etests/test_update_bytecode_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ import (

// TestUpdateBytecodeConnector tests updating the bytecode of a connector and interact with it
func TestUpdateBytecodeConnector(r *runner.E2ERunner, _ []string) {
// Skip if V2 ZETA flows are disabled.
//
// This test requires ZETA withdrawals through the GatewayZEVM contract, which only works
// when V2 ZETA flows are enabled (IsV2ZetaEnabled flag in crosschain flags).
//
// - The chain params contain a ConnectorContractAddress that observers watch for ZetaSent events
// - When testLegacy=true: LegacySetupEVM sets ConnectorContractAddress to the legacy connector (ConnectorEthAddr) V1
// - When testLegacy=false: UpdateEVMChainParams sets ConnectorContractAddress to the V2 connector (ConnectorNativeAddr) V2
// Admin tests do not use the flag, therefore, are using the ConnectorNative only

if !r.IsV2ZETAEnabled() {
r.Logger.Print("⚠️ skipping TestUpdateBytecodeConnector: V2 ZETA flows are disabled")
return
}

// Can withdraw 10ZETA
amount := big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(10))
evmChainID, err := r.EVMClient.ChainID(r.Ctx)
Expand Down
21 changes: 13 additions & 8 deletions e2e/e2etests/test_zeta_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,24 @@ func TestZetaDeposit(r *runner.E2ERunner, args []string) {
amount := utils.ParseBigInt(r, args[0])
receiverAddress := r.EVMAddress()

oldBalance, err := r.ZEVMClient.BalanceAt(r.Ctx, receiverAddress, nil)
require.NoError(r, err)

r.ApproveZetaOnEVM(r.GatewayEVMAddr)
// perform the deposit
tx := r.ZETADeposit(receiverAddress, amount, gatewayevm.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, "zeta_deposit")
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined)

newBalance, err := r.ZEVMClient.BalanceAt(r.Ctx, receiverAddress, nil)
require.NoError(r, err)
require.Equal(r, new(big.Int).Add(oldBalance, amount), newBalance)
if r.IsV2ZETAEnabled() {
// V2 ZETA flows enabled: deposit should succeed
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined)
oldBalance, err := r.ZEVMClient.BalanceAt(r.Ctx, receiverAddress, nil)
require.NoError(r, err)
newBalance, err := r.ZEVMClient.BalanceAt(r.Ctx, receiverAddress, nil)
require.NoError(r, err)
require.True(r, newBalance.Cmp(oldBalance) >= 0)
} else {
// V2 ZETA flows disabled: deposit should be aborted
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_Aborted)
require.Equal(r, cctx.CctxStatus.StatusMessage, crosschaintypes.ErrZetaThroughGateway.Error())
}
}
24 changes: 16 additions & 8 deletions e2e/e2etests/test_zeta_deposit_and_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@ func TestZetaDepositAndCall(r *runner.E2ERunner, args []string) {
// 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, "zeta_deposit_and_call")
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined)

// check the payload was received on the contract
r.AssertTestDAppZEVMCalled(true, payload, sender, amount)

// check the balance was updated
newBalance, err := r.ZEVMClient.BalanceAt(r.Ctx, receiverAddress, nil)
require.NoError(r, err)
require.Equal(r, new(big.Int).Add(oldBalance, amount), newBalance)
if r.IsV2ZETAEnabled() {
// V2 ZETA flows enabled: deposit and call should succeed
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined)

// check the payload was received on the contract
r.AssertTestDAppZEVMCalled(true, payload, sender, amount)

// check the balance was updated
newBalance, err := r.ZEVMClient.BalanceAt(r.Ctx, receiverAddress, nil)
require.NoError(r, err)
require.Equal(r, new(big.Int).Add(oldBalance, amount), newBalance)
} else {
// V2 ZETA flows disabled: deposit should be aborted
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_Aborted)
require.Equal(r, cctx.CctxStatus.StatusMessage, crosschaintypes.ErrZetaThroughGateway.Error())
}
}
28 changes: 18 additions & 10 deletions e2e/e2etests/test_zeta_deposit_and_call_no_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,23 @@ func TestZetaDepositAndCallNoMessage(r *runner.E2ERunner, args []string) {
// 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, "zeta_deposit_and_call_no_message")
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined)

// check the payload was received on the contract
messageIndex, err := r.TestDAppV2ZEVM.GetNoMessageIndex(&bind.CallOpts{}, r.EVMAddress())
require.NoError(r, err)
r.AssertTestDAppZEVMCalled(true, messageIndex, r.EVMAddress().Bytes(), amount)

// check the balance was updated
newBalance, err := r.ZEVMClient.BalanceAt(r.Ctx, receiverAddress, nil)
require.NoError(r, err)
require.Equal(r, new(big.Int).Add(oldBalance, amount), newBalance)
if r.IsV2ZETAEnabled() {
// V2 ZETA flows enabled: deposit and call should succeed
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined)

// check the payload was received on the contract
messageIndex, err := r.TestDAppV2ZEVM.GetNoMessageIndex(&bind.CallOpts{}, r.EVMAddress())
require.NoError(r, err)
r.AssertTestDAppZEVMCalled(true, messageIndex, r.EVMAddress().Bytes(), amount)

// check the balance was updated
newBalance, err := r.ZEVMClient.BalanceAt(r.Ctx, receiverAddress, nil)
require.NoError(r, err)
require.Equal(r, new(big.Int).Add(oldBalance, amount), newBalance)
} else {
// V2 ZETA flows disabled: deposit should be aborted
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_Aborted)
require.Equal(r, cctx.CctxStatus.StatusMessage, crosschaintypes.ErrZetaThroughGateway.Error())
}
}
24 changes: 16 additions & 8 deletions e2e/e2etests/test_zeta_deposit_and_call_revert.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,21 @@ func TestZetaDepositAndCallRevert(r *runner.E2ERunner, args []string) {
OnRevertGasLimit: big.NewInt(0),
})

// wait for the cctx to be reverted
// 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, "zeta_deposit_and_call")
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_Reverted)

// check the balance is more than 0
balance, err = r.ZetaEth.BalanceOf(&bind.CallOpts{}, revertAddress)
require.NoError(r, err)
require.True(r, balance.Cmp(big.NewInt(0)) > 0)
r.Logger.CCTX(*cctx, "zeta_deposit_and_call_revert")

if r.IsV2ZETAEnabled() {
// V2 ZETA flows enabled: deposit and call should revert
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_Reverted)

// check the balance is more than 0
balance, err = r.ZetaEth.BalanceOf(&bind.CallOpts{}, revertAddress)
require.NoError(r, err)
require.True(r, balance.Cmp(big.NewInt(0)) > 0)
} else {
// V2 ZETA flows disabled: deposit should be aborted
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_Aborted)
require.Equal(r, cctx.CctxStatus.StatusMessage, crosschaintypes.ErrZetaThroughGateway.Error())
}
}
36 changes: 22 additions & 14 deletions e2e/e2etests/test_zeta_deposit_and_call_revert_with_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,27 @@ func TestZetaDepositAndCallRevertWithCall(r *runner.E2ERunner, args []string) {
OnRevertGasLimit: big.NewInt(200000),
})

// wait for the cctx to be reverted
// 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, "zeta_deposit_and_call")
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_Reverted)

// check the payload was received on the contract
r.AssertTestDAppEVMCalled(true, payload, big.NewInt(0))

// check expected sender was used
senderForMsg, err := r.TestDAppV2EVM.SenderWithMessage(
&bind.CallOpts{},
[]byte(payload),
)
require.NoError(r, err)
require.Equal(r, r.EVMAuth.From, senderForMsg)
r.Logger.CCTX(*cctx, "zeta_deposit_and_call_revert_with_call")

if r.IsV2ZETAEnabled() {
// V2 ZETA flows enabled: deposit and call should revert
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_Reverted)

// check the payload was received on the contract
r.AssertTestDAppEVMCalled(true, payload, big.NewInt(0))

// check expected sender was used
senderForMsg, err := r.TestDAppV2EVM.SenderWithMessage(
&bind.CallOpts{},
[]byte(payload),
)
require.NoError(r, err)
require.Equal(r, r.EVMAuth.From, senderForMsg)
} else {
// V2 ZETA flows disabled: deposit should be aborted
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_Aborted)
require.Equal(r, cctx.CctxStatus.StatusMessage, crosschaintypes.ErrZetaThroughGateway.Error())
}
}
39 changes: 23 additions & 16 deletions e2e/e2etests/test_zeta_deposit_revert_and_abort.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,32 @@ func TestZetaDepositRevertAndAbort(r *runner.E2ERunner, args []string) {
},
)

// wait for the cctx to be reverted
// 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, "zeta_deposit_and_call")
r.Logger.CCTX(*cctx, "zeta_deposit_revert_and_abort")
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_Aborted)

// check onAbort was called
aborted, err := testAbort.IsAborted(&bind.CallOpts{})
require.NoError(r, err)
require.True(r, aborted)
if r.IsV2ZETAEnabled() {
// V2 ZETA flows enabled: deposit should fail, revert should fail, then abort with onAbort called

// Asset is empty as ZETA is the native gas token on ZEVM
emptyAddress := ethcommon.Address{}
// check abort context was passed
abortContext, err := testAbort.GetAbortedWithMessage(&bind.CallOpts{}, "revert")
require.NoError(r, err)
require.EqualValues(r, emptyAddress.Hex(), abortContext.Asset.Hex())
// check onAbort was called
aborted, err := testAbort.IsAborted(&bind.CallOpts{})
require.NoError(r, err)
require.True(r, aborted)

// check abort contract received the tokens
balance, err := r.ZEVMClient.BalanceAt(r.Ctx, testAbortAddr, nil)
require.NoError(r, err)
require.True(r, balance.Uint64() > 0)
// Asset is empty as ZETA is the native gas token on ZEVM
emptyAddress := ethcommon.Address{}
// check abort context was passed
abortContext, err := testAbort.GetAbortedWithMessage(&bind.CallOpts{}, "revert")
require.NoError(r, err)
require.EqualValues(r, emptyAddress.Hex(), abortContext.Asset.Hex())

// check abort contract received the tokens
balance, err := r.ZEVMClient.BalanceAt(r.Ctx, testAbortAddr, nil)
require.NoError(r, err)
require.True(r, balance.Uint64() > 0)
} else {
// V2 ZETA flows disabled: deposit should be aborted with ErrZetaThroughGateway
require.Equal(r, cctx.CctxStatus.StatusMessage, crosschaintypes.ErrZetaThroughGateway.Error())
}
}
13 changes: 9 additions & 4 deletions e2e/e2etests/test_zeta_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ func TestZetaWithdraw(r *runner.E2ERunner, args []string) {
// perform the withdraw
tx := r.ZETAWithdraw(r.EVMAddress(), amount, evmChainID, 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")
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined)
if r.IsV2ZETAEnabled() {
// V2 ZETA flows enabled: withdraw should succeed
cctx := utils.WaitCctxMinedByInboundHash(r.Ctx, tx.Hash().Hex(), r.CctxClient, r.Logger, r.CctxTimeout)
r.Logger.CCTX(*cctx, "zeta_withdraw")
utils.RequireCCTXStatus(r, cctx, crosschaintypes.CctxStatus_OutboundMined)
} else {
// V2 ZETA flows disabled: tx should revert on GatewayZEVM, no CCTX created
utils.EnsureNoCctxMinedByInboundHash(r.Ctx, tx.Hash().Hex(), r.CctxClient)
}
}
Loading
Loading