Skip to content

Commit

Permalink
Package version 21 (stellar#1394)
Browse files Browse the repository at this point in the history
This is a followup to
stellar#1384 that ungates the
`unstable-next-api` feature code (and deletes the previous variants) and
sets the package version to 21.0.0
  • Loading branch information
graydon authored Apr 11, 2024
1 parent 96a3562 commit 2f3b738
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 99 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
45 changes: 0 additions & 45 deletions soroban-env-host/src/e2e_invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -80,7 +79,6 @@ pub struct InvokeHostFunctionRecordingModeResult {
pub contract_events: Vec<ContractEvent>,
/// 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,
}

Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
})
}
Expand Down Expand Up @@ -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<LedgerKey>) -> Result<Option<EntryWithLiveUntil>, HostError> {
if let Some(Some((entry, live_until_ledger))) =
Expand All @@ -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<LedgerKey>) -> Result<(Rc<LedgerEntry>, Option<u32>), HostError> {
if let Some(Some((entry, live_until_ledger))) =
self.map.get::<Rc<LedgerKey>>(key, self.budget)?
{
Ok((Rc::clone(entry), *live_until_ledger))
} else {
Err(HostError::from((
ScErrorType::Storage,
ScErrorCode::InternalError,
)))
}
}

fn has(&self, key: &Rc<LedgerKey>) -> Result<bool, HostError> {
if let Some(maybe_value) = self.map.get::<Rc<LedgerKey>>(key, self.budget)? {
Ok(maybe_value.is_some())
} else {
Err(HostError::from((
ScErrorType::Storage,
ScErrorCode::InternalError,
)))
}
}
}
17 changes: 0 additions & 17 deletions soroban-env-host/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<LedgerKey>) -> Result<Option<EntryWithLiveUntil>, 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<LedgerKey>) -> Result<EntryWithLiveUntil, HostError>;
fn has(&self, key: &Rc<LedgerKey>) -> Result<bool, HostError>;
}

/// Describes the total set of [LedgerKey]s that a given transaction
/// will access, as well as the [AccessType] governing each key.
///
Expand Down Expand Up @@ -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::<Rc<LedgerKey>>(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)?;
}
}
Expand Down
21 changes: 0 additions & 21 deletions soroban-env-host/src/testutils.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -134,7 +133,6 @@ impl MockSnapshotSource {
}
}

#[cfg(any(test, feature = "unstable-next-api"))]
impl SnapshotSource for MockSnapshotSource {
fn get(&self, key: &Rc<LedgerKey>) -> Result<Option<EntryWithLiveUntil>, HostError> {
if let Some((entry, live_until)) = self.0.get(key) {
Expand All @@ -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<LedgerKey>) -> Result<(Rc<LedgerEntry>, Option<u32>), 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<LedgerKey>) -> Result<bool, HostError> {
Ok(self.0.contains_key(key))
}
}

#[cfg(test)]
pub(crate) fn interface_meta_with_custom_versions(proto: u32, pre: u32) -> Vec<u8> {
use crate::xdr::{Limited, Limits, ScEnvMetaEntry, WriteXdr};
Expand Down

0 comments on commit 2f3b738

Please sign in to comment.