Skip to content
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

Add Solana implementation #15

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
4cbcee8
Add Solana (#17)
barnjamin May 13, 2024
759f8ed
solana: complete swap gas (direct) (#20)
a5-pickle May 14, 2024
d25e195
Solana: add payload redeem type (#19)
gator-boi May 15, 2024
edc1e0f
solana: rename StagedTransfer to StagedInbound (#26)
gator-boi May 15, 2024
677dfe1
solana: fix ts relayer fees (#28)
gator-boi May 15, 2024
8c7eb49
resync submodule (#27)
a5-pickle May 15, 2024
c473f2f
Update LL submodule version (#32)
barnjamin May 20, 2024
4f9dead
solana: staged outbound (#30)
a5-pickle May 21, 2024
5a0e617
bump submodule and sdk versions (#34)
barnjamin May 21, 2024
4f34ffe
solana: make test quote more usable (#35)
a5-pickle May 21, 2024
96c4428
solana: update outbound USDC tests (#36)
gator-boi May 21, 2024
c59ae12
solana: add tests for release and stage inbound (#37)
gator-boi May 22, 2024
5e8f76b
solana: fix type (#39)
a5-pickle May 22, 2024
eab7b39
solana: restructure staged outbound tests (#40)
gator-boi May 22, 2024
e2df3eb
solana: initiate swap (exact in) (#41)
a5-pickle May 22, 2024
4ce0a94
fix clippy (#45)
a5-pickle May 23, 2024
e114e9e
solana: inbound swap with relay (#44)
gator-boi May 23, 2024
1957cff
solana: add time check for usdc relay (#47)
gator-boi May 23, 2024
3caf161
solana: complete swap payload (#48)
a5-pickle May 23, 2024
154d494
fix `RedeemMode::Payload` encoding (#50)
a5-pickle May 24, 2024
94819b2
solana: fix `compute_min_amount_out` (#54)
a5-pickle May 24, 2024
a2290c5
solana: add swap tests (#55)
gator-boi May 28, 2024
5d130a1
solana: fix complete swap payload (#58)
a5-pickle May 28, 2024
2fdd2c7
solana: add ix to close staged outbound (#59)
gator-boi May 30, 2024
0f32763
solana: fix swaps and use token 2022 mint for tests (#62)
a5-pickle May 30, 2024
c74ec9a
solana: add docstrings (#61)
gator-boi May 30, 2024
41eba97
solana: clean up initialize (#66)
a5-pickle Jun 6, 2024
eadb21d
solana: add exact in arg (#68)
a5-pickle Jun 6, 2024
4f5f6c8
solana: token -> token_interface (#69)
a5-pickle Jun 11, 2024
1f19fde
Solana <> EVM integration testing (#64)
gator-boi Jun 11, 2024
65de822
update dependencies (#74)
a5-pickle Jun 20, 2024
feefd55
solana: add upper bound to compound (#72)
a5-pickle Jun 25, 2024
d698ba9
solana: add min amount out to stage outbound (#77)
gator-boi Jul 25, 2024
776929d
solana: fix docs (#78)
gator-boi Jul 25, 2024
5e2e8ff
solana: us unwrap_or_else (#79)
gator-boi Jul 25, 2024
a2258ec
solana: finish TODOs (#80)
gator-boi Jul 25, 2024
c56e524
solana: add `make build` (#83)
a5-pickle Aug 9, 2024
3b0cd05
solana: fix space calc (#82)
a5-pickle Aug 9, 2024
7cf10fc
solana: add redeemer to complete transfer ixs (#81)
a5-pickle Aug 9, 2024
ec69f3c
e2e: fix test (#84)
a5-pickle Aug 13, 2024
71a0a28
update .gitmodules (#87)
a5-pickle Aug 29, 2024
825fadb
fix package-lock.json
a5-pickle Aug 19, 2024
01e411d
solana: amount in != 0
a5-pickle Aug 19, 2024
30f67d8
solana: add delegate check
a5-pickle Aug 19, 2024
1bc0f38
evm: fix wormhole-solidity-sdk commit
a5-pickle Oct 2, 2024
1c1749a
solana: add replay protection with dust
a5-pickle Oct 1, 2024
5f49c59
solana: remove unnecessary signer seeds
a5-pickle Oct 1, 2024
0b6ac7a
solana: remove redundant allocated space
a5-pickle Oct 1, 2024
5daca98
solana: pay prepared by
a5-pickle Oct 1, 2024
fbd9516
Update submodule (#91)
a5-pickle Oct 24, 2024
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
58 changes: 58 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: e2e
on:
push:
branches:
- main
pull_request:

env:
ANCHOR_VERSION: 0.30.1
NODE_VERSION: 20.11.0
RUSTC_VERSION: 1.75.0
SOLANA_VERSION: 1.18.15
jobs:
test:
name: bash sh/run_test.sh
runs-on:
labels: ubuntu-latest-l
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install Solana CLI tools
run: sh -c "$(curl -sSfL https://release.anza.xyz/v${{ env.SOLANA_VERSION }}/install)"
shell: bash
- name: Update PATH
run: echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
shell: bash
- name: Install Anchor
run: npm i -g @coral-xyz/anchor-cli@${{ env.ANCHOR_VERSION }}
shell: bash
- name: make node_modules
run: make node_modules
- name: cd evm && make build
run: make build
working-directory: ./evm
- name: cd evm/ts-sdk && npm run build
run: npm run build
working-directory: ./evm/ts-sdk
- name: cd solana && make anchor-test-setup
run: make anchor-test-setup
working-directory: ./solana
- name: cd solana && anchor build -- --features integration-test
run: anchor build -- --features integration-test
working-directory: ./solana
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUSTC_VERSION }}
- name: cd e2e && bash sh/run_test.sh
run: bash sh/run_test.sh
working-directory: ./e2e
99 changes: 99 additions & 0 deletions .github/workflows/solana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: solana
on:
push:
branches:
- main
pull_request:

env:
ANCHOR_VERSION: 0.30.1
NODE_VERSION: 20.11.0
RUSTC_VERSION: 1.75.0
SOLANA_VERSION: 1.18.15
jobs:
make-cargo-test-all:
name: make cargo-test-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUSTC_VERSION }}
components: clippy, rustfmt
- name: make cargo-test-all
run: make cargo-test-all
working-directory: ./solana

make-lint:
name: make lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUSTC_VERSION }}
components: clippy, rustfmt
- name: make lint
run: make lint
working-directory: ./solana

make-anchor-test:
name: make anchor-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install Solana CLI tools
run: sh -c "$(curl -sSfL https://release.anza.xyz/v${{ env.SOLANA_VERSION }}/install)"
shell: bash
- name: Update PATH
run: echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
shell: bash
- name: Install Anchor
run: npm i -g @coral-xyz/anchor-cli@${{ env.ANCHOR_VERSION }}
shell: bash
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUSTC_VERSION }}
- name: make anchor-test
run: make anchor-test
working-directory: ./solana

make-check-build:
name: make check-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- uses: metadaoproject/setup-anchor@v2
with:
node-version: "20.11.0"
solana-cli-version: "1.18.15"
anchor-version: "0.30.1"
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUSTC_VERSION }}
- name: make check-build
run: make check-build
working-directory: ./solana
75 changes: 75 additions & 0 deletions .github/workflows/universal-rs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: universal-rs

on:
push:
branches:
- main
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: test ${{ matrix.rust }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
rust: ["stable", "beta", "nightly", "1.75"] # MSRV
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- uses: Swatinem/rust-cache@v2
- name: test
run: cargo test --all-features
working-directory: ./universal/rs

clippy:
name: clippy
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@clippy
- run: cargo clippy --all-targets --all-features
working-directory: ./universal/rs
env:
RUSTFLAGS: -Dwarnings

docs:
name: docs
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-docs
- run: cargo doc --no-deps --document-private-items
working-directory: ./universal/rs
env:
RUSTDOCFLAGS: "--cfg docsrs -D warnings"

fmt:
name: fmt
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --all --check
working-directory: ./universal/rs
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.vscode
node_modules
dist
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "lib/example-liquidity-layer"]
path = lib/example-liquidity-layer
url = https://github.com/wormhole-foundation/example-liquidity-layer.git
branch = v0.3.2
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

.PHONY: build
build: node_modules
cd evm && $(MAKE)
cd solana && $(MAKE) && $(MAKE) anchor-build-idl
npm run build

.PHONY: clean
clean: fast-transfer-clean
rm -rf e2e/node_modules
cd evm && $(MAKE) clean
cd solana && $(MAKE) clean
npm run clean
rm -rf node_modules

.PHONY: fast-transfer-sync
fast-transfer-sync:
git submodule update --init --checkout --recursive
git submodule sync --recursive

.PHONY: fast-transfer-clean
fast-transfer-clean:
rm -rf lib/example-liquidity-layer
$(MAKE) fast-transfer-sync

.PHONY: fast-transfer-setup
fast-transfer-setup: fast-transfer-sync
cd lib/example-liquidity-layer/solana && $(MAKE) anchor-test-setup
cd lib/example-liquidity-layer/evm && $(MAKE) build

.PHONY: fast-transfer-sdk
fast-transfer-sdk: fast-transfer-setup
cd lib/example-liquidity-layer \
&& $(MAKE) build \
&& npm run build -w solana -w evm \
&& npm pack -w universal/ts -w solana -w evm

node_modules: fast-transfer-sdk
npm install -w solana lib/example-liquidity-layer/wormhole-foundation-example-liquidity-layer-*
npm install -w e2e lib/example-liquidity-layer/wormhole-foundation-example-liquidity-layer-*
npm ci
6 changes: 6 additions & 0 deletions e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.anchor
.env
.private
.vscode
Anchor.toml
target
8 changes: 8 additions & 0 deletions e2e/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

.anchor
.DS_Store
target
node_modules
dist
build
test-ledger
15 changes: 15 additions & 0 deletions e2e/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"overrides": [
{
"files": "*.ts",
"options": {
"printWidth": 100,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"trailingComma": "all",
"bracketSpacing": true
}
}
]
}
32 changes: 32 additions & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "swap-layer-e2e",
"version": "1.0.0",
"description": "Swap Layer EVM <> Solana end-to-end test",
"main": "index.js",
"scripts": {
"test": "bash sh/run_test.sh"
},
"dependencies": {
"@solana/web3.js": "^1.91.6",
"@types/chai": "^4.3.16",
"@types/mocha": "^10.0.6",
"@types/node": "^20.12.13",
"@wormhole-foundation/example-liquidity-layer-definitions": "file:../lib/example-liquidity-layer/wormhole-foundation-example-liquidity-layer-definitions-0.0.1.tgz",
"@wormhole-foundation/example-liquidity-layer-evm": "file:../lib/example-liquidity-layer/wormhole-foundation-example-liquidity-layer-evm-0.0.1.tgz",
"@wormhole-foundation/example-liquidity-layer-solana": "file:../lib/example-liquidity-layer/wormhole-foundation-example-liquidity-layer-solana-0.0.1.tgz",
"@wormhole-foundation/sdk-base": "^0.10.9",
"@wormhole-foundation/sdk-definitions": "^0.10.9",
"@wormhole-foundation/sdk-evm": "^0.10.9",
"@wormhole-foundation/sdk-solana": "^0.10.9",
"chai": "^4.3.4",
"dotenv": "^16.4.5",
"mocha": "^9.0.3",
"prettier": "^3.2.5",
"ts-mocha": "^10.0.0"
},
"devDependencies": {
"envfile": "^7.1.0",
"ethers": "^5.7.2",
"typechain": "^8.3.2"
}
}
28 changes: 28 additions & 0 deletions e2e/sh/run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#/bin/bash

ROOT=$(realpath $(dirname $0)/../..)

rm -f Anchor.toml

sed 's/\= "ts\//\= "..\/solana\/ts\//' $ROOT/solana/Anchor.toml > Anchor.toml
sed -E -i 's/"programs\/swap-layer"/"..\/solana\/programs\/swap-layer"/' Anchor.toml
sed -E -i 's/^test \= ".+"/test = "npx ts-mocha -p .\/tsconfig.anchor-test.json -t 1000000 --bail --exit tests\/[0-9]*.ts"/' Anchor.toml

rm -rf target
cp -r $ROOT/solana/target $ROOT/e2e

# start anvil in the evm directory
cd $ROOT/evm
bash test/script/start_anvil.sh

echo "Anvil instances started successfully."

cd $ROOT/e2e

anchor test --skip-build

EXIT_CODE=$?

pkill anvil

exit $EXIT_CODE
Loading