Runs CLZ bytecode (`PUSH1 0x80, CLZ, PUSH1 0x00, MSTORE, PUSH1 0x20, PUSH1 0x00, RETURN`) against the given spec and returns the execution result.
(
spec: BaseSpecId,
)
| 867 | /// Runs CLZ bytecode (`PUSH1 0x80, CLZ, PUSH1 0x00, MSTORE, PUSH1 0x20, PUSH1 0x00, RETURN`) |
| 868 | /// against the given spec and returns the execution result. |
| 869 | fn run_clz_bytecode( |
| 870 | spec: BaseSpecId, |
| 871 | ) -> revm::context_interface::result::ExecutionResult<BaseHaltReason> { |
| 872 | let contract = Address::from([0x42; 20]); |
| 873 | let mut db = InMemoryDB::default(); |
| 874 | db.insert_account_info( |
| 875 | contract, |
| 876 | AccountInfo { |
| 877 | code: Some(Bytecode::new_legacy(bytes!("60801E60005260206000F3"))), |
| 878 | ..Default::default() |
| 879 | }, |
| 880 | ); |
| 881 | db.insert_account_info( |
| 882 | Address::ZERO, |
| 883 | AccountInfo { balance: U256::from(1_000_000), ..Default::default() }, |
| 884 | ); |
| 885 | |
| 886 | let ctx = Context::base() |
| 887 | .with_db(db) |
| 888 | .with_tx( |
| 889 | BaseTransaction::builder() |
| 890 | .base(TxEnv::builder().gas_limit(100_000).kind(TxKind::Call(contract))) |
| 891 | .enveloped_tx(Some(bytes!("FACADE"))) |
| 892 | .build_fill(), |
| 893 | ) |
| 894 | .with_cfg(CfgEnv::new_with_spec(spec)) |
| 895 | .with_chain(L1BlockInfo { |
| 896 | l2_block: Some(U256::ZERO), |
| 897 | operator_fee_scalar: Some(U256::ZERO), |
| 898 | operator_fee_constant: Some(U256::ZERO), |
| 899 | ..Default::default() |
| 900 | }); |
| 901 | let mut evm = ctx.build_base(); |
| 902 | |
| 903 | let mut handler = |
| 904 | BaseHandler::<_, EVMError<_, BaseTransactionError>, EthFrame<EthInterpreter>>::new(); |
| 905 | handler.run(&mut evm).unwrap() |
| 906 | } |
| 907 | |
| 908 | #[test] |
| 909 | fn test_clz_opcode_azul() { |