Skip to content

Commit

Permalink
revert shims for stylus 0.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
qalisander committed May 16, 2024
1 parent 8193953 commit 62b5c4f
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions lib/grip/src/shims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,35 +120,26 @@ pub unsafe extern "C" fn storage_load_bytes32(key: *const u8, out: *mut u8) {
unsafe { write_bytes32(out, value) };
}

/// Writes a 32-byte value to the permanent storage cache. Stylus's storage
/// format is identical to that of the EVM. This means that, under the hood,
/// this hostio represents storing a 32-byte value into the EVM state trie at
/// offset `key`. Refunds are tabulated exactly as in the EVM. The semantics,
/// Stores a 32-byte value to permanent storage. Stylus's storage format is
/// identical to that of the EVM. This means that, under the hood, this hostio
/// is storing a 32-byte value into the EVM state trie at offset `key`.
/// Furthermore, refunds are tabulated exactly as in the EVM. The semantics,
/// then, are equivalent to that of the EVM's [`SSTORE`] opcode.
///
/// Note: because the value is cached, one must call `storage_flush_cache` to
/// persist it.
/// Note: we require the [`SSTORE`] sentry per EVM rules. The `gas_cost`
/// returned by the EVM API may exceed this amount, but that's ok because the
/// predominant cost is due to state bloat concerns.
///
/// [`SSTORE`]: https://www.evm.codes/#55
#[no_mangle]
pub unsafe extern "C" fn storage_cache_bytes32(
pub unsafe extern "C" fn storage_store_bytes32(
key: *const u8,
value: *const u8,
) {
let (key, value) = unsafe { (read_bytes32(key), read_bytes32(value)) };

STORAGE.lock().unwrap().insert(key, value);
}

/// Persists any dirty values in the storage cache to the EVM state trie,
/// dropping the cache entirely if requested. Analogous to repeated invocations
/// of [`SSTORE`].
///
/// [`SSTORE`]: https://www.evm.codes/#55
pub fn storage_flush_cache(_: bool) {
// No-op: we don't use the cache in our unit-tests.
}

/// Dummy msg sender set for tests.
pub const MSG_SENDER: &[u8; 42] = b"0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF";

Expand Down

0 comments on commit 62b5c4f

Please sign in to comment.