Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
73 changes: 71 additions & 2 deletions contract_manager/scripts/check_proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ import Web3 from "web3";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";

import { CosmWasmChain, EvmChain, SuiChain } from "../src/core/chains";
import { SuiLazerContract } from "../src/core/contracts";
import {
CosmWasmChain,
EvmChain,
IotaChain,
SuiChain,
} from "../src/core/chains";
import { IotaLazerContract, SuiLazerContract } from "../src/core/contracts";
import {
EvmEntropyContract,
EvmLazerContract,
Expand Down Expand Up @@ -317,6 +322,70 @@ async function main() {
console.log(` expected ${buildHash}`);
console.log(` found ${hash}`);
}
} else if (targetChainId.startsWith("iota_sui_")) {
const chain = Object.values(DefaultStore.chains).find(
(candidate) =>
candidate instanceof IotaChain &&
candidate.wormholeChainName === targetChainId,
);

if (!(chain instanceof IotaChain)) {
console.error(`'${targetChainId}' is not a valid IOTA chain`);
continue;
}

const packagePath = path.resolve(
scriptDir,
"../../lazer/contracts/iota",
);

const contracts = Object.values(DefaultStore.lazer_contracts)
.filter((contract) => contract instanceof IotaLazerContract)
.filter((contract) => contract.chain.getId() === chain.getId());

if (contracts.length === 0) {
console.error(
`Could not find valid IOTA Lazer contract for '${targetChainId}' in store`,
);
continue;
}

const client = chain.getProvider();
for (const contract of contracts) {
const info = await chain.getStatePackageInfo(
client,
contract.stateId,
);
if (BigInt(info.version) + 1n !== version) {
console.log(
"Proposal upgrade version does not follow current version:",
);
console.log(
` current version is ${info.version}, proposed ${version}`,
);
}

await chain.updateLazerMeta(
packagePath,
{
receiver_chain_id: chain.getWormholeChainId(),
version: version.toString(),
},
info.package,
);
const pkg = await chain.buildLazerPackage(
packagePath,
contract.wormholeStateId,
);
const buildHash = Buffer.from(pkg.digest).toString("hex");
if (buildHash !== hash) {
console.log(
"Proposal package digest does not match local build:",
);
console.log(` expected ${buildHash}`);
console.log(` found ${hash}`);
}
}
} else {
console.log(`Unsupported target chain '${targetChainId}'`);
}
Expand Down
6 changes: 6 additions & 0 deletions contract_manager/src/store/contracts/IotaLazerContracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@
"stateId": "0xf1d6ae91b61ae8aebafe81c016c87ad2405fa7bf0cc0378b8b5f84040a927792",
"type": "IotaLazerContract",
"wormholeStateId": "0xad261798ec5b6026082b495647837f97cb8b6b38c16ebc3060d331d35805a717"
},
{
"chain": "iota_mainnet",
"stateId": "0xbfaaf85f467dd5d9af0f064afb61ceb8c5f0f27c480d4a68ccd4d85cf1c634fb",
"type": "IotaLazerContract",
"wormholeStateId": "0x7fa7eb76e4c840102d2a57589b658c44ac506847f972c6fdacdf824cb8f53cb4"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@
"chain": "iota_testnet",
"stateId": "0xad261798ec5b6026082b495647837f97cb8b6b38c16ebc3060d331d35805a717",
"type": "IotaWormholeContract"
},
{
"chain": "iota_mainnet",
"stateId": "0x7fa7eb76e4c840102d2a57589b658c44ac506847f972c6fdacdf824cb8f53cb4",
"type": "IotaWormholeContract"
}
Comment on lines +17 to 21

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Second iota_mainnet wormhole entry does not collide with existing one

