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
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

### Features

### Tests

### Fixes

* [4414](https://github.com/zeta-chain/node/pull/4414) - fix example package deployment by removing gateway object reference

### Breaking Changes

* 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,
Expand Down
7 changes: 4 additions & 3 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,10 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
e2etests.TestSuiTokenWithdrawAndCallRevertWithCallName,
e2etests.TestSuiWithdrawRestrictedName,
}
if !deployerRunner.IsRunningUpgrade() {
suiTests = append(suiTests, suiBreakingTestsV35Upgrade...)
}
// run withdrawAndCall tests, because upgrade is already done in setup_sui.go
//if !deployerRunner.IsRunningUpgrade() {
suiTests = append(suiTests, suiBreakingTestsV35Upgrade...)
//}

eg.Go(suiTestRoutine(conf, deployerRunner, verbose, suiTests...))
}
Expand Down
1 change: 1 addition & 0 deletions contrib/localnet/orchestrator/Dockerfile.fastbuild
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ 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/example /work/example
COPY e2e/contracts/sui/protocol-contracts-sui /work/protocol-contracts-sui
COPY e2e/contracts/sui/protocol-contracts-sui-upgrade /work/protocol-contracts-sui-upgrade
COPY cmd/zetae2e/config/localnet.yml /work/config.yml

Expand Down
2 changes: 0 additions & 2 deletions e2e/contracts/sui/example/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
# authors = ["..."] # e.g., ["Joe Smith ([email protected])", "John Snow ([email protected])"]

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.51.5" }
gateway = { local = "../protocol-contracts-sui-upgrade"}

# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`.
Expand All @@ -21,7 +20,6 @@ gateway = { local = "../protocol-contracts-sui-upgrade"}

[addresses]
example = "0x0"
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.
Expand Down
11 changes: 2 additions & 9 deletions e2e/contracts/sui/example/sources/example.move
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::ascii;
use std::ascii::String;
use sui::address::from_bytes;
use sui::coin::Coin;
use gateway::gateway::{Gateway, MessageContext, active_message_context, message_context_sender, message_context_target};
use gateway::gateway::{MessageContext, message_context_sender, message_context_target};

// === Errors ===

Expand All @@ -16,9 +16,7 @@ const EUnauthorizedSender: u64 = 2;
// zetaclient should be able to differentiate this error from real withdraw_impl nonce mismatch
const ENonceMismatch: u64 = 3;

const EInactiveMessageContext: u64 = 4;

const EPackageMismatch: u64 = 5;
const EPackageMismatch: u64 = 4;

// stub for shared objects
public struct GlobalConfig has key {
Expand Down Expand Up @@ -61,7 +59,6 @@ fun init(ctx: &mut TxContext) {
}

public entry fun on_call<SOURCE_COIN>(
gateway: &Gateway,
message_context: &MessageContext,
in_coins: Coin<SOURCE_COIN>,
cetus_config: &mut GlobalConfig,
Expand All @@ -79,10 +76,6 @@ public entry fun on_call<SOURCE_COIN>(
assert!(false, ENonceMismatch);
};

// check if the message context is active
let active_message_context = active_message_context(gateway);
assert!(active_message_context == object::id(message_context), EInactiveMessageContext);

// decode the sender, target package, and receiver from the payload
let (authenticated_sender, target_package, receiver) = decode_sender_target_and_receiver(data);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[package]
name = "gateway"
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
published-at = "ORIGINAL-PACKAGE-ID"
published-at = "0x0"
# license = "" # e.g., "MIT", "GPL", "Apache 2.0"
# authors = ["..."] # e.g., ["Joe Smith ([email protected])", "John Snow ([email protected])"]

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

# For remote import, use the `{ git = "...", subdir = "...", rev = "..." }`.
# Revision can be a branch, a tag, and a commit hash.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@ fun init(ctx: &mut TxContext) {

// === Entrypoints ===

// upgraded returns true to indicate gateway has been upgraded
entry fun upgraded(): bool {
true
}

// increase_nonce increases the nonce of the gateway
// it is used when a failed outbound needs to be reported to ZetaChain
// it is sent by the tss and therefore requires the withdraw cap
Expand Down
8 changes: 8 additions & 0 deletions e2e/contracts/sui/protocol-contracts-sui/.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
36 changes: 36 additions & 0 deletions e2e/contracts/sui/protocol-contracts-sui/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[package]
name = "gateway"
edition = "2024.beta" # edition = "legacy" to use legacy (pre-2024) Move
# license = "" # e.g., "MIT", "GPL", "Apache 2.0"
# authors = ["..."] # e.g., ["Joe Smith ([email protected])", "John Snow ([email protected])"]

[dependencies]

# 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"

46 changes: 46 additions & 0 deletions e2e/contracts/sui/protocol-contracts-sui/sources/evm.move
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
Loading