@@ -21,7 +21,7 @@ pub const PREIMAGE_ORACLE_ADDR: [u8; 20] = hex!("0000000000000000000000000000000
21
21
pub const MIPS_CREATION_CODE : & str = include_str ! ( "../../bindings/mips_creation.bin" ) ;
22
22
/// The deployed EVM bytecode of the PreimageOracle contract.
23
23
pub const PREIMAGE_ORACLE_DEPLOYED_CODE : & str =
24
- include_str ! ( "../../bindings/preimage_oracle_deployed .bin" ) ;
24
+ include_str ! ( "../../bindings/preimage_creation .bin" ) ;
25
25
26
26
/// A wrapper around a [revm] interpreter with an in-memory backend that has the MIPS & PreimageOracle
27
27
/// smart contracts deployed at deterministic addresses. This is used for differential testing the
@@ -62,10 +62,27 @@ impl<'a> MipsEVM<'a, CacheDB<EmptyDB>> {
62
62
) ;
63
63
64
64
// Deploy the PreimageOracle contract.
65
- self . deploy_contract (
66
- Address :: from_slice ( PREIMAGE_ORACLE_ADDR . as_slice ( ) ) ,
67
- Bytes :: from ( hex:: decode ( PREIMAGE_ORACLE_DEPLOYED_CODE ) ?) ,
68
- ) ?;
65
+ let preimage_creation_heap = hex:: decode ( PREIMAGE_ORACLE_DEPLOYED_CODE ) ?
66
+ . into_iter ( )
67
+ . chain ( [ 0u8 ; 64 ] )
68
+ . collect :: < Vec < _ > > ( ) ;
69
+ self . fill_tx_env ( TransactTo :: Create , preimage_creation_heap. into ( ) ) ;
70
+ if let Ok ( ResultAndState {
71
+ result :
72
+ revm:: primitives:: ExecutionResult :: Success {
73
+ reason : _,
74
+ gas_used : _,
75
+ gas_refunded : _,
76
+ logs : _,
77
+ output : Output :: Create ( code, _) ,
78
+ } ,
79
+ state : _,
80
+ } ) = self . inner . transact ( )
81
+ {
82
+ self . deploy_contract ( Address :: from_slice ( PREIMAGE_ORACLE_ADDR . as_slice ( ) ) , code) ?;
83
+ } else {
84
+ anyhow:: bail!( "Failed to deploy PreimageOracle contract" ) ;
85
+ } ;
69
86
70
87
// Deploy the MIPS contract prior to deploying it manually. This contract has an immutable
71
88
// variable, so we let the creation code fill this in for us, and then deploy it to the
@@ -229,40 +246,6 @@ mod test {
229
246
path:: PathBuf ,
230
247
} ;
231
248
232
- #[ test]
233
- fn sanity_evm_execution ( ) {
234
- const SAMPLE : [ u8 ; 2180 ] = hex ! ( "f8e0cb960000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000e22306a30adb7e99858491484b0d6627fe00efea43ec78488033a797a499e22ad6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007000e000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5b4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d3021ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85e58769b32a1beaf1ea27375a44095a0d1fb664ce2dd358e7fcbfb78c26a193440eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968ffd70157e48063fc33c97a050f7f640233bf646cc98d9524c6b92bcf3ab56f839867cc5f7f196b93bae1e27e6320742445d290f2263827498b54fec539f756afcefad4e508c098b9a7e1d8feb19955fb02ba9675585078710969d3440f5054e0f9dc3e7fe016e050eff260334f18a5d4fe391d82092319f5964f2e2eb7c1c3a5f8b13a49e282f609c317a833fb8d976d11517c571d1221a265d25af778ecf8923490c6ceeb450aecdc82e28293031d10c7d73bf85e57bf041a97360aa2c5d99cc1df82d9c4b87413eae2ef048f94b4d3554cea73d92b0f7af96e0271c691e2bb5c67add7c6caf302256adedf7ab114da0acfe870d449a3a489f781d659e8beccda7bce9f4e8618b6bd2f4132ce798cdc7a60e7e1460a7299e3c6342a579626d22733e50f526ec2fa19a22b31e8ed50f23cd1fdf94c9154ed3a7609a2f1ff981fe1d3b5c807b281e4683cc6d6315cf95b9ade8641defcb32372f1c126e398ef7a5a2dce0a8a7f68bb74560f8f71837c2c2ebbcbf7fffb42ae1896f13f7c7479a0b46a28b6f55540f89444f63de0378e3d121be09e06cc9ded1c20e65876d36aa0c65e9645644786b620e2dd2ad648ddfcbf4a7e5b1a3a4ecfe7f64667a3f0b7e2f4418588ed35a2458cffeb39b93d26f18d2ab13bdce6aee58e7b99359ec2dfd95a9c16dc00d6ef18b7933a6f8dc65ccb55667138776f7dea101070dc8796e3774df84f40ae0c8229d0d6069e5c8f39a7c299677a09d367fc7b05e3bc380ee652cdc72595f74c7b1043d0e1ffbab734648c838dfb0527d971b602bc216c9619ef0abf5ac974a1ed57f4050aa510dd9c74f508277b39d7973bb2dfccc5eeb0618db8cd74046ff337f0a7bf2c8e03e10f642c1886798d71806ab1e888d9e5ee87d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" ) ;
235
-
236
- let mut mips_evm = MipsEVM :: new ( ) ;
237
- mips_evm. try_init ( ) . unwrap ( ) ;
238
-
239
- mips_evm. fill_tx_env (
240
- TransactTo :: Call ( MIPS_ADDR . into ( ) ) ,
241
- Bytes :: from ( SAMPLE . to_vec ( ) ) ,
242
- ) ;
243
-
244
- let ResultAndState { result, state : _ } = mips_evm. inner . transact ( ) . unwrap ( ) ;
245
-
246
- assert ! ( result. is_success( ) ) ;
247
- let ExecutionResult :: Success {
248
- reason : _,
249
- gas_used : _,
250
- gas_refunded : _,
251
- logs : _,
252
- output : Output :: Call ( output) ,
253
- } = result
254
- else {
255
- panic ! ( "Expected success, got {:?}" , result) ;
256
- } ;
257
-
258
- assert_eq ! (
259
- output,
260
- Bytes :: from_static( & hex!(
261
- "03720be420feea4ae4f803f0f630004f8bd2b0256171dd26043e48bf524da332"
262
- ) )
263
- ) ;
264
- }
265
-
266
249
#[ test]
267
250
fn evm ( ) {
268
251
let mut mips_evm = MipsEVM :: new ( ) ;
0 commit comments