The PR adds a second iota_mainnet IotaWormholeContract entry (contract_manager/src/store/contracts/IotaWormholeContracts.json:17-21) alongside the existing one. The store keys contracts by getId() which combines chain and stateId (contract_manager/src/core/contracts/iota.ts:411-413), so the two entries have distinct IDs and won't trigger the Multiple contracts with id error in contract_manager/src/node/utils/store.ts:246-251. This mirrors the pre-existing pattern where iota_testnet already has two entries. No collision, but reviewers should confirm that consumers looking up a wormhole contract by chain (rather than by full id) handle multiple iota_mainnet entries as intended.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

]
4 changes: 2 additions & 2 deletions lazer/contracts/iota/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[move]
version = 3
manifest_digest = "66D9A4A0C94BE1F1B456FD17DCA458740FAB7FEB4B29B11D61C412901098FDF7"
manifest_digest = "BD847B302BA5DF359235AE531504B10E80B93ACBB05F27C1B6CE87733FA02AB2"
deps_digest = "397E6A9F7A624706DBDFEE056CE88391A15876868FD18A88504DA74EB458D697"
dependencies = [
{ id = "Iota", name = "Iota" },
Expand Down Expand Up @@ -44,7 +44,7 @@ dependencies = [

[[move.package]]
id = "wormhole"
source = { local = "vendor/wormhole_testnet" }
source = { local = "vendor/wormhole_mainnet" }

dependencies = [
{ id = "Iota", name = "Iota" },
Expand Down
3 changes: 2 additions & 1 deletion lazer/contracts/iota/Move.mainnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
[package]
name = "pyth_lazer"
edition = "2024"
published-at = "0x8aa43bd5c14eac8de636e2106f53a1cc9dc2bc0e1a1ad51c9846a0b167552e29"

[dependencies]
wormhole = { local = "./vendor/wormhole_mainnet" }

[addresses]
pyth_lazer = "0x0"
pyth_lazer = "0x8aa43bd5c14eac8de636e2106f53a1cc9dc2bc0e1a1ad51c9846a0b167552e29"
2 changes: 1 addition & 1 deletion lazer/contracts/iota/Move.toml
29 changes: 18 additions & 11 deletions lazer/contracts/iota/sources/actions.move
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,32 @@ public fun update_trusted_signer(state: &mut State, vaa: VAA) {

// TODO: test assumes current version 1 - make it parameterized?
#[test_only]
const TEST_UPGRADE_VAA: vector<u8> = vector[1,0,0,0,0,1,0,62,191,234,208,186,78,125,210,45,4,92,222,86,204,156,241,198,137,172,250,223,202,62,169,134,101,126,196,192,193,208,2,42,239,153,148,22,28,185,33,169,145,83,144,129,19,10,250,137,126,68,69,147,34,15,88,251,181,223,210,68,218,3,57,1,105,96,189,159,0,0,0,0,0,1,163,98,52,239,55,73,162,201,65,54,182,52,91,206,255,69,7,145,239,30,188,153,233,24,241,111,128,117,164,65,187,36,0,0,0,0,0,0,0,3,1,80,84,71,77,3,0,234,181,0,0,0,0,0,0,0,2,150,25,135,237,196,172,202,28,255,8,183,26,248,190,44,218,232,231,228,145,102,251,208,126,38,83,236,196,200,98,162,166];
const TEST_UPGRADE_VAA: vector<u8> = vector[1,0,0,0,0,1,0,62,191,234,208,186,78,125,210,45,4,92,222,86,204,156,241,198,137,172,250,223,202,62,169,134,101,126,196,192,193,208,2,42,239,153,148,22,28,185,33,169,145,83,144,129,19,10,250,137,126,68,69,147,34,15,88,251,181,223,210,68,218,3,57,1,105,96,189,159,0,0,0,0,0,1,163,98,52,239,55,73,162,201,65,54,182,52,91,206,255,69,7,145,239,30,188,153,233,24,241,111,128,117,164,65,187,36,0,0,0,0,0,0,0,3,1,80,84,71,77,3,0,195,198,0,0,0,0,0,0,0,2,150,25,135,237,196,172,202,28,255,8,183,26,248,190,44,218,232,231,228,145,102,251,208,126,38,83,236,196,200,98,162,166];

#[test_only]
const TEST_UPDATE_TRUSTED_SIGNER_ADD: vector<u8> = vector[1,0,0,0,0,1,0,130,99,43,67,229,38,185,128,163,7,136,200,43,255,225,6,91,170,185,122,98,216,114,251,178,140,39,95,47,69,81,168,71,44,182,30,4,172,249,65,194,69,202,90,80,3,247,96,179,73,252,64,129,83,157,178,236,208,160,223,104,216,209,8,1,105,96,163,154,0,0,0,0,0,1,163,98,52,239,55,73,162,201,65,54,182,52,91,206,255,69,7,145,239,30,188,153,233,24,241,111,128,117,164,65,187,36,0,0,0,0,0,0,0,2,1,80,84,71,77,3,1,234,181,3,164,56,15,1,19,110,178,100,15,144,193,126,30,49,158,2,187,175,190,239,46,110,103,220,72,175,83,249,130,126,21,91,0,0,0,0,107,65,2,245];
const TEST_UPDATE_TRUSTED_SIGNER_ADD: vector<u8> = vector[1,0,0,0,0,1,0,234,83,124,39,121,208,192,140,211,201,103,211,97,61,215,254,114,47,118,191,136,20,228,116,80,133,16,111,240,32,247,248,48,10,199,239,3,72,136,238,68,232,44,18,193,79,147,63,125,15,98,29,171,66,188,10,95,30,230,125,192,131,134,45,0,106,95,70,49,0,0,0,0,0,1,11,254,215,118,242,4,212,154,104,231,232,41,51,43,43,216,92,147,140,114,234,120,164,66,174,221,197,220,63,183,47,12,0,0,0,0,0,0,0,1,1,80,84,71,77,3,1,195,198,3,164,56,15,1,19,110,178,100,15,144,193,126,30,49,158,2,187,175,190,239,46,110,103,220,72,175,83,249,130,126,21,91,0,0,0,0,125,46,145,224];

#[test_only]
const TEST_UPDATE_TRUSTED_SIGNER_REMOVE: vector<u8> = vector[1,0,0,0,0,1,0,126,229,228,215,73,253,91,76,106,169,218,253,166,44,124,73,160,137,101,208,42,14,31,50,50,159,142,115,96,250,75,21,28,255,109,56,88,214,114,100,168,141,151,198,96,216,246,79,179,46,99,200,178,135,166,181,2,17,188,60,92,27,119,247,1,105,96,191,6,0,0,0,0,0,1,163,98,52,239,55,73,162,201,65,54,182,52,91,206,255,69,7,145,239,30,188,153,233,24,241,111,128,117,164,65,187,36,0,0,0,0,0,0,0,4,1,80,84,71,77,3,1,234,181,3,164,56,15,1,19,110,178,100,15,144,193,126,30,49,158,2,187,175,190,239,46,110,103,220,72,175,83,249,130,126,21,91,0,0,0,0,0,0,0,0];
const TEST_UPDATE_TRUSTED_SIGNER_REMOVE: vector<u8> = vector[1,0,0,0,0,1,0,126,229,228,215,73,253,91,76,106,169,218,253,166,44,124,73,160,137,101,208,42,14,31,50,50,159,142,115,96,250,75,21,28,255,109,56,88,214,114,100,168,141,151,198,96,216,246,79,179,46,99,200,178,135,166,181,2,17,188,60,92,27,119,247,1,105,96,191,6,0,0,0,0,0,1,163,98,52,239,55,73,162,201,65,54,182,52,91,206,255,69,7,145,239,30,188,153,233,24,241,111,128,117,164,65,187,36,0,0,0,0,0,0,0,4,1,80,84,71,77,3,1,195,198,3,164,56,15,1,19,110,178,100,15,144,193,126,30,49,158,2,187,175,190,239,46,110,103,220,72,175,83,249,130,126,21,91,0,0,0,0,0,0,0,0];

#[test_only]
const TEST_TRUSTED_SIGNER: vector<u8> = x"03a4380f01136eb2640f90c17e1e319e02bbafbeef2e6e67dc48af53f9827e155b";

#[test_only]
fun test_governance(): Governance {
governance::new(1, external_address::new(bytes32::new(
x"a36234ef3749a2c94136b6345bceff450791ef1ebc99e918f16f8075a441bb24"
)))
const TEST_GOVERNANCE_ADDRESS: vector<u8> = x"a36234ef3749a2c94136b6345bceff450791ef1ebc99e918f16f8075a441bb24";

#[test_only]
const TEST_UPDATE_TRUSTED_SIGNER_ADD_GOVERNANCE_ADDRESS: vector<u8> = x"0bfed776f204d49a68e7e829332b2bd85c938c72ea78a442aeddc5dc3fb72f0c";

#[test_only]
fun test_governance(address: vector<u8>): Governance {
governance::new(1, external_address::new(bytes32::new(address)))
}

#[test]
public fun test_upgrade() {
let mut ctx = tx_context::dummy();
let mut state = state::new_for_test(&mut ctx, test_governance());
let mut state = state::new_for_test(&mut ctx, test_governance(TEST_GOVERNANCE_ADDRESS));

let (_, verifiedVaa) = vaa::parse_test_only(TEST_UPGRADE_VAA);
let ticket = upgrade(&mut state, verifiedVaa);
Expand All @@ -106,7 +110,10 @@ public fun test_upgrade() {
#[test]
public fun test_update_trusted_signer_add() {
let mut ctx = tx_context::dummy();
let mut state = state::new_for_test(&mut ctx, test_governance());
let mut state = state::new_for_test(
&mut ctx,
test_governance(TEST_UPDATE_TRUSTED_SIGNER_ADD_GOVERNANCE_ADDRESS)
);
let current_cap = state.current_cap();

let (_, verifiedVaa) = vaa::parse_test_only(TEST_UPDATE_TRUSTED_SIGNER_ADD);
Expand All @@ -115,7 +122,7 @@ public fun test_update_trusted_signer_add() {
let signers = state.trusted_signers(&current_cap);
assert_eq!(signers.length(), 1);
let signer = &signers[0];
assert_eq!(signer.expires_at_ms(), 1799422709 * 1000);
assert_eq!(signer.expires_at_ms(), 2100204000 * 1000);
assert_eq!(*signer.public_key(), TEST_TRUSTED_SIGNER);

state.destroy();
Expand All @@ -124,7 +131,7 @@ public fun test_update_trusted_signer_add() {
#[test]
public fun test_update_trusted_signer_remove() {
let mut ctx = tx_context::dummy();
let mut state = state::new_for_test(&mut ctx, test_governance());
let mut state = state::new_for_test(&mut ctx, test_governance(TEST_GOVERNANCE_ADDRESS));
let current_cap = state.current_cap();

state.update_trusted_signer(&current_cap, TEST_TRUSTED_SIGNER, 1799422709);
Expand Down
2 changes: 1 addition & 1 deletion lazer/contracts/iota/sources/meta.move
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ public(package) fun version(): u64 {
/// - https://wormhole.com/docs/products/reference/chain-ids/#__tabbed_1_1
/// - `/governance/xc_admin/packages/xc_admin_common/src/chains.ts`
public(package) fun receiver_chain_id(): u16 {
50118
60085
}
50 changes: 50 additions & 0 deletions lazer/contracts/iota/vendor/wormhole_mainnet/Move.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 3
manifest_digest = "B4D3527E305AD310F2FB380F9ADEA958648C2D763EB756798C848A99F71677D5"
deps_digest = "F9B494B64F0615AED0E98FC12A85B85ECD2BC5185C22D30E7F67786BB52E507C"
dependencies = [
{ id = "Iota", name = "Iota" },
{ id = "IotaSystem", name = "IotaSystem" },
{ id = "MoveStdlib", name = "MoveStdlib" },
{ id = "Stardust", name = "Stardust" },
]

[[move.package]]
id = "Iota"
source = { git = "https://github.com/iotaledger/iota.git", rev = "efc8e49575112ad01a8d8a3b7973f86cc1c716a4", subdir = "crates/iota-framework/packages/iota-framework" }

dependencies = [
{ id = "MoveStdlib", name = "MoveStdlib" },
]

[[move.package]]
id = "IotaSystem"
source = { git = "https://github.com/iotaledger/iota.git", rev = "efc8e49575112ad01a8d8a3b7973f86cc1c716a4", subdir = "crates/iota-framework/packages/iota-system" }

dependencies = [
{ id = "Iota", name = "Iota" },
{ id = "MoveStdlib", name = "MoveStdlib" },
]

[[move.package]]
id = "MoveStdlib"
source = { git = "https://github.com/iotaledger/iota.git", rev = "efc8e49575112ad01a8d8a3b7973f86cc1c716a4", subdir = "crates/iota-framework/packages/move-stdlib" }

[[move.package]]
id = "Stardust"
source = { git = "https://github.com/iotaledger/iota.git", rev = "efc8e49575112ad01a8d8a3b7973f86cc1c716a4", subdir = "crates/iota-framework/packages/stardust" }

dependencies = [
{ id = "Iota", name = "Iota" },
{ id = "MoveStdlib", name = "MoveStdlib" },
]

[env]

[env.mainnet]
chain-id = "6364aad5"
original-published-id = "0x675bb3e3ca140ab1b0eac46ab4bb8b73bef365f544b77764a46d79267998ed48"
latest-published-id = "0x675bb3e3ca140ab1b0eac46ab4bb8b73bef365f544b77764a46d79267998ed48"
published-version = "1"
3 changes: 2 additions & 1 deletion lazer/contracts/iota/vendor/wormhole_mainnet/Move.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "wormhole"
version = "0.2.0"
published-at = "0x675bb3e3ca140ab1b0eac46ab4bb8b73bef365f544b77764a46d79267998ed48"

[addresses]
wormhole = "0x0"
wormhole = "0x675bb3e3ca140ab1b0eac46ab4bb8b73bef365f544b77764a46d79267998ed48"
Loading