Skip to content

Commit f7f6f4e

Browse files
committed
Merge branch 'pyth-stylus-governance-impl' of https://github.com/pyth-network/pyth-crosschain into pyth-stylus-governance-impl
2 parents 066d45d + b8f6dad commit f7f6f4e

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

target_chains/stylus/contracts/pyth-receiver/src/pyth_governance_test.rs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -194,25 +194,33 @@ mod test {
194194
) {
195195
pyth_wormhole_init(&pyth_contract, &wormhole_contract, &alice, 0);
196196
197-
let hex_str = "010000000001001daf08e5e3799cbc6096a90c2361e43220325418f377620a7a73d6bece18322679f6ada9725d9081743805efb8bccecd51098f1d76f34cba8b835fae643bbd9c000000000100000000000100000000000000000000000000000000000000000000000000000000000000110000000000000001005054474d010600027e5f4552091a69125d5dfcb7b8c2659029395bdf";
198-
let bytes = Vec::from_hex(hex_str).expect("Invalid hex string");
199-
200-
let result = pyth_contract
201-
.sender(alice)
202-
.execute_governance_instruction(bytes.clone());
203-
if result.is_err() {
204-
println!(
205-
"SetWormholeAddress Error: {:?}",
206-
result.as_ref().unwrap_err()
207-
);
208-
}
209-
assert!(result.is_ok());
210-
211-
let result2 = pyth_contract
212-
.sender(alice)
213-
.execute_governance_instruction(bytes.clone());
214-
assert!(result2.is_err(), "Second execution should fail due to sequence number check");
197+
let guardians = vec![address!("0x7e5f4552091a69125d5dfcb7b8c2659029395bdf")];
198+
let governance_contract =
199+
Address::from_slice(&GOVERNANCE_CONTRACT.to_be_bytes::<32>()[12..32]);
200+
wormhole_contract_2
201+
.sender(alice)
202+
.initialize(
203+
guardians,
204+
0,
205+
CHAIN_ID,
206+
GOVERNANCE_CHAIN_ID,
207+
governance_contract,
208+
)
209+
.unwrap();
210+
211+
212+
213+
let hex_str = format!("010000000001001daf08e5e3799cbc6096a90c2361e43220325418f377620a7a73d6bece18322679f6ada9725d9081743805efb8bccecd51098f1d76f34cba8b835fae643bbd9c000000000100000000000100000000000000000000000000000000000000000000000000000000000000110000000000000001005054474d01060002{:040x}", wormhole_contract_2.address());
214+
let bytes = Vec::from_hex(&hex_str).expect("Invalid hex string");
215215
216+
let result = pyth_contract
217+
.sender(alice)
218+
.execute_governance_instruction(bytes.clone());
219+
if result.is_err() {
220+
println!(
221+
"SetWormholeAddress Error: {:?}",
222+
result.as_ref().unwrap_err()
223+
);
216224
}
217225
*/
218226

target_chains/stylus/contracts/wormhole/src/lib.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,8 @@ impl WormholeContract {
331331

332332
fn verify_vm(&self, vaa: &VerifiedVM) -> Result<(), WormholeError> {
333333
let guardian_set = self.get_gs_internal(vaa.guardian_set_index)?;
334-
if vaa.guardian_set_index
335-
!= self
336-
.current_guardian_set_index
337-
.get()
338-
.try_into()
339-
.unwrap_or(0u32)
340-
&& guardian_set.expiration_time > 0
341-
{
334+
let current_gsi = self.current_guardian_set_index.get().try_into().unwrap_or(0u32);
335+
if vaa.guardian_set_index != current_gsi && guardian_set.expiration_time > 0 {
342336
return Err(WormholeError::GuardianSetExpired);
343337
}
344338

0 commit comments

Comments
 (0)