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 #152

Merged
merged 90 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
aa9acd0
solana: [wip] implement native token transfers
kcsongor Jan 24, 2024
12b12a7
solana: RateLimitSpace is not an account
kcsongor Feb 2, 2024
cbe53c1
solana: normalise amounts in VAAs
kcsongor Feb 2, 2024
3dee8b2
solana: set released = true for outbound transfers too
kcsongor Feb 5, 2024
b9760d0
solana: rename in/outbound queued transfer -> in/outbox item
kcsongor Feb 5, 2024
e78302d
solana: use anchor 0.29.0
kcsongor Feb 5, 2024
edad44e
solana: Cargo.toml: use resolver = 2
kcsongor Feb 5, 2024
724f6e7
solana: use anchor idl build feature
kcsongor Feb 5, 2024
2fa3e9b
solana: support token22 (via anchor interfaces)
kcsongor Feb 5, 2024
e9b9088
solana: transfer: don't burn dust
kcsongor Feb 5, 2024
1dba4b2
solana: implement limit update logic
kcsongor Feb 7, 2024
1543cee
solana: admin functionality
kcsongor Feb 8, 2024
ceadb25
solana: add ability to pause contract
kcsongor Feb 8, 2024
0dc731d
solana: send fee to wh fee collector
kcsongor Feb 9, 2024
935d881
solana: update message serialisation
kcsongor Feb 9, 2024
2a58c96
solana: initialise sequence and outbound rate limit
kcsongor Feb 9, 2024
7923d27
solana: implement lock/unlock
kcsongor Feb 9, 2024
ae55cf9
solana: store decimals of normalised amount
kcsongor Feb 9, 2024
6c98549
solana: wrap messages in endpoint message
kcsongor Feb 9, 2024
db7c3ec
solana: initialise rate limit when adding sibling
kcsongor Feb 10, 2024
05f5f5b
solana: init custody token account for lock/unlock
kcsongor Feb 10, 2024
aff4c39
solana: update serialisation code to be in line with evm impl
kcsongor Feb 10, 2024
6d3cec4
solana: check mint authority is NTT manager in burning mode
kcsongor Feb 11, 2024
e70c016
solana: fix custody PDA
kcsongor Feb 12, 2024
e69d82b
solana: add test fixtures (mainnet wh binaries & accounts)
kcsongor Feb 12, 2024
d01daf3
solana: add js packages (for test & sdk)
kcsongor Feb 12, 2024
2b291f1
solana: ts: implement sdk
kcsongor Feb 12, 2024
e12d73d
solana: tests: add test for lock&unlock using ts sdk
kcsongor Feb 12, 2024
629d5ff
solana: gracefully handle redeems being delayed
kcsongor Feb 12, 2024
3808015
solana: transfer: remove race condition
kcsongor Feb 12, 2024
0fab3fe
solana: transfer: add option to revert if tx would be delayed
kcsongor Feb 12, 2024
58f843e
solana: InboundRateLimit -> InboxRateLimit
kcsongor Feb 12, 2024
767f52b
solana: implement backflows
kcsongor Feb 12, 2024
4005365
solana: move core bridge binary to tests/fixtures
kcsongor Feb 13, 2024
e60ccbb
solana: unify custody&mint token authorities
kcsongor Feb 13, 2024
996b623
solana: solana-program-test
kcsongor Feb 13, 2024
b9560dc
solana: test release_outbound in solana-program-test
kcsongor Feb 14, 2024
d7629c3
solana: more transfer tests
kcsongor Feb 14, 2024
7837e46
solana: sender/recipient is token authority
kcsongor Feb 14, 2024
3aafc98
solana: fix denormalisation when the normalised decimals are less than 8
kcsongor Feb 14, 2024
5a0de11
solana: allow redeeming when paused
kcsongor Feb 14, 2024
cddc661
solana: adjust decimals instead of assert equality in operations on n…
kcsongor Feb 14, 2024
22b583c
solana: test cancel flows
kcsongor Feb 14, 2024
abd4237
solana: test pausing
kcsongor Feb 14, 2024
69d061a
solana: update structs (+ wire format) to match solidity impl
kcsongor Feb 15, 2024
cba5624
solana: multi endpoint arch
kcsongor Feb 15, 2024
244dc54
solana: anchor keys sync
kcsongor Feb 15, 2024
32aada2
solana: patch idl file and add Makefile to run tests
kcsongor Feb 15, 2024
9fc01e3
solana: update ts sdk to support multi endpoint arch
kcsongor Feb 15, 2024
34cbb26
solana: threshold voting
kcsongor Feb 15, 2024
3f7449c
solana: content-addressed inbox items
kcsongor Feb 15, 2024
b7d2377
solana: enabled endpoints bitmap
kcsongor Feb 15, 2024
d5f0580
solana: reorder Makefile targets
kcsongor Feb 16, 2024
f7d5ae0
solana: cargo fmt
kcsongor Feb 16, 2024
06e76e2
solana: CI
kcsongor Feb 16, 2024
eff2608
solana: test: submit VAAs via core bridge
kcsongor Feb 16, 2024
8e261db
solana: general purpose governance program
kcsongor Feb 16, 2024
0c420e3
solana: assert decimals are equal instead of shifting
kcsongor Feb 18, 2024
80dc247
solana: use unnormalised values internally
kcsongor Feb 18, 2024
16e8147
solana: simplify governance CPI
kcsongor Feb 20, 2024
fa830f9
solana: fix CI
kcsongor Feb 20, 2024
2b09fe2
solana: remove EnabledEndpoint
kcsongor Feb 20, 2024
43537bd
solana: deploy programs as upgradeable in solana-program-test
kcsongor Feb 20, 2024
8339186
solana: solana: set upgrade authority; rm transfer authority args
a5-pickle Feb 20, 2024
c0bd3a9
solana: solana: couple things...
a5-pickle Feb 21, 2024
f76f07a
solana: solana: fix clippy
a5-pickle Feb 21, 2024
666b3b3
solana: fix solana version parse
a5-pickle Feb 21, 2024
6690b7b
solana: ProgramData idl generation
kcsongor Feb 21, 2024
e2d7a33
solana: drop generics from typescript idl type
kcsongor Feb 21, 2024
9be6e5e
solana: solana: fix anchor test
a5-pickle Feb 21, 2024
4ec60ea
solana: update inbox item PDA derivation
kcsongor Feb 21, 2024
37917c6
solana: add endpoint_payload to EndpointMessage
kcsongor Feb 21, 2024
7679935
rename workflows
a5-pickle Feb 21, 2024
00d66cf
test anchor
a5-pickle Feb 21, 2024
08f8e15
solana: specify toolchain
a5-pickle Feb 21, 2024
d9e688c
run make target in anchor test in CI
kcsongor Feb 22, 2024
4a0ab66
fix make target name
kcsongor Feb 22, 2024
7681c86
solana: hello npm
a5-pickle Feb 22, 2024
6a6d5c1
solana: relax trait bounds
kcsongor Feb 22, 2024
07a0d84
solana/Makefile: node_modules depends on package-lock.json
kcsongor Feb 22, 2024
4ff9304
solana: remove done TODO
kcsongor Feb 22, 2024
5836408
solana: reduce timestamp calls
a5-pickle Feb 22, 2024
1536c98
solana: allow cancelling ownership transfer
kcsongor Feb 22, 2024
4922504
solana: fix program IDs; fix .gitignore; arch sbf
a5-pickle Feb 22, 2024
a39026c
solana: move release_outbound to wormhole endpoint ixs
kcsongor Feb 22, 2024
f28c393
solana: add testnet setup; refactor ts program instance
a5-pickle Feb 22, 2024
3d341f4
solana: split out structs to a separate crate
kcsongor Feb 22, 2024
389de51
solana: some clean up
kcsongor Feb 22, 2024
5e444b3
solana: fail on wrong mode earlier; one less timestamp call
a5-pickle Feb 22, 2024
59fdd27
cargo fmt
kcsongor Feb 22, 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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml → .github/workflows/evm.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: EVM CI

