-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
959 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"inputs":[],"name":"storeBlobBaseFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"x","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6080604052348015600e575f5ffd5b5060c680601a5f395ff3fe6080604052348015600e575f5ffd5b50600436106030575f3560e01c80630c55699c1460345780634c4b2fc814604e575b5f5ffd5b603a6056565b604051604591906079565b60405180910390f35b6054605b565b005b5f5481565b4a5f81905550565b5f819050919050565b6073816063565b82525050565b5f602082019050608a5f830184606c565b9291505056fea2646970667358221220203976141a6cec06f953d81e19d2a5c9fdf81af642a41beb42f6c2e9cf22a77464736f6c634300081c0033 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.28; | ||
|
||
contract BlobBaseFee{ | ||
uint256 public x; | ||
function storeBlobBaseFee() external { | ||
x = block.blobbasefee; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"inputs":[],"name":"memoryCopy","outputs":[{"internalType":"bytes32","name":"x","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6080604052348015600e575f5ffd5b5060bc80601a5f395ff3fe6080604052348015600e575f5ffd5b50600436106026575f3560e01c80632dbaeee914602a575b5f5ffd5b60306044565b604051603b9190606f565b60405180910390f35b5f60506020526020805f5e5f519050805f5590565b5f819050919050565b6069816059565b82525050565b5f60208201905060805f8301846062565b9291505056fea264697066735822122036ac0d8164bbe16a7971d0609110f6a3caba5a571d3997e8bcc9e4a9a1ed53c864736f6c634300081c0033 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
|
||
pragma solidity 0.8.28; | ||
|
||
contract Mcopy { | ||
|
||
function memoryCopy() external returns (bytes32 x) { | ||
assembly { | ||
mstore(0x20, 0x50) // Store 0x50 at word 1 in memory | ||
mcopy(0, 0x20, 0x20) // Copies 0x50 to word 0 in memory | ||
x := mload(0) // Returns 32 bytes "0x50" | ||
sstore(0, x) // Stores 0x50 at storage slot 0 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"inputs":[{"internalType":"address payable","name":"recipient","type":"address"}],"stateMutability":"payable","type":"constructor"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
608060405260405160b838038060b88339818101604052810190602191906091565b8073ffffffffffffffffffffffffffffffffffffffff16ff5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f606582603e565b9050919050565b607381605d565b8114607c575f5ffd5b50565b5f81519050608b81606c565b92915050565b5f6020828403121560a35760a2603a565b5b5f60ae84828501607f565b9150509291505056fe |
10 changes: 10 additions & 0 deletions
10
crates/evm/src/evm/test_data/SelfdestructingConstructor.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.28; | ||
|
||
contract SelfdestructingConstructor { | ||
// Constructor with an address parameter | ||
constructor(address payable recipient) payable { | ||
// Call selfdestruct to send the contract's balance to the recipient | ||
selfdestruct(recipient); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"inputs":[],"name":"claimGift","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6080604052348015600e575f5ffd5b506102e68061001c5f395ff3fe608060405260043610610021575f3560e01c80638f7c8d101461002c57610028565b3661002857005b5f5ffd5b348015610037575f5ffd5b50610040610042565b005b5f5f905c906101000a900460ff1615610090576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161008790610251565b60405180910390fd5b60015f5f6101000a815c8160ff021916908315150217905d50670de0b6b3a76400004710156100bd575f5ffd5b5f5f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff161561010f575f5ffd5b5f3373ffffffffffffffffffffffffffffffffffffffff16670de0b6b3a764000060405161013c9061029c565b5f6040518083038185875af1925050503d805f8114610176576040519150601f19603f3d011682016040523d82523d5f602084013e61017b565b606091505b5050905080610188575f5ffd5b60015f5f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff021916908315150217905550505f5f5f6101000a815c8160ff021916908315150217905d50565b5f82825260208201905092915050565b7f5265656e7472616e637920617474656d707400000000000000000000000000005f82015250565b5f61023b6012836101f7565b915061024682610207565b602082019050919050565b5f6020820190508181035f8301526102688161022f565b9050919050565b5f81905092915050565b50565b5f6102875f8361026f565b915061029282610279565b5f82019050919050565b5f6102a68261027c565b915081905091905056fea2646970667358221220a38a24567c1b46caacc375bdb5e850d00f7fd8a4cfeb62c770af9e0d0b3d9c0464736f6c634300081c0033 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.28; | ||
|
||
contract TransientStorage { | ||
mapping(address => bool) sentGifts; | ||
bool transient locked; | ||
|
||
modifier nonReentrant { | ||
require(!locked, "Reentrancy attempt"); | ||
locked = true; | ||
_; | ||
// Unlocks the guard, making the pattern composable. | ||
// After the function exits, it can be called again, even in the same transaction. | ||
locked = false; | ||
} | ||
|
||
function claimGift() nonReentrant public { | ||
require(address(this).balance >= 1 ether); | ||
require(!sentGifts[msg.sender]); | ||
(bool success, ) = msg.sender.call{value: 1 ether}(""); | ||
require(success); | ||
|
||
// In a reentrant function, doing this last would open up the vulnerability | ||
sentGifts[msg.sender] = true; | ||
} | ||
|
||
// Function to receive Ether. This is required to receive Ether into the contract | ||
receive() external payable {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use alloy_sol_types::{sol, SolCall}; | ||
|
||
use super::TestContract; | ||
|
||
// BlobBaseFeeContract wrapper. | ||
sol! { | ||
#[sol(abi)] | ||
BlobBaseFee, | ||
"./src/evm/test_data/BlobBaseFee.abi" | ||
} | ||
|
||
/// BlobBaseFeeContract wrapper. | ||
pub struct BlobBaseFeeContract { | ||
bytecode: Vec<u8>, | ||
} | ||
|
||
impl Default for BlobBaseFeeContract { | ||
fn default() -> Self { | ||
let bytecode = { | ||
let bytecode_hex = include_str!("../../../evm/src/evm/test_data/BlobBaseFee.bin"); | ||
hex::decode(bytecode_hex).unwrap() | ||
}; | ||
|
||
Self { bytecode } | ||
} | ||
} | ||
|
||
impl TestContract for BlobBaseFeeContract { | ||
fn byte_code(&self) -> Vec<u8> { | ||
self.byte_code() | ||
} | ||
} | ||
|
||
impl BlobBaseFeeContract { | ||
/// BlobBaseFee bytecode. | ||
pub fn byte_code(&self) -> Vec<u8> { | ||
self.bytecode.clone() | ||
} | ||
|
||
/// Store blobbasefee | ||
pub fn store_blob_base_fee(&self) -> Vec<u8> { | ||
BlobBaseFee::storeBlobBaseFeeCall {}.abi_encode() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use alloy_sol_types::{sol, SolCall}; | ||
|
||
use super::TestContract; | ||
|
||
// McopyContract wrapper. | ||
sol! { | ||
#[sol(abi)] | ||
Mcopy, | ||
"./src/evm/test_data/Mcopy.abi" | ||
} | ||
|
||
/// McopyContract wrapper. | ||
pub struct McopyContract { | ||
bytecode: Vec<u8>, | ||
} | ||
|
||
impl Default for McopyContract { | ||
fn default() -> Self { | ||
let bytecode = { | ||
let bytecode_hex = include_str!("../../../evm/src/evm/test_data/Mcopy.bin"); | ||
hex::decode(bytecode_hex).unwrap() | ||
}; | ||
|
||
Self { bytecode } | ||
} | ||
} | ||
|
||
impl TestContract for McopyContract { | ||
fn byte_code(&self) -> Vec<u8> { | ||
self.byte_code() | ||
} | ||
} | ||
|
||
impl McopyContract { | ||
/// Mcopy bytecode. | ||
pub fn byte_code(&self) -> Vec<u8> { | ||
self.bytecode.clone() | ||
} | ||
|
||
/// Claims the gift. | ||
pub fn call_mcopy(&self) -> Vec<u8> { | ||
Mcopy::memoryCopyCall {}.abi_encode() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
crates/evm/src/smart_contracts/selfdestructing_constructor.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use alloy_primitives::Address; | ||
use alloy_sol_types::{sol, SolConstructor}; | ||
|
||
use super::TestContract; | ||
|
||
// SelfdestructingConstructorContract wrapper. | ||
sol! { | ||
#[sol(abi)] | ||
SelfdestructingConstructor, | ||
"./src/evm/test_data/SelfdestructingConstructor.abi" | ||
} | ||
|
||
/// SelfdestructingConstructorContract wrapper. | ||
pub struct SelfdestructingConstructorContract { | ||
bytecode: Vec<u8>, | ||
} | ||
|
||
impl Default for SelfdestructingConstructorContract { | ||
fn default() -> Self { | ||
let bytecode = { | ||
let bytecode_hex = | ||
include_str!("../../../evm/src/evm/test_data/SelfdestructingConstructor.bin"); | ||
hex::decode(bytecode_hex).unwrap() | ||
}; | ||
|
||
Self { bytecode } | ||
} | ||
} | ||
|
||
impl TestContract for SelfdestructingConstructorContract { | ||
fn byte_code(&self) -> Vec<u8> { | ||
self.byte_code() | ||
} | ||
} | ||
|
||
impl SelfdestructingConstructorContract { | ||
/// SelfdestructingConstructor bytecode. | ||
pub fn byte_code(&self) -> Vec<u8> { | ||
self.bytecode.clone() | ||
} | ||
|
||
/// Claims the gift. | ||
pub fn construct(&self, recipient: Address) -> Vec<u8> { | ||
let mut v = self.byte_code(); | ||
|
||
v.extend_from_slice( | ||
&SelfdestructingConstructor::constructorCall { recipient }.abi_encode(), | ||
); | ||
|
||
v | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
crates/evm/src/smart_contracts/transient_storage_contract.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use alloy_sol_types::{sol, SolCall}; | ||
|
||
use super::TestContract; | ||
|
||
// TransientStorageContract wrapper. | ||
sol! { | ||
#[sol(abi)] | ||
TransientStorage, | ||
"./src/evm/test_data/TransientStorage.abi" | ||
} | ||
|
||
/// TransientStorageContract wrapper. | ||
pub struct TransientStorageContract { | ||
bytecode: Vec<u8>, | ||
} | ||
|
||
impl Default for TransientStorageContract { | ||
fn default() -> Self { | ||
let bytecode = { | ||
let bytecode_hex = include_str!("../../../evm/src/evm/test_data/TransientStorage.bin"); | ||
hex::decode(bytecode_hex).unwrap() | ||
}; | ||
|
||
Self { bytecode } | ||
} | ||
} | ||
|
||
impl TestContract for TransientStorageContract { | ||
fn byte_code(&self) -> Vec<u8> { | ||
self.byte_code() | ||
} | ||
} | ||
|
||
impl TransientStorageContract { | ||
/// TransientStorage bytecode. | ||
pub fn byte_code(&self) -> Vec<u8> { | ||
self.bytecode.clone() | ||
} | ||
|
||
/// Claims the gift. | ||
pub fn claim_gift(&self) -> Vec<u8> { | ||
TransientStorage::claimGiftCall {}.abi_encode() | ||
} | ||
} |
Oops, something went wrong.