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

feat: add transient storage methods for the execute context for rust bindings #725

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
25 changes: 25 additions & 0 deletions bindings/rust/evmc-vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,31 @@ impl<'a> ExecutionContext<'a> {
)
}
}

/// Read from a transient storage key.
pub fn get_transient_storage(&self, address: &Address, key: &Bytes32) -> Bytes32 {
unsafe {
assert!((*self.host).get_transient_storage.is_some());
(*self.host).get_transient_storage.unwrap()(
self.context,
address as *const Address,
key as *const Bytes32,
)
}
}

/// Set value of a transient storage key.
pub fn set_transient_storage(&mut self, address: &Address, key: &Bytes32, value: &Bytes32) {
unsafe {
assert!((*self.host).set_transient_storage.is_some());
(*self.host).set_transient_storage.unwrap()(
self.context,
address as *const Address,
key as *const Bytes32,
value as *const Bytes32,
)
}
}
}

impl From<ffi::evmc_result> for ExecutionResult {
Expand Down