on:
workflow_dispatch:
Expand All @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: true

name: Foundry project
name: forge test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
126 changes: 126 additions & 0 deletions .github/workflows/solana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Solana CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- dev
jobs:
solana-sbf:
name: Solana Cargo SBF
runs-on: ubuntu-20.04
env:
RUSTFLAGS: -Dwarnings

steps:
- uses: actions/checkout@v3
- name: Get rust toolchain version
id: toolchain
run: |
RUST_VERSION="$(awk '/channel =/ { print substr($3, 2, length($3)-2) }' solana/rust-toolchain)"
echo "::set-output name=version::${RUST_VERSION}"

- name: Get solana version
id: solana
run: |
SOLANA_VERSION="$(awk '/solana-program =/ { print substr($3, 3, length($3)-3) }' solana/Cargo.toml)"
echo "::set-output name=version::${SOLANA_VERSION}"

- name: Cache rust toolchain
uses: actions/cache@v3
env:
cache-name: solana-toolchain
with:
path: |
~/.cargo/bin
~/.rustup
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.toolchain.outputs.version }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Install rust toolchain
uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb
with:
toolchain: ${{ steps.toolchain.outputs.version }}
components: "clippy,rustfmt"

- name: Cache rust packages / build cache
uses: actions/cache@v3
env:
cache-name: solana-rust-packages
with:
path: |
~/.cargo/bin
~/.cargo/registry
~/.cargo/git/db
solana/target
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('solana/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Run `cargo fmt`
run: cargo fmt --check --all --manifest-path solana/Cargo.toml

- name: Run `cargo check`
run: cargo check --workspace --tests --manifest-path solana/Cargo.toml

- name: Run `cargo clippy`
run: cargo clippy --workspace --tests --manifest-path solana/Cargo.toml

- name: Cache solana tools
id: cache-solana
uses: actions/cache@v3
env:
cache-name: solana-tools
with:
path: |
~/.local/share/solana/install/
~/.cache/solana/
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.solana.outputs.version }}

