Skip to content

Commit 8e11caa

Browse files
authored
Bump wormhole rust crates to v2.14.8, remove rent adjustment (#601)
This change upgrades our wormhole dependency to the current latest release. It introduces a fix in rent calculation logic, making Solitaire compatible with PythNet. This lets us get rid of dedicated rent adjustment logic, which we also remove in this change.
1 parent 4b00881 commit 8e11caa

File tree

11 files changed

+20
-105
lines changed

11 files changed

+20
-105
lines changed

target_chains/cosmwasm/Cargo.lock

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

target_chains/cosmwasm/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ codegen-units = 1
1212
panic = 'abort'
1313
incremental = false
1414
overflow-checks = true
15+
16+
[patch.crates-io]
17+
cw20-wrapped-2 = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.14.8"}

target_chains/cosmwasm/contracts/pyth/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ schemars = "0.8.1"
2020
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
2121
serde_derive = { version = "1.0.103"}
2222
terraswap = "2.4.0"
23-
wormhole-bridge-terra-2 = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.8.9", features = ["library"] }
23+
wormhole-bridge-terra-2 = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.14.8", features = ["library"] }
2424
thiserror = { version = "1.0.20" }
2525
k256 = { version = "0.9.4", default-features = false, features = ["ecdsa"] }
2626
sha3 = { version = "0.9.1", default-features = false }

tilt_devnet/docker_images/Dockerfile.solana

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ RUN cargo init --lib /tmp/decoy-crate && \
3131

3232
WORKDIR /usr/src/bridge
3333

34-
ARG WORMHOLE_REV=2.14.7
34+
ARG WORMHOLE_REV=2.14.8
3535
ADD https://github.com/wormhole-foundation/wormhole/archive/refs/tags/v${WORMHOLE_REV}.tar.gz .
3636
RUN tar -xvf v${WORMHOLE_REV}.tar.gz
3737
RUN mv wormhole-${WORMHOLE_REV} wormhole

wormhole_attester/Cargo.lock

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

wormhole_attester/client/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ borsh = "=0.9.3"
2121
clap = {version = "3.1.18", features = ["derive"]}
2222
env_logger = "0.8.4"
2323
log = "0.4.14"
24-
wormhole-bridge-solana = {git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.8.9"}
24+
wormhole-bridge-solana = {git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.14.8"}
2525
pyth-wormhole-attester = {path = "../program"}
2626
pyth-wormhole-attester-sdk = { path = "../sdk/rust", features=["solana"] }
2727
pyth-sdk-solana = "0.6.1"
@@ -32,7 +32,7 @@ solana-client = "=1.10.31"
3232
solana-program = "=1.10.31"
3333
solana-sdk = "=1.10.31"
3434
solana-transaction-status = "=1.10.31"
35-
solitaire = {git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.8.9"}
35+
solitaire = {git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.14.8"}
3636
tokio = {version = "1", features = ["sync", "rt-multi-thread", "time"]}
3737
futures = "0.3.21"
3838
sha3 = "0.10.6"

wormhole_attester/program/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ trace = ["solitaire/trace", "wormhole-bridge-solana/trace"]
1515
no-entrypoint = []
1616

1717
[dependencies]
18-
wormhole-bridge-solana = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.8.9" }
19-
solitaire = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.8.9"}
20-
rocksalt = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.8.9"}
18+
wormhole-bridge-solana = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.14.8" }
19+
solitaire = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.14.8"}
20+
rocksalt = { git = "https://github.com/wormhole-foundation/wormhole", tag = "v2.14.8"}
2121
solana-program = "=1.10.31"
2222
borsh = "=0.9.3"
2323
pyth-client = "0.2.2"

wormhole_attester/program/src/attest.rs

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,9 @@ use {
2424
},
2525
solana_program::{
2626
clock::Clock,
27-
program::{
28-
invoke,
29-
invoke_signed,
30-
},
27+
program::invoke_signed,
3128
program_error::ProgramError,
3229
rent::Rent,
33-
system_instruction,
34-
sysvar::Sysvar as SolanaSysvar,
3530
},
3631
solitaire::{
3732
trace,
@@ -368,42 +363,5 @@ pub fn attest(ctx: &ExecutionContext, accs: &mut Attest, data: AttestData) -> So
368363
.as_slice(),
369364
)?;
370365

371-
// NOTE: 2022-09-05
372-
//
373-
// This part is added to avoid rent exemption error that is introduced using
374-
// a wrong implementation in solitaire
375-
//
376-
// This is done after the cross-contract call to get the proper account sizes
377-
// and avoid breaking wormhole call.
378-
//
379-
// It can be removed once wormhole mitigates this problem and upgrades its contract
380-
381-
// Checking the message account balance
382-
let wh_message_balance = accs.wh_message.info().lamports();
383-
let wh_message_rent_exempt = Rent::get()?.minimum_balance(accs.wh_message.info().data_len());
384-
385-
if wh_message_balance < wh_message_rent_exempt {
386-
let required_deposit = wh_message_rent_exempt - wh_message_balance;
387-
388-
let transfer_ix = system_instruction::transfer(
389-
accs.payer.key,
390-
accs.wh_message.info().key,
391-
required_deposit,
392-
);
393-
invoke(&transfer_ix, ctx.accounts)?
394-
}
395-
396-
// Checking the sequence account balance
397-
let wh_sequence_balance = accs.wh_sequence.info().lamports();
398-
let wh_sequence_rent_exempt = Rent::get()?.minimum_balance(accs.wh_sequence.data_len());
399-
400-
if wh_sequence_balance < wh_sequence_rent_exempt {
401-
let required_deposit = wh_sequence_rent_exempt - wh_sequence_balance;
402-
403-
let transfer_ix =
404-
system_instruction::transfer(accs.payer.key, accs.wh_sequence.key, required_deposit);
405-
invoke(&transfer_ix, ctx.accounts)?
406-
}
407-
408366
Ok(())
409367
}

wormhole_attester/program/src/initialize.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ use {
33
P2WConfigAccount,
44
Pyth2WormholeConfig,
55
},
6-
solana_program::{
7-
program::invoke,
8-
rent::Rent,
9-
system_instruction,
10-
sysvar::Sysvar,
11-
},
126
solitaire::{
137
trace,
148
AccountState,
@@ -41,21 +35,5 @@ pub fn initialize(
4135
.create(ctx, accs.payer.info().key, CreationLamports::Exempt)?;
4236
accs.new_config.1 = data;
4337

44-
// TODO(2022-09-05): Remove this rent collection after
45-
// sysvar-based rent calculation becomes mainline in Solitaire.
46-
let config_balance = accs.new_config.info().lamports();
47-
let config_rent_exempt = Rent::get()?.minimum_balance(accs.new_config.info().data_len());
48-
49-
if config_balance < config_rent_exempt {
50-
let required_deposit = config_rent_exempt - config_balance;
51-
52-
let transfer_ix = system_instruction::transfer(
53-
accs.payer.key,
54-
accs.new_config.info().key,
55-
required_deposit,
56-
);
57-
invoke(&transfer_ix, ctx.accounts)?
58-
}
59-
6038
Ok(())
6139
}

wormhole_attester/program/src/migrate.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@ use {
88
Pyth2WormholeConfig,
99
},
1010
solana_program::{
11-
program::invoke,
1211
program_error::ProgramError,
13-
rent::Rent,
14-
system_instruction,
1512
system_program,
16-
sysvar::Sysvar,
1713
},
1814
solitaire::{
1915
trace,
20-
AccountSize,
2116
AccountState,
2217
CreationLamports,
2318
ExecutionContext,
@@ -77,25 +72,6 @@ pub fn migrate(ctx: &ExecutionContext, accs: &mut Migrate, _data: ()) -> SoliRes
7772
.create(ctx, accs.payer.info().key, CreationLamports::Exempt)?;
7873
accs.new_config.1 = Pyth2WormholeConfig::from(old_config.clone());
7974

80-
// Adjust new config lamports
81-
// NOTE(2022-09-29): Necessary due to PythNet rent calculation
82-
// differences, remove when solitaire supports Rent::get()?
83-
let acc_lamports = accs.new_config.info().lamports();
84-
85-
let new_lamports = Rent::get()?.minimum_balance(accs.new_config.size());
86-
87-
let diff_lamports: u64 = (acc_lamports as i64 - new_lamports as i64).unsigned_abs();
88-
89-
if acc_lamports < new_lamports {
90-
// Less than enough lamports, debit the payer
91-
let transfer_ix = system_instruction::transfer(
92-
accs.payer.info().key,
93-
accs.new_config.info().key,
94-
diff_lamports,
95-
);
96-
invoke(&transfer_ix, ctx.accounts)?;
97-
}
98-
9975
// Reclaim old config lamports
10076

10177
// Save current balance

0 commit comments

Comments
 (0)