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
4 changes: 4 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
core.setOutput('STATEFUL_DATA_TESTS', labels.includes('STATEFUL_DATA_TESTS'));
core.setOutput('TSS_MIGRATION_TESTS', labels.includes('TSS_MIGRATION_TESTS'));
core.setOutput('SOLANA_TESTS', labels.includes('SOLANA_TESTS'));
core.setOutput('V2_TESTS', labels.includes('V2_TESTS')); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
} else if (context.eventName === 'merge_group') {
core.setOutput('DEFAULT_TESTS', true);
} else if (context.eventName === 'push' && context.ref === 'refs/heads/develop') {
Expand Down Expand Up @@ -160,6 +161,9 @@ jobs:
- make-target: "start-solana-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.SOLANA_TESTS == 'true' }}
- make-target: "start-v2-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.V2_TESTS == 'true' }}
name: ${{ matrix.make-target }}
uses: ./.github/workflows/reusable-e2e.yml
with:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ start-solana-test: zetanode solana

start-v2-test: zetanode
@echo "--> Starting e2e smart contracts v2 test"
export E2E_ARGS="--test-v2" && \
export E2E_ARGS="--skip-regular --test-v2" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) -f docker-compose.yml up -d

###############################################################################
Expand Down
5 changes: 5 additions & 0 deletions cmd/zetae2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,10 @@ func ExportContractsFromRunner(r *runner.E2ERunner, conf config.Config) config.C
conf.Contracts.ZEVM.ContextAppAddr = config.DoubleQuotedString(r.ContextAppAddr.Hex())
conf.Contracts.ZEVM.TestDappAddr = config.DoubleQuotedString(r.ZevmTestDAppAddr.Hex())

// v2
conf.Contracts.EVM.Gateway = config.DoubleQuotedString(r.GatewayEVMAddr.Hex())
conf.Contracts.EVM.ERC20CustodyNew = config.DoubleQuotedString(r.ERC20CustodyV2Addr.Hex())
conf.Contracts.ZEVM.Gateway = config.DoubleQuotedString(r.GatewayZEVMAddr.Hex())

return conf
}
4 changes: 3 additions & 1 deletion cmd/zetae2e/config/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ contracts:
connector_zevm: "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67"
wzeta: "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf"
test_dapp: "0xA8D5060feb6B456e886F023709A2795373691E63"
gateway: "0xa825eAa55b497AF892faca73a3797046C10B7c23"
evm:
zeta_eth: "0x733aB8b06DDDEf27Eaa72294B0d7c9cEF7f12db9"
connector_eth: "0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca"
custody: "0xff3135df4F2775f4091b81f4c7B6359CfA07862a"
erc20: "0xbD1e64A22B9F92D9Ce81aA9B4b0fFacd80215564"
test_dapp: "0xBFF76e77D56B3C1202107f059425D56f0AEF87Ed"
test_dapp: "0xBFF76e77D56B3C1202107f059425D56f0AEF87Ed"
gateway: "0xF0deebCB0E9C829519C4baa794c5445171973826"
18 changes: 9 additions & 9 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,15 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
if testV2 {
eg.Go(v2TestRoutine(conf, deployerRunner, verbose,
e2etests.TestV2ETHDepositName,
e2etests.TestV2ETHDepositAndCallName,
e2etests.TestV2ETHWithdrawName,
e2etests.TestV2ETHWithdrawAndCallName,
e2etests.TestV2ERC20DepositName,
e2etests.TestV2ERC20DepositAndCallName,
e2etests.TestV2ERC20WithdrawName,
e2etests.TestV2ERC20WithdrawAndCallName,
e2etests.TestV2ZEVMToEVMCallName,
e2etests.TestV2EVMToZEVMCallName,
//e2etests.TestV2ETHDepositAndCallName,
//e2etests.TestV2ETHWithdrawName,
//e2etests.TestV2ETHWithdrawAndCallName,
//e2etests.TestV2ERC20DepositName,
//e2etests.TestV2ERC20DepositAndCallName,
//e2etests.TestV2ERC20WithdrawName,
//e2etests.TestV2ERC20WithdrawAndCallName,
//e2etests.TestV2ZEVMToEVMCallName,
//e2etests.TestV2EVMToZEVMCallName,
))
}

