Skip to content

Commit 2650cb7

Browse files
kcsongora5-pickle
andauthored
Add solana implementation (#152)
* solana: implement native token transfers * rename workflows --------- Co-authored-by: A5 Pickle <a5-pickle@users.noreply.github.com>
1 parent ceb6cc8 commit 2650cb7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+21423
-2
lines changed

.github/workflows/test.yml .github/workflows/evm.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: test
1+
name: EVM CI
22

33
on:
44
workflow_dispatch:
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: true
1717

18-
name: Foundry project
18+
name: forge test
1919
runs-on: ubuntu-latest
2020
steps:
2121
- uses: actions/checkout@v4

.github/workflows/solana.yml

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Solana CI
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- dev
9+
jobs:
10+
solana-sbf:
11+
name: Solana Cargo SBF
12+
runs-on: ubuntu-20.04
13+
env:
14+
RUSTFLAGS: -Dwarnings
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Get rust toolchain version
19+
id: toolchain
20+
run: |
21+
RUST_VERSION="$(awk '/channel =/ { print substr($3, 2, length($3)-2) }' solana/rust-toolchain)"
22+
echo "::set-output name=version::${RUST_VERSION}"
23+
24+
- name: Get solana version
25+
id: solana
26+
run: |
27+
SOLANA_VERSION="$(awk '/solana-program =/ { print substr($3, 3, length($3)-3) }' solana/Cargo.toml)"
28+
echo "::set-output name=version::${SOLANA_VERSION}"
29+
30+
- name: Cache rust toolchain
31+
uses: actions/cache@v3
32+
env:
33+
cache-name: solana-toolchain
34+
with:
35+
path: |
36+
~/.cargo/bin
37+
~/.rustup
38+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.toolchain.outputs.version }}
39+
restore-keys: |
40+
${{ runner.os }}-build-${{ env.cache-name }}-
41+
${{ runner.os }}-build-
42+
${{ runner.os }}-
43+
44+
- name: Install rust toolchain
45+
uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb
46+
with:
47+
toolchain: ${{ steps.toolchain.outputs.version }}
48+
components: "clippy,rustfmt"
49+
50+
- name: Cache rust packages / build cache
51+
uses: actions/cache@v3
52+
env:
53+
cache-name: solana-rust-packages
54+
with:
55+
path: |
56+
~/.cargo/bin
57+
~/.cargo/registry
58+
~/.cargo/git/db
59+
solana/target
60+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('solana/Cargo.lock') }}
61+
restore-keys: |
62+
${{ runner.os }}-build-${{ env.cache-name }}-
63+
${{ runner.os }}-build-
64+
${{ runner.os }}-
65+
66+
- name: Run `cargo fmt`
67+
run: cargo fmt --check --all --manifest-path solana/Cargo.toml
68+
69+
- name: Run `cargo check`
70+
run: cargo check --workspace --tests --manifest-path solana/Cargo.toml
71+
72+
- name: Run `cargo clippy`
73+
run: cargo clippy --workspace --tests --manifest-path solana/Cargo.toml
74+
75+
- name: Cache solana tools
76+
id: cache-solana
77+
uses: actions/cache@v3
78+
env:
79+
cache-name: solana-tools
80+
with:
81+
path: |
82+
~/.local/share/solana/install/
83+
~/.cache/solana/
84+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.solana.outputs.version }}
85+
86+
- if: ${{ steps.cache-solana.outputs.cache-hit != 'true' }}
87+
name: Install solana tools
88+
env:
89+
SOLANA_VERSION: ${{ steps.solana.outputs.version }}
90+
run: |
91+
sh -c "$(curl -sSfL https://release.solana.com/v${SOLANA_VERSION}/install)"
92+
~/.local/share/solana/install/active_release/bin/sdk/sbf/scripts/install.sh
93+
94+
- name: cargo build-sbf && cargo test-sbf
95+
env:
96+
RUST_BACKTRACE: "1"
97+
run: |
98+
cd solana
99+
export BPF_OUT_DIR="$(pwd)/target/deploy"
100+
export PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}"
101+
102+
mkdir -p "${BPF_OUT_DIR}"
103+
104+
BPF_PACKAGES=(
105+
programs/example-native-token-transfers/Cargo.toml
106+
programs/wormhole-governance/Cargo.toml
107+
)
108+
for p in "${BPF_PACKAGES[@]}"; do
109+
cargo build-sbf --manifest-path "${p}"
110+
done
111+
for p in "${BPF_PACKAGES[@]}"; do
112+
cargo test-sbf --manifest-path "${p}"
113+
done
114+
anchor-test:
115+
name: Anchor Test
116+
runs-on: ubuntu-latest
117+
# Anchor Docker image: https://www.anchor-lang.com/docs/verifiable-builds#images
118+
container: backpackapp/build:v0.29.0
119+
steps:
120+
- uses: actions/checkout@v4
121+
- name: Set default Rust toolchain
122+
run: rustup default stable
123+
working-directory: ./solana
124+
- name: anchor test --arch sbf
125+
run: make anchor-test
126+
working-directory: ./solana

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Compiler files
22
cache/
33
out/
4+
target/
45

