From 0dd2241fc17f36d6225d89ba0f8313bca8cb58d0 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Wed, 23 Oct 2024 15:23:49 +1000 Subject: [PATCH 1/3] Fix breaking changes in latest stable and nightly rust --- Makefile | 2 +- soroban-sdk-macros/src/arbitrary.rs | 32 +-- soroban-sdk/src/crypto.rs | 5 +- soroban-sdk/src/ledger.rs | 4 +- tests/fuzz/fuzz/Cargo.lock | 371 +++++++++++++++++++--------- 5 files changed, 265 insertions(+), 149 deletions(-) diff --git a/Makefile b/Makefile index f358ff6ef..cd36cfdf7 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ readme: cd soroban-sdk \ && cargo +nightly rustdoc -- -Zunstable-options -wjson \ && cat ../target/doc/soroban_sdk.json \ - | jq -r '.index[.root].docs' \ + | jq -r '.index[.root|tostring].docs' \ > README.md watch: diff --git a/soroban-sdk-macros/src/arbitrary.rs b/soroban-sdk-macros/src/arbitrary.rs index 07044aba7..f9df4cf64 100644 --- a/soroban-sdk-macros/src/arbitrary.rs +++ b/soroban-sdk-macros/src/arbitrary.rs @@ -313,29 +313,19 @@ fn quote_arbitrary( arbitrary_ctor: TokenStream2, ) -> TokenStream2 { quote! { - // This allows us to create a scope to import std and arbitrary, while - // also keeping everything from the current scope. This is better than a - // module because: modules inside functions have surprisingly - // inconsistent scoping rules and visibility management is harder. - const _: () = { - // derive(Arbitrary) expects these two to be in scope - use #path::testutils::arbitrary::std; - use #path::testutils::arbitrary::arbitrary; + #[derive(#path::testutils::arbitrary::arbitrary::Arbitrary)] + #[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)] + #vis #arbitrary_type_decl - #[derive(#path::testutils::arbitrary::arbitrary::Arbitrary)] - #[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)] - #vis #arbitrary_type_decl + impl #path::testutils::arbitrary::SorobanArbitrary for #ident { + type Prototype = #arbitrary_type_ident; + } - impl #path::testutils::arbitrary::SorobanArbitrary for #ident { - type Prototype = #arbitrary_type_ident; + impl #path::TryFromVal<#path::Env, #arbitrary_type_ident> for #ident { + type Error = #path::ConversionError; + fn try_from_val(env: &#path::Env, v: &#arbitrary_type_ident) -> std::result::Result { + Ok(#arbitrary_ctor) } - - impl #path::TryFromVal<#path::Env, #arbitrary_type_ident> for #ident { - type Error = #path::ConversionError; - fn try_from_val(env: &#path::Env, v: &#arbitrary_type_ident) -> std::result::Result { - Ok(#arbitrary_ctor) - } - } - }; + } } } diff --git a/soroban-sdk/src/crypto.rs b/soroban-sdk/src/crypto.rs index c725ebcf0..d27cf1f0d 100644 --- a/soroban-sdk/src/crypto.rs +++ b/soroban-sdk/src/crypto.rs @@ -7,7 +7,7 @@ use crate::{ }; pub mod bls12_381; -/// A BytesN generated by a cryptographic hash function. +/// A `BytesN` generated by a cryptographic hash function. /// /// The `Hash` type contains a `BytesN` and can only be constructed in /// contexts where the value has been generated by a secure cryptographic @@ -177,7 +177,8 @@ impl Crypto { CryptoHazmat::new(env).secp256r1_verify(public_key, &message_digest.0, signature) } - /// Get a [Bls12_381] for accessing the bls12-381 functions. + /// Get a [Bls12_381][bls12_381::Bls12_381] for accessing the bls12-381 + /// functions. pub fn bls12_381(&self) -> bls12_381::Bls12_381 { bls12_381::Bls12_381::new(self.env()) } diff --git a/soroban-sdk/src/ledger.rs b/soroban-sdk/src/ledger.rs index 4b6b5a5a0..566b5d6dc 100644 --- a/soroban-sdk/src/ledger.rs +++ b/soroban-sdk/src/ledger.rs @@ -4,7 +4,7 @@ use crate::{env::internal, unwrap::UnwrapInfallible, BytesN, Env, TryIntoVal}; /// Ledger retrieves information about the current ledger. /// /// For more details about the ledger and the ledger header that the values in the Ledger are derived from, see: -/// - https://developers.stellar.org/docs/learn/encyclopedia/network-configuration/ledger-headers +/// - /// /// ### Examples /// @@ -83,7 +83,7 @@ impl Ledger { /// 00:00:00 UTC. /// /// For more details see: - /// - https://developers.stellar.org/docs/learn/encyclopedia/network-configuration/ledger-headers#close-time + /// - pub fn timestamp(&self) -> u64 { internal::Env::get_ledger_timestamp(self.env()) .unwrap_infallible() diff --git a/tests/fuzz/fuzz/Cargo.lock b/tests/fuzz/fuzz/Cargo.lock index d108f1c43..dfbec92eb 100644 --- a/tests/fuzz/fuzz/Cargo.lock +++ b/tests/fuzz/fuzz/Cargo.lock @@ -1,22 +1,19 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] -name = "addr2line" -version = "0.21.0" +name = "ahash" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ - "gimli", + "cfg-if", + "once_cell", + "version_check", + "zerocopy", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "android-tzdata" version = "0.1.1" @@ -42,37 +39,134 @@ dependencies = [ ] [[package]] -name = "autocfg" -version = "1.1.0" +name = "ark-bls12-381" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] [[package]] -name = "backtrace" -version = "0.3.69" +name = "ark-ec" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools", + "num-traits", + "zeroize", ] [[package]] -name = "base16ct" -version = "0.2.0" +name = "ark-ff" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest", + "itertools", + "num-bigint", + "num-traits", + "paste", + "rustc_version", + "zeroize", +] [[package]] -name = "base32" +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ce669cd6c8588f79e15cf450314f9638f967fc5770ff1c7c1deb0925ea7cfa" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" @@ -116,7 +210,7 @@ dependencies = [ "num-bigint", "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -208,21 +302,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37e366bff8cd32dd8754b0991fb66b279dc48f598c3a18914852a6673deef583" dependencies = [ "quote", - "syn", + "syn 2.0.39", ] [[package]] name = "curve25519-dalek" -version = "4.1.2" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ "cfg-if", "cpufeatures", "curve25519-dalek-derive", "digest", "fiat-crypto", - "platforms", "rustc_version", "subtle", "zeroize", @@ -236,7 +329,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -260,7 +353,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 2.0.39", ] [[package]] @@ -271,9 +364,15 @@ checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.39", ] +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + [[package]] name = "der" version = "0.7.6" @@ -284,6 +383,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "derive_arbitrary" version = "1.3.2" @@ -292,7 +402,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -315,9 +425,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "ecdsa" -version = "0.16.7" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", "digest", @@ -359,9 +469,9 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elliptic-curve" -version = "0.13.5" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", @@ -439,12 +549,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "gimli" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" - [[package]] name = "group" version = "0.13.0" @@ -462,6 +566,15 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + [[package]] name = "hashbrown" version = "0.14.3" @@ -551,9 +664,9 @@ checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590" [[package]] name = "itertools" -version = "0.11.0" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] @@ -584,9 +697,9 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.1" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if", "ecdsa", @@ -632,21 +745,6 @@ version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "miniz_oxide" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" -dependencies = [ - "adler", -] - [[package]] name = "num-bigint" version = "0.4.3" @@ -666,7 +764,7 @@ checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -688,15 +786,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "object" -version = "0.32.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.18.0" @@ -731,12 +820,6 @@ dependencies = [ "spki", ] -[[package]] -name = "platforms" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -750,7 +833,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2b0377b720bde721213a46cda1289b2f34abf0a436907cad91578c20de0454d" dependencies = [ "proc-macro2", - "syn", + "syn 2.0.39", ] [[package]] @@ -820,12 +903,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - [[package]] name = "rustc_version" version = "0.4.0" @@ -877,7 +954,7 @@ checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -918,7 +995,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -960,21 +1037,21 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "soroban-builtin-sdk-macros" -version = "21.2.0" +version = "22.0.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44877373b3dc6c662377cb1600e3a62706d75e484b6064f9cd22e467c676b159" +checksum = "8cdb13e8f4556fe89d2b1c8f529a66997e1d90fd6f10440dc5a1717f5f733251" dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] name = "soroban-env-common" -version = "21.2.0" +version = "22.0.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "590add16843a61b01844e19e89bccaaee6aa21dc76809017b0662c17dc139ee9" +checksum = "984c9a1a84c05599f5c9cb17d5fbb75fe1c7106598659a34d9da8a8f16d2c23f" dependencies = [ "arbitrary", "crate-git-revision", @@ -991,9 +1068,9 @@ dependencies = [ [[package]] name = "soroban-env-guest" -version = "21.2.0" +version = "22.0.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ec8dc43acdd6c7e7b371acf44fc1a7dac24934ae3b2f05fafd618818548176" +checksum = "570dfaa0f35b373a2f9793b89a1864caf68e9071c5c8a4100654aa3434b4fde1" dependencies = [ "soroban-env-common", "static_assertions", @@ -1001,11 +1078,14 @@ dependencies = [ [[package]] name = "soroban-env-host" -version = "21.2.0" +version = "22.0.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e25aaffe0c62eb65e0e349f725b4b8b13ad0764d78a15aab5bbccb5c4797726" +checksum = "e59d22359f8d372872b7630fc0dc6884c36356d5d33d3fca83d2b76e572c2a32" dependencies = [ - "backtrace", + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", "curve25519-dalek", "ecdsa", "ed25519-dalek", @@ -1034,9 +1114,9 @@ dependencies = [ [[package]] name = "soroban-env-macros" -version = "21.2.0" +version = "22.0.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e16b761459fdf3c4b62b24df3941498d14e5246e6fadfb4774ed8114d243aa4" +checksum = "76184b736ac2ce144461efbe7c3551ac2c2973fa144e32957bb2ae2d80467f64" dependencies = [ "itertools", "proc-macro2", @@ -1044,12 +1124,12 @@ dependencies = [ "serde", "serde_json", "stellar-xdr", - "syn", + "syn 2.0.39", ] [[package]] name = "soroban-ledger-snapshot" -version = "21.5.0" +version = "22.0.0-rc.2.1" dependencies = [ "serde", "serde_json", @@ -1061,7 +1141,7 @@ dependencies = [ [[package]] name = "soroban-sdk" -version = "21.5.0" +version = "22.0.0-rc.2.1" dependencies = [ "arbitrary", "bytes-lit", @@ -1079,7 +1159,7 @@ dependencies = [ [[package]] name = "soroban-sdk-macros" -version = "21.5.0" +version = "22.0.0-rc.2.1" dependencies = [ "crate-git-revision", "darling", @@ -1092,12 +1172,12 @@ dependencies = [ "soroban-spec", "soroban-spec-rust", "stellar-xdr", - "syn", + "syn 2.0.39", ] [[package]] name = "soroban-spec" -version = "21.5.0" +version = "22.0.0-rc.2.1" dependencies = [ "base64 0.13.1", "stellar-xdr", @@ -1107,7 +1187,7 @@ dependencies = [ [[package]] name = "soroban-spec-rust" -version = "21.5.0" +version = "22.0.0-rc.2.1" dependencies = [ "prettyplease", "proc-macro2", @@ -1115,7 +1195,7 @@ dependencies = [ "sha2", "soroban-spec", "stellar-xdr", - "syn", + "syn 2.0.39", "thiserror", ] @@ -1156,20 +1236,20 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "stellar-strkey" -version = "0.0.8" +version = "0.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12d2bf45e114117ea91d820a846fd1afbe3ba7d717988fee094ce8227a3bf8bd" +checksum = "5e3aa3ed00e70082cb43febc1c2afa5056b9bb3e348bbb43d0cd0aa88a611144" dependencies = [ - "base32", "crate-git-revision", + "data-encoding", "thiserror", ] [[package]] name = "stellar-xdr" -version = "21.2.0" +version = "22.0.0-rc.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2675a71212ed39a806e415b0dbf4702879ff288ec7f5ee996dda42a135512b50" +checksum = "c88dc0e928b9cb65ea43836b52560bb4ead3e32895f5019ca223dc7cd1966cbf" dependencies = [ "arbitrary", "base64 0.13.1", @@ -1193,6 +1273,17 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.39" @@ -1206,7 +1297,7 @@ dependencies = [ [[package]] name = "test_fuzz" -version = "21.5.0" +version = "22.0.0-rc.2.1" dependencies = [ "soroban-sdk", ] @@ -1237,7 +1328,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -1312,7 +1403,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.39", "wasm-bindgen-shared", ] @@ -1334,7 +1425,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1470,8 +1561,42 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "zeroize" -version = "1.6.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] From cea49c09a6fb43117b8bfcd39f3056ea7ef34ee7 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Wed, 23 Oct 2024 23:13:46 +1000 Subject: [PATCH 2/3] fix arbitrary issue another way --- .github/workflows/rust.yml | 6 +++--- Makefile | 11 +++++----- soroban-sdk-macros/src/arbitrary.rs | 32 +++++++++++++++++++---------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ebde4e671..cd42b8407 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -131,7 +131,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: stellar/actions/rust-cache@main - - run: rustup install nightly + - run: rustup install nightly-2024-10-10 - uses: stellar/binaries@v15 with: name: cargo-fuzz @@ -143,7 +143,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: stellar/actions/rust-cache@main - - run: rustup install nightly + - run: rustup install nightly-2024-10-10 - run: make doc readme: @@ -151,7 +151,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: stellar/actions/rust-cache@main - - run: rustup install nightly + - run: rustup install nightly-2024-10-10 - run: make readme - run: git add -N . && git diff HEAD --exit-code diff --git a/Makefile b/Makefile index cd36cfdf7..158a9e422 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,7 @@ CARGO_DOC_ARGS?=--open doc: fmt cargo test --doc -p soroban-sdk -p soroban-sdk-macros --features testutils,hazmat - # TODO: Upgrade to latest nightly after problem that was introduced in nightly-2024-02-05 (https://github.com/dalek-cryptography/curve25519-dalek/issues/618) is resolved. - cargo +nightly doc -p soroban-sdk --no-deps --all-features $(CARGO_DOC_ARGS) + cargo +nightly-2024-10-10 doc -p soroban-sdk --no-deps --all-features $(CARGO_DOC_ARGS) test: fmt build cargo hack --feature-powerset --ignore-unknown-features --features testutils --exclude-features docs test @@ -24,11 +23,13 @@ check: build fmt cargo hack check --release --target wasm32-unknown-unknown build-fuzz: - cd tests/fuzz/fuzz && cargo +nightly fuzz check + # Allow warnings when using nightly until https://github.com/rust-lang/rust/issues/131643 is fixed. + cd tests/fuzz/fuzz && cargo +nightly-2024-10-10 fuzz check readme: + # Allow warnings when using nightly until https://github.com/rust-lang/rust/issues/131643 is fixed. cd soroban-sdk \ - && cargo +nightly rustdoc -- -Zunstable-options -wjson \ + && cargo +nightly-2024-10-10 rustdoc -- -Zunstable-options -wjson \ && cat ../target/doc/soroban_sdk.json \ | jq -r '.index[.root|tostring].docs' \ > README.md @@ -37,7 +38,7 @@ watch: cargo watch --clear --watch-when-idle --shell '$(MAKE)' watch-doc: - cargo +nightly watch --clear --watch-when-idle --shell '$(MAKE) doc CARGO_DOC_ARGS=' + cargo +nightly-2024-10-10 watch --clear --watch-when-idle --shell '$(MAKE) doc CARGO_DOC_ARGS=' fmt: cargo fmt --all diff --git a/soroban-sdk-macros/src/arbitrary.rs b/soroban-sdk-macros/src/arbitrary.rs index f9df4cf64..07044aba7 100644 --- a/soroban-sdk-macros/src/arbitrary.rs +++ b/soroban-sdk-macros/src/arbitrary.rs @@ -313,19 +313,29 @@ fn quote_arbitrary( arbitrary_ctor: TokenStream2, ) -> TokenStream2 { quote! { - #[derive(#path::testutils::arbitrary::arbitrary::Arbitrary)] - #[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)] - #vis #arbitrary_type_decl + // This allows us to create a scope to import std and arbitrary, while + // also keeping everything from the current scope. This is better than a + // module because: modules inside functions have surprisingly + // inconsistent scoping rules and visibility management is harder. + const _: () = { + // derive(Arbitrary) expects these two to be in scope + use #path::testutils::arbitrary::std; + use #path::testutils::arbitrary::arbitrary; - impl #path::testutils::arbitrary::SorobanArbitrary for #ident { - type Prototype = #arbitrary_type_ident; - } + #[derive(#path::testutils::arbitrary::arbitrary::Arbitrary)] + #[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)] + #vis #arbitrary_type_decl - impl #path::TryFromVal<#path::Env, #arbitrary_type_ident> for #ident { - type Error = #path::ConversionError; - fn try_from_val(env: &#path::Env, v: &#arbitrary_type_ident) -> std::result::Result { - Ok(#arbitrary_ctor) + impl #path::testutils::arbitrary::SorobanArbitrary for #ident { + type Prototype = #arbitrary_type_ident; } - } + + impl #path::TryFromVal<#path::Env, #arbitrary_type_ident> for #ident { + type Error = #path::ConversionError; + fn try_from_val(env: &#path::Env, v: &#arbitrary_type_ident) -> std::result::Result { + Ok(#arbitrary_ctor) + } + } + }; } } From 06c91a88b9378db7d0270c9d1af227bf2b74f156 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Wed, 23 Oct 2024 23:16:15 +1000 Subject: [PATCH 3/3] add comments --- .github/workflows/rust.yml | 3 +++ Makefile | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cd42b8407..c3216a244 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -131,6 +131,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: stellar/actions/rust-cache@main + # TODO: Unpin nightly version after https://github.com/rust-lang/rust/issues/131643 is fixed. - run: rustup install nightly-2024-10-10 - uses: stellar/binaries@v15 with: @@ -143,6 +144,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: stellar/actions/rust-cache@main + # TODO: Unpin nightly version after https://github.com/rust-lang/rust/issues/131643 is fixed. - run: rustup install nightly-2024-10-10 - run: make doc @@ -151,6 +153,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: stellar/actions/rust-cache@main + # TODO: Unpin nightly version after https://github.com/rust-lang/rust/issues/131643 is fixed. - run: rustup install nightly-2024-10-10 - run: make readme - run: git add -N . && git diff HEAD --exit-code diff --git a/Makefile b/Makefile index 158a9e422..f21ac1d91 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ CARGO_DOC_ARGS?=--open doc: fmt cargo test --doc -p soroban-sdk -p soroban-sdk-macros --features testutils,hazmat + # TODO: Unpin nightly version after https://github.com/rust-lang/rust/issues/131643 is fixed. cargo +nightly-2024-10-10 doc -p soroban-sdk --no-deps --all-features $(CARGO_DOC_ARGS) test: fmt build @@ -23,11 +24,11 @@ check: build fmt cargo hack check --release --target wasm32-unknown-unknown build-fuzz: - # Allow warnings when using nightly until https://github.com/rust-lang/rust/issues/131643 is fixed. + # TODO: Unpin nightly version after https://github.com/rust-lang/rust/issues/131643 is fixed. cd tests/fuzz/fuzz && cargo +nightly-2024-10-10 fuzz check readme: - # Allow warnings when using nightly until https://github.com/rust-lang/rust/issues/131643 is fixed. + # TODO: Unpin nightly version after https://github.com/rust-lang/rust/issues/131643 is fixed. cd soroban-sdk \ && cargo +nightly-2024-10-10 rustdoc -- -Zunstable-options -wjson \ && cat ../target/doc/soroban_sdk.json \