From ef275d9f4a2e8e05f5b55ef9660d7d287765c593 Mon Sep 17 00:00:00 2001 From: Jay Geng Date: Mon, 24 Jun 2024 20:01:53 -0400 Subject: [PATCH] Revert "Check UDT enum integer must derive from `Copy` (#1264)" (#1283) ### What This reverts commit e43b3dbc463d510cf708b9e72a87794f348170c6. ### Why It only works if the `derive` attribute comes after the `contracttype` and is contained in a single list. i.e. below works ``` #[contracttype] #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum MyType ``` but these two don't ``` #[derive(Clone, Copy, PartialEq, Eq, Debug)] #[contracttype] pub enum MyType ``` ``` #[contracttype] #[derive(Clone, Copy)] #[derive(PartialEq, Eq, Debug)] pub enum MyType ``` ### Known limitations [TODO or N/A] --- .github/workflows/rust.yml | 6 +-- Cargo.lock | 37 ++++++++----------- Cargo.toml | 18 ++++----- soroban-sdk-macros/src/derive_enum_int.rs | 31 +--------------- soroban-sdk/Cargo.toml | 3 +- .../token_client/test_mock_all_auth.1.json | 4 +- .../tests/token_client/test_mock_auth.1.json | 2 +- .../test_a/test_with_mock_all_auth.1.json | 2 +- .../test_b/test_with_mock_all_auth.1.json | 2 +- 9 files changed, 36 insertions(+), 69 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index b809cce0f..bd64e0c3f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -62,11 +62,11 @@ jobs: steps: - uses: actions/checkout@v3 - run: rustup update - - uses: stellar/binaries@v18 + - uses: stellar/binaries@v24 with: name: cargo-semver-checks - version: 0.27.0 - - run: cargo semver-checks + version: 0.32.0 + - run: cargo semver-checks --baseline-version 21.1.0-rc.1 build-and-test: strategy: diff --git a/Cargo.lock b/Cargo.lock index c42572f61..a468bf1f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -240,16 +240,15 @@ dependencies = [ [[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", @@ -381,15 +380,16 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek", "ed25519", "rand_core", "serde", "sha2", + "subtle", "zeroize", ] @@ -782,12 +782,6 @@ dependencies = [ "spki", ] -[[package]] -name = "platforms" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" - [[package]] name = "powerfmt" version = "0.2.0" @@ -1111,9 +1105,9 @@ checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "soroban-builtin-sdk-macros" -version = "21.1.0" +version = "21.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084aab008009e712c445a9d7eab837a86559a6c2341f30bc4f33e9b258947688" +checksum = "4aa78f4b1c752f5471b033fe54279ef0617ace342be7be11acc7d90e5677790e" dependencies = [ "itertools", "proc-macro2", @@ -1123,9 +1117,9 @@ dependencies = [ [[package]] name = "soroban-env-common" -version = "21.1.0" +version = "21.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c16ee889fe99d6828bf3ffac00c84382793c31d62682401dbfa3e1b512f0c542" +checksum = "9acd7dbf8fc4222f62a4f06c5b32c3e097de97f5ff48218c8d77676d3424f363" dependencies = [ "arbitrary", "crate-git-revision", @@ -1142,9 +1136,9 @@ dependencies = [ [[package]] name = "soroban-env-guest" -version = "21.1.0" +version = "21.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95e591a15e488e66d3edd4be044fc4ffea438945f022c27129e933275744666f" +checksum = "558a69d53d543a4b1ac60681332594dc1417080cffd2a6851bb6e0a376ebc76f" dependencies = [ "soroban-env-common", "static_assertions", @@ -1152,9 +1146,9 @@ dependencies = [ [[package]] name = "soroban-env-host" -version = "21.1.0" +version = "21.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b73f48ae8081ecfb6c0d56c67f139c52cb6d5b6800d5e1adb9eef8e14a155b9" +checksum = "956beee1e959b7b8ac7bea8396454d1534927276830430bf015eafdc756d84ae" dependencies = [ "backtrace", "curve25519-dalek", @@ -1185,9 +1179,9 @@ dependencies = [ [[package]] name = "soroban-env-macros" -version = "21.1.0" +version = "21.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06d0581e3aba14892ee0ce63788f3d3e5d9eb1ab18906a9b7c66d77dae9e9fea" +checksum = "e04b96c8cf73c941ca134eefd00aa5085c4bcae5d534dd3937f4d69b401a838b" dependencies = [ "itertools", "proc-macro2", @@ -1218,6 +1212,7 @@ dependencies = [ "arbitrary", "bytes-lit", "ctor", + "curve25519-dalek", "ed25519-dalek", "hex", "proptest", diff --git a/Cargo.toml b/Cargo.toml index 18be48612..d953af01e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,19 +24,19 @@ soroban-ledger-snapshot = { version = "21.1.0-rc.1", path = "soroban-ledger-snap soroban-token-sdk = { version = "21.1.0-rc.1", path = "soroban-token-sdk" } [workspace.dependencies.soroban-env-common] -version = "=21.1.0" -#git = "https://github.com/stellar/rs-soroban-env" -#rev = "ad83e6cef73ca04f75d03ad1b0f43434886ce93b" +version = "=21.1.2" +# git = "https://github.com/stellar/rs-soroban-env" +# rev = "0c918ac2bd808ba1a850281c6b1c731e7fe50c53" [workspace.dependencies.soroban-env-guest] -version = "=21.1.0" -#git = "https://github.com/stellar/rs-soroban-env" -#rev = "ad83e6cef73ca04f75d03ad1b0f43434886ce93b" +version = "=21.1.2" +# git = "https://github.com/stellar/rs-soroban-env" +# rev = "0c918ac2bd808ba1a850281c6b1c731e7fe50c53" [workspace.dependencies.soroban-env-host] -version = "=21.1.0" -#git = "https://github.com/stellar/rs-soroban-env" -#rev = "ad83e6cef73ca04f75d03ad1b0f43434886ce93b" +version = "=21.1.2" +# git = "https://github.com/stellar/rs-soroban-env" +# rev = "0c918ac2bd808ba1a850281c6b1c731e7fe50c53" [workspace.dependencies.stellar-strkey] version = "=0.0.8" diff --git a/soroban-sdk-macros/src/derive_enum_int.rs b/soroban-sdk-macros/src/derive_enum_int.rs index cac271399..d38baa5b6 100644 --- a/soroban-sdk-macros/src/derive_enum_int.rs +++ b/soroban-sdk-macros/src/derive_enum_int.rs @@ -3,9 +3,7 @@ use proc_macro2::TokenStream as TokenStream2; use quote::{format_ident, quote}; use stellar_xdr::curr as stellar_xdr; use stellar_xdr::{ScSpecUdtEnumV0, StringM}; -use syn::{ - spanned::Spanned, Attribute, DataEnum, Error, ExprLit, Ident, Lit, Meta, Path, Visibility, -}; +use syn::{spanned::Spanned, Attribute, DataEnum, Error, ExprLit, Ident, Lit, Path, Visibility}; use stellar_xdr::{ScSpecEntry, ScSpecUdtEnumCaseV0, WriteXdr}; @@ -13,26 +11,6 @@ use crate::{doc::docs_from_attrs, DEFAULT_XDR_RW_LIMITS}; // TODO: Add conversions to/from ScVal types. -fn derives_copy(attrs: &[Attribute]) -> bool { - for attr in attrs { - if let Meta::List(ml) = &attr.meta { - if let Some(_ps) = ml.path.segments.iter().find(|ps| ps.ident == "derive") { - if let Some(_tt) = ml.tokens.clone().into_iter().find(|tt| { - // match this token with what we want - if let proc_macro2::TokenTree::Ident(id) = tt { - id == "Copy" - } else { - false - } - }) { - return true; - } - } - } - } - false -} - pub fn derive_type_enum_int( path: &Path, vis: &Visibility, @@ -45,13 +23,6 @@ pub fn derive_type_enum_int( // Collect errors as they are encountered and emit them at the end. let mut errors = Vec::::new(); - if !derives_copy(attrs) { - errors.push(Error::new( - enum_ident.span(), - format!("enum integer {enum_ident} must have `derive(Copy)`"), - )); - } - let variants = &data.variants; let (spec_cases, try_froms, try_intos): (Vec<_>, Vec<_>, Vec<_>) = variants .iter() diff --git a/soroban-sdk/Cargo.toml b/soroban-sdk/Cargo.toml index c37dd5f03..2fbc0eb5f 100644 --- a/soroban-sdk/Cargo.toml +++ b/soroban-sdk/Cargo.toml @@ -29,7 +29,8 @@ stellar-strkey = { workspace = true } arbitrary = { version = "1.3.0", features = ["derive"], optional = true } serde = { version = "1.0.0", features = ["derive"] } serde_json = "1.0.0" -ed25519-dalek = { version = "2.0.0", features = ["rand_core"], optional = true } +ed25519-dalek = { version = "2.1.1", features = ["rand_core"], optional = true } +curve25519-dalek = { version = "4.1.3", features = ["digest"], optional = true } # match the version of rand used in dalek rand = "0.8.5" ctor = { version = "0.2.1", optional = true } diff --git a/soroban-sdk/test_snapshots/tests/token_client/test_mock_all_auth.1.json b/soroban-sdk/test_snapshots/tests/token_client/test_mock_all_auth.1.json index 3b6708714..f1f70a18d 100644 --- a/soroban-sdk/test_snapshots/tests/token_client/test_mock_all_auth.1.json +++ b/soroban-sdk/test_snapshots/tests/token_client/test_mock_all_auth.1.json @@ -128,7 +128,7 @@ }, "ext": "v0" }, - 15 + 6311999 ] ], [ @@ -232,7 +232,7 @@ }, "ext": "v0" }, - 15 + 6311999 ] ], [ diff --git a/soroban-sdk/test_snapshots/tests/token_client/test_mock_auth.1.json b/soroban-sdk/test_snapshots/tests/token_client/test_mock_auth.1.json index b0a7256ad..3e380b061 100644 --- a/soroban-sdk/test_snapshots/tests/token_client/test_mock_auth.1.json +++ b/soroban-sdk/test_snapshots/tests/token_client/test_mock_auth.1.json @@ -127,7 +127,7 @@ }, "ext": "v0" }, - 15 + 6311999 ] ], [ diff --git a/tests/auth/test_snapshots/test_a/test_with_mock_all_auth.1.json b/tests/auth/test_snapshots/test_a/test_with_mock_all_auth.1.json index 4bfb3fbd1..c13cd551f 100644 --- a/tests/auth/test_snapshots/test_a/test_with_mock_all_auth.1.json +++ b/tests/auth/test_snapshots/test_a/test_with_mock_all_auth.1.json @@ -96,7 +96,7 @@ }, "ext": "v0" }, - 15 + 6311999 ] ], [ diff --git a/tests/auth/test_snapshots/test_b/test_with_mock_all_auth.1.json b/tests/auth/test_snapshots/test_b/test_with_mock_all_auth.1.json index e55737d0d..41feb264a 100644 --- a/tests/auth/test_snapshots/test_b/test_with_mock_all_auth.1.json +++ b/tests/auth/test_snapshots/test_b/test_with_mock_all_auth.1.json @@ -146,7 +146,7 @@ }, "ext": "v0" }, - 15 + 6311999 ] ], [