Expand Down
8 changes: 0 additions & 8 deletions cmd/zetae2e/local/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ func v2TestRoutine(
txERC20Send := deployerRunner.SendERC20OnEvm(account.EVMAddress(), 10)
v2Runner.WaitForTxReceiptOnEvm(txERC20Send)

// depositing the necessary tokens on ZetaChain
// TODO: update with v2 deposits
// https://github.com/zeta-chain/node/issues/2554
txEtherDeposit := v2Runner.DepositEther(false)
txERC20Deposit := v2Runner.DepositERC20()
v2Runner.WaitForMinedCCTX(txEtherDeposit)
v2Runner.WaitForMinedCCTX(txERC20Deposit)

// run erc20 test
testsToRun, err := v2Runner.GetE2ETestsToRunByName(
e2etests.AllE2ETests,
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/zetacored/zetacored_tx_crosschain_vote-inbound.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Broadcast message to vote an inbound

```
zetacored tx crosschain vote-inbound [sender] [senderChainID] [txOrigin] [receiver] [receiverChainID] [amount] [message] [inboundHash] [inBlockHeight] [coinType] [asset] [eventIndex] [flags]
zetacored tx crosschain vote-inbound [sender] [senderChainID] [txOrigin] [receiver] [receiverChainID] [amount] [message] [inboundHash] [inBlockHeight] [coinType] [asset] [eventIndex] [protocolContractVersion] [flags]
```

### Options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Broadcast message UpdateGatewayContract to update the gateway contract address

```
zetacored tx fungible update-gateway-contract [contract-address] [flags]
zetacored tx fungible update-gateway-contract [contract-address] [flags]
```

### Options
Expand Down
11 changes: 11 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57121,6 +57121,8 @@ definitions:
items:
type: object
$ref: '#/definitions/crosschainOutboundParams'
protocol_contract_version:
$ref: '#/definitions/crosschainProtocolContractVersion'
crosschainGasPrice:
type: object
properties:
Expand Down Expand Up @@ -57315,6 +57317,15 @@ definitions:
items:
type: object
$ref: '#/definitions/crosschainTxHash'
crosschainProtocolContractVersion:
type: string
enum:
- V1
- V2
default: V1
title: |-
ProtocolContractVersion represents the version of the protocol contract used
for cctx workflow
crosschainQueryAllCctxResponse:
type: object
properties:
Expand Down
1 change: 1 addition & 0 deletions docs/spec/crosschain/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ message MsgVoteInbound {
string tx_origin = 13;
string asset = 14;
uint64 event_index = 15;
ProtocolContractVersion protocol_contract_version = 16;
}
```

Expand Down
2 changes: 1 addition & 1 deletion e2e/e2etests/e2etests.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ var AllE2ETests = []runner.E2ETest{
[]runner.ArgDefinition{
{Description: "amount in wei", DefaultValue: "10000000000000000"},
},
TestV2ERC20Deposit,
TestV2ETHDeposit,
),
runner.NewE2ETest(
TestV2ETHDepositAndCallName,
Expand Down
2 changes: 2 additions & 0 deletions e2e/e2etests/test_v2_eth_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ func TestV2ETHDeposit(r *runner.E2ERunner, args []string) {
amount, ok := big.NewInt(0).SetString(args[0], 10)
require.True(r, ok, "Invalid amount specified for TestV2ETHDeposit")

r.Logger.Info("starting v2 eth deposit test")

// perform the deposit
tx := r.V2ETHDeposit(r.EVMAddress(), amount)

Expand Down
27 changes: 27 additions & 0 deletions e2e/runner/logger.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package runner

import (
"encoding/hex"
"fmt"
"sync"

ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/fatih/color"
"github.com/zeta-chain/protocol-contracts/v1/pkg/contracts/zevm/zrc20.sol"
"github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayevm.sol"

crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
)
Expand Down Expand Up @@ -199,6 +201,31 @@ func (l *Logger) ZRC20Withdrawal(
}
}

type depositParser interface {
ParseDeposit(ethtypes.Log) (*gatewayevm.GatewayEVMDeposit, error)
}

// GatewayDeposit prints a GatewayDeposit event
func (l *Logger) GatewayDeposit(
contract depositParser,
receipt ethtypes.Receipt,
name string,
) {
for _, log := range receipt.Logs {
event, err := contract.ParseDeposit(*log)
if err != nil {
continue
}

l.Info(" Gateway Deposit: %s", name)
l.Info(" Sender: %s", event.Sender.Hex())
l.Info(" Receiver: %s", event.Receiver.Hex())
l.Info(" Amount: %s", event.Amount.String())
l.Info(" Asset: %s", event.Asset.Hex())
l.Info(" Payload: %s", hex.EncodeToString(event.Payload))
}
}

func (l *Logger) getPrefixWithPadding() string {
// add padding to prefix
prefix := l.prefix
Expand Down
10 changes: 10 additions & 0 deletions e2e/runner/v2_evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
ethcommon "github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/require"

"github.com/zeta-chain/zetacore/e2e/utils"
)

// V2ETHDeposit calls Deposit of Gateway with gas token on EVM
Expand All @@ -20,6 +22,14 @@ func (r *E2ERunner) V2ETHDeposit(receiver ethcommon.Address, amount *big.Int) *e
tx, err := r.GatewayEVM.Deposit(r.EVMAuth, receiver)
require.NoError(r, err)

r.Logger.EVMTransaction(*tx, "eth_deposit")

receipt := utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout)
r.requireTxSuccessful(receipt, "eth_deposit failed")

r.Logger.EVMReceipt(*receipt, "eth_deposit")
r.Logger.GatewayDeposit(r.GatewayEVM, *receipt, "eth_deposit")

return tx
}

Expand Down
4 changes: 4 additions & 0 deletions e2e/runner/v2_setup_zeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@ func (r *E2ERunner) SetZEVMContractsV2() {
require.NoError(r, err)
r.Logger.Info("Gateway ZEVM contract address: %s, tx hash: %s", gatewayZEVMAddr.Hex(), txGateway.Hash().Hex())

// Set the gateway address in the protocol
err = r.ZetaTxServer.UpdateGatewayAddress(utils.AdminPolicyName, r.GatewayZEVMAddr.Hex())
require.NoError(r, err)

ensureTxReceipt(txProxy, "Gateway proxy deployment failed")
}
9 changes: 4 additions & 5 deletions e2e/txserver/zeta_tx_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,11 @@ func (zts ZetaTxServer) UpdateGatewayAddress(account, gatewayAddr string) error
return err
}

//_, err = zts.BroadcastTx(account, fungibletypes.Neew(
// addr.String(),
// gatewayAddr,
//))
_, err = zts.BroadcastTx(account, fungibletypes.NewMsgUpdateGatewayContract(
addr.String(),
gatewayAddr,
))
return err

}

// DeploySystemContractsAndZRC20 deploys the system contracts and ZRC20 contracts
Expand Down
9 changes: 9 additions & 0 deletions proto/zetachain/zetacore/crosschain/cross_chain_tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ message Status {
bool isAbortRefunded = 4;
}

// ProtocolContractVersion represents the version of the protocol contract used
// for cctx workflow
enum ProtocolContractVersion {
option (gogoproto.goproto_enum_stringer) = true;
V1 = 0;
V2 = 1;
}

message CrossChainTx {
string creator = 1;
string index = 2;
Expand All @@ -103,4 +111,5 @@ message CrossChainTx {
Status cctx_status = 8;
InboundParams inbound_params = 9;
repeated OutboundParams outbound_params = 10;
ProtocolContractVersion protocol_contract_version = 11;
}
4 changes: 4 additions & 0 deletions proto/zetachain/zetacore/crosschain/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "zetachain/zetacore/pkg/chains/chains.proto";
import "zetachain/zetacore/pkg/coin/coin.proto";
import "zetachain/zetacore/pkg/proofs/proofs.proto";
import "zetachain/zetacore/crosschain/rate_limiter_flags.proto";
import "zetachain/zetacore/crosschain/cross_chain_tx.proto";

option go_package = "github.com/zeta-chain/zetacore/x/crosschain/types";

Expand Down Expand Up @@ -162,6 +163,9 @@ message MsgVoteInbound {
string asset = 14;
// event index of the sent asset in the observed tx
uint64 event_index = 15;

// protocol contract version to use for the cctx workflow
ProtocolContractVersion protocol_contract_version = 16;
}

message MsgVoteInboundResponse {}
Expand Down
1 change: 1 addition & 0 deletions testutil/keeper/crosschain.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ func MockRevertForHandleEVMDeposit(
mock.Anything,
coin.CoinType_ERC20,
mock.Anything,
mock.Anything,
).Return(&evmtypes.MsgEthereumTxResponse{VmError: "reverted"}, false, errDeposit)
}

Expand Down
24 changes: 13 additions & 11 deletions testutil/keeper/mocks/crosschain/fungible.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading