From a2ca6daeb62725e16ba5a674f6d900137f7a7149 Mon Sep 17 00:00:00 2001 From: Garand Tyson Date: Sun, 17 Nov 2024 18:31:42 -0800 Subject: [PATCH] Rebase --- soroban-simulation/src/snapshot_source.rs | 10 +- soroban-simulation/src/test/simulation.rs | 28 +++-- .../src/test/snapshot_source.rs | 2 +- soroban-simulation/src/testutils.rs | 20 ++-- soroban-test-wasms/wasm-workspace/Cargo.lock | 104 +++++++++++++----- 5 files changed, 109 insertions(+), 55 deletions(-) diff --git a/soroban-simulation/src/snapshot_source.rs b/soroban-simulation/src/snapshot_source.rs index e78ffe420..010d12e65 100644 --- a/soroban-simulation/src/snapshot_source.rs +++ b/soroban-simulation/src/snapshot_source.rs @@ -70,7 +70,7 @@ impl AutoRestoringSnapshotSource { Ok(Self { snapshot_source, min_persistent_live_until_ledger: ledger_info.min_live_until_ledger_checked( - ContractDataDurability::Persistent).ok_or_else(|| + ContractDataDurability::Persistent).ok_or_else(|| anyhow!("minimum persistent live until ledger overflows - ledger info is misconfigured"))?, current_ledger_sequence: ledger_info.sequence_number, new_keys_requiring_proof: RefCell::new(Default::default()), @@ -91,7 +91,9 @@ impl AutoRestoringSnapshotSource { if keys.is_empty() { return Ok(None); } - Ok(Some(self.snapshot_source.generate_new_entries_proof(keys.iter().cloned().collect::>().as_slice())?)) + Ok(Some(self.snapshot_source.generate_new_entries_proof( + keys.iter().cloned().collect::>().as_slice(), + )?)) } /// Simulates a `RestoreFootprintOp` for all the keys that have been @@ -294,7 +296,7 @@ impl<'a> SnapshotSource for SimulationSnapshotSource<'a> { .borrow_mut() .maybe_update_entry(key, entry) { - return Ok(Some((updated_entry, live_until.clone()))); + return Ok(Some((updated_entry, *live_until))); } } Ok(entry_with_live_until) @@ -318,7 +320,7 @@ impl<'a, T: SnapshotSourceWithArchive> SnapshotSourceWithArchive { return Ok(LedgerEntryWithArchivalState { entry: Some(updated_entry), - live_until_ledger: entry_state.live_until_ledger.clone(), + live_until_ledger: entry_state.live_until_ledger, state: entry_state.state, }); } diff --git a/soroban-simulation/src/test/simulation.rs b/soroban-simulation/src/test/simulation.rs index feb8a03c9..ffb56a441 100644 --- a/soroban-simulation/src/test/simulation.rs +++ b/soroban-simulation/src/test/simulation.rs @@ -15,14 +15,16 @@ use soroban_env_host::e2e_testutils::{ }; use soroban_env_host::fees::{FeeConfiguration, RentFeeConfiguration}; use soroban_env_host::xdr::{ - AccountId, AlphaNum4, AssetCode4, ContractCostParamEntry, ContractCostParams, ContractCostType, - ContractDataDurability, ContractDataEntry, ContractExecutable, ExtensionPoint, Hash, - HostFunction, Int128Parts, InvokeContractArgs, LedgerEntry, LedgerEntryData, LedgerFootprint, - LedgerKey, LedgerKeyContractData, LedgerKeyTrustLine, PublicKey, ScAddress, ScBytes, - ScContractInstance, ScErrorCode, ScErrorType, ScMap, ScNonceKey, ScString, ScSymbol, ScVal, + AccountId, AlphaNum4, ArchivalProof, ArchivalProofBody, AssetCode4, ContractCostParamEntry, + ContractCostParams, ContractCostType, ContractDataDurability, ContractDataEntry, + ContractExecutable, ExtensionPoint, Hash, HostFunction, Int128Parts, InvokeContractArgs, + LedgerEntry, LedgerEntryData, LedgerFootprint, LedgerKey, LedgerKeyContractData, + LedgerKeyTrustLine, NonexistenceProofBody, PublicKey, ScAddress, ScBytes, ScContractInstance, + ScErrorCode, ScErrorType, ScMap, ScNonceKey, ScString, ScSymbol, ScVal, SorobanAddressCredentials, SorobanAuthorizationEntry, SorobanAuthorizedFunction, SorobanAuthorizedInvocation, SorobanCredentials, SorobanResources, SorobanTransactionData, - TrustLineAsset, TrustLineEntry, TrustLineEntryExt, TrustLineFlags, Uint256, VecM, + SorobanTransactionDataExt, TrustLineAsset, TrustLineEntry, TrustLineEntryExt, TrustLineFlags, + Uint256, VecM, }; use soroban_env_host::HostError; use soroban_test_wasms::{ADD_I32, AUTH_TEST_CONTRACT, TRY_CALL_SAC}; @@ -1144,8 +1146,10 @@ fn test_simulate_successful_sac_call() { ) .unwrap(), ); + let snapshot_source = + Rc::new(AutoRestoringSnapshotSource::new(snapshot_source, &ledger_info).unwrap()); let res = simulate_invoke_host_function_op( - snapshot_source, + snapshot_source.clone(), &network_config, &SimulationAdjustmentConfig::no_adjustments(), &ledger_info, @@ -1154,6 +1158,7 @@ fn test_simulate_successful_sac_call() { &source_account, [1; 32], true, + || snapshot_source.get_new_keys_proof(), ) .unwrap(); assert_eq!(res.invoke_result.unwrap(), ScVal::Void); @@ -1175,7 +1180,7 @@ fn test_simulate_successful_sac_call() { assert_eq!( res.transaction_data, Some(SorobanTransactionData { - ext: ExtensionPoint::V0, + ext: SorobanTransactionDataExt::V0, resources: SorobanResources { footprint: LedgerFootprint { read_only: vec![ledger_entry_to_ledger_key(&contract_instance_le).unwrap(),] @@ -1243,9 +1248,11 @@ fn test_simulate_unsuccessful_sac_call_with_try_call() { ) .unwrap(), ); + let snapshot_source = + Rc::new(AutoRestoringSnapshotSource::new(snapshot_source, &ledger_info).unwrap()); let res = simulate_invoke_host_function_op( - snapshot_source, + snapshot_source.clone(), &network_config, &SimulationAdjustmentConfig::no_adjustments(), &ledger_info, @@ -1254,6 +1261,7 @@ fn test_simulate_unsuccessful_sac_call_with_try_call() { &source_account, [1; 32], true, + || snapshot_source.get_new_keys_proof(), ) .unwrap(); // The return value indicates the whether the internal `mint` call has @@ -1271,7 +1279,7 @@ fn test_simulate_unsuccessful_sac_call_with_try_call() { assert_eq!( res.transaction_data, Some(SorobanTransactionData { - ext: ExtensionPoint::V0, + ext: SorobanTransactionDataExt::V0, resources: SorobanResources { footprint: LedgerFootprint { read_only: vec![ diff --git a/soroban-simulation/src/test/snapshot_source.rs b/soroban-simulation/src/test/snapshot_source.rs index 03f79a7bc..9dc2be1fe 100644 --- a/soroban-simulation/src/test/snapshot_source.rs +++ b/soroban-simulation/src/test/snapshot_source.rs @@ -309,7 +309,7 @@ fn test_automatic_restoration_with_archival_state() { b"persistent_archived_need_proof_no_entry" ))) .is_err()); - // We don't try to restore the non-existent entires (this shouldn't + // We don't try to restore the non-existent entires (this shouldn't // normally be called at all though in such case). assert_eq!( auto_restoring_snapshot diff --git a/soroban-simulation/src/testutils.rs b/soroban-simulation/src/testutils.rs index c20c61c29..283e1d16e 100644 --- a/soroban-simulation/src/testutils.rs +++ b/soroban-simulation/src/testutils.rs @@ -22,6 +22,13 @@ pub struct MockSnapshotSource { map: BTreeMap, LedgerEntryWithArchivalState>, } +pub type EntriesWithArchivalState = Vec<( + Option, + Option, + Option, + LedgerEntryArchivalState, +)>; + impl MockSnapshotSource { pub fn from_entries( entries: Vec<(LedgerEntry, Option)>, @@ -33,7 +40,7 @@ impl MockSnapshotSource { let state = if let Some(live_until_ledger) = &live_until_ledger { if *live_until_ledger < current_ledger_seq { if matches!( - get_key_durability(&*key), + get_key_durability(&key), Some(ContractDataDurability::Persistent) ) { LedgerEntryArchivalState::Archived(false) @@ -68,14 +75,7 @@ impl MockSnapshotSource { Ok(Self { map }) } - pub fn from_entries_with_archival_state( - entries: Vec<( - Option, - Option, - Option, - LedgerEntryArchivalState, - )>, - ) -> Result { + pub fn from_entries_with_archival_state(entries: EntriesWithArchivalState) -> Result { let mut map = BTreeMap::, LedgerEntryWithArchivalState>::new(); for (maybe_key, maybe_entry, live_until_ledger, state) in entries { let key = if let Some(k) = maybe_key { @@ -195,7 +195,7 @@ impl SnapshotSource for MockSnapshotSource { ) -> std::result::Result, HostError> { if let Some(entry_state) = self.map.get(key) { if let Some(entry) = &entry_state.entry { - Ok(Some((entry.clone(), entry_state.live_until_ledger.clone()))) + Ok(Some((entry.clone(), entry_state.live_until_ledger))) } else { if matches!(entry_state.state, LedgerEntryArchivalState::Archived(_)) { Err(HostError::from(( diff --git a/soroban-test-wasms/wasm-workspace/Cargo.lock b/soroban-test-wasms/wasm-workspace/Cargo.lock index 19327437c..22863e295 100644 --- a/soroban-test-wasms/wasm-workspace/Cargo.lock +++ b/soroban-test-wasms/wasm-workspace/Cargo.lock @@ -288,7 +288,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -333,7 +332,6 @@ dependencies = [ "ff", "generic-array", "group", - "pkcs8", "rand_core", "sec1", "subtle", @@ -667,9 +665,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -753,6 +749,18 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2", +] + [[package]] name = "paste" version = "1.0.14" @@ -797,6 +805,15 @@ dependencies = [ "syn", ] +[[package]] +name = "primeorder" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7dbe9ed3b56368bd99483eb32fe9c17fdd3730aebadc906918ce78d54c7eeb4" +dependencies = [ + "elliptic-curve", +] + [[package]] name = "proc-macro2" version = "1.0.69" @@ -893,7 +910,6 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] @@ -1003,9 +1019,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "soroban-builtin-sdk-macros" -version = "20.3.0" +version = "21.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc32c6e817f3ca269764ec0d7d14da6210b74a5bf14d4e745aa3ee860558900" +checksum = "44877373b3dc6c662377cb1600e3a62706d75e484b6064f9cd22e467c676b159" dependencies = [ "itertools", "proc-macro2", @@ -1015,9 +1031,9 @@ dependencies = [ [[package]] name = "soroban-env-common" -version = "20.3.0" +version = "21.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c14e18d879c520ff82612eaae0590acaf6a7f3b977407e1abb1c9e31f94c7814" +checksum = "590add16843a61b01844e19e89bccaaee6aa21dc76809017b0662c17dc139ee9" dependencies = [ "crate-git-revision", "ethnum", @@ -1028,13 +1044,14 @@ dependencies = [ "soroban-wasmi", "static_assertions", "stellar-xdr", + "wasmparser", ] [[package]] name = "soroban-env-guest" -version = "20.3.0" +version = "21.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5122ca2abd5ebcc1e876a96b9b44f87ce0a0e06df8f7c09772ddb58b159b7454" +checksum = "05ec8dc43acdd6c7e7b371acf44fc1a7dac24934ae3b2f05fafd618818548176" dependencies = [ "soroban-env-common", "static_assertions", @@ -1042,12 +1059,15 @@ dependencies = [ [[package]] name = "soroban-env-host" -version = "20.3.0" +version = "21.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "114a0fa0d0cc39d0be16b1ee35b6e5f4ee0592ddcf459bde69391c02b03cf520" +checksum = "4e25aaffe0c62eb65e0e349f725b4b8b13ad0764d78a15aab5bbccb5c4797726" dependencies = [ "curve25519-dalek", + "ecdsa", "ed25519-dalek", + "elliptic-curve", + "generic-array", "getrandom", "hex-literal", "hmac", @@ -1055,8 +1075,10 @@ dependencies = [ "num-derive", "num-integer", "num-traits", + "p256", "rand", "rand_chacha", + "sec1", "sha2", "sha3", "soroban-builtin-sdk-macros", @@ -1064,13 +1086,14 @@ dependencies = [ "soroban-wasmi", "static_assertions", "stellar-strkey", + "wasmparser", ] [[package]] name = "soroban-env-macros" -version = "20.3.0" +version = "21.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13e3f8c86f812e0669e78fcb3eae40c385c6a9dd1a4886a1de733230b4fcf27" +checksum = "3e16b761459fdf3c4b62b24df3941498d14e5246e6fadfb4774ed8114d243aa4" dependencies = [ "itertools", "proc-macro2", @@ -1083,9 +1106,9 @@ dependencies = [ [[package]] name = "soroban-ledger-snapshot" -version = "20.5.0" +version = "21.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a54708f44890e0546180db6b4f530e2a88d83b05a9b38a131caa21d005e25a" +checksum = "a46f8b134b1e0b517f70d24dd72399cd263fd18c3c7cfcb5e56ffc6de9dad0c3" dependencies = [ "serde", "serde_json", @@ -1097,9 +1120,9 @@ dependencies = [ [[package]] name = "soroban-sdk" -version = "20.5.0" +version = "21.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84fc8be9068dd4e0212d8b13ad61089ea87e69ac212c262914503a961c8dc3a3" +checksum = "60cd55eb88cbe1d9e7fe3ab1845c7c10c26b27e2d226e973150e5b55580aa359" dependencies = [ "bytes-lit", "rand", @@ -1114,9 +1137,9 @@ dependencies = [ [[package]] name = "soroban-sdk-macros" -version = "20.5.0" +version = "21.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db20def4ead836663633f58d817d0ed8e1af052c9650a04adf730525af85b964" +checksum = "6f24c6b0c46e41852a8603bb32d43cf6a4046ce65483f6383903ec653118cd90" dependencies = [ "crate-git-revision", "darling", @@ -1134,9 +1157,9 @@ dependencies = [ [[package]] name = "soroban-spec" -version = "20.5.0" +version = "21.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eefeb5d373b43f6828145d00f0c5cc35e96db56a6671ae9614f84beb2711cab" +checksum = "c2c70b20e68cae3ef700b8fa3ae29db1c6a294b311fba66918f90cb8f9fd0a1a" dependencies = [ "base64 0.13.1", "stellar-xdr", @@ -1146,9 +1169,9 @@ dependencies = [ [[package]] name = "soroban-spec-rust" -version = "20.5.0" +version = "21.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3152bca4737ef734ac37fe47b225ee58765c9095970c481a18516a2b287c7a33" +checksum = "a2dafbde981b141b191c6c036abc86097070ddd6eaaa33b273701449501e43d3" dependencies = [ "prettyplease", "proc-macro2", @@ -1215,9 +1238,9 @@ dependencies = [ [[package]] name = "stellar-xdr" -version = "20.1.0" +version = "21.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e59cdf3eb4467fb5a4b00b52e7de6dca72f67fac6f9b700f55c95a5d86f09c9d" +checksum = "2675a71212ed39a806e415b0dbf4702879ff288ec7f5ee996dda42a135512b50" dependencies = [ "base64 0.13.1", "crate-git-revision", @@ -1468,11 +1491,12 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.88.0" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8cf7dd82407fe68161bedcd57fde15596f32ebf6e9b3bdbf3ae1da20e38e5e" +checksum = "a58e28b80dd8340cb07b8242ae654756161f6fc8d0038123d679b7b99964fa50" dependencies = [ - "indexmap 1.9.3", + "indexmap 2.1.0", + "semver", ] [[package]] @@ -1555,3 +1579,23 @@ name = "zeroize" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" + +[[patch.unused]] +name = "soroban-env-common" +version = "22.0.0" + +[[patch.unused]] +name = "soroban-env-guest" +version = "22.0.0" + +[[patch.unused]] +name = "soroban-env-host" +version = "22.0.0" + +[[patch.unused]] +name = "soroban-sdk" +version = "20.0.0-rc2" + +[[patch.unused]] +name = "stellar-xdr" +version = "22.0.0"