- if: ${{ steps.cache-solana.outputs.cache-hit != 'true' }}
name: Install solana tools
env:
SOLANA_VERSION: ${{ steps.solana.outputs.version }}
run: |
sh -c "$(curl -sSfL https://release.solana.com/v${SOLANA_VERSION}/install)"
~/.local/share/solana/install/active_release/bin/sdk/sbf/scripts/install.sh

- name: cargo build-sbf && cargo test-sbf
env:
RUST_BACKTRACE: "1"
run: |
cd solana
export BPF_OUT_DIR="$(pwd)/target/deploy"
export PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}"

mkdir -p "${BPF_OUT_DIR}"

BPF_PACKAGES=(
programs/example-native-token-transfers/Cargo.toml
programs/wormhole-governance/Cargo.toml
)
for p in "${BPF_PACKAGES[@]}"; do
cargo build-sbf --manifest-path "${p}"
done
for p in "${BPF_PACKAGES[@]}"; do
cargo test-sbf --manifest-path "${p}"
done
anchor-test:
name: Anchor Test
runs-on: ubuntu-latest
# Anchor Docker image: https://www.anchor-lang.com/docs/verifiable-builds#images
container: backpackapp/build:v0.29.0
steps:
- uses: actions/checkout@v4
- name: Set default Rust toolchain
run: rustup default stable
working-directory: ./solana
- name: anchor test --arch sbf
run: make anchor-test
working-directory: ./solana
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Compiler files
cache/
out/
target/

# Ignores development broadcast logs
!/broadcast
Expand All @@ -15,3 +16,9 @@ docs/

# macOS stuff
.DS_Store

# VSCode
.vscode

# Misc
.private
19 changes: 19 additions & 0 deletions solana/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": "standard-with-typescript",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
plugins: [
'@stylistic'
],
"rules": {
'@stylistic/indent': ['error', 2],
'@stylistic/max-len': ['error', 80],
}
}
4 changes: 4 additions & 0 deletions solana/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.anchor
**/*.rs.bk
node_modules
test-ledger
8 changes: 8 additions & 0 deletions solana/.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
46 changes: 46 additions & 0 deletions solana/Anchor.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[toolchain]
anchor_version = "0.29.0" # CLI
solana_version = "1.17.2"

[features]
seeds = false
skip-lint = false

[programs.localnet]
example_native_token_transfers = "nttiK1SepaQt6sZ4WGW5whvc9tEnGXGxuKeptcQPCcS"
wormhole_governance = "wgvEiKVzX9yyEoh41jZAdC6JqGUTS4CFXbFGBV5TKdZ"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "Localnet"
wallet = "keys/test.json"

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

[test]
startup_wait = 5000
shutdown_wait = 2000
upgradeable = true

[[test.genesis]]
address = "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth"
program = "programs/example-native-token-transfers/tests/fixtures/mainnet_core_bridge.so"

[test.validator]
url = "https://api.mainnet-beta.solana.com"
ticks_per_slot = 16

[[test.validator.account]]
address = "2yVjuQwpsvdsrywzsJJVs9Ueh4zayyo5DYJbBNc3DDpn"
filename = "tests/accounts/mainnet/core_bridge_config.json"

[[test.validator.account]]
address = "9bFNrXNb2WTx8fMHXCheaZqkLZ3YCCaiqTftHxeintHy"
filename = "tests/accounts/mainnet/core_bridge_fee_collector.json"

[[test.validator.account]]
address = "DS7qfSAgYsonPpKoAjcGhX9VFjXdGkiHjEDkTidf8H2P"
filename = "tests/accounts/mainnet/guardian_set_0.json"
Loading
Loading