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

Update submodule #91

Merged
merged 10 commits into from
Oct 24, 2024
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
44 changes: 32 additions & 12 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ on:
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: ubuntu-latest
# Anchor Docker image: https://www.anchor-lang.com/docs/verifiable-builds#images
# container: backpackapp/build:v0.30.1
runs-on:
labels: ubuntu-latest-l
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -21,18 +23,36 @@ jobs:
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- uses: metadaoproject/setup-anchor@v2
- uses: actions/setup-node@v4
with:
node-version: "20.11.0"
solana-cli-version: "1.18.15"
anchor-version: "0.30.1"
- name: Set default Rust toolchain
run: rustup default stable
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: make build
- name: cd evm && make build
run: make build
working-directory: ./evm
- name: bash sh/run_test.sh
- 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
working-directory: ./e2e
32 changes: 22 additions & 10 deletions .github/workflows/solana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ on:
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
Expand Down Expand Up @@ -51,14 +54,22 @@ jobs:
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- uses: metadaoproject/setup-anchor@v2
- uses: actions/setup-node@v4
with:
node-version: "20.11.0"
solana-cli-version: "1.18.15"
anchor-version: "0.30.1"
- name: Set default Rust toolchain
run: rustup default stable
working-directory: ./solana
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
Expand All @@ -79,9 +90,10 @@ jobs:
node-version: "20.11.0"
solana-cli-version: "1.18.15"
anchor-version: "0.30.1"
- name: Set default Rust toolchain
run: rustup default stable
working-directory: ./solana
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUSTC_VERSION }}
- name: make check-build
run: make check-build
working-directory: ./solana
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "lib/example-liquidity-layer"]
path = lib/example-liquidity-layer
url = https://github.com/wormhole-foundation/example-liquidity-layer.git
rev = dcaf657f1efd2805a26efbe9710609d9480c5bd9
branch = v0.3.2
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ build: node_modules

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

