Skip to content

Commit

Permalink
Pick up protocol 21 (#1252)
Browse files Browse the repository at this point in the history
### What

Update env to pick up protocol 21. 
Fix breakage due to the `SnapshotSource` interface change. 

### Why

[TODO: Why this change is being made. Include any context required to
understand the why.]

### Known limitations

[TODO or N/A]
  • Loading branch information
jayz22 authored Apr 12, 2024
1 parent 9ea5328 commit 476a471
Show file tree
Hide file tree
Showing 105 changed files with 134 additions and 142 deletions.
22 changes: 11 additions & 11 deletions Cargo.lock

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

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ soroban-ledger-snapshot = { version = "20.5.0", path = "soroban-ledger-snapshot"
soroban-token-sdk = { version = "20.5.0", path = "soroban-token-sdk" }

[workspace.dependencies.soroban-env-common]
version = "=20.3.0"
version = "=21.0.0"
git = "https://github.com/stellar/rs-soroban-env"
rev = "a8c713db03ba5ebfdc4786b73dcba00284e15dbe"
rev = "4d9b1020f7b5baa0f972eb08ed8aa2cd3343ad7c"

[workspace.dependencies.soroban-env-guest]
version = "=20.3.0"
version = "=21.0.0"
git = "https://github.com/stellar/rs-soroban-env"
rev = "a8c713db03ba5ebfdc4786b73dcba00284e15dbe"
rev = "4d9b1020f7b5baa0f972eb08ed8aa2cd3343ad7c"

[workspace.dependencies.soroban-env-host]
version = "=20.3.0"
version = "=21.0.0"
git = "https://github.com/stellar/rs-soroban-env"
rev = "a8c713db03ba5ebfdc4786b73dcba00284e15dbe"
rev = "4d9b1020f7b5baa0f972eb08ed8aa2cd3343ad7c"

[workspace.dependencies.stellar-strkey]
version = "=0.0.8"
Expand All @@ -63,7 +63,7 @@ version = "=20.1.0"
default-features = false
features = ["curr"]
git = "https://github.com/stellar/rs-stellar-xdr"
rev = "3a001b1fbb20e4cfa2cef2c0cc450564e8528057"
rev = "a80c899c61e869fd00b7b475a4947ab6aaf9dcac"

#[patch."https://github.com/stellar/rs-soroban-env"]
#soroban-env-common = { path = "../rs-soroban-env/soroban-env-common" }
Expand Down
22 changes: 11 additions & 11 deletions soroban-ledger-snapshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{

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

Expand Down Expand Up @@ -182,22 +182,22 @@ impl Default for LedgerSnapshot {
}

impl SnapshotSource for &LedgerSnapshot {
fn get(&self, key: &Rc<LedgerKey>) -> Result<(Rc<LedgerEntry>, Option<u32>), HostError> {
fn get(
&self,
key: &Rc<LedgerKey>,
) -> Result<Option<(Rc<LedgerEntry>, Option<u32>)>, 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> {
fn get(
&self,
key: &Rc<LedgerKey>,
) -> Result<Option<(Rc<LedgerEntry>, Option<u32>)>, HostError> {
<_ as SnapshotSource>::get(&self, key)
}
fn has(&self, key: &Rc<LedgerKey>) -> Result<bool, HostError> {
<_ as SnapshotSource>::has(&self, key)
}
}
16 changes: 4 additions & 12 deletions soroban-sdk/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,7 @@ 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 @@ -484,20 +481,15 @@ impl Env {
fn get(
&self,
_key: &Rc<xdr::LedgerKey>,
) -> Result<(Rc<xdr::LedgerEntry>, Option<u32>), soroban_env_host::HostError>
) -> Result<Option<(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)
Ok(None)
}
}

let rf = Rc::new(EmptySnapshotSource());
let info = internal::LedgerInfo {
protocol_version: 20,
protocol_version: 21,
sequence_number: 0,
timestamp: 0,
network_id: [0; 32],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"auth": [],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"auth": [],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"auth": [],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"auth": [],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"auth": [],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"auth": [],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"auth": [],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"auth": [],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"auth": [],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"auth": [],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
]
],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
]
],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
]
],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
]
],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[]
],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
]
],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[]
],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
]
],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[]
],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
]
],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[]
],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
2 changes: 1 addition & 1 deletion soroban-sdk/test_snapshots/tests/budget/test_budget.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[]
],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[]
],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[]
],
"ledger": {
"protocol_version": 20,
"protocol_version": 21,
"sequence_number": 0,
"timestamp": 0,
"network_id": "0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
Loading

0 comments on commit 476a471

Please sign in to comment.