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
5 changes: 5 additions & 0 deletions contract_manager/store/chains/IotaChains.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
mainnet: false
rpcUrl: https://api.testnet.iota.cafe/
type: IotaChain
- id: iota_mainnet
wormholeChainName: iota_sui_mainnet
mainnet: true
rpcUrl: https://api.mainnet.iota.cafe/
type: IotaChain
4 changes: 4 additions & 0 deletions contract_manager/store/contracts/IotaPriceFeedContracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
stateId: "0x68dda579251917b3db28e35c4df495c6e664ccc085ede867a9b773c8ebedc2c1"
wormholeStateId: "0x8bc490f69520a97ca1b3de864c96aa2265a0cf5d90f5f3f016b2eddf0cf2af2b"
type: IotaPriceFeedContract
- chain: iota_mainnet
stateId: "0x6bc33855c7675e006f55609f61eebb1c8a104d8973a698ee9efd3127c210b37f"
wormholeStateId: "0xd43b448afc9dd01deb18273ec39d8f27ddd4dd46b0922383874331771b70df73"
type: IotaPriceFeedContract
3 changes: 3 additions & 0 deletions contract_manager/store/contracts/IotaWormholeContracts.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- chain: iota_testnet
stateId: "0x8bc490f69520a97ca1b3de864c96aa2265a0cf5d90f5f3f016b2eddf0cf2af2b"
type: IotaWormholeContract
- chain: iota_mainnet
stateId: "0xd43b448afc9dd01deb18273ec39d8f27ddd4dd46b0922383874331771b70df73"
type: IotaWormholeContract
2 changes: 2 additions & 0 deletions governance/xc_admin/packages/xc_admin_common/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ export const RECEIVER_CHAINS = {
xion: 60081,
worldchain: 60082,
swellchain: 60083,
// empty chain id 60084
iota_sui_mainnet: 60085,

// Testnets as a separate chain ids (to use stable data sources and governance for them)
injective_testnet: 60013,
Expand Down
15 changes: 15 additions & 0 deletions target_chains/sui/contracts/Move.iota_mainnet.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "Pyth"
version = "0.0.2"
published-at = "0x7792c84e1f8683dac893126712f7cf3ba5fcc82450839f0a481215f60199769f"

[dependencies.Iota]
git = "https://github.com/iotaledger/iota.git"
subdir = "crates/iota-framework/packages/iota-framework"
rev = "751c23caf24efd071463b9ffd07eabcb15f44f31"

[dependencies.Wormhole]
local = "../vendor/wormhole_iota_mainnet/wormhole"

[addresses]
pyth = "0x7792c84e1f8683dac893126712f7cf3ba5fcc82450839f0a481215f60199769f"
2 changes: 2 additions & 0 deletions target_chains/sui/vendor/wormhole_iota_mainnet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deploy.out
sui.log.*
13 changes: 13 additions & 0 deletions target_chains/sui/vendor/wormhole_iota_mainnet/Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# first build the image

cd ..; DOCKER_BUILDKIT=1 docker build --no-cache --progress plain -f sui/Dockerfile.base -t sui .

# tag the image with the appropriate version

docker tag sui:latest ghcr.io/wormhole-foundation/sui:1.19.1-mainnet

# push to ghcr

docker push ghcr.io/wormhole-foundation/sui:1.19.1-mainnet

echo remember to update both Dockerfile and Dockerfile.export
33 changes: 33 additions & 0 deletions target_chains/sui/vendor/wormhole_iota_mainnet/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM cli-gen AS cli-export
FROM const-gen AS const-export
FROM ghcr.io/wormhole-foundation/sui:1.19.1-mainnet@sha256:544a1b2aa5701fae25a19aed3c5e8c24e0caf7d1c9f511b6844d339a8f0b2a00 as sui

# initial run
# COPY sui/devnet/genesis_config genesis_config
# RUN sui genesis -f --from-config genesis_config

# subsequent runs after committing files from /root/.sui/sui_config/
COPY sui/devnet/ /root/.sui/sui_config/

WORKDIR /tmp

COPY sui/scripts/ scripts
COPY sui/wormhole/ wormhole
COPY sui/token_bridge/ token_bridge
COPY sui/examples/ examples
COPY sui/Makefile Makefile

# Copy .env and CLI
COPY --from=const-export .env .env
COPY --from=cli-export clients/js /cli

# Link `worm`
WORKDIR /cli

RUN npm link

FROM sui AS tests

WORKDIR /tmp

RUN --mount=type=cache,target=/root/.move,id=move_cache make test
24 changes: 24 additions & 0 deletions target_chains/sui/vendor/wormhole_iota_mainnet/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM rust:1.62@sha256:5777f201f507075309c4d2d1c1e8d8219e654ae1de154c844341050016a64a0c as sui-node

WORKDIR /tmp

RUN curl -L https://github.com/MystenLabs/sui/releases/download/mainnet-v1.19.1/sui-mainnet-v1.19.1-ubuntu-x86_64.tgz > sui-mainnet-v1.19.1-ubuntu-x86_64.tgz
RUN echo "6a8cc96759760293143a00fe7031a5fea70d2dff5b98d18c0470c09555da63e0 sui-mainnet-v1.19.1-ubuntu-x86_64.tgz" | sha256sum -c --status

RUN tar -xvf sui-mainnet-v1.19.1-ubuntu-x86_64.tgz
RUN mv target/release/sui-ubuntu-x86_64 /bin/sui
RUN mv target/release/sui-faucet-ubuntu-x86_64 /bin/sui-faucet
RUN mv target/release/sui-node-ubuntu-x86_64 /bin/sui-node

RUN rm sui-mainnet-v1.19.1-ubuntu-x86_64.tgz

RUN apt-get update
RUN apt-get install -y ca-certificates curl gnupg
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg

ARG NODE_MAJOR=18
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list

RUN apt-get update
RUN apt-get install nodejs -y
15 changes: 15 additions & 0 deletions target_chains/sui/vendor/wormhole_iota_mainnet/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
TEST_CONTRACT_DIRS := wormhole token_bridge examples/coins examples/core_messages
CLEAN_CONTRACT_DIRS := wormhole token_bridge examples/coins examples/core_messages

.PHONY: clean
clean:
$(foreach dir,$(TEST_CONTRACT_DIRS), make -C $(dir) $@ &&) true

.PHONY: test
test:
$(foreach dir,$(TEST_CONTRACT_DIRS), make -C $(dir) $@ &&) true

test-docker:
DOCKER_BUILDKIT=1 docker build --progress plain -f ../Dockerfile.cli -t cli-gen ..
DOCKER_BUILDKIT=1 docker build --build-arg num_guardians=1 --progress plain -f ../Dockerfile.const -t const-gen ..
DOCKER_BUILDKIT=1 docker build -f Dockerfile ..
114 changes: 114 additions & 0 deletions target_chains/sui/vendor/wormhole_iota_mainnet/NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
brew install cmake

rustup install stable-x86_64-apple-darwin
#rustup target add stable-x86_64-apple-darwin
rustup target add x86_64-apple-darwin

=== Building

% ./node_builder.sh

=== Running

% ./start_node.sh

# If you don't remember your newly generated address

% sui client addresses
Showing 1 results.
0x13b3cb89cf3226d3b860294fc75dc6c91f0c5ecf

# Give yourself some money

% scripts/faucet.sh `sui client addresses | tail -1`

# Looking at the prefunded address

% sui client objects --address 0x13b3cb89cf3226d3b860294fc75dc6c91f0c5ecf

=== Boot tilt

# fund our standard account

We don't run a faucet since it doesn't always unlock the client LOCK files. So, instead we just steal a chunk of coins
from the default accounts created when the node was initialized. Once sui is showing as live...

``` sh
% kubectl exec -it sui-0 -c sui-node -- /tmp/funder.sh
```

# getting into the sui k8s node (if you need to crawl around)

kubectl exec -it sui-0 -c sui-node -- /bin/bash
kubectl exec -it guardian-0 -c guardiand -- /bin/bash

# setup the client.yaml

``` sh
% rm -rf $HOME/.sui
% sui keytool import "daughter exclude wheat pudding police weapon giggle taste space whip satoshi occur" ed25519
% sui client
```
point it at http://localhost:9000. The key you create doesn't matter.

# edit $HOME/.sui/sui_config/client.yaml

``` sh
sed -i -e 's/active_address.*/active_address: "0x13b3cb89cf3226d3b860294fc75dc6c91f0c5ecf"/' ~/.sui/sui_config/client.yaml
```


# deploy the contract

``` sh
% scripts/deploy.sh
```

# start the watcher

``` sh
% . env.sh
% python3 tests/ws.py
```

# publish a message (different window)

``` sh
% . env.sh
% scripts/publish_message.sh
```

==

docker run -it -v `pwd`:`pwd` -w `pwd` --net=host ghcr.io/wormhole-foundation/sui:0.16.0 bash
dnf -y install git make

``` sh
% rm -rf $HOME/.sui
% sui keytool import "daughter exclude wheat pudding police weapon giggle taste space whip satoshi occur" secp256k1
% sui client
```

to get a new emitter

kubectl exec -it sui-0 -c sui-node -- /tmp/funder.sh
scripts/deploy.sh
. env.sh
sui client call --function get_new_emitter --module wormhole --package $WORM_PACKAGE --gas-budget 20000 --args \"$WORM_STATE\"

sui client objects
scripts/publish_message.sh 0x165ef7366c4267c6506bcf63d2419556f34f48d6


curl -s -X POST -d '{"jsonrpc":"2.0", "id": 1, "method": "sui_getEvents", "params": [{"MoveEvent": "0xf4179152ab02e4212d7e7b20f37a9a86ab6d50fb::state::WormholeMessage"}, null, 10, true]}' -H 'Content-Type: application/json' http://127.0.0.1:9002 | jq

curl -s -X POST -d '{"jsonrpc":"2.0", "id": 1, "method": "sui_getEvents", "params": [{"Transaction": "cL+uWFEVcQrkAiOxOJmaK7JmlOJdE3/8X5JFbJwBxCQ="}, null, 10, true]}' -H 'Content-Type: application/json' http://127.0.0.1:9002 | jq

"txhash": "0x70bfae585115710ae40223b138999a2bb26694e25d137ffc5f92456c9c01c424", "txhash_b58": "8b8Bn8MUqAWeVz2BE5hMicC9KaRkV6UM4v1JLWGUjxcT", "
Digest: cL+uWFEVcQrkAiOxOJmaK7JmlOJdE3/8X5JFbJwBxCQ=

kubectl exec -it guardian-0 -- /guardiand admin send-observation-request --socket /tmp/admin.sock 21 70bfae585115710ae40223b138999a2bb26694e25d137ffc5f92456c9c01c424

// curl -s -X POST -d '{"jsonrpc":"2.0", "id": 1, "method": "sui_getCommitteeInfo", "params": []}' -H 'Content-Type: application/json' http://127.0.0.1:9002 | jq

// curl -s -X POST -d '{"jsonrpc":"2.0", "id": 1, "method": "sui_getLatestCheckpointSequenceNumber", "params": []}' -H 'Content-Type: application/json' http://127.0.0.1:9000
130 changes: 130 additions & 0 deletions target_chains/sui/vendor/wormhole_iota_mainnet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Wormhole on Sui

This folder contains the reference implementation of the Wormhole cross-chain
messaging protocol smart contracts on the [Sui](https://mystenlabs.com/)
blockchain, implemented in the [Move](https://move-book.com/) programming
language.

# Project structure

The project is laid out as follows:

- [wormhole](./wormhole) the core messaging layer
- [token_bridge](./token_bridge) the asset transfer layer
- [coin](./coin) a template for creating Wormhole wrapped coins

# Installation

Make sure your Cargo version is at least 1.65.0 and then follow the steps below:

- https://docs.sui.io/build/install

#https://docs.sui.io/guides/developer/getting-started/sui-install# Prerequisites

Install the `Sui` CLI. This tool is used to compile the contracts and run the tests.

```sh
cargo install --locked --git https://github.com/MystenLabs/sui.git --rev 041c5f2bae2fe52079e44b70514333532d69f4e6 sui
```

Some useful Sui CLI commands are

- `sui start` to spin up a local network
- `rpc-server` to start a server for handling rpc calls

Next, install the [worm](../clients/js/README.md) CLI tool by running

```sh
wormhole/clients/js $ make install
```

`worm` is the swiss army knife for interacting with wormhole contracts on all
supported chains, and generating signed messages (VAAs) for testing.

As an optional, but recommended step, install the
[move-analyzer](https://github.com/move-language/move/tree/main/language/move-analyzer)
Language Server (LSP):

```sh
cargo install --git https://github.com/move-language/move.git move-analyzer --branch main --features "address32"
```

This installs the LSP backend which is then supported by most popular editors such as [emacs](https://github.com/emacs-lsp/lsp-mode), [vim](https://github.com/neoclide/coc.nvim), and even [vscode](https://marketplace.visualstudio.com/items?itemName=move.move-analyzer).

<details>
<summary>For emacs, you may need to add the following to your config file:</summary>

```lisp
;; Move
(define-derived-mode move-mode rust-mode "Move"
:group 'move-mode)

(add-to-list 'auto-mode-alist '("\\.move\\'" . move-mode))

(with-eval-after-load 'lsp-mode
(add-to-list 'lsp-language-id-configuration
'(move-mode . "move"))

(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection "move-analyzer")
:activation-fn (lsp-activate-on "move")
:server-id 'move-analyzer)))
```

</details>

## Building & running tests

The project uses a simple `make`-based build system for building and running
tests. Running `make test` in this directory will run the tests for each
contract. If you only want to run the tests for, say, the token bridge contract,
then you can run `make test` in the `token_bridge` directory, or run `make -C
token_bridge test` from this directory.

Additionally, `make test-docker` runs the tests in a docker container which is
set up with all the necessary dependencies. This is the command that runs in CI.

## Running a local validator and deploying the contracts to it

Simply run

```sh
worm start-validator sui
```

which will start a local sui validator with an RPC endpoint at `0.0.0.0:9000`.

Once the validator is running, the contracts are ready to deploy. In the
[scripts](./scripts) directory, run

```sh
scripts $ ./deploy.sh devnet
```

This will deploy the core contract and the token bridge.

When you make a change to the contract, you can simply restart the validator and
run the deploy script again.

<!-- However, a better way is to run one of the following scripts:

``` sh
scripts $ ./upgrade devnet Core # for upgrading the wormhole contract
scripts $ ./upgrade devnet TokenBridge # for upgrading the token bridge contract
scripts $ ./upgrade devnet NFTBridge # for upgrading the NFT bridge contract
```

Behind the scenes, these scripts exercise the whole contract upgrade code path
(see below), including generating and verifying a signed governance action, and
the Move bytecode verifier checking ABI compatibility. If an upgrade here fails
due to incompatibility, it will likely on mainnet too. (TODO: add CI action to
simulate upgrades against main when there's a stable version) -->

# Implementation notes / coding practices

In this section, we describe some of the implementation design decisions and
coding practices we converged on along the way. Note that the coding guidelines
are prescriptive rather than descriptive, and the goal is for the contracts to
ultimately follow these, but they might not during earlier development phases.

### TODO
Loading
Loading