Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decorate error for nonce missing from the footprint. #1112

Merged
merged 3 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions soroban-env-host/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@ impl AccountAuthorizationTracker {
fn snapshot(&self, budget: &Budget) -> Result<AccountAuthorizationTrackerSnapshot, HostError> {
Ok(AccountAuthorizationTrackerSnapshot {
invocation_tracker_root_snapshot: self.invocation_tracker.snapshot(budget)?,
// We need to snapshot authenctioncation and nocne-related fields as
// We need to snapshot authentication and nonce-related fields as
// during the rollback the nonce might be 'un-consumed' during
// the storage rollback. We don't snapshot `is_valid` since this is
// not recoverable and nonce is never consumed for invalid
Expand Down Expand Up @@ -1799,7 +1799,19 @@ impl Host {
let live_until_ledger = live_until_ledger
.max(self.get_min_live_until_ledger(xdr::ContractDataDurability::Temporary)?);
self.with_mut_storage(|storage| {
if storage.has(&nonce_key, self.budget_ref())? {
if storage.has(&nonce_key, self.budget_ref()).map_err(|err| {
if err.error.is_type(ScErrorType::Storage)
&& err.error.is_code(ScErrorCode::ExceededLimit)
{
return self.err(
ScErrorType::Storage,
ScErrorCode::ExceededLimit,
"trying to access nonce outside of footprint for address",
&[address.to_val()],
);
}
err
})? {
return Err(self.err(
ScErrorType::Auth,
ScErrorCode::ExistingValue,
Expand Down Expand Up @@ -1857,6 +1869,7 @@ impl Host {

#[cfg(any(test, feature = "testutils"))]
use crate::{host::frame::ContractReentryMode, xdr::SorobanAuthorizedInvocation};

#[cfg(any(test, feature = "testutils"))]
impl Host {
/// Invokes the reserved `__check_auth` function on a provided contract.
Expand Down
2 changes: 1 addition & 1 deletion soroban-env-host/src/host_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl Host {
Err(self.err(
ScErrorType::Object,
ScErrorCode::MissingValue,
"unknown object reference",
"unknown object reference, is it coming from a different environment?",
&[payload_val],
))
}
Expand Down