diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index fbb5b1d5..419f86be 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -14,6 +14,7 @@ jobs: name: 'Test (Smoke)(${{ matrix.cfg_release_channel }})' env: CFG_RELEASE_CHANNEL: ${{ matrix.cfg_release_channel }} + PRIV_KEY: ${{ secrets.SEPOLIA_PRIVATE_KEY }} strategy: matrix: target: [wasm32-unknown-unknown] diff --git a/ci/smoke_test.sh b/ci/smoke_test.sh index 6c8b56c4..fa23fd4b 100755 --- a/ci/smoke_test.sh +++ b/ci/smoke_test.sh @@ -11,4 +11,4 @@ cargo stylus new counter cd counter echo "[workspace]" >> Cargo.toml -cargo stylus deploy -e http://localhost:8547 --private-key 0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659 +cargo stylus deploy --private-key $PRIV_KEY diff --git a/examples/erc20/Cargo.lock b/examples/erc20/Cargo.lock index 52f131b8..578ef6e0 100644 --- a/examples/erc20/Cargo.lock +++ b/examples/erc20/Cargo.lock @@ -624,10 +624,11 @@ dependencies = [ [[package]] name = "stylus-proc" -version = "0.1.0" +version = "0.4.2" dependencies = [ "alloy-primitives", "alloy-sol-types", + "cfg-if 1.0.0", "convert_case 0.6.0", "lazy_static", "proc-macro2", @@ -640,10 +641,11 @@ dependencies = [ [[package]] name = "stylus-sdk" -version = "0.1.0" +version = "0.4.2" dependencies = [ "alloy-primitives", "alloy-sol-types", + "cfg-if 1.0.0", "derivative", "fnv", "hex", diff --git a/examples/erc20/src/main.rs b/examples/erc20/src/main.rs index e12bf2fb..6778a35b 100644 --- a/examples/erc20/src/main.rs +++ b/examples/erc20/src/main.rs @@ -48,7 +48,7 @@ impl Weth { self.erc20.burn(msg::sender(), amount)?; // send the user their funds - call::transfer_eth(self, msg::sender(), amount) + call::transfer_eth(msg::sender(), amount) } // sums numbers diff --git a/stylus-sdk/src/hostio.rs b/stylus-sdk/src/hostio.rs index 7d2d861a..5e3535b0 100644 --- a/stylus-sdk/src/hostio.rs +++ b/stylus-sdk/src/hostio.rs @@ -52,6 +52,24 @@ extern "C" { /// [`SSTORE`]: https://www.evm.codes/#55 pub fn storage_store_bytes32(key: *const u8, value: *const u8); + /// Reads a 32-byte value from transient storage. Stylus's storage format is identical to + /// that of the EVM. This means that, under the hood, this hostio is accessing the 32-byte + /// value stored in the EVM transient storage at offset `key`, which will be `0` when not + /// previously set. The semantics, then, are equivalent to that of the EVM's [`TLOAD`] opcode. + /// + /// [`TLOAD`]: https://eips.ethereum.org/EIPS/eip-1153 + #[allow(dead_code)] + pub fn transient_load_bytes32(key: *const u8, dest: *mut u8); + + /// Stores a 32-byte value to transient 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 transient storage at offset `key`. Furthermore, refunds are tabulated exactly as in + /// the EVM. The semantics, then, are equivalent to that of the EVM's [`TSTORE`] opcode. + /// + /// [`TSTORE`]: https://eips.ethereum.org/EIPS/eip-1153 + #[allow(dead_code)] + pub fn transient_store_bytes32(key: *const u8, value: *const u8); + /// Gets the basefee of the current block. The semantics are equivalent to that of the EVM's /// [`BASEFEE`] opcode. /// diff --git a/stylus-sdk/src/storage/mod.rs b/stylus-sdk/src/storage/mod.rs index 80853ba8..99bf9239 100644 --- a/stylus-sdk/src/storage/mod.rs +++ b/stylus-sdk/src/storage/mod.rs @@ -82,6 +82,26 @@ pub unsafe fn store_bytes32(key: U256, data: B256) { unsafe { hostio::storage_store_bytes32(B256::from(key).as_ptr(), data.as_ptr()) }; } +/// Retrieves a 32-byte EVM word from transient storage directly, bypassing all caches. +/// +/// # Safety +/// +/// May alias transient storage. +pub unsafe fn transient_load_bytes32(key: U256) -> B256 { + let mut data = B256::ZERO; + unsafe { hostio::transient_load_bytes32(B256::from(key).as_ptr(), data.as_mut_ptr()) }; + data +} + +/// Stores a 32-byte EVM word to transient storage directly, bypassing all caches. +/// +/// # Safety +/// +/// May alias transient storage. +pub unsafe fn transient_store_bytes32(key: U256, data: B256) { + unsafe { hostio::transient_store_bytes32(B256::from(key).as_ptr(), data.as_ptr()) }; +} + /// Overwrites the value in a cell. #[inline] fn overwrite_cell(cell: &mut OnceCell, value: T) { diff --git a/stylus-sdk/src/types.rs b/stylus-sdk/src/types.rs index 95692201..eb2594e7 100644 --- a/stylus-sdk/src/types.rs +++ b/stylus-sdk/src/types.rs @@ -49,7 +49,7 @@ impl AddressVM for Address { fn has_code(&self) -> bool { let hash = self.codehash(); - hash.is_zero() - || hash == b256!("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470") + !hash.is_zero() + && hash != b256!("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470") } }