implement EXTCODESIZE

Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
xermicus
2024-05-22 22:56:03 +02:00
parent 06aa289d9b
commit 5138fe3d06
8 changed files with 100 additions and 8 deletions
+19 -1
View File
@@ -1,4 +1,4 @@
use alloy_primitives::{I256, U256};
use alloy_primitives::{Address, I256, U256};
use alloy_sol_types::{sol, SolCall, SolConstructor};
use crate::mock_runtime::{CallOutput, State};
@@ -123,6 +123,12 @@ sol!(
}
);
sol!(
contract ExtCode {
function ExtCodeSize(address who) public view returns (uint ret);
}
);
impl Contract {
/// Execute the contract.
///
@@ -405,6 +411,18 @@ impl Contract {
calldata: vec![0; 4],
}
}
pub fn ext_code_size(address: Address) -> Self {
let code = include_str!("../contracts/ExtCode.sol");
let name = "ExtCode";
Self {
name,
evm_runtime: crate::compile_evm_bin_runtime(name, code),
pvm_runtime: crate::compile_blob(name, code),
calldata: ExtCode::ExtCodeSizeCall::new((address,)).abi_encode(),
}
}
}
#[cfg(test)]