From 3e762aa985f88c347a65f7f6ac36e3eab740159c Mon Sep 17 00:00:00 2001 From: guibescos <59208140+guibescos@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:31:36 +0000 Subject: [PATCH] [Near] Bump wormhole (#1239) * Try * Near * revert * Try to add CI * Cleanup * Cleanup * Fmt * cleanup * Fix CI * Cleanup * Cleanup * Cleanup rust toolchains * Pin to tag --- .github/workflows/ci-near-contract.yml | 29 ++++ target_chains/near/example/rust-toolchain | 1 - target_chains/near/receiver/Cargo.lock | 141 ++++++++++++------ target_chains/near/receiver/Cargo.toml | 12 +- target_chains/near/receiver/rust-toolchain | 1 - target_chains/near/receiver/src/governance.rs | 28 ++-- target_chains/near/receiver/src/lib.rs | 17 +-- target_chains/near/receiver/src/state.rs | 6 +- .../near/receiver/tests/workspaces.rs | 104 ++++++------- target_chains/near/rust-toolchain.toml | 2 + .../near/wormhole-stub/rust-toolchain | 1 - 11 files changed, 210 insertions(+), 132 deletions(-) create mode 100644 .github/workflows/ci-near-contract.yml delete mode 100644 target_chains/near/example/rust-toolchain delete mode 100644 target_chains/near/receiver/rust-toolchain create mode 100644 target_chains/near/rust-toolchain.toml delete mode 100644 target_chains/near/wormhole-stub/rust-toolchain diff --git a/.github/workflows/ci-near-contract.yml b/.github/workflows/ci-near-contract.yml new file mode 100644 index 00000000..d97dee85 --- /dev/null +++ b/.github/workflows/ci-near-contract.yml @@ -0,0 +1,29 @@ +name: Test Near Contract + +on: + pull_request: + paths: + - target_chains/near/** + - wormhole_attester/sdk/rust/** + push: + branches: + - main + paths: + - target_chains/near/** + - wormhole_attester/sdk/rust/** + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-latest + defaults: + run: + working-directory: target_chains/near/receiver + steps: + - uses: actions/checkout@v2 + - name: Install nextest + run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin + - name: Test + run: ./workspace-test.sh diff --git a/target_chains/near/example/rust-toolchain b/target_chains/near/example/rust-toolchain deleted file mode 100644 index 5048afab..00000000 --- a/target_chains/near/example/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -1.69.0-x86_64-unknown-linux-gnu diff --git a/target_chains/near/receiver/Cargo.lock b/target_chains/near/receiver/Cargo.lock index 2a464d9b..c80ecfd6 100644 --- a/target_chains/near/receiver/Cargo.lock +++ b/target_chains/near/receiver/Cargo.lock @@ -286,18 +286,41 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" dependencies = [ - "borsh-derive", + "borsh-derive 0.9.3", "hashbrown 0.11.2", ] +[[package]] +name = "borsh" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +dependencies = [ + "borsh-derive 0.10.3", + "hashbrown 0.12.3", +] + [[package]] name = "borsh-derive" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" dependencies = [ - "borsh-derive-internal", - "borsh-schema-derive-internal", + "borsh-derive-internal 0.9.3", + "borsh-schema-derive-internal 0.9.3", + "proc-macro-crate 0.1.5", + "proc-macro2", + "syn 1.0.107", +] + +[[package]] +name = "borsh-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" +dependencies = [ + "borsh-derive-internal 0.10.3", + "borsh-schema-derive-internal 0.10.3", "proc-macro-crate 0.1.5", "proc-macro2", "syn 1.0.107", @@ -314,6 +337,17 @@ dependencies = [ "syn 1.0.107", ] +[[package]] +name = "borsh-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.107", +] + [[package]] name = "borsh-schema-derive-internal" version = "0.9.3" @@ -325,6 +359,17 @@ dependencies = [ "syn 1.0.107", ] +[[package]] +name = "borsh-schema-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.107", +] + [[package]] name = "bs58" version = "0.4.0" @@ -1018,6 +1063,9 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] [[package]] name = "heck" @@ -1371,7 +1419,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "885db39b08518fa700b73fa2214e8adbbfba316ba82dd510f50519173eadaf73" dependencies = [ - "borsh", + "borsh 0.9.3", "schemars", "semver", "serde", @@ -1383,7 +1431,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d258582a1878e6db67400b0504a5099db85718d22c2e07f747fe1706ae7150" dependencies = [ - "borsh", + "borsh 0.9.3", "serde", ] @@ -1393,7 +1441,7 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d924011380de759c3dc6fdbcda37a19a5c061f56dab69d28a34ecee765e23e4" dependencies = [ - "borsh", + "borsh 0.9.3", "serde", ] @@ -1424,7 +1472,7 @@ checksum = "1e75673d69fd7365508f3d32483669fe45b03bfb34e4d9363e90adae9dfb416c" dependencies = [ "arrayref", "blake2", - "borsh", + "borsh 0.9.3", "bs58", "c2-chacha", "curve25519-dalek", @@ -1450,7 +1498,7 @@ checksum = "7754612b47737d277fb818e9fdbb1406e90f9e57151c55c3584d714421976cb6" dependencies = [ "arrayref", "blake2", - "borsh", + "borsh 0.9.3", "bs58", "c2-chacha", "curve25519-dalek", @@ -1473,7 +1521,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d1335ffce1476da6516dcd22b26cece1a495fc725c0e8fec1879073752ac068d" dependencies = [ - "borsh", + "borsh 0.9.3", "lazy_static", "log", "near-chain-configs", @@ -1508,7 +1556,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ad1a9a1640539c81f065425c31bffcfbf6b31ef1aeaade59ce905f5df6ac860" dependencies = [ - "borsh", + "borsh 0.9.3", "byteorder", "bytesize", "chrono", @@ -1537,7 +1585,7 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97670b302dce15f09bba50f24c67aa08130fd01528cc61d4415892401e88e974" dependencies = [ - "borsh", + "borsh 0.9.3", "byteorder", "bytesize", "cfg-if 1.0.0", @@ -1568,7 +1616,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91d508f0fc340f6461e4e256417685720d3c4c00bb5a939b105160e49137caba" dependencies = [ "base64 0.11.0", - "borsh", + "borsh 0.9.3", "bs58", "derive_more", "near-account-id 0.14.0", @@ -1585,7 +1633,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7929e19d862221949734c4a0063a8f55e7069de3a2ebc2d4f4c13497a5e953cb" dependencies = [ "base64 0.13.1", - "borsh", + "borsh 0.9.3", "bs58", "derive_more", "near-account-id 0.15.0", @@ -1662,7 +1710,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15eb3de2defe3626260cc209a6cdb985c6b27b0bd4619fad97dcfae002c3c5bd" dependencies = [ "base64 0.13.1", - "borsh", + "borsh 0.9.3", "bs58", "near-abi", "near-crypto 0.14.0", @@ -1702,7 +1750,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0da466a30f0446639cbd788c30865086fac3e8dcb07a79e51d2b0775ed4261e" dependencies = [ - "borsh", + "borsh 0.9.3", "near-account-id 0.14.0", "near-rpc-error-macro 0.14.0", "serde", @@ -1714,7 +1762,7 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5591c9c8afa83a040cb5c3f29bc52b2efae2c32d4bcaee1bba723738da1a5cf6" dependencies = [ - "borsh", + "borsh 0.9.3", "near-account-id 0.15.0", "near-rpc-error-macro 0.15.0", "serde", @@ -1728,7 +1776,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81b534828419bacbf1f7b11ef7b00420f248c548c485d3f0cfda8bb6931152f2" dependencies = [ "base64 0.13.1", - "borsh", + "borsh 0.9.3", "bs58", "byteorder", "near-account-id 0.14.0", @@ -2136,12 +2184,12 @@ dependencies = [ "pythnet-sdk", "serde", "serde_json", - "serde_wormhole 0.1.0 (git+https://github.com/wormhole-foundation/wormhole)", + "serde_wormhole", "strum", "thiserror", "tokio", "workspaces", - "wormhole-core", + "wormhole-sdk", ] [[package]] @@ -2150,8 +2198,8 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5c805ba3dfb5b7ed6a8ffa62ec38391f485a79c7cf6b3b11d3bd44fb0325824" dependencies = [ - "borsh", - "borsh-derive", + "borsh 0.9.3", + "borsh-derive 0.9.3", "hex 0.4.3", "schemars", "serde", @@ -2163,8 +2211,8 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00bf2540203ca3c7a5712fdb8b5897534b7f6a0b6e7b0923ff00466c5f9efcb3" dependencies = [ - "borsh", - "borsh-derive", + "borsh 0.9.3", + "borsh-derive 0.9.3", "hex 0.4.3", "schemars", "serde", @@ -2184,7 +2232,7 @@ name = "pythnet-sdk" version = "2.0.0" dependencies = [ "bincode", - "borsh", + "borsh 0.10.3", "bytemuck", "byteorder", "fast-math", @@ -2530,22 +2578,31 @@ checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" [[package]] name = "serde" -version = "1.0.152" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] -name = "serde_derive" -version = "1.0.152" +name = "serde_bytes" +version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 2.0.38", ] [[package]] @@ -2596,20 +2653,12 @@ dependencies = [ [[package]] name = "serde_wormhole" version = "0.1.0" -source = "git+https://github.com/wormhole-foundation/wormhole?rev=4ddeca4dbdba50e2cbf6e603242f8c75d9246e2a#4ddeca4dbdba50e2cbf6e603242f8c75d9246e2a" -dependencies = [ - "itoa", - "serde", - "thiserror", -] - -[[package]] -name = "serde_wormhole" -version = "0.1.0" -source = "git+https://github.com/wormhole-foundation/wormhole#4ddeca4dbdba50e2cbf6e603242f8c75d9246e2a" +source = "git+https://github.com/wormhole-foundation/wormhole?tag=v2.23.37#846c2e9c9dce18a48745e79ba2ee7eaa5acaf1f4" dependencies = [ + "base64 0.13.1", "itoa", "serde", + "serde_bytes", "thiserror", ] @@ -3366,7 +3415,7 @@ dependencies = [ "async-process", "async-trait", "base64 0.13.1", - "borsh", + "borsh 0.9.3", "bs58", "chrono", "dirs 3.0.2", @@ -3391,15 +3440,15 @@ dependencies = [ ] [[package]] -name = "wormhole-core" +name = "wormhole-sdk" version = "0.1.0" -source = "git+https://github.com/wormhole-foundation/wormhole#4ddeca4dbdba50e2cbf6e603242f8c75d9246e2a" +source = "git+https://github.com/wormhole-foundation/wormhole?tag=v2.23.37#846c2e9c9dce18a48745e79ba2ee7eaa5acaf1f4" dependencies = [ "anyhow", "bstr", "schemars", "serde", - "serde_wormhole 0.1.0 (git+https://github.com/wormhole-foundation/wormhole?rev=4ddeca4dbdba50e2cbf6e603242f8c75d9246e2a)", + "serde_wormhole", "sha3", "thiserror", ] @@ -3446,7 +3495,7 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e61de68ede9ffdd69c01664f65a178c5188b73f78faa21f0936016a888ff7c" dependencies = [ - "borsh", + "borsh 0.9.3", "byteorder", "crunchy", "lazy_static", diff --git a/target_chains/near/receiver/Cargo.toml b/target_chains/near/receiver/Cargo.toml index 5353fbf3..e3f01372 100644 --- a/target_chains/near/receiver/Cargo.toml +++ b/target_chains/near/receiver/Cargo.toml @@ -22,22 +22,24 @@ num-derive = { version = "0.3.3" } pyth-wormhole-attester-sdk = { path = "../../../wormhole_attester/sdk/rust" } pyth-sdk = { version = "0.7.0" } pythnet-sdk = { path = "../../../pythnet/pythnet_sdk" } -serde_wormhole = { git = "https://github.com/wormhole-foundation/wormhole" } +serde_wormhole = { git = "https://github.com/wormhole-foundation/wormhole", tag="v2.23.37" } strum = { version = "0.24.1", features = ["derive"] } thiserror = { version = "1.0.38" } -wormhole-core = { git = "https://github.com/wormhole-foundation/wormhole" } +wormhole-sdk = { git = "https://github.com/wormhole-foundation/wormhole", tag="v2.23.37" } [patch.crates-io] -serde_wormhole = { git = "https://github.com/wormhole-foundation/wormhole", rev = "4ddeca4dbdba50e2cbf6e603242f8c75d9246e2a" } +serde_wormhole = { git = "https://github.com/wormhole-foundation/wormhole", tag="v2.23.37" } [dev-dependencies] lazy_static = { version = "1.4.0" } serde_json = { version = "1.0.91" } serde = { version = "1.0.152", features = ["derive"] } tokio = { version = "1.23.0", features = ["full"] } -serde_wormhole = { git = "https://github.com/wormhole-foundation/wormhole" } +serde_wormhole = { git = "https://github.com/wormhole-foundation/wormhole", tag="v2.23.37" } workspaces = { version = "0.7.0" } -wormhole-core = { git = "https://github.com/wormhole-foundation/wormhole" } +wormhole-sdk = { git = "https://github.com/wormhole-foundation/wormhole", tag="v2.23.37" } + + [profile.release] codegen-units = 1 diff --git a/target_chains/near/receiver/rust-toolchain b/target_chains/near/receiver/rust-toolchain deleted file mode 100644 index 5048afab..00000000 --- a/target_chains/near/receiver/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -1.69.0-x86_64-unknown-linux-gnu diff --git a/target_chains/near/receiver/src/governance.rs b/target_chains/near/receiver/src/governance.rs index 9da19a23..d052e6e9 100644 --- a/target_chains/near/receiver/src/governance.rs +++ b/target_chains/near/receiver/src/governance.rs @@ -35,8 +35,9 @@ use { PromiseOrValue, }, num_traits::FromPrimitive, + serde_wormhole::RawMessage, strum::EnumDiscriminants, - wormhole::Chain as WormholeChain, + wormhole_sdk::Chain as WormholeChain, }; /// Magic Header for identifying Governance VAAs. @@ -263,9 +264,8 @@ impl Pyth { // signatures. Avoids a cross-contract call early. { let vaa = hex::decode(&vaa).map_err(|_| InvalidHex)?; - let vaa = serde_wormhole::from_slice_with_payload::>(&vaa); - let vaa = vaa.map_err(|_| InvalidVaa)?; - let (vaa, _rest) = vaa; + let vaa: wormhole_sdk::Vaa<&RawMessage> = + serde_wormhole::from_slice(&vaa).map_err(|_| InvalidVaa)?; // Convert to local VAA type to catch API changes. let vaa = Vaa::from(vaa); @@ -323,11 +323,11 @@ impl Pyth { // at this point so we only care about the `rest` component which contains bytes we can // deserialize into an Action. let vaa = hex::decode(vaa).map_err(|_| InvalidPayload)?; - let (vaa, rest): (wormhole::Vaa<()>, _) = - serde_wormhole::from_slice_with_payload(&vaa).map_err(|_| InvalidPayload)?; + let vaa: wormhole_sdk::Vaa<&RawMessage> = + serde_wormhole::from_slice(&vaa).map_err(|_| InvalidPayload)?; // Deserialize and verify the action is destined for this chain. - let instruction = GovernanceInstruction::deserialize(rest)?; + let instruction = GovernanceInstruction::deserialize(vaa.payload)?; ensure!( instruction.target == Chain::from(WormholeChain::Near) @@ -345,7 +345,7 @@ impl Pyth { self.executed_governance_vaa = vaa.sequence; - match GovernanceInstruction::deserialize(rest)?.action { + match GovernanceInstruction::deserialize(vaa.payload)?.action { SetDataSources { data_sources } => self.set_sources(data_sources), SetFee { base, expo } => self.set_update_fee(base, expo)?, SetValidPeriod { valid_seconds } => self.set_valid_period(valid_seconds), @@ -428,15 +428,15 @@ impl Pyth { ensure!(is_promise_success(), VaaVerificationFailed); let vaa = hex::decode(claim_vaa).map_err(|_| InvalidPayload)?; - let (vaa, rest): (wormhole::Vaa<()>, _) = - serde_wormhole::from_slice_with_payload(&vaa).expect("Failed to deserialize VAA"); + let vaa: wormhole_sdk::Vaa<&RawMessage> = + serde_wormhole::from_slice(&vaa).expect("Failed to deserialize VAA"); // Convert to local VAA type to catch API changes. let vaa = Vaa::from(vaa); // Parse GovernanceInstruction from Payload. let instruction = - GovernanceInstruction::deserialize(rest).expect("Failed to deserialize action"); + GovernanceInstruction::deserialize(vaa.payload).expect("Failed to deserialize action"); // Execute the embedded VAA action. match instruction.action { @@ -722,9 +722,9 @@ mod tests { GovernanceActionId::AuthorizeGovernanceDataSourceTransfer => { let vaa = { - let vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + let vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), sequence: 1, payload: (), ..Default::default() diff --git a/target_chains/near/receiver/src/lib.rs b/target_chains/near/receiver/src/lib.rs index 4dc80059..761b9614 100644 --- a/target_chains/near/receiver/src/lib.rs +++ b/target_chains/near/receiver/src/lib.rs @@ -46,6 +46,7 @@ use { }, }, }, + serde_wormhole::RawMessage, state::{ Price, PriceFeed, @@ -273,11 +274,10 @@ impl Pyth { // at this point so we only care about the `rest` component which contains bytes we can // deserialize into an Action. let vaa = hex::decode(&vaa).unwrap(); - let (_, rest): (wormhole::Vaa<()>, _) = - serde_wormhole::from_slice_with_payload(&vaa).unwrap(); + let vaa: wormhole_sdk::Vaa<&RawMessage> = serde_wormhole::from_slice(&vaa).unwrap(); // Attempt to deserialize the Payload based on header. - let bytes = &mut Cursor::new(rest); + let bytes = &mut Cursor::new(vaa.payload); let mut header = [0u8; 4]; bytes.clone().read_exact(&mut header).unwrap(); @@ -357,9 +357,9 @@ impl Pyth { match update_data.proof { Proof::WormholeMerkle { vaa, updates } => { - let (_, rest): (wormhole::Vaa<()>, _) = - serde_wormhole::from_slice_with_payload(vaa.as_ref()).unwrap(); - let message = WormholeMessage::try_from_bytes(rest) + let vaa: wormhole_sdk::Vaa<&RawMessage> = + serde_wormhole::from_slice(vaa.as_ref()).unwrap(); + let message = WormholeMessage::try_from_bytes(vaa.payload) .map_err(|_| Error::InvalidWormholeMessage)?; let root: MerkleRoot = MerkleRoot::new(match message.payload { WormholePayload::Merkle(merkle_root) => merkle_root.root, @@ -550,11 +550,10 @@ impl Pyth { impl Pyth { /// Verify a VAA source from a serialized VAA. fn verify_encoded_vaa_source(&self, vaa: &[u8]) -> Result<(), Error> { - let (vaa, _): (wormhole::Vaa<()>, _) = - serde_wormhole::from_slice_with_payload(vaa).unwrap(); + let vaa: wormhole_sdk::Vaa<&RawMessage> = serde_wormhole::from_slice(vaa).unwrap(); // Convert to local VAA type to catch API changes. - let vaa = Vaa::from(vaa); + let vaa: Vaa<&RawMessage> = Vaa::from(vaa); if !self.sources.contains(&Source { emitter: vaa.emitter_address, diff --git a/target_chains/near/receiver/src/state.rs b/target_chains/near/receiver/src/state.rs index a4a12505..e1c0659a 100644 --- a/target_chains/near/receiver/src/state.rs +++ b/target_chains/near/receiver/src/state.rs @@ -16,7 +16,7 @@ use { }, pyth_wormhole_attester_sdk::PriceAttestation, pythnet_sdk::messages::PriceFeedMessage, - wormhole::Chain as WormholeChain, + wormhole_sdk::Chain as WormholeChain, }; /// Type alias for Wormhole's compact Signature format. @@ -225,8 +225,8 @@ pub struct Vaa

{ pub payload: P, } -impl

From> for Vaa

{ - fn from(vaa: wormhole::Vaa

) -> Self { +impl

From> for Vaa

{ + fn from(vaa: wormhole_sdk::Vaa

) -> Self { Self { version: vaa.version, guardian_set_index: vaa.guardian_set_index, diff --git a/target_chains/near/receiver/tests/workspaces.rs b/target_chains/near/receiver/tests/workspaces.rs index bdccc26f..e4b4b7c1 100644 --- a/target_chains/near/receiver/tests/workspaces.rs +++ b/target_chains/near/receiver/tests/workspaces.rs @@ -48,7 +48,7 @@ use { Cursor, Write, }, - wormhole::Chain as WormholeChain, + wormhole_sdk::Chain as WormholeChain, }; async fn initialize_chain() -> ( @@ -112,9 +112,9 @@ async fn test_set_sources() { let (_, contract, _) = initialize_chain().await; // Submit a new Source to the contract, this will trigger a cross-contract call to wormhole - let vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + let vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), sequence: 1, payload: (), ..Default::default() @@ -178,18 +178,18 @@ async fn test_set_governance_source() { let (_, contract, _) = initialize_chain().await; // Submit a new Source to the contract, this will trigger a cross-contract call to wormhole - let vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + let vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), payload: (), sequence: 2, ..Default::default() }; let vaa = { - let request_vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Solana, - emitter_address: wormhole::Address([1; 32]), + let request_vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Solana, + emitter_address: wormhole_sdk::Address([1; 32]), payload: (), sequence: 1, ..Default::default() @@ -247,10 +247,10 @@ async fn test_set_governance_source() { .is_empty()); // An action from the new source should now be accepted. - let vaa = wormhole::Vaa { + let vaa = wormhole_sdk::Vaa { sequence: 3, // NOTE: Incremented Governance Sequence - emitter_chain: wormhole::Chain::Solana, - emitter_address: wormhole::Address([1; 32]), + emitter_chain: wormhole_sdk::Chain::Solana, + emitter_address: wormhole_sdk::Address([1; 32]), payload: (), ..Default::default() }; @@ -295,10 +295,10 @@ async fn test_set_governance_source() { .is_empty()); // But not from the old source. - let vaa = wormhole::Vaa { + let vaa = wormhole_sdk::Vaa { sequence: 4, // NOTE: Incremented Governance Sequence - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), payload: (), ..Default::default() }; @@ -348,9 +348,9 @@ async fn test_stale_threshold() { let (_, contract, _) = initialize_chain().await; // Submit a Price Attestation to the contract. - let vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + let vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), payload: (), sequence: 1, ..Default::default() @@ -440,9 +440,9 @@ async fn test_stale_threshold() { // Submit another Price Attestation to the contract with an even older timestamp. Which // should now fail due to the existing newer price. - let vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + let vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), sequence: 2, payload: (), ..Default::default() @@ -516,9 +516,9 @@ async fn test_stale_threshold() { ); // Now we extend the staleness threshold with a Governance VAA. - let vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + let vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), sequence: 3, payload: (), ..Default::default() @@ -586,9 +586,9 @@ async fn test_contract_fees() { .as_secs(); // Set a high fee for the contract needed to submit a price. - let vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + let vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), payload: (), sequence: 1, ..Default::default() @@ -658,9 +658,9 @@ async fn test_contract_fees() { ); // Attempt to update the price feed with a now too low deposit. - let vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + let vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), sequence: 2, payload: (), ..Default::default() @@ -734,9 +734,9 @@ async fn test_same_governance_sequence_fails() { let (_, contract, _) = initialize_chain().await; // Set a high fee for the contract needed to submit a price. - let vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + let vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), payload: (), sequence: 1, ..Default::default() @@ -798,9 +798,9 @@ async fn test_out_of_order_sequences_fail() { let (_, contract, _) = initialize_chain().await; // Set a high fee for the contract needed to submit a price. - let vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + let vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), payload: (), sequence: 1, ..Default::default() @@ -839,9 +839,9 @@ async fn test_out_of_order_sequences_fail() { .is_empty()); // Generate another VAA with sequence 3. - let vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + let vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), payload: (), sequence: 3, ..Default::default() @@ -880,9 +880,9 @@ async fn test_out_of_order_sequences_fail() { .is_empty()); // Generate another VAA with sequence 2. - let vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + let vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), payload: (), sequence: 2, ..Default::default() @@ -926,9 +926,9 @@ async fn test_out_of_order_sequences_fail() { async fn test_governance_target_fails_if_not_near() { let (_, contract, _) = initialize_chain().await; - let vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + let vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), payload: (), sequence: 1, ..Default::default() @@ -1000,9 +1000,9 @@ async fn test_accumulator_updates() { root: root_hash, })); - let vaa = wormhole::Vaa { + let vaa = wormhole_sdk::Vaa { emitter_chain: emitter_chain.into(), - emitter_address: wormhole::Address(emitter_address), + emitter_address: wormhole_sdk::Address(emitter_address), sequence: 2, payload: (), ..Default::default() @@ -1045,16 +1045,16 @@ async fn test_accumulator_updates() { price_updates, tree, [1; 32], - wormhole::Chain::Any.into(), + wormhole_sdk::Chain::Any.into(), ) } let (_, contract, _) = initialize_chain().await; // Submit a new Source to the contract, this will trigger a cross-contract call to wormhole - let vaa = wormhole::Vaa { - emitter_chain: wormhole::Chain::Any, - emitter_address: wormhole::Address([0; 32]), + let vaa = wormhole_sdk::Vaa { + emitter_chain: wormhole_sdk::Chain::Any, + emitter_address: wormhole_sdk::Address([0; 32]), sequence: 1, payload: (), ..Default::default() diff --git a/target_chains/near/rust-toolchain.toml b/target_chains/near/rust-toolchain.toml new file mode 100644 index 00000000..f2415f83 --- /dev/null +++ b/target_chains/near/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.69.0" diff --git a/target_chains/near/wormhole-stub/rust-toolchain b/target_chains/near/wormhole-stub/rust-toolchain deleted file mode 100644 index 5048afab..00000000 --- a/target_chains/near/wormhole-stub/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -1.69.0-x86_64-unknown-linux-gnu