diff --git a/Cargo.lock b/Cargo.lock index d09a4ec73..153acac77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -548,6 +548,12 @@ dependencies = [ "serde", ] +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + [[package]] name = "hmac" version = "0.12.1" @@ -1127,7 +1133,6 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "soroban-builtin-sdk-macros" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=8e593abadd9d3723810c644af01e1124badca244#8e593abadd9d3723810c644af01e1124badca244" dependencies = [ "itertools", "proc-macro2", @@ -1138,7 +1143,6 @@ dependencies = [ [[package]] name = "soroban-env-common" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=8e593abadd9d3723810c644af01e1124badca244#8e593abadd9d3723810c644af01e1124badca244" dependencies = [ "arbitrary", "crate-git-revision", @@ -1155,7 +1159,6 @@ dependencies = [ [[package]] name = "soroban-env-guest" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=8e593abadd9d3723810c644af01e1124badca244#8e593abadd9d3723810c644af01e1124badca244" dependencies = [ "soroban-env-common", "static_assertions", @@ -1164,12 +1167,13 @@ dependencies = [ [[package]] name = "soroban-env-host" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=8e593abadd9d3723810c644af01e1124badca244#8e593abadd9d3723810c644af01e1124badca244" dependencies = [ "backtrace", "curve25519-dalek", "ed25519-dalek", "getrandom", + "hex-literal", + "hmac", "k256", "num-derive", "num-integer", @@ -1188,7 +1192,6 @@ dependencies = [ [[package]] name = "soroban-env-macros" version = "20.0.0-rc2" -source = "git+https://github.com/stellar/rs-soroban-env?rev=8e593abadd9d3723810c644af01e1124badca244#8e593abadd9d3723810c644af01e1124badca244" dependencies = [ "itertools", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 58ec53cf3..0c6903a26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,10 +64,10 @@ rev = "d6f8ece2c89809d5e2800b9df64ae60787ee492b" default-features = false features = ["curr"] -#[patch."https://github.com/stellar/rs-soroban-env"] -#soroban-env-common = { path = "../rs-soroban-env/soroban-env-common" } -#soroban-env-guest = { path = "../rs-soroban-env/soroban-env-guest" } -#soroban-env-host = { path = "../rs-soroban-env/soroban-env-host/" } +[patch."https://github.com/stellar/rs-soroban-env"] +soroban-env-common = { path = "../rs-soroban-env/soroban-env-common" } +soroban-env-guest = { path = "../rs-soroban-env/soroban-env-guest" } +soroban-env-host = { path = "../rs-soroban-env/soroban-env-host/" } #[patch."https://github.com/stellar/rs-stellar-xdr"] #stellar-xdr = { path = "../rs-stellar-xdr/" } diff --git a/soroban-sdk/src/env.rs b/soroban-sdk/src/env.rs index 8a2d323fd..52325838d 100644 --- a/soroban-sdk/src/env.rs +++ b/soroban-sdk/src/env.rs @@ -131,8 +131,6 @@ use internal::{ pub struct MaybeEnv { maybe_env_impl: internal::MaybeEnvImpl, #[cfg(any(test, feature = "testutils"))] - in_contract: Option, - #[cfg(any(test, feature = "testutils"))] generators: Option>>, #[cfg(any(test, feature = "testutils"))] auth_snapshot: Option>>, @@ -182,8 +180,6 @@ impl MaybeEnv { Self { maybe_env_impl: None, #[cfg(any(test, feature = "testutils"))] - in_contract: None, - #[cfg(any(test, feature = "testutils"))] generators: None, #[cfg(any(test, feature = "testutils"))] auth_snapshot: None, @@ -215,8 +211,6 @@ impl TryFrom for Env { Ok(Env { env_impl, #[cfg(any(test, feature = "testutils"))] - in_contract: value.in_contract.unwrap_or_default(), - #[cfg(any(test, feature = "testutils"))] generators: value.generators.unwrap_or_default(), #[cfg(any(test, feature = "testutils"))] auth_snapshot: value.auth_snapshot.unwrap_or_default(), @@ -235,8 +229,6 @@ impl From for MaybeEnv { MaybeEnv { maybe_env_impl: Some(value.env_impl.clone()), #[cfg(any(test, feature = "testutils"))] - in_contract: Some(value.in_contract), - #[cfg(any(test, feature = "testutils"))] generators: Some(value.generators.clone()), #[cfg(any(test, feature = "testutils"))] auth_snapshot: Some(value.auth_snapshot.clone()), @@ -258,8 +250,6 @@ impl From for MaybeEnv { pub struct Env { env_impl: internal::EnvImpl, #[cfg(any(test, feature = "testutils"))] - in_contract: bool, - #[cfg(any(test, feature = "testutils"))] generators: Rc>, #[cfg(any(test, feature = "testutils"))] auth_snapshot: Rc>, @@ -477,7 +467,7 @@ use xdr::{ impl Env { #[doc(hidden)] pub fn in_contract(&self) -> bool { - self.in_contract + self.env_impl.has_frame().unwrap() } #[doc(hidden)] @@ -563,7 +553,6 @@ impl Env { let env = Env { env_impl, - in_contract: false, generators: generators.unwrap_or_default(), snapshot, auth_snapshot, @@ -621,7 +610,6 @@ impl Env { ) -> Option { let env = Env { env_impl: env_impl.clone(), - in_contract: true, generators: Default::default(), auth_snapshot: Default::default(), snapshot: None, diff --git a/soroban-sdk/src/tests/prng.rs b/soroban-sdk/src/tests/prng.rs index 77c3729a0..046a1b435 100644 --- a/soroban-sdk/src/tests/prng.rs +++ b/soroban-sdk/src/tests/prng.rs @@ -37,7 +37,7 @@ fn test_prng_shuffle() { e.as_contract(&id, || { let v = vec![&e, 1, 2, 3]; - assert_eq!(v.to_shuffled(), vec![&e, 3, 2, 1]); + assert_eq!(v.to_shuffled(), vec![&e, 3, 1, 2]); }); e.as_contract(&id, || { @@ -54,7 +54,7 @@ fn test_vec_shuffle() { e.as_contract(&id, || { let v = vec![&e, 1, 2, 3]; let s = v.to_shuffled(); - assert_eq!(s, vec![&e, 3, 2, 1]); + assert_eq!(s, vec![&e, 3, 1, 2]); assert_eq!(v, vec![&e, 1, 2, 3]); }); @@ -74,9 +74,9 @@ fn test_prng_fill_u64() { e.as_contract(&id, || { let mut v: u64 = 0; e.prng().fill(&mut v); - assert_eq!(v, 15905370036469238889); + assert_eq!(v, 6775509081846337106); e.prng().fill(&mut v); - assert_eq!(v, 9820564573332354559); + assert_eq!(v, 2134185115815765970); }); } @@ -86,8 +86,8 @@ fn test_prng_gen_u64() { let id = e.register_contract(None, TestPrngContract); e.as_contract(&id, || { - assert_eq!(e.prng().gen::(), 15905370036469238889); - assert_eq!(e.prng().gen::(), 9820564573332354559); + assert_eq!(e.prng().gen::(), 6775509081846337106); + assert_eq!(e.prng().gen::(), 2134185115815765970); }); } @@ -97,7 +97,7 @@ fn test_prng_gen_range_u64() { let id = e.register_contract(None, TestPrngContract); e.as_contract(&id, || { - assert_eq!(e.prng().gen_range::(..), 15905370036469238889); + assert_eq!(e.prng().gen_range::(..), 6775509081846337106); assert_eq!(e.prng().gen_range::(u64::MAX..), u64::MAX); assert_eq!( e.prng().gen_range::(u64::MAX - 1..u64::MAX), @@ -134,8 +134,8 @@ fn test_prng_fill_bytes() { Bytes::from_array( &e, &[ - 105, 12, 228, 36, 199, 57, 187, 220, 255, 181, 66, 167, 114, 167, 73, 136, 126, - 229, 99, 124, 156, 9, 231, 42, 211, 148, 110, 234, 189, 179, 224, 119 + 82, 78, 226, 155, 156, 113, 7, 94, 210, 231, 31, 49, 14, 38, 158, 29, 119, 169, + 67, 74, 0, 33, 229, 5, 124, 88, 142, 155, 100, 252, 88, 124 ] ) ); @@ -145,8 +145,8 @@ fn test_prng_fill_bytes() { Bytes::from_array( &e, &[ - 12, 120, 166, 125, 4, 130, 72, 67, 232, 216, 155, 171, 240, 65, 91, 25, 149, - 135, 147, 217, 131, 98, 2, 123, 78, 144, 194, 14, 36, 113, 79, 193 + 135, 192, 91, 227, 201, 91, 94, 147, 96, 233, 24, 221, 122, 144, 212, 16, 4, + 136, 28, 41, 249, 105, 126, 159, 101, 184, 58, 122, 80, 8, 9, 250 ] ) ); @@ -164,8 +164,8 @@ fn test_prng_gen_len_bytes() { Bytes::from_array( &e, &[ - 105, 12, 228, 36, 199, 57, 187, 220, 255, 181, 66, 167, 114, 167, 73, 136, 126, - 229, 99, 124, 156, 9, 231, 42, 211, 148, 110, 234, 189, 179, 224, 119 + 82, 78, 226, 155, 156, 113, 7, 94, 210, 231, 31, 49, 14, 38, 158, 29, 119, 169, + 67, 74, 0, 33, 229, 5, 124, 88, 142, 155, 100, 252, 88, 124 ] ) ); @@ -174,8 +174,8 @@ fn test_prng_gen_len_bytes() { Bytes::from_array( &e, &[ - 12, 120, 166, 125, 4, 130, 72, 67, 232, 216, 155, 171, 240, 65, 91, 25, 149, - 135, 147, 217, 131, 98, 2, 123, 78, 144, 194, 14, 36, 113, 79, 193 + 135, 192, 91, 227, 201, 91, 94, 147, 96, 233, 24, 221, 122, 144, 212, 16, 4, + 136, 28, 41, 249, 105, 126, 159, 101, 184, 58, 122, 80, 8, 9, 250 ] ) ); @@ -195,8 +195,8 @@ fn test_prng_fill_bytesn() { BytesN::from_array( &e, &[ - 105, 12, 228, 36, 199, 57, 187, 220, 255, 181, 66, 167, 114, 167, 73, 136, 126, - 229, 99, 124, 156, 9, 231, 42, 211, 148, 110, 234, 189, 179, 224, 119 + 82, 78, 226, 155, 156, 113, 7, 94, 210, 231, 31, 49, 14, 38, 158, 29, 119, 169, + 67, 74, 0, 33, 229, 5, 124, 88, 142, 155, 100, 252, 88, 124 ] ) ); @@ -206,8 +206,8 @@ fn test_prng_fill_bytesn() { BytesN::from_array( &e, &[ - 12, 120, 166, 125, 4, 130, 72, 67, 232, 216, 155, 171, 240, 65, 91, 25, 149, - 135, 147, 217, 131, 98, 2, 123, 78, 144, 194, 14, 36, 113, 79, 193 + 135, 192, 91, 227, 201, 91, 94, 147, 96, 233, 24, 221, 122, 144, 212, 16, 4, + 136, 28, 41, 249, 105, 126, 159, 101, 184, 58, 122, 80, 8, 9, 250 ] ) ); @@ -225,8 +225,8 @@ fn test_prng_gen_bytesn() { BytesN::from_array( &e, &[ - 105, 12, 228, 36, 199, 57, 187, 220, 255, 181, 66, 167, 114, 167, 73, 136, 126, - 229, 99, 124, 156, 9, 231, 42, 211, 148, 110, 234, 189, 179, 224, 119 + 82, 78, 226, 155, 156, 113, 7, 94, 210, 231, 31, 49, 14, 38, 158, 29, 119, 169, + 67, 74, 0, 33, 229, 5, 124, 88, 142, 155, 100, 252, 88, 124 ] ) ); @@ -235,8 +235,8 @@ fn test_prng_gen_bytesn() { BytesN::from_array( &e, &[ - 12, 120, 166, 125, 4, 130, 72, 67, 232, 216, 155, 171, 240, 65, 91, 25, 149, - 135, 147, 217, 131, 98, 2, 123, 78, 144, 194, 14, 36, 113, 79, 193 + 135, 192, 91, 227, 201, 91, 94, 147, 96, 233, 24, 221, 122, 144, 212, 16, 4, + 136, 28, 41, 249, 105, 126, 159, 101, 184, 58, 122, 80, 8, 9, 250 ] ) ); @@ -255,16 +255,16 @@ fn test_prng_fill_slice() { assert_eq!( v, [ - 105, 12, 228, 36, 199, 57, 187, 220, 255, 181, 66, 167, 114, 167, 73, 136, 126, - 229, 99, 124, 156, 9, 231, 42, 211, 148, 110, 234, 189, 179, 224, 119 + 82, 78, 226, 155, 156, 113, 7, 94, 210, 231, 31, 49, 14, 38, 158, 29, 119, 169, 67, + 74, 0, 33, 229, 5, 124, 88, 142, 155, 100, 252, 88, 124 ] ); e.prng().fill(v); assert_eq!( v, [ - 12, 120, 166, 125, 4, 130, 72, 67, 232, 216, 155, 171, 240, 65, 91, 25, 149, 135, - 147, 217, 131, 98, 2, 123, 78, 144, 194, 14, 36, 113, 79, 193 + 135, 192, 91, 227, 201, 91, 94, 147, 96, 233, 24, 221, 122, 144, 212, 16, 4, 136, + 28, 41, 249, 105, 126, 159, 101, 184, 58, 122, 80, 8, 9, 250 ] ); }); @@ -281,16 +281,16 @@ fn test_prng_fill_array() { assert_eq!( v, [ - 105, 12, 228, 36, 199, 57, 187, 220, 255, 181, 66, 167, 114, 167, 73, 136, 126, - 229, 99, 124, 156, 9, 231, 42, 211, 148, 110, 234, 189, 179, 224, 119 + 82, 78, 226, 155, 156, 113, 7, 94, 210, 231, 31, 49, 14, 38, 158, 29, 119, 169, 67, + 74, 0, 33, 229, 5, 124, 88, 142, 155, 100, 252, 88, 124 ] ); e.prng().fill(&mut v); assert_eq!( v, [ - 12, 120, 166, 125, 4, 130, 72, 67, 232, 216, 155, 171, 240, 65, 91, 25, 149, 135, - 147, 217, 131, 98, 2, 123, 78, 144, 194, 14, 36, 113, 79, 193 + 135, 192, 91, 227, 201, 91, 94, 147, 96, 233, 24, 221, 122, 144, 212, 16, 4, 136, + 28, 41, 249, 105, 126, 159, 101, 184, 58, 122, 80, 8, 9, 250 ] ); }); @@ -305,15 +305,15 @@ fn test_prng_gen_array() { assert_eq!( e.prng().gen::<[u8; 32]>(), [ - 105, 12, 228, 36, 199, 57, 187, 220, 255, 181, 66, 167, 114, 167, 73, 136, 126, - 229, 99, 124, 156, 9, 231, 42, 211, 148, 110, 234, 189, 179, 224, 119 + 82, 78, 226, 155, 156, 113, 7, 94, 210, 231, 31, 49, 14, 38, 158, 29, 119, 169, 67, + 74, 0, 33, 229, 5, 124, 88, 142, 155, 100, 252, 88, 124 ] ); assert_eq!( e.prng().gen::<[u8; 32]>(), [ - 12, 120, 166, 125, 4, 130, 72, 67, 232, 216, 155, 171, 240, 65, 91, 25, 149, 135, - 147, 217, 131, 98, 2, 123, 78, 144, 194, 14, 36, 113, 79, 193 + 135, 192, 91, 227, 201, 91, 94, 147, 96, 233, 24, 221, 122, 144, 212, 16, 4, 136, + 28, 41, 249, 105, 126, 159, 101, 184, 58, 122, 80, 8, 9, 250 ] ); }); 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 6053e5651..00cb1b8be 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 @@ -104,7 +104,7 @@ "contract": "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEGWF", "key": { "ledger_key_nonce": { - "nonce": 5827323990544907992 + "nonce": 801925984706572462 } }, "durability": "temporary" @@ -119,7 +119,7 @@ "contract": "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEGWF", "key": { "ledger_key_nonce": { - "nonce": 5827323990544907992 + "nonce": 801925984706572462 } }, "durability": "temporary", @@ -208,7 +208,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", "key": { "ledger_key_nonce": { - "nonce": 1851768990755774890 + "nonce": 5541220902715666415 } }, "durability": "temporary" @@ -223,7 +223,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", "key": { "ledger_key_nonce": { - "nonce": 1851768990755774890 + "nonce": 5541220902715666415 } }, "durability": "temporary", 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 b8a166e83..0670949fe 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 @@ -103,7 +103,7 @@ "contract": "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEGWF", "key": { "ledger_key_nonce": { - "nonce": 5827323990544907992 + "nonce": 801925984706572462 } }, "durability": "temporary" @@ -118,7 +118,7 @@ "contract": "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEGWF", "key": { "ledger_key_nonce": { - "nonce": 5827323990544907992 + "nonce": 801925984706572462 } }, "durability": "temporary", 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 8b7f4f398..9a37ed333 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 @@ -72,7 +72,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 5827323990544907992 + "nonce": 801925984706572462 } }, "durability": "temporary" @@ -87,7 +87,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 5827323990544907992 + "nonce": 801925984706572462 } }, "durability": "temporary", 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 abbe3a87f..c85ac1004 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 @@ -122,7 +122,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", "key": { "ledger_key_nonce": { - "nonce": 5827323990544907992 + "nonce": 801925984706572462 } }, "durability": "temporary" @@ -137,7 +137,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", "key": { "ledger_key_nonce": { - "nonce": 5827323990544907992 + "nonce": 801925984706572462 } }, "durability": "temporary",