56
# Ignores development broadcast logs
67
!/broadcast
@@ -15,3 +16,9 @@ docs/
1516

1617
# macOS stuff
1718
.DS_Store
19+
20+
# VSCode
21+
.vscode
22+
23+
# Misc
24+
.private

solana/.eslintrc.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true,
5+
"node": true
6+
},
7+
"extends": "standard-with-typescript",
8+
"parserOptions": {
9+
"ecmaVersion": "latest",
10+
"sourceType": "module"
11+
},
12+
plugins: [
13+
'@stylistic'
14+
],
15+
"rules": {
16+
'@stylistic/indent': ['error', 2],
17+
'@stylistic/max-len': ['error', 80],
18+
}
19+
}

solana/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.anchor
2+
**/*.rs.bk
3+
node_modules
4+
test-ledger

solana/.prettierignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
.anchor
3+
.DS_Store
4+
target
5+
node_modules
6+
dist
7+
build
8+
test-ledger

solana/Anchor.toml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[toolchain]
2+
anchor_version = "0.29.0" # CLI
3+
solana_version = "1.17.2"
4+
5+
[features]
6+
seeds = false
7+
skip-lint = false
8+
9+
[programs.localnet]
10+
example_native_token_transfers = "nttiK1SepaQt6sZ4WGW5whvc9tEnGXGxuKeptcQPCcS"
11+
wormhole_governance = "wgvEiKVzX9yyEoh41jZAdC6JqGUTS4CFXbFGBV5TKdZ"
12+
13+
[registry]
14+
url = "https://api.apr.dev"
15+
16+
[provider]
17+
cluster = "Localnet"
18+
wallet = "keys/test.json"
19+
20+
[scripts]
21+
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
22+
23+
[test]
24+
startup_wait = 5000
25+
shutdown_wait = 2000
26+
upgradeable = true
27+
28+
[[test.genesis]]
29+
address = "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth"
30+
program = "programs/example-native-token-transfers/tests/fixtures/mainnet_core_bridge.so"
31+
32+
[test.validator]
33+
url = "https://api.mainnet-beta.solana.com"
34+
ticks_per_slot = 16
35+
36+
[[test.validator.account]]
37+
address = "2yVjuQwpsvdsrywzsJJVs9Ueh4zayyo5DYJbBNc3DDpn"
38+
filename = "tests/accounts/mainnet/core_bridge_config.json"
39+
40+
[[test.validator.account]]
41+
address = "9bFNrXNb2WTx8fMHXCheaZqkLZ3YCCaiqTftHxeintHy"
42+
filename = "tests/accounts/mainnet/core_bridge_fee_collector.json"
43+
44+
[[test.validator.account]]
45+
address = "DS7qfSAgYsonPpKoAjcGhX9VFjXdGkiHjEDkTidf8H2P"
46+
filename = "tests/accounts/mainnet/guardian_set_0.json"

0 commit comments

Comments
 (0)