Skip to content

Commit

Permalink
Bump env used by SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
dmkozh committed Mar 1, 2024
1 parent 9d802fc commit b7bfa18
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 41 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ soroban-token-sdk = { version = "20.3.2", path = "soroban-token-sdk" }
[workspace.dependencies.soroban-env-common]
version = "=20.2.2"
git = "https://github.com/stellar/rs-soroban-env"
rev = "f035dda68e061a8fa18ab0c4e35b4b0618d15324"
rev = "8c9ab83c406bd86f56d52eae3e39dccf6b45b3da"

[workspace.dependencies.soroban-env-guest]
version = "=20.2.2"
git = "https://github.com/stellar/rs-soroban-env"
rev = "f035dda68e061a8fa18ab0c4e35b4b0618d15324"
rev = "8c9ab83c406bd86f56d52eae3e39dccf6b45b3da"

[workspace.dependencies.soroban-env-host]
version = "=20.2.2"
git = "https://github.com/stellar/rs-soroban-env"
rev = "f035dda68e061a8fa18ab0c4e35b4b0618d15324"
rev = "8c9ab83c406bd86f56d52eae3e39dccf6b45b3da"

[workspace.dependencies.stellar-strkey]
version = "=0.0.8"
Expand Down
24 changes: 6 additions & 18 deletions soroban-ledger-snapshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use std::{
};

use soroban_env_host::{
storage::SnapshotSource,
xdr::{LedgerEntry, LedgerKey, ScError, ScErrorCode},
storage::{EntryWithLiveUntil, SnapshotSource},
xdr::{LedgerEntry, LedgerKey},
Host, HostError, LedgerInfo,
};

Expand Down Expand Up @@ -181,23 +181,11 @@ impl Default for LedgerSnapshot {
}
}

impl SnapshotSource for &LedgerSnapshot {
fn get(&self, key: &Rc<LedgerKey>) -> Result<(Rc<LedgerEntry>, Option<u32>), HostError> {
impl SnapshotSource for LedgerSnapshot {
fn get(&self, key: &Rc<LedgerKey>) -> Result<Option<EntryWithLiveUntil>, HostError> {
match self.ledger_entries.iter().find(|(k, _)| **k == **key) {
Some((_, v)) => Ok((Rc::new(*v.0.clone()), v.1)),
None => Err(ScError::Storage(ScErrorCode::MissingValue).into()),
Some((_, v)) => Ok(Some((Rc::new(*v.0.clone()), v.1))),
None => Ok(None),
}
}
fn has(&self, key: &Rc<LedgerKey>) -> Result<bool, HostError> {
Ok(self.ledger_entries.iter().any(|(k, _)| **k == **key))
}
}

impl SnapshotSource for LedgerSnapshot {
fn get(&self, key: &Rc<LedgerKey>) -> Result<(Rc<LedgerEntry>, Option<u32>), HostError> {
<_ as SnapshotSource>::get(&self, key)
}
fn has(&self, key: &Rc<LedgerKey>) -> Result<bool, HostError> {
<_ as SnapshotSource>::has(&self, key)
}
}
2 changes: 1 addition & 1 deletion soroban-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ bytes-lit = "0.0.5"
soroban-env-guest = { workspace = true }

[target.'cfg(not(target_family="wasm"))'.dependencies]
soroban-env-host = { workspace = true, features = [] }
soroban-env-host = { workspace = true, features = ["unstable-next-api"] }
soroban-ledger-snapshot = { workspace = true }
stellar-strkey = { workspace = true }
arbitrary = { version = "1.3.0", features = ["derive"], optional = true }
Expand Down
32 changes: 18 additions & 14 deletions soroban-sdk/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,13 @@ use crate::{
use core::{cell::RefCell, cell::RefMut};
#[cfg(any(test, feature = "testutils"))]
use internal::ContractInvocationEvent;
use soroban_env_host::storage::EntryWithLiveUntil;
#[cfg(any(test, feature = "testutils"))]
use soroban_ledger_snapshot::LedgerSnapshot;
#[cfg(any(test, feature = "testutils"))]
use std::{path::Path, rc::Rc};
#[cfg(any(test, feature = "testutils"))]
use xdr::{
LedgerEntry, LedgerKey, LedgerKeyContractData, ScErrorCode, ScErrorType,
SorobanAuthorizationEntry,
};
use xdr::{LedgerEntry, LedgerKey, LedgerKeyContractData, SorobanAuthorizationEntry};

#[cfg(any(test, feature = "testutils"))]
#[cfg_attr(feature = "docs", doc(cfg(feature = "testutils")))]
Expand All @@ -487,15 +485,9 @@ impl Env {
impl internal::storage::SnapshotSource for EmptySnapshotSource {
fn get(
&self,
_key: &Rc<xdr::LedgerKey>,
) -> Result<(Rc<xdr::LedgerEntry>, Option<u32>), soroban_env_host::HostError>
{
let err: internal::Error = (ScErrorType::Storage, ScErrorCode::MissingValue).into();
Err(err.into())
}

fn has(&self, _key: &Rc<xdr::LedgerKey>) -> Result<bool, soroban_env_host::HostError> {
Ok(false)
_key: &Rc<LedgerKey>,
) -> Result<Option<EntryWithLiveUntil>, soroban_env_host::HostError> {
Ok(None)
}
}

Expand Down Expand Up @@ -1469,6 +1461,18 @@ impl internal::EnvBase for Env {
self.env_impl.error_from_error_val(e)
}

fn check_protocol_version_lower_bound(&self, v: u32) -> Result<(), Self::Error> {
Ok(self
.env_impl
.check_protocol_version_lower_bound(v)
.unwrap_optimized())
}
fn check_protocol_version_upper_bound(&self, v: u32) -> Result<(), Self::Error> {
Ok(self
.env_impl
.check_protocol_version_upper_bound(v)
.unwrap_optimized())
}
// Note: the function `escalate_error_to_panic` only exists _on the `Env`
// trait_ when the feature `soroban-env-common/testutils` is enabled. This
// is because the host wants to never have this function even _compiled in_
Expand Down Expand Up @@ -1648,7 +1652,7 @@ macro_rules! impl_env_for_sdk {
// pattern-repetition matcher so that it will match all such
// descriptions.
$(#[$fn_attr:meta])*
{ $fn_str:literal, fn $fn_id:ident $args:tt -> $ret:ty }
{ $fn_str:literal, $($min_proto:literal)?, $($max_proto:literal)?, fn $fn_id:ident $args:tt -> $ret:ty }
)*
}
)*
Expand Down

0 comments on commit b7bfa18

Please sign in to comment.