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
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
* [3692](https://github.com/zeta-chain/node/pull/3692) - e2e staking test for `MsgUndelegate` tx, to test observer staking hooks
* [3831](https://github.com/zeta-chain/node/pull/3831) - e2e tests for sui fungible token withdraw and call
* [3582](https://github.com/zeta-chain/node/pull/3852) - add solana to tss migration e2e tests
* [3866](https://github.com/zeta-chain/node/pull/3866) - add e2e test for upgrading sui gateway package

### Refactor

Expand Down
1 change: 1 addition & 0 deletions cmd/zetae2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func ExportContractsFromRunner(r *runner.E2ERunner, conf config.Config) config.C
conf.Contracts.Sui.GatewayPackageID = config.DoubleQuotedString(r.SuiGateway.PackageID())
conf.Contracts.Sui.GatewayObjectID = config.DoubleQuotedString(r.SuiGateway.ObjectID())
}
conf.Contracts.Sui.GatewayUpgradeCap = config.DoubleQuotedString(r.SuiGatewayUpgradeCap)

conf.Contracts.Sui.FungibleTokenCoinType = config.DoubleQuotedString(r.SuiTokenCoinType)
conf.Contracts.Sui.FungibleTokenTreasuryCap = config.DoubleQuotedString(r.SuiTokenTreasuryCap)
Expand Down
3 changes: 3 additions & 0 deletions cmd/zetae2e/config/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
if suiPackageID != "" && suiGatewayID != "" {
r.SuiGateway = sui.NewGateway(suiPackageID.String(), suiGatewayID.String())
}
if c := conf.Contracts.Sui.GatewayUpgradeCap; c != "" {
r.SuiGatewayUpgradeCap = c.String()
}
if c := conf.Contracts.Sui.FungibleTokenCoinType; c != "" {
r.SuiTokenCoinType = c.String()
}
Expand Down
14 changes: 6 additions & 8 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/stretchr/testify/require"

zetae2econfig "github.com/zeta-chain/node/cmd/zetae2e/config"
"github.com/zeta-chain/node/e2e/config"
Expand Down Expand Up @@ -611,6 +610,12 @@ func localE2ETest(cmd *cobra.Command, _ []string) {

noError(deployerRunner.WithdrawEmissions())

// Run gateway upgrade tests for external chains
deployerRunner.RunGatewayUpgradeTestsExternalChains(conf, runner.UpgradeGatewayOptions{
TestSolana: testSolana,
TestSui: testSui,
})

// 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()
Expand All @@ -625,13 +630,6 @@ func localE2ETest(cmd *cobra.Command, _ []string) {

logger.Print("✅ e2e tests completed in %s", time.Since(testStartTime).String())

if testSolana {
require.True(
deployerRunner,
deployerRunner.VerifySolanaContractsUpgrade(conf.AdditionalAccounts.UserSolana.SolanaPrivateKey.String()),
)
}

if testTSSMigration {
TSSMigration(deployerRunner, logger, verbose, conf)
}
Expand Down
5 changes: 5 additions & 0 deletions contrib/localnet/orchestrator/Dockerfile.fastbuild
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@
# check=error=true
FROM ghcr.io/zeta-chain/ethereum-client-go:v1.10.26 AS geth
FROM ghcr.io/zeta-chain/solana-docker:1.18.15 AS solana
FROM ghcr.io/zeta-chain/sui-docker:mainnet-v1.41.1 AS sui
FROM zetanode:latest

COPY --from=geth /usr/local/bin/geth /usr/local/bin/
COPY --from=solana /usr/bin/solana /usr/local/bin/
COPY --from=sui /usr/local/bin/sui /usr/local/bin/

COPY contrib/localnet/orchestrator/start-zetae2e.sh /work/
COPY contrib/localnet/orchestrator/proposals_e2e_start/ /work/proposals_e2e_start/
COPY contrib/localnet/orchestrator/proposals_e2e_end/ /work/proposals_e2e_end/
COPY contrib/localnet/scripts/wait-for-ton.sh /work/
COPY contrib/localnet/sui/sui_client.yaml /root/.sui/sui_config/client.yaml
COPY e2e/contracts/sui/protocol-contracts-sui-upgrade /work/protocol-contracts-sui-upgrade
COPY cmd/zetae2e/config/localnet.yml /work/config.yml

RUN chmod +x /work/*.sh

WORKDIR /work
9 changes: 9 additions & 0 deletions contrib/localnet/sui/sui_client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
keystore:
File: /root/.sui/sui_config/sui.keystore
envs:
- alias: localnet
rpc: "http://sui:9000"
ws: ~
basic_auth: ~
active_env: localnet
6 changes: 4 additions & 2 deletions e2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ type SuiExample struct {

// Sui contains the addresses of predeployed contracts on the Sui chain
type Sui struct {
GatewayPackageID DoubleQuotedString `yaml:"gateway_package_id"`
GatewayObjectID DoubleQuotedString `yaml:"gateway_object_id"`
GatewayPackageID DoubleQuotedString `yaml:"gateway_package_id"`
GatewayObjectID DoubleQuotedString `yaml:"gateway_object_id"`
// GatewayUpgradeCap is the capability object used to upgrade the gateway
GatewayUpgradeCap DoubleQuotedString `yaml:"gateway_upgrade_cap"`
FungibleTokenCoinType DoubleQuotedString `yaml:"fungible_token_coin_type"`
FungibleTokenTreasuryCap DoubleQuotedString `yaml:"fungible_token_treasury_cap"`
Example SuiExample `yaml:"example"`
Expand Down
Binary file modified e2e/contracts/sui/gateway.mv
Binary file not shown.
8 changes: 8 additions & 0 deletions e2e/contracts/sui/protocol-contracts-sui-upgrade/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.idea
.vscode

build/
source/dependencies
Move.lock
*.key
.DS_Store
38 changes: 38 additions & 0 deletions e2e/contracts/sui/protocol-contracts-sui-upgrade/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "gateway"
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
published-at = "ORIGINAL-PACKAGE-ID"
# license = "" # e.g., "MIT", "GPL", "Apache 2.0"
# authors = ["..."] # e.g., ["Joe Smith (joesmith@noemail.com)", "John Snow (johnsnow@noemail.com)"]

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/testnet" }

# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`.
# Revision can be a branch, a tag, and a commit hash.
# MyRemotePackage = { git = "https://some.remote/host.git", subdir = "remote/path", rev = "main" }

# For local dependencies use `local = path`. Path is relative to the package root
# Local = { local = "../path/to" }

# To resolve a version conflict and force a specific version for dependency
# override use `override = true`
# Override = { local = "../conflicting/version", override = true }

[addresses]
gateway = "0x0"

# Named addresses will be accessible in Move as `@name`. They're also exported:
# for example, `std = "0x1"` is exported by the Standard Library.
# alice = "0xA11CE"

[dev-dependencies]
# The dev-dependencies section allows overriding dependencies for `--test` and
# `--dev` modes. You can introduce test-only dependencies here.
# Local = { local = "../path/to/dev-build" }

[dev-addresses]
# The dev-addresses section allows overwriting named addresses for the `--test`
# and `--dev` modes.
# alice = "0xB0B"

16 changes: 16 additions & 0 deletions e2e/contracts/sui/protocol-contracts-sui-upgrade/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Zetachain x Sui Gateway

This package is only used for gateway upgrade test.

The `sui client upgrade` command requires the presence of the whole `gateway` package for re-publishing,
so we have a minimized copy of sui gateway project in here to help the upgrading process.


The source code is copied from [protocol-contracts-sui](https://github.com/zeta-chain/protocol-contracts-sui) with one single additional function added:

```
// upgraded returns true to indicate gateway has been upgraded
entry fun upgraded(): bool {
true
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module gateway::evm;

use std::ascii::{String, into_bytes};

/// Check if a given string is a valid Ethereum address.
public fun is_valid_evm_address(addr: String): bool {
if (addr.length() != 42) {
return false
};

let mut addrBytes = addr.into_bytes();

// check prefix 0x, 0=48, x=120
if (addrBytes[0] != 48 || addrBytes[1] != 120) {
return false
};

// remove 0x prefix
addrBytes.remove(0);
addrBytes.remove(0);

// check if remaining characters are hex (0-9, a-f, A-F)
is_hex_vec(addrBytes)
}

/// Check that vector contains only hex chars (0-9, a-f, A-F).
fun is_hex_vec(input: vector<u8>): bool {
let mut i = 0;
let len = input.length();

while (i < len) {
let c = input[i];

let is_hex = (c >= 48 && c <= 57) || // '0' to '9'
(c >= 97 && c <= 102) || // 'a' to 'f'
(c >= 65 && c <= 70); // 'A' to 'F'

if (!is_hex) {
return false
};

i = i + 1;
};

true
}
Loading