-
Notifications
You must be signed in to change notification settings - Fork 173
test: add sui gateway upgrade E2E test #3866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d48cb78
add sui gateway upgrade e2e test
ws4charlie c9ec5a4
add changelog entry
ws4charlie 3167f61
Merge branch 'develop' into sui-e2e-package-upgrade
ws4charlie c128bb3
rename protocol contracts sui folder to indicate its purpose
ws4charlie ae3d2c7
add private key length check in conversion
ws4charlie 3f18678
group gateway upgrade test in a sub function
ws4charlie 5106a77
improve naming and add back deleted e2e log print
ws4charlie 123e72b
fix gosec errors
ws4charlie 77306ac
move sui client.yaml copying to Dockerfile; improve naming
ws4charlie f7ffadc
output sui gateway upgrade response in JSON format to extract package…
ws4charlie 195d3c6
minimize the number of files for sui upgrade test
ws4charlie 11dad7b
fix gosec G306 error
ws4charlie 87f12f2
uncomment previously commented tests during development
ws4charlie 30b8b49
add more description to README file to explain the sui upgrade packag…
ws4charlie 1378884
Merge branch 'develop' of https://github.com/zeta-chain/node into sui…
ws4charlie 77a0efb
Merge branch 'develop' into sui-e2e-package-upgrade
ws4charlie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
38
e2e/contracts/sui/protocol-contracts-sui-upgrade/Move.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
16
e2e/contracts/sui/protocol-contracts-sui-upgrade/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| ``` |
46 changes: 46 additions & 0 deletions
46
e2e/contracts/sui/protocol-contracts-sui-upgrade/sources/evm.move
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.