Expand Down
9 changes: 4 additions & 5 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@
"@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.7.0-beta.6",
"@wormhole-foundation/sdk-definitions": "^0.7.0-beta.6",
"@wormhole-foundation/sdk-evm": "^0.7.0-beta.6",
"@wormhole-foundation/sdk-solana": "^0.7.0-beta.6",
"@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": {
"@typechain/ethers-v5": "^11.1.2",
"envfile": "^7.1.0",
"ethers": "^5.7.2",
"typechain": "^8.3.2"
Expand Down
12 changes: 6 additions & 6 deletions e2e/sh/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ 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

mkdir -p target/deploy
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/solana
make anchor-test-setup
anchor build -- --features integration-test
cp target/deploy/swap_layer.so $ROOT/e2e/target/deploy

cd $ROOT/e2e

anchor test --skip-build

EXIT_CODE=$?

pkill anvil

exit $EXIT_CODE
40 changes: 20 additions & 20 deletions e2e/tests/02__swapLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ describe("Swap Layer", () => {
const amountIn = 20_000_000_000; // 20k USDC

const output: InitiateArgs = {
transferMode: {
mode: "LiquidityLayer",
fastTransferMode: {
mode: "Disabled",
},
redeemMode: {
mode: "Direct",
Expand Down Expand Up @@ -171,8 +171,8 @@ describe("Swap Layer", () => {
.then((encodedFee) => Number(encodedFee));

const output: InitiateArgs = {
transferMode: {
mode: "LiquidityLayer",
fastTransferMode: {
mode: "Disabled",
},
redeemMode: {
mode: "Relay",
Expand Down Expand Up @@ -270,8 +270,8 @@ describe("Swap Layer", () => {
.then((b) => b.timestamp);

const output: InitiateArgs = {
transferMode: {
mode: "LiquidityLayer",
fastTransferMode: {
mode: "Disabled",
},
redeemMode: {
mode: "Direct",
Expand Down Expand Up @@ -377,8 +377,8 @@ describe("Swap Layer", () => {
.then((encodedFee) => BigInt(encodedFee));

const output: InitiateArgs = {
transferMode: {
mode: "LiquidityLayer",
fastTransferMode: {
mode: "Disabled",
},
redeemMode: {
mode: "Relay",
Expand Down Expand Up @@ -1045,8 +1045,8 @@ describe("Swap Layer", () => {
const amountIn = 20_000_000_000; // 20k USDC

const output: InitiateArgs = {
transferMode: {
mode: "LiquidityLayer",
fastTransferMode: {
mode: "Disabled",
},
redeemMode: {
mode: "Direct",
Expand Down Expand Up @@ -1152,8 +1152,8 @@ describe("Swap Layer", () => {
.then((encodedFee) => Number(encodedFee));

const output: InitiateArgs = {
transferMode: {
mode: "LiquidityLayer",
fastTransferMode: {
mode: "Disabled",
},
redeemMode: {
mode: "Relay",
Expand Down Expand Up @@ -1277,8 +1277,8 @@ describe("Swap Layer", () => {
.then((b) => b.timestamp);

const output: InitiateArgs = {
transferMode: {
mode: "LiquidityLayer",
fastTransferMode: {
mode: "Disabled",
},
redeemMode: {
mode: "Direct",
Expand Down Expand Up @@ -1406,8 +1406,8 @@ describe("Swap Layer", () => {
.then((encodedFee) => BigInt(encodedFee));

const output: InitiateArgs = {
transferMode: {
mode: "LiquidityLayer",
fastTransferMode: {
mode: "Disabled",
},
redeemMode: {
mode: "Relay",
Expand Down Expand Up @@ -1542,8 +1542,8 @@ describe("Swap Layer", () => {
.then((b) => b.timestamp);

const output: InitiateArgs = {
transferMode: {
mode: "LiquidityLayer",
fastTransferMode: {
mode: "Disabled",
},
redeemMode: {
mode: "Direct",
Expand Down Expand Up @@ -1682,8 +1682,8 @@ describe("Swap Layer", () => {
const amountOut = amountIn - relayingFee - 500_000n;

const output: InitiateArgs = {
transferMode: {
mode: "LiquidityLayer",
fastTransferMode: {
mode: "Disabled",
},
redeemMode: {
mode: "Relay",
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/helpers/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const ONE_SOL = 1000000000;

// Avalanche Mainnet Fork
export const EVM_LOCALHOSTS = {
Ethereum: "http://127.0.0.1:8548",
Base: "http://127.0.0.1:8549",
Ethereum: "http://127.0.0.1:8545",
Base: "http://127.0.0.1:8546",
};

// USDT tokens on Ethereum.
Expand Down
8 changes: 4 additions & 4 deletions evm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ endef
.PHONY: build test clean dependencies

build: dependencies
forge build
forge build --skip test

test: dependencies
forge test --fork-url $$TEST_RPC -vvv
Expand All @@ -33,13 +33,13 @@ LIB_DEPS = foundry-rs/forge-std
LIB_DEPS += openzeppelin/openzeppelin-contracts@dc44c9f #4.9.6
LIB_DEPS += Uniswap/permit2@cc56ad0 #latest commit as per 22/04/2024
LIB_DEPS += wormhole-foundation/wormhole-solidity-sdk@60fb760 #post-merged branch
LIB_DEPS += wormhole-foundation/example-liquidity-layer@f57444f #main branch
LIB_DEPS += wormhole-foundation/example-liquidity-layer@v0.3.2 #latest build tag

# dynamically generate install rule for each lib dependency and add to depdenencies
$(foreach dep,$(LIB_DEPS), $(eval $(call install_lib,$(dep))))

clean:
forge clean
rm -rf lib
rm -rf node_modules
@$(MAKE) -C env clean
cd ts-sdk && npm run clean
@$(MAKE) -C env clean
12 changes: 8 additions & 4 deletions evm/test/script/start_anvil.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ OWNER_PRIVATE_KEY=0x646f1ce2fdad0e6deeeb5c7e8e5543bdde65e86029e2fd9fc169899c440a

. $ENV/Ethereum.env

echo $RELEASE_RPC

# Ethereum (CCTP).
anvil --port 8548 \
anvil --port 8545 \
-m "myth like bonus scare over problem client lizard pioneer submit female collect" \
--fork-url $RELEASE_RPC \
--fork-block-number 20034932 \
Expand All @@ -23,14 +25,16 @@ anvil --port 8548 \
sleep 2

forge script $ROOT/DeploySwapLayerForTest.s.sol \
--rpc-url http://localhost:8548 \
--rpc-url http://localhost:8545 \
--broadcast \
--private-key $OWNER_PRIVATE_KEY

. $ENV/Base.env

echo $RELEASE_RPC

# Base (CCTP).
anvil --port 8549 \
anvil --port 8546 \
-m "myth like bonus scare over problem client lizard pioneer submit female collect" \
--fork-url $RELEASE_RPC \
--fork-block-number 15456753 \
Expand All @@ -39,7 +43,7 @@ anvil --port 8549 \
sleep 2

forge script $ROOT/DeploySwapLayerForTest.s.sol \
--rpc-url http://localhost:8549 \
--rpc-url http://localhost:8546 \
--broadcast \
--private-key $OWNER_PRIVATE_KEY

Expand Down
2 changes: 1 addition & 1 deletion evm/ts-scripts/config/localTestnet/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"description": "Fuji",
"evmNetworkId": 43113,
"chainId": 6,
"rpc": "http://localhost:8548",
"rpc": "http://localhost:8545",
"rpcWs": "wss://avalanche-fuji-c-chain.publicnode.com",
"wormholeAddress": "0x7bbcE28e64B3F8b84d876Ab298393c38ad7aac4C",
"liquidityLayerAddress": "0x7353B29FDc79435dcC7ECc9Ac9F9b61d83B4E0F4",
Expand Down
Loading
Loading