wormhole/sui
Csongor Kiss a46bccaa9b
Upgrade sui packages and compiler to 1.19.1-mainnet (#3803)
* sui: upgrade to mainnet-1.19.1

* sui: update Dockerfile.base

* sui: update tilt deployment to support new sui binary

* sui: remove faucet and simplify tilt deploy script

* sui: add script for switching Move.toml files between networks

* devnet: update sui addresses, regen config

---------

Co-authored-by: Evan Gray <battledingo@gmail.com>
2024-04-15 17:16:07 +01:00
..
devnet Upgrade sui packages and compiler to 1.19.1-mainnet (#3803) 2024-04-15 17:16:07 +01:00
examples Upgrade sui packages and compiler to 1.19.1-mainnet (#3803) 2024-04-15 17:16:07 +01:00
scripts Upgrade sui packages and compiler to 1.19.1-mainnet (#3803) 2024-04-15 17:16:07 +01:00
testing sui: redesign Wormhole and Token Bridge contracts 2023-05-02 12:34:41 -04:00
token_bridge Upgrade sui packages and compiler to 1.19.1-mainnet (#3803) 2024-04-15 17:16:07 +01:00
wormhole Upgrade sui packages and compiler to 1.19.1-mainnet (#3803) 2024-04-15 17:16:07 +01:00
.gitignore sui: redesign Wormhole and Token Bridge contracts 2023-05-02 12:34:41 -04:00
Docker.md Upgrade sui packages and compiler to 1.19.1-mainnet (#3803) 2024-04-15 17:16:07 +01:00
Dockerfile Upgrade sui packages and compiler to 1.19.1-mainnet (#3803) 2024-04-15 17:16:07 +01:00
Dockerfile.base Upgrade sui packages and compiler to 1.19.1-mainnet (#3803) 2024-04-15 17:16:07 +01:00
Makefile docker: build CLI in shared image 2023-06-01 15:33:07 +01:00
NOTES.md sui: redesign Wormhole and Token Bridge contracts 2023-05-02 12:34:41 -04:00
README.md Upgrade sui packages and compiler to 1.19.1-mainnet (#3803) 2024-04-15 17:16:07 +01:00

README.md

Wormhole on Sui

This folder contains the reference implementation of the Wormhole cross-chain messaging protocol smart contracts on the Sui blockchain, implemented in the Move programming language.

Project structure

The project is laid out as follows:

  • wormhole the core messaging layer
  • token_bridge the asset transfer layer
  • 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/guides/developer/getting-started/sui-install# Prerequisites

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

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 CLI tool by running

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 Language Server (LSP):

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, vim, and even vscode.

For emacs, you may need to add the following to your config file:
;; 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)))

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

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 directory, run

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.

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