Skip to content

Commit 73c2af2

Browse files
authored
[remote-executor] Isolate wormhole-solana crate (#843)
* Point to another wormhole sdk * Works * Reset this dir * Refresh cargo lock * Bump solana * Pin git packages * Allow large errors * Update to the right wormhole-solana * Fix cli * Add cargo lock * Remove print statement
1 parent e670f57 commit 73c2af2

File tree

12 files changed

+1186
-800
lines changed

12 files changed

+1186
-800
lines changed

.github/workflows/remote-executor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
override: true
2121
- name: Install Solana
2222
run: |
23-
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
23+
sh -c "$(curl -sSfL https://release.solana.com/v1.14.18/install)"
2424
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
2525
- name: Run executor tests
2626
run: cargo test-bpf --manifest-path ./governance/remote_executor/Cargo.toml

governance/remote_executor/Cargo.lock

Lines changed: 80 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

governance/remote_executor/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ members = [
66

77
[profile.release]
88
overflow-checks = true
9+
10+
[patch.crates-io]
11+
serde_wormhole = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.17.1" }

governance/remote_executor/cli/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ anchor-client = "0.25.0"
1313
shellexpand = "2.1.2"
1414
anyhow = "1.0.65"
1515
base64 = "0.13.0"
16-
wormhole-solana = { git = "https://github.com/guibescos/wormhole", branch = "reisen/sdk-solana"}
17-
wormhole-core = { git = "https://github.com/guibescos/wormhole", branch = "reisen/sdk-solana"}
16+
wormhole-solana = { git = "https://github.com/guibescos/wormhole-solana", rev="f14b3b54c1e37e1aaf8c2ac2a5e236832ffdb3c2"}
17+
wormhole-sdk = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.17.1" }
18+
serde_wormhole = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.17.1"}
1819
hex = "0.4.3"

governance/remote_executor/cli/src/main.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#![deny(warnings)]
2+
3+
use {
4+
serde_wormhole::RawMessage,
5+
wormhole_sdk::vaa::{
6+
Body,
7+
Header,
8+
Vaa,
9+
},
10+
};
211
pub mod cli;
312
use {
413
anchor_client::{
@@ -47,7 +56,6 @@ use {
4756
transaction::Transaction,
4857
},
4958
std::str::FromStr,
50-
wormhole::VAA,
5159
wormhole_solana::{
5260
instructions::{
5361
post_message,
@@ -86,9 +94,10 @@ fn main() -> Result<()> {
8694

8795
let signature_set_keypair = Keypair::new();
8896

89-
let vaa = VAA::from_bytes(vaa_bytes.clone())?;
97+
let vaa: Vaa<&RawMessage> = serde_wormhole::from_slice(&vaa_bytes)?;
98+
let (header, body): (Header, Body<&RawMessage>) = vaa.into();
9099

91-
let posted_vaa_key = PostedVAA::key(&wormhole, vaa.digest().unwrap().hash);
100+
let posted_vaa_key = PostedVAA::key(&wormhole, body.digest().unwrap().hash);
92101

93102
// First verify VAA
94103
let verify_txs = verify_signatures_txs(
@@ -106,15 +115,15 @@ fn main() -> Result<()> {
106115

107116
// Post VAA
108117
let post_vaa_data = PostVAAData {
109-
version: vaa.version,
110-
guardian_set_index: vaa.guardian_set_index,
111-
timestamp: vaa.timestamp,
112-
nonce: vaa.nonce,
113-
emitter_chain: vaa.emitter_chain.into(),
114-
emitter_address: vaa.emitter_address,
115-
sequence: vaa.sequence,
116-
consistency_level: vaa.consistency_level,
117-
payload: vaa.payload,
118+
version: header.version,
119+
guardian_set_index: header.guardian_set_index,
120+
timestamp: body.timestamp,
121+
nonce: body.nonce,
122+
emitter_chain: body.emitter_chain.into(),
123+
emitter_address: body.emitter_address.0,
124+
sequence: body.sequence,
125+
consistency_level: body.consistency_level,
126+
payload: body.payload.to_vec(),
118127
};
119128

120129
process_transaction(

governance/remote_executor/programs/remote-executor/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ pythtest = []
1818

1919
[dependencies]
2020
anchor-lang = {version = "0.25.0", features = ["init-if-needed"]}
21-
wormhole-solana = { git = "https://github.com/guibescos/wormhole", branch = "reisen/sdk-solana"}
22-
wormhole-core = { git = "https://github.com/guibescos/wormhole", branch = "reisen/sdk-solana"}
21+
wormhole-solana = { git = "https://github.com/guibescos/wormhole-solana", rev="f14b3b54c1e37e1aaf8c2ac2a5e236832ffdb3c2"}
22+
wormhole-sdk = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.17.1" }
23+
serde_wormhole = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.17.1"}
2324
boolinator = "2.4.0"
2425

2526
[dev-dependencies]
27+
2628
solana-program-test = "=1.10.31"
2729
tokio = "1.14.1"
2830
solana-sdk = "=1.10.31"

governance/remote_executor/programs/remote-executor/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![deny(warnings)]
22
#![allow(clippy::result_unit_err)]
3+
#![allow(clippy::result_large_err)]
34

45
use {
56
anchor_lang::{
@@ -12,7 +13,7 @@ use {
1213
claim_record::ClaimRecord,
1314
posted_vaa::AnchorVaa,
1415
},
15-
wormhole::Chain::{
16+
wormhole_sdk::Chain::{
1617
self,
1718
Solana,
1819
},

governance/remote_executor/programs/remote-executor/src/state/governance_payload.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use {
1010
mem::size_of,
1111
ops::Deref,
1212
},
13-
wormhole::Chain,
13+
wormhole_sdk::Chain,
1414
};
1515

1616
pub const MAGIC_NUMBER: u32 = 0x4d475450; // Reverse order of the solidity contract because borsh uses little endian numbers (the solidity contract uses 0x5054474d)

governance/remote_executor/programs/remote-executor/src/tests/executor_simulator.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use {
3131
ToAccountMetas,
3232
},
3333
solana_program_test::{
34-
find_file,
3534
read_file,
3635
BanksClient,
3736
BanksClientError,
@@ -54,8 +53,11 @@ use {
5453
TransactionError,
5554
},
5655
},
57-
std::collections::HashMap,
58-
wormhole::Chain,
56+
std::{
57+
collections::HashMap,
58+
path::Path,
59+
},
60+
wormhole_sdk::Chain,
5961
wormhole_solana::VAA,
6062
};
6163

@@ -81,9 +83,12 @@ pub enum VaaAttack {
8183
impl ExecutorBench {
8284
/// Deploys the executor program as upgradable
8385
pub fn new() -> ExecutorBench {
84-
let mut bpf_data = read_file(find_file("remote_executor.so").unwrap_or_else(|| {
85-
panic!("Unable to locate {}", "remote_executor.so");
86-
}));
86+
let mut bpf_data = read_file(
87+
std::env::current_dir()
88+
.unwrap()
89+
.join(Path::new("../../target/deploy/remote_executor.so")),
90+
);
91+
8792

8893
let mut program_test = ProgramTest::default();
8994
let program_key = crate::id();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "1.66.1"

0 commit comments

Comments
 (0)