diff --git a/Cargo.lock b/Cargo.lock index 7b01c584..a06ba21c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,7 +112,6 @@ dependencies = [ "alloy-primitives", "alloy-sol-types", "cfg-if 1.0.0", - "derive_more", "grip", "mini-alloc", "once_cell", @@ -564,9 +563,9 @@ dependencies = [ [[package]] name = "stylus-proc" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "366c3323b03fc99c7d0124cec4eee10e37a226a14b08829a416feec9f2ebb641" +checksum = "9f274700c5c74abfcc9068f96564615173d8fed72ea44afd1e4404bb04478c00" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -583,9 +582,9 @@ dependencies = [ [[package]] name = "stylus-sdk" -version = "0.4.3" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74778bf11048b0155b937ee6d52440709d864aa488843238b62272e6c9bdbc1a" +checksum = "f4424e5f067b1b0922a4294efc01acaa1e36bfc7b31e6b0aed33d7221680f974" dependencies = [ "alloy-primitives", "alloy-sol-types", diff --git a/Cargo.toml b/Cargo.toml index f78a0b7d..cd6c987c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,8 +24,8 @@ repository = "https://github.com/OpenZeppelin/rust-contracts-stylus" [workspace.dependencies] alloy-primitives = { version = "0.3.1", default-features = false } alloy-sol-types = { version = "0.3.1", default-features = false } -stylus-sdk = { version = "0.4.3", default-features = false } -stylus-proc = { version = "0.4.3", default-features = false } +stylus-sdk = { version = "0.5.0", default-features = false } +stylus-proc = { version = "0.5.0", default-features = false } mini-alloc = "0.4.2" [profile.release] diff --git a/contracts/Cargo.toml b/contracts/Cargo.toml index 3f6bbde0..3cb58cdf 100644 --- a/contracts/Cargo.toml +++ b/contracts/Cargo.toml @@ -15,7 +15,6 @@ alloy-sol-types.workspace = true stylus-sdk.workspace = true stylus-proc.workspace = true mini-alloc.workspace = true -derive_more = "0.99.17" cfg-if = "1.0" [dev-dependencies] diff --git a/contracts/src/erc721/mod.rs b/contracts/src/erc721/mod.rs index 31c2e33f..68f7e637 100644 --- a/contracts/src/erc721/mod.rs +++ b/contracts/src/erc721/mod.rs @@ -2,7 +2,6 @@ use alloc::vec; use alloy_primitives::{fixed_bytes, Address, FixedBytes, U128, U256}; -use derive_more::From; use stylus_sdk::{ abi::Bytes, alloy_sol_types::sol, call::Call, evm, msg, prelude::*, }; @@ -91,7 +90,7 @@ sol! { /// An ERC-721 error defined as described in [ERC-6093]. /// /// [ERC-6093]: https://eips.ethereum.org/EIPS/eip-6093 -#[derive(SolidityError, Debug, From)] +#[derive(SolidityError, Debug)] pub enum Error { /// Indicates that an address can't be an owner. /// For example, `address(0)` is a forbidden owner in ERC-721. Used in diff --git a/lib/grip/src/shims.rs b/lib/grip/src/shims.rs index 68b57af4..a77acf08 100644 --- a/lib/grip/src/shims.rs +++ b/lib/grip/src/shims.rs @@ -120,19 +120,18 @@ pub unsafe extern "C" fn storage_load_bytes32(key: *const u8, out: *mut u8) { unsafe { write_bytes32(out, value) }; } -/// 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, +/// 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, /// then, are equivalent to that of the EVM's [`SSTORE`] opcode. /// -/// 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. +/// Note: because the value is cached, one must call `storage_flush_cache` to +/// persist it. /// /// [`SSTORE`]: https://www.evm.codes/#55 #[no_mangle] -pub unsafe extern "C" fn storage_store_bytes32( +pub unsafe extern "C" fn storage_cache_bytes32( key: *const u8, value: *const u8, ) { @@ -141,6 +140,15 @@ pub unsafe extern "C" fn storage_store_bytes32( 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";