From 2f3b7383f6da4f25a1b6e62481c656508f6cdb46 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 11 Apr 2024 16:38:37 -0700 Subject: [PATCH] Package version 21 (#1394) This is a followup to https://github.com/stellar/rs-soroban-env/pull/1384 that ungates the `unstable-next-api` feature code (and deletes the previous variants) and sets the package version to 21.0.0 --- Cargo.lock | 20 ++++++------- Cargo.toml | 12 ++++---- soroban-env-host/src/e2e_invoke.rs | 45 ------------------------------ soroban-env-host/src/storage.rs | 17 ----------- soroban-env-host/src/testutils.rs | 21 -------------- 5 files changed, 16 insertions(+), 99 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4b7db0f5e..70d2e55ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1352,7 +1352,7 @@ checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "soroban-bench-utils" -version = "20.3.0" +version = "21.0.0" dependencies = [ "perf-event", "soroban-env-common", @@ -1361,7 +1361,7 @@ dependencies = [ [[package]] name = "soroban-builtin-sdk-macros" -version = "20.3.0" +version = "21.0.0" dependencies = [ "itertools", "proc-macro2", @@ -1371,7 +1371,7 @@ dependencies = [ [[package]] name = "soroban-env-common" -version = "20.3.0" +version = "21.0.0" dependencies = [ "arbitrary", "crate-git-revision", @@ -1390,7 +1390,7 @@ dependencies = [ [[package]] name = "soroban-env-guest" -version = "20.3.0" +version = "21.0.0" dependencies = [ "soroban-env-common", "static_assertions", @@ -1398,7 +1398,7 @@ dependencies = [ [[package]] name = "soroban-env-host" -version = "20.3.0" +version = "21.0.0" dependencies = [ "arbitrary", "backtrace", @@ -1452,7 +1452,7 @@ dependencies = [ [[package]] name = "soroban-env-macros" -version = "20.3.0" +version = "21.0.0" dependencies = [ "itertools", "proc-macro2", @@ -1465,7 +1465,7 @@ dependencies = [ [[package]] name = "soroban-simulation" -version = "20.3.0" +version = "21.0.0" dependencies = [ "anyhow", "pretty_assertions", @@ -1479,7 +1479,7 @@ dependencies = [ [[package]] name = "soroban-synth-wasm" -version = "20.3.0" +version = "21.0.0" dependencies = [ "arbitrary", "expect-test", @@ -1493,7 +1493,7 @@ dependencies = [ [[package]] name = "soroban-test-wasms" -version = "20.3.0" +version = "21.0.0" [[package]] name = "soroban-wasmi" @@ -1607,7 +1607,7 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "test_no_std" -version = "20.3.0" +version = "21.0.0" dependencies = [ "soroban-env-common", ] diff --git a/Cargo.toml b/Cargo.toml index 8a2b8c4f7..2795b04ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,15 +20,15 @@ exclude = ["soroban-test-wasms/wasm-workspace"] # NB: When bumping the major version make sure to clean up the # code guarded by `unstable-*` features to make it enabled # unconditionally. -version = "20.3.0" +version = "21.0.0" rust-version = "1.74.0" [workspace.dependencies] -soroban-env-common = { version = "=20.3.0", path = "soroban-env-common", default-features = false } -soroban-env-guest = { version = "=20.3.0", path = "soroban-env-guest" } -soroban-env-host = { version = "=20.3.0", path = "soroban-env-host" } -soroban-env-macros = { version = "=20.3.0", path = "soroban-env-macros" } -soroban-builtin-sdk-macros = { version = "=20.3.0", path = "soroban-builtin-sdk-macros" } +soroban-env-common = { version = "=21.0.0", path = "soroban-env-common", default-features = false } +soroban-env-guest = { version = "=21.0.0", path = "soroban-env-guest" } +soroban-env-host = { version = "=21.0.0", path = "soroban-env-host" } +soroban-env-macros = { version = "=21.0.0", path = "soroban-env-macros" } +soroban-builtin-sdk-macros = { version = "=21.0.0", path = "soroban-builtin-sdk-macros" } # NB: this must match the wasmparser version wasmi is using wasmparser = "=0.116.1" diff --git a/soroban-env-host/src/e2e_invoke.rs b/soroban-env-host/src/e2e_invoke.rs index 81a141d92..10566da13 100644 --- a/soroban-env-host/src/e2e_invoke.rs +++ b/soroban-env-host/src/e2e_invoke.rs @@ -5,7 +5,6 @@ use std::{cmp::max, rc::Rc}; use crate::ledger_info::get_key_durability; -#[cfg(any(test, feature = "unstable-next-api"))] use crate::storage::EntryWithLiveUntil; #[cfg(any(test, feature = "recording_mode"))] use crate::{ @@ -80,7 +79,6 @@ pub struct InvokeHostFunctionRecordingModeResult { pub contract_events: Vec, /// Size of the encoded contract events and the return value. /// Non-zero only when invocation has succeeded. - #[cfg(any(test, feature = "unstable-next-api"))] pub contract_events_and_return_value_size: u32, } @@ -160,14 +158,7 @@ pub fn get_ledger_changes( new_live_until_ledger: 0, }); } - #[cfg(any(test, feature = "unstable-next-api"))] let entry_with_live_until = init_storage_snapshot.get(key)?; - #[cfg(not(any(test, feature = "unstable-next-api")))] - let entry_with_live_until = if init_storage_snapshot.has(key)? { - Some(init_storage_snapshot.get(key)?) - } else { - None - }; if let Some((old_entry, old_live_until_ledger)) = entry_with_live_until { let mut buf = vec![]; metered_write_xdr(budget, old_entry.as_ref(), &mut buf)?; @@ -567,14 +558,7 @@ pub fn invoke_host_function_in_recording_mode( let mut encoded_ttl_entries = Vec::with_capacity(storage.footprint.0.len()); let mut read_bytes = 0_u32; for (lk, _) in &storage.footprint.0 { - #[cfg(any(test, feature = "unstable-next-api"))] let entry_with_live_until = ledger_snapshot.get(lk)?; - #[cfg(not(any(test, feature = "unstable-next-api")))] - let entry_with_live_until = if ledger_snapshot.has(lk)? { - Some(ledger_snapshot.get(lk)?) - } else { - None - }; if let Some((le, live_until)) = entry_with_live_until { let encoded_le = host.to_xdr_non_metered(&*le)?; read_bytes = read_bytes.saturating_add(encoded_le.len() as u32); @@ -652,7 +636,6 @@ pub fn invoke_host_function_in_recording_mode( auth: output_auth, ledger_changes, contract_events, - #[cfg(any(test, feature = "unstable-next-api"))] contract_events_and_return_value_size, }) } @@ -831,7 +814,6 @@ struct StorageMapSnapshotSource<'a> { map: &'a StorageMap, } -#[cfg(any(test, feature = "unstable-next-api"))] impl<'a> SnapshotSource for StorageMapSnapshotSource<'a> { fn get(&self, key: &Rc) -> Result, HostError> { if let Some(Some((entry, live_until_ledger))) = @@ -843,30 +825,3 @@ impl<'a> SnapshotSource for StorageMapSnapshotSource<'a> { } } } - -#[cfg(not(any(test, feature = "unstable-next-api")))] -impl<'a> SnapshotSource for StorageMapSnapshotSource<'a> { - fn get(&self, key: &Rc) -> Result<(Rc, Option), HostError> { - if let Some(Some((entry, live_until_ledger))) = - self.map.get::>(key, self.budget)? - { - Ok((Rc::clone(entry), *live_until_ledger)) - } else { - Err(HostError::from(( - ScErrorType::Storage, - ScErrorCode::InternalError, - ))) - } - } - - fn has(&self, key: &Rc) -> Result { - if let Some(maybe_value) = self.map.get::>(key, self.budget)? { - Ok(maybe_value.is_some()) - } else { - Err(HostError::from(( - ScErrorType::Storage, - ScErrorCode::InternalError, - ))) - } - } -} diff --git a/soroban-env-host/src/storage.rs b/soroban-env-host/src/storage.rs index 9a849094d..9df539449 100644 --- a/soroban-env-host/src/storage.rs +++ b/soroban-env-host/src/storage.rs @@ -55,20 +55,12 @@ pub enum AccessType { /// A helper type used by [FootprintMode::Recording] to provide access /// to a stable read-snapshot of a ledger. /// The snapshot is expected to only return live ledger entries. -#[cfg(any(test, feature = "unstable-next-api"))] pub trait SnapshotSource { /// Returns the ledger entry for the key and its live_until ledger if entry /// exists, or `None` otherwise. fn get(&self, key: &Rc) -> Result, HostError>; } -#[cfg(not(any(test, feature = "unstable-next-api")))] -pub trait SnapshotSource { - // Returns the ledger entry for the key and its live_until ledger. - fn get(&self, key: &Rc) -> Result; - fn has(&self, key: &Rc) -> Result; -} - /// Describes the total set of [LedgerKey]s that a given transaction /// will access, as well as the [AccessType] governing each key. /// @@ -471,16 +463,7 @@ impl Storage { // In recording mode we treat the map as a cache // that misses read-through to the underlying src. if !self.map.contains_key::>(key, budget)? { - #[cfg(any(test, feature = "unstable-next-api"))] let value = src.get(&key)?; - - #[cfg(not(any(test, feature = "unstable-next-api")))] - let value = if src.has(&key)? { - Some(src.get(key)?) - } else { - None - }; - self.map = self.map.insert(key.clone(), value, budget)?; } } diff --git a/soroban-env-host/src/testutils.rs b/soroban-env-host/src/testutils.rs index 5e37d18bc..c51ed5982 100644 --- a/soroban-env-host/src/testutils.rs +++ b/soroban-env-host/src/testutils.rs @@ -1,5 +1,4 @@ use crate::e2e_invoke::ledger_entry_to_ledger_key; -#[cfg(any(test, feature = "unstable-next-api"))] use crate::storage::EntryWithLiveUntil; use crate::{ budget::Budget, @@ -134,7 +133,6 @@ impl MockSnapshotSource { } } -#[cfg(any(test, feature = "unstable-next-api"))] impl SnapshotSource for MockSnapshotSource { fn get(&self, key: &Rc) -> Result, HostError> { if let Some((entry, live_until)) = self.0.get(key) { @@ -145,25 +143,6 @@ impl SnapshotSource for MockSnapshotSource { } } -#[cfg(not(any(test, feature = "unstable-next-api")))] -impl SnapshotSource for MockSnapshotSource { - fn get(&self, key: &Rc) -> Result<(Rc, Option), HostError> { - if let Some(val) = self.0.get(key) { - Ok((Rc::clone(&val.0), val.1)) - } else { - Err(( - crate::xdr::ScErrorType::Storage, - crate::xdr::ScErrorCode::MissingValue, - ) - .into()) - } - } - - fn has(&self, key: &Rc) -> Result { - Ok(self.0.contains_key(key)) - } -} - #[cfg(test)] pub(crate) fn interface_meta_with_custom_versions(proto: u32, pre: u32) -> Vec { use crate::xdr::{Limited, Limits, ScEnvMetaEntry, WriteXdr};