diff --git a/cmd/ef_tests/levm/runner/levm_runner.rs b/cmd/ef_tests/levm/runner/levm_runner.rs index fb0273b7e..ef0958c3e 100644 --- a/cmd/ef_tests/levm/runner/levm_runner.rs +++ b/cmd/ef_tests/levm/runner/levm_runner.rs @@ -73,31 +73,38 @@ pub fn prepare_vm_for_tx(vector: &TestVector, test: &EFTest) -> Result, pub chain_id: U256, pub base_fee_per_gas: U256, - pub gas_price: U256, + pub gas_price: U256, // Effective gas price pub block_excess_blob_gas: Option, pub block_blob_gas_used: Option, - pub tx_blob_hashes: Option>, + pub tx_blob_hashes: Vec, + pub tx_max_priority_fee_per_gas: Option, + pub tx_max_fee_per_gas: Option, + pub tx_max_fee_per_blob_gas: Option, + pub block_gas_limit: U256, } impl Environment { @@ -38,6 +42,10 @@ impl Environment { block_excess_blob_gas: Default::default(), block_blob_gas_used: Default::default(), tx_blob_hashes: Default::default(), + tx_max_priority_fee_per_gas: Default::default(), + tx_max_fee_per_gas: Default::default(), + tx_max_fee_per_blob_gas: Default::default(), + block_gas_limit: Default::default(), } } } diff --git a/crates/vm/levm/src/errors.rs b/crates/vm/levm/src/errors.rs index 3a5970dd4..2f6a4300a 100644 --- a/crates/vm/levm/src/errors.rs +++ b/crates/vm/levm/src/errors.rs @@ -76,6 +76,48 @@ pub enum VMError { // Internal #[error("Internal error: {0}")] Internal(#[from] InternalError), + #[error("Transaction validation error: {0}")] + TxValidation(#[from] TxValidationError), +} + +impl VMError { + pub fn is_internal(&self) -> bool { + matches!(self, VMError::Internal(_)) + } +} + +#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error, Serialize, Deserialize)] +pub enum TxValidationError { + #[error("Sender account should not have bytecode")] + SenderNotEOA, + #[error("Insufficient account founds")] + InsufficientAccountFunds, + #[error("Nonce is max (overflow)")] + NonceIsMax, + #[error("Initcode size exceeded")] + InitcodeSizeExceeded, + #[error("Priority fee greater than max fee per gas")] + PriorityGreaterThanMaxFeePerGas, + #[error("Intrinsic gas too low")] + IntrinsicGasTooLow, + #[error("Gas allowance exceeded")] + GasAllowanceExceeded, + #[error("Insufficient max fee per gas")] + InsufficientMaxFeePerGas, + #[error("Insufficient max fee per blob gas")] + InsufficientMaxFeePerBlobGas, + #[error("Type3TxZeroBlobs")] + Type3TxZeroBlobs, + #[error("Type3TxInvalidBlobVersionedHash")] + Type3TxInvalidBlobVersionedHash, + #[error("Type3TxBlobCountExceeded")] + Type3TxBlobCountExceeded, + #[error("Type3TxContractCreation")] + Type3TxContractCreation, + #[error("Undefined state")] + UndefinedState(i32), // This error is temporarily for things that cause an undefined state. + #[error("Gas limit price product overflow")] + GasLimitPriceProductOverflow, } #[derive(Debug, Clone, PartialEq, Eq, Hash, thiserror::Error, Serialize, Deserialize)] diff --git a/crates/vm/levm/src/opcode_handlers/block.rs b/crates/vm/levm/src/opcode_handlers/block.rs index e9662f61e..ae81bbbb1 100644 --- a/crates/vm/levm/src/opcode_handlers/block.rs +++ b/crates/vm/levm/src/opcode_handlers/block.rs @@ -7,7 +7,7 @@ use crate::{ }; use ethrex_core::{ types::{BLOB_BASE_FEE_UPDATE_FRACTION, MIN_BASE_FEE_PER_BLOB_GAS}, - H256, U256, + U256, }; // Block Information (11) @@ -170,22 +170,16 @@ impl VM { .try_into() .map_err(|_err| VMError::VeryLargeNumber)?; - let blob_hash: H256 = match &self.env.tx_blob_hashes { - Some(vec) => match vec.get(index) { - Some(el) => *el, - None => { - return Err(VMError::BlobHashIndexOutOfBounds); - } - }, - None => { - return Err(VMError::MissingBlobHashes); - } - }; - - // Could not find a better way to translate from H256 to U256 - let u256_blob = U256::from(blob_hash.as_bytes()); - - current_call_frame.stack.push(u256_blob)?; + let blob_hashes = &self.env.tx_blob_hashes; + + blob_hashes + .get(index) + .map(|el| { + current_call_frame + .stack + .push(U256::from_big_endian(el.as_bytes())) + }) + .unwrap_or_else(|| current_call_frame.stack.push(U256::zero()))?; Ok(OpcodeSuccess::Continue) } diff --git a/crates/vm/levm/src/vm.rs b/crates/vm/levm/src/vm.rs index 0bc2b752e..83be8be8a 100644 --- a/crates/vm/levm/src/vm.rs +++ b/crates/vm/levm/src/vm.rs @@ -6,9 +6,9 @@ use crate::{ environment::Environment, errors::{ InternalError, OpcodeSuccess, OutOfGasError, ResultReason, TransactionReport, TxResult, - VMError, + TxValidationError, VMError, }, - gas_cost, + gas_cost::{self}, opcodes::Opcode, AccountInfo, }; @@ -168,7 +168,10 @@ impl VM { // TODO: https://github.com/lambdaclass/ethrex/issues/1088 } - pub fn execute(&mut self, current_call_frame: &mut CallFrame) -> TransactionReport { + pub fn execute( + &mut self, + current_call_frame: &mut CallFrame, + ) -> Result { // Backup of Database, Substate and Gas Refunds if sub-context is reverted let (backup_db, backup_substate, backup_refunded_gas) = ( self.cache.clone(), @@ -177,20 +180,7 @@ impl VM { ); loop { - let opcode = match current_call_frame.next_opcode() { - Ok(opt) => opt.unwrap_or(Opcode::STOP), - Err(e) => { - return TransactionReport { - result: TxResult::Revert(e), - new_state: self.cache.clone(), - gas_used: current_call_frame.gas_used.low_u64(), - gas_refunded: self.env.refunded_gas.low_u64(), - output: current_call_frame.returndata.clone(), // Bytes::new() if error is not RevertOpcode - logs: current_call_frame.logs.clone(), - created_address: None, - }; - } - }; + let opcode = current_call_frame.next_opcode()?.unwrap_or(Opcode::STOP); // This will execute opcode stop if there are no more opcodes, there are other ways of solving this but this is the simplest and doesn't change VM behavior. // Note: This is commented because it's used for debugging purposes in development. // dbg!(¤t_call_frame.gas_used); @@ -301,7 +291,7 @@ impl VM { Ok(OpcodeSuccess::Continue) => {} Ok(OpcodeSuccess::Result(_)) => { self.call_frames.push(current_call_frame.clone()); - return TransactionReport { + return Ok(TransactionReport { result: TxResult::Success, new_state: self.cache.clone(), gas_used: current_call_frame.gas_used.low_u64(), @@ -309,11 +299,15 @@ impl VM { output: current_call_frame.returndata.clone(), logs: current_call_frame.logs.clone(), created_address: None, - }; + }); } Err(error) => { self.call_frames.push(current_call_frame.clone()); + if error.is_internal() { + return Err(error); + } + // Unless error is from Revert opcode, all gas is consumed if error != VMError::RevertOpcode { let left_gas = current_call_frame @@ -326,7 +320,7 @@ impl VM { self.restore_state(backup_db, backup_substate, backup_refunded_gas); - return TransactionReport { + return Ok(TransactionReport { result: TxResult::Revert(error), new_state: self.cache.clone(), gas_used: current_call_frame.gas_used.low_u64(), @@ -334,7 +328,7 @@ impl VM { output: current_call_frame.returndata.clone(), // Bytes::new() if error is not RevertOpcode logs: current_call_frame.logs.clone(), created_address: None, - }; + }); } } } @@ -351,27 +345,12 @@ impl VM { self.env.refunded_gas = backup_refunded_gas; } - // let account = self.db.accounts.get(&self.env.origin).ok_or(VMError::FatalUnwrap)?; - /// Based on Ethereum yellow paper's initial tests of intrinsic validity (Section 6). The last version is - /// Shanghai, so there are probably missing Cancun validations. The intrinsic validations are: - /// - /// (1) The transaction is well-formed RLP, with no additional trailing bytes; - /// (2) The transaction signature is valid; - /// (3) The transaction nonce is valid (equivalent to the sender account's - /// current nonce); - /// (4) The sender account has no contract code deployed (see EIP-3607). - /// (5) The gas limit is no smaller than the intrinsic gas, used by the - /// transaction; - /// (6) The sender account balance contains at least the cost, required in - /// up-front payment; - /// (7) The max fee per gas, in the case of type 2 transactions, or gasPrice, - /// in the case of type 0 and type 1 transactions, is greater than or equal to - /// the block’s base fee; - /// (8) For type 2 transactions, max priority fee per fas, must be no larger - /// than max fee per fas. - fn validate_transaction(&mut self) -> Result<(), VMError> { - // Validations (1), (2), (3), (5), and (8) are assumed done in upper layers. + fn is_create(&self) -> bool { + matches!(self.tx_kind, TxKind::Create) + } + fn revert_create(&mut self) -> Result<(), VMError> { + // Note: currently working with copies let call_frame = self .call_frames .last() @@ -380,65 +359,163 @@ impl VM { ))? .clone(); + self.decrement_account_nonce(call_frame.msg_sender)?; + + let new_contract_address = call_frame.to; + if cache::remove_account(&mut self.cache, &new_contract_address).is_none() { + return Err(VMError::AddressDoesNotMatchAnAccount); // Should not be this error + } + + Ok(()) + } + + /// ## Description + /// This method performs validations and returns an error if any of the validations fail. + /// It also makes initial changes alongside the validations: + /// - It increases sender nonce + /// - It substracts up-front-cost from sender balance. (Not doing this for now) + /// - It calculates and adds intrinsic gas to the 'gas used' of callframe and environment. (Not doing this for now) + /// See 'docs' for more information about validations. + fn validate_transaction(&mut self, initial_call_frame: &mut CallFrame) -> Result<(), VMError> { + //TODO: This should revert the transaction, not throw an error. And I don't know if it should be done here... + // if self.is_create() { + // // If address is already in db, there's an error + // let new_address_acc = self.db.get_account_info(call_frame.to); + // if !new_address_acc.is_empty() { + // return Err(VMError::AddressAlreadyOccupied); + // } + // } + let sender_address = self.env.origin; + let sender_account = self.get_account(sender_address); + + // (1) GASLIMIT_PRICE_PRODUCT_OVERFLOW + let gaslimit_price_product = + self.env + .gas_price + .checked_mul(self.env.gas_limit) + .ok_or(VMError::TxValidation( + TxValidationError::GasLimitPriceProductOverflow, + ))?; + + // Up front cost is the maximum amount of wei that a user is willing to pay for. + let up_front_cost = gaslimit_price_product + .checked_add(initial_call_frame.msg_value) + .ok_or(VMError::TxValidation( + TxValidationError::InsufficientAccountFunds, + ))?; + + // (2) INSUFFICIENT_ACCOUNT_FUNDS + // NOT CHANGING SENDER BALANCE HERE FOR NOW + // This will be increment_account_balance + sender_account + .info + .balance + .checked_sub(up_front_cost) + .ok_or(VMError::TxValidation( + TxValidationError::InsufficientAccountFunds, + ))?; + + // (3) INSUFFICIENT_MAX_FEE_PER_GAS + if self.env.gas_price < self.env.base_fee_per_gas { + return Err(VMError::TxValidation( + TxValidationError::InsufficientMaxFeePerGas, + )); + } + + // (4) INITCODE_SIZE_EXCEEDED if self.is_create() { - // If address is already in db, there's an error - let new_address_acc = self.db.get_account_info(call_frame.to); - if !new_address_acc.is_empty() { - return Err(VMError::AddressAlreadyOccupied); + // INITCODE_SIZE_EXCEEDED + if initial_call_frame.calldata.len() >= INIT_CODE_MAX_SIZE { + return Err(VMError::TxValidation( + TxValidationError::InitcodeSizeExceeded, + )); } } - let (sender_account_info, _address_was_cold) = self.access_account(self.env.origin); - - self.increment_account_nonce(self.env.origin)?; + // (5) INTRINSIC_GAS_TOO_LOW + // TODO: Not doing this for now + // self.add_intrinsic_gas(initial_call_frame)?; + + // (6) NONCE_IS_MAX + self.increment_account_nonce(sender_address)?; + + // (7) PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS + if let (Some(tx_max_priority_fee), Some(tx_max_fee_per_gas)) = ( + self.env.tx_max_priority_fee_per_gas, + self.env.tx_max_fee_per_gas, + ) { + if tx_max_priority_fee > tx_max_fee_per_gas { + return Err(VMError::TxValidation( + TxValidationError::PriorityGreaterThanMaxFeePerGas, + )); + } + } - // (4) - if sender_account_info.has_code() { - return Err(VMError::SenderAccountShouldNotHaveBytecode); + // (8) SENDER_NOT_EOA + if sender_account.has_code() { + return Err(VMError::TxValidation(TxValidationError::SenderNotEOA)); } - // (6) - if sender_account_info.balance < call_frame.msg_value { - return Err(VMError::SenderBalanceShouldContainTransferValue); + // (9) GAS_ALLOWANCE_EXCEEDED + if self.env.gas_limit > self.env.block_gas_limit { + return Err(VMError::TxValidation( + TxValidationError::GasAllowanceExceeded, + )); } - // (7) - if self.env.gas_price < self.env.base_fee_per_gas { - return Err(VMError::GasPriceIsLowerThanBaseFee); + // (10) INSUFFICIENT_MAX_FEE_PER_BLOB_GAS + if let Some(tx_max_fee_per_blob_gas) = self.env.tx_max_fee_per_blob_gas { + if tx_max_fee_per_blob_gas < self.env.base_fee_per_gas { + return Err(VMError::TxValidation( + TxValidationError::InsufficientMaxFeePerGas, + )); + } } - Ok(()) - } - fn is_create(&self) -> bool { - matches!(self.tx_kind, TxKind::Create) - } + //TODO: Implement the rest of the validations (TYPE_3) - fn revert_create(&mut self) -> Result<(), VMError> { - // Note: currently working with copies - let call_frame = self - .call_frames - .last() - .ok_or(VMError::Internal( - InternalError::CouldNotAccessLastCallframe, - ))? - .clone(); + // Transaction is type 3 if tx_max_fee_per_blob_gas is Some + if self.env.tx_max_fee_per_blob_gas.is_some() { + let blob_hashes = &self.env.tx_blob_hashes; - self.decrement_account_nonce(call_frame.msg_sender)?; + // (11) TYPE_3_TX_ZERO_BLOBS + if blob_hashes.is_empty() { + return Err(VMError::TxValidation(TxValidationError::Type3TxZeroBlobs)); + } - let new_contract_address = call_frame.to; - if cache::remove_account(&mut self.cache, &new_contract_address).is_none() { - return Err(VMError::AddressDoesNotMatchAnAccount); // Should not be this error - } + // (12) TYPE_3_TX_INVALID_BLOB_VERSIONED_HASH + for blob_hash in blob_hashes { + let blob_hash = blob_hash.as_bytes(); + if let Some(first_byte) = blob_hash.first() { + if !VALID_BLOB_PREFIXES.contains(first_byte) { + return Err(VMError::TxValidation( + TxValidationError::Type3TxInvalidBlobVersionedHash, + )); + } + } + } + + // (13) TYPE_3_TX_PRE_FORK -> This is not necessary for now because we are not supporting pre-cancun transactions yet. But we should somehow be able to tell the current context. + + // (14) TYPE_3_TX_BLOB_COUNT_EXCEEDED + if blob_hashes.len() > MAX_BLOB_COUNT { + return Err(VMError::TxValidation( + TxValidationError::Type3TxBlobCountExceeded, + )); + } - // Should revert this? - // sender_account.info.balance -= self.call_frames.first().ok_or(VMError::FatalUnwrap)?.msg_value; + // (15) TYPE_3_TX_CONTRACT_CREATION + if self.is_create() { + return Err(VMError::TxValidation( + TxValidationError::Type3TxContractCreation, + )); + } + } Ok(()) } pub fn transact(&mut self) -> Result { - self.validate_transaction()?; - let initial_gas = Default::default(); self.env.consumed_gas = initial_gas; @@ -448,7 +525,9 @@ impl VM { .pop() .ok_or(VMError::Internal(InternalError::CouldNotPopCallframe))?; - let mut report = self.execute(&mut current_call_frame); + self.validate_transaction(&mut current_call_frame)?; + + let mut report = self.execute(&mut current_call_frame)?; let initial_call_frame = self .call_frames @@ -643,7 +722,7 @@ impl VM { current_call_frame.sub_return_data_offset = ret_offset; current_call_frame.sub_return_data_size = ret_size; - let tx_report = self.execute(&mut new_call_frame); + let tx_report = self.execute(&mut new_call_frame)?; // Add gas used by the sub-context to the current one after it's execution. current_call_frame.gas_used = current_call_frame @@ -942,7 +1021,7 @@ impl VM { .info .nonce .checked_add(1) - .ok_or(VMError::NonceOverflow)?; + .ok_or(VMError::TxValidation(TxValidationError::NonceIsMax))?; Ok(account.info.nonce) } diff --git a/crates/vm/levm/tests/edge_case_tests.rs b/crates/vm/levm/tests/edge_case_tests.rs index 57198efc1..01093c8af 100644 --- a/crates/vm/levm/tests/edge_case_tests.rs +++ b/crates/vm/levm/tests/edge_case_tests.rs @@ -17,14 +17,14 @@ fn test_extcodecopy_memory_allocation() { let mut current_call_frame = vm.call_frames.pop().unwrap(); current_call_frame.gas_limit = U256::from(100_000_000); vm.env.gas_price = U256::from(10_000); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); } #[test] fn test_overflow_mcopy() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[90, 90, 90, 94])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); } #[test] @@ -32,56 +32,56 @@ fn test_overflow_call() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[61, 48, 56, 54, 51, 51, 51, 241])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); } #[test] fn test_usize_overflow_revert() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[61, 63, 61, 253])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); } #[test] fn test_overflow_returndatacopy() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[50, 49, 48, 51, 62])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); } #[test] fn test_overflow_keccak256() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[51, 63, 61, 32])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); } #[test] fn test_arithmetic_operation_overflow_selfdestruct() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[50, 255])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); } #[test] fn test_overflow_swap() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[48, 144])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); } #[test] fn test_end_of_range_swap() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[58, 50, 50, 51, 57])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); } #[test] fn test_usize_overflow_blobhash() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[71, 73])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); } #[test] @@ -93,7 +93,7 @@ fn add_op() { ]) .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!(vm.current_call_frame_mut().unwrap().pc(), 34); } @@ -102,14 +102,14 @@ fn add_op() { fn test_is_negative() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[58, 63, 58, 5])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); } #[test] fn test_non_compliance_keccak256() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[88, 88, 32, 89])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( *current_call_frame.stack.stack.first().unwrap(), U256::from_str("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470") @@ -130,7 +130,7 @@ fn test_sdiv_zero_dividend_and_negative_divisor() { ])) .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!(current_call_frame.stack.pop().unwrap(), U256::zero()); } @@ -139,7 +139,7 @@ fn test_non_compliance_returndatacopy() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[56, 56, 56, 56, 56, 56, 62, 56])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - let txreport = vm.execute(&mut current_call_frame); + let txreport = vm.execute(&mut current_call_frame).unwrap(); assert_eq!(txreport.result, TxResult::Revert(VMError::VeryLargeNumber)); } @@ -147,7 +147,7 @@ fn test_non_compliance_returndatacopy() { fn test_non_compliance_extcodecopy() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[88, 88, 88, 89, 60, 89])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!(current_call_frame.stack.stack.pop().unwrap(), U256::zero()); } @@ -158,7 +158,7 @@ fn test_non_compliance_extcodecopy_memory_resize() { ])) .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!(current_call_frame.stack.pop().unwrap(), U256::from(32)); } @@ -167,7 +167,7 @@ fn test_non_compliance_calldatacopy_memory_resize() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[0x60, 34, 0x5f, 0x5f, 55, 89])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( *current_call_frame.stack.stack.first().unwrap(), U256::from(64) @@ -183,7 +183,7 @@ fn test_non_compliance_addmod() { ])) .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( current_call_frame.stack.stack.first().unwrap(), &U256::zero() @@ -205,7 +205,7 @@ fn test_non_compliance_addmod2() { ])) .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( current_call_frame.stack.stack.first().unwrap(), &U256::from("0xfc7490ee00fc74a0ee00fc7490ee00fc7490ee5") @@ -219,7 +219,7 @@ fn test_non_compliance_codecopy() { ])) .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( current_call_frame.stack.stack.first().unwrap(), &U256::zero() @@ -231,7 +231,7 @@ fn test_non_compliance_smod() { let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[0x60, 1, 0x60, 1, 0x19, 0x07])).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( current_call_frame.stack.stack.first().unwrap(), &U256::zero() @@ -245,7 +245,7 @@ fn test_non_compliance_extcodecopy_size_and_destoffset() { ])) .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( current_call_frame.stack.stack.first().unwrap(), &U256::from(64) diff --git a/crates/vm/levm/tests/tests.rs b/crates/vm/levm/tests/tests.rs index 8e6dc7888..1b05547de 100644 --- a/crates/vm/levm/tests/tests.rs +++ b/crates/vm/levm/tests/tests.rs @@ -58,7 +58,7 @@ fn add_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::one()); assert!(vm.current_call_frame_mut().unwrap().pc() == 68); @@ -75,7 +75,7 @@ fn mul_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::from(8)); } @@ -91,7 +91,7 @@ fn sub_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::from(2)); } @@ -108,7 +108,7 @@ fn div_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::from(5)); @@ -122,7 +122,7 @@ fn div_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::zero()); } @@ -139,7 +139,7 @@ fn sdiv_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::from(2)); } @@ -156,7 +156,7 @@ fn mod_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::from(1)); } @@ -174,7 +174,7 @@ fn smod_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -204,7 +204,7 @@ fn smod_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let c = U256::from_str_radix( "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe", @@ -228,7 +228,7 @@ fn addmod_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::from(4)); } @@ -246,7 +246,7 @@ fn mulmod_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::from(4)); } @@ -263,7 +263,7 @@ fn exp_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::from(100)); } @@ -280,7 +280,7 @@ fn sign_extend_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::from(0x7F)); // Case 2: Input: 0, 0xFF. Output: 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF @@ -293,7 +293,7 @@ fn sign_extend_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::MAX); } @@ -309,7 +309,7 @@ fn lt_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::one()); } @@ -326,7 +326,7 @@ fn gt_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::one()); } @@ -343,7 +343,7 @@ fn slt_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::one()); } @@ -360,7 +360,7 @@ fn sgt_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::one()); } @@ -377,7 +377,7 @@ fn eq_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::one()); // Case 2: Input: 10, 20. Output: 0 (false) @@ -390,7 +390,7 @@ fn eq_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::zero()); } @@ -405,7 +405,7 @@ fn is_zero_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::one()); // Case 2: Input is non-zero (e.g., 10), Output should be 0 (since 10 != 0 is false) @@ -417,7 +417,7 @@ fn is_zero_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!(vm.current_call_frame_mut().unwrap().stack.pop().unwrap() == U256::zero()); } @@ -432,7 +432,7 @@ fn and_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0b1000)); @@ -452,7 +452,7 @@ fn and_binary_with_zero() { TX_BASE_COST + gas_cost::AND + gas_cost::PUSHN.checked_mul(U256::from(2)).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::zero()); @@ -470,7 +470,7 @@ fn and_with_hex_numbers() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xF0F0)); @@ -485,7 +485,7 @@ fn and_with_hex_numbers() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xF000)); @@ -500,7 +500,7 @@ fn and_with_hex_numbers() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0b1000000000000)); @@ -518,7 +518,7 @@ fn or_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0b1110)); @@ -533,7 +533,7 @@ fn or_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0b1010)); @@ -548,7 +548,7 @@ fn or_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xFFFFFFFFFFFFFFFF_u64)); @@ -566,7 +566,7 @@ fn or_with_hex_numbers() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xFFFF)); @@ -581,7 +581,7 @@ fn or_with_hex_numbers() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xF0F0)); @@ -596,7 +596,7 @@ fn or_with_hex_numbers() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0b1011111100101111)); @@ -614,7 +614,7 @@ fn xor_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0b110)); @@ -629,7 +629,7 @@ fn xor_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0b1010)); @@ -644,7 +644,7 @@ fn xor_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(u64::MAX)); @@ -659,7 +659,7 @@ fn xor_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::zero()); @@ -677,7 +677,7 @@ fn xor_with_hex_numbers() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xFF)); @@ -692,7 +692,7 @@ fn xor_with_hex_numbers() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::zero()); @@ -707,7 +707,7 @@ fn xor_with_hex_numbers() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xF0F)); @@ -722,7 +722,7 @@ fn xor_with_hex_numbers() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xF0)); @@ -737,7 +737,7 @@ fn xor_with_hex_numbers() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0b111011001000100)); @@ -754,7 +754,7 @@ fn not() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); let expected = !U256::from(0b1010); @@ -769,7 +769,7 @@ fn not() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::zero()); @@ -783,7 +783,7 @@ fn not() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::MAX); @@ -797,7 +797,7 @@ fn not() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::MAX - 1); @@ -815,7 +815,7 @@ fn byte_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xF1)); @@ -830,7 +830,7 @@ fn byte_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0x33)); @@ -848,7 +848,7 @@ fn byte_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xFF)); @@ -863,7 +863,7 @@ fn byte_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xFF)); @@ -878,7 +878,7 @@ fn byte_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0x0D)); @@ -893,7 +893,7 @@ fn byte_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::zero()); @@ -908,7 +908,7 @@ fn byte_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::zero()); @@ -923,7 +923,7 @@ fn byte_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::zero()); @@ -944,7 +944,7 @@ fn byte_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0x90)); @@ -959,7 +959,7 @@ fn byte_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0x57)); @@ -974,7 +974,7 @@ fn byte_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xDD)); @@ -989,7 +989,7 @@ fn byte_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0x40)); @@ -1007,7 +1007,7 @@ fn shl_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xDDDD)); @@ -1022,7 +1022,7 @@ fn shl_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0x2468acf0)); @@ -1037,7 +1037,7 @@ fn shl_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(4886718336_u64)); @@ -1052,7 +1052,7 @@ fn shl_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xFF << 4)); @@ -1070,7 +1070,7 @@ fn shl_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::zero()); @@ -1085,7 +1085,7 @@ fn shl_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::zero()); @@ -1100,7 +1100,7 @@ fn shl_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::MAX - 1); @@ -1118,7 +1118,7 @@ fn shr_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xDDDD)); @@ -1133,7 +1133,7 @@ fn shr_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0x91a2b3c)); @@ -1148,7 +1148,7 @@ fn shr_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0x1234567)); @@ -1163,7 +1163,7 @@ fn shr_basic() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0xF)); @@ -1181,7 +1181,7 @@ fn shr_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::zero()); @@ -1196,7 +1196,7 @@ fn shr_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::zero()); @@ -1211,7 +1211,7 @@ fn shr_edge_cases() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::MAX >> 1); @@ -1229,7 +1229,7 @@ fn sar_shift_by_0() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0x12345678)); @@ -1253,7 +1253,7 @@ fn sar_shifting_large_value_with_all_bits_set() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); let expected = U256::from_big_endian(&[ @@ -1282,7 +1282,7 @@ fn sar_shifting_negative_value_and_small_shift() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); let expected = U256::from_big_endian(&[ @@ -1305,7 +1305,7 @@ fn sar_shift_positive_value() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(result, U256::from(0x07FFFF)); @@ -1329,7 +1329,7 @@ fn sar_shift_negative_value() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let result = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); let expected = U256::from_big_endian(&[ @@ -1362,7 +1362,7 @@ fn keccak256_zero_offset_size_four() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -1392,7 +1392,7 @@ fn keccak256_zero_offset_size_bigger_than_actual_memory() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap() @@ -1414,7 +1414,7 @@ fn keccak256_zero_offset_zero_size() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -1444,7 +1444,7 @@ fn keccak256_offset_four_size_four() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -1466,7 +1466,7 @@ fn mstore() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -1488,7 +1488,7 @@ fn mstore_saves_correct_value() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let stored_value = vm.current_call_frame_mut().unwrap().memory.load(0).unwrap(); @@ -1511,7 +1511,7 @@ fn mstore8() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let stored_value = vm.current_call_frame_mut().unwrap().memory.load(0).unwrap(); @@ -1539,7 +1539,7 @@ fn mcopy() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let copied_value = vm .current_call_frame_mut() @@ -1568,7 +1568,7 @@ fn mload() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let loaded_value = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(loaded_value, U256::from(0x33333)); @@ -1582,7 +1582,7 @@ fn msize() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let initial_size = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(initial_size, U256::from(0)); @@ -1599,7 +1599,7 @@ fn msize() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let after_store_size = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(after_store_size, U256::from(32)); @@ -1616,7 +1616,7 @@ fn msize() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let final_size = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(final_size, U256::from(96)); @@ -1638,7 +1638,7 @@ fn mstore_mload_offset_not_multiple_of_32() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let memory_size = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); let loaded_value = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); @@ -1662,7 +1662,7 @@ fn mstore_mload_offset_not_multiple_of_32() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let memory_size = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); let loaded_value = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); @@ -1684,7 +1684,7 @@ fn mload_uninitialized_memory() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let memory_size = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); let loaded_value = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); @@ -1733,7 +1733,7 @@ fn call_returns_if_bytecode_empty() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let success = vm.current_call_frame_mut().unwrap().stack.pop().unwrap(); assert_eq!(success, U256::one()); @@ -1777,7 +1777,7 @@ fn call_changes_callframe_and_stores() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let current_call_frame = vm.current_call_frame_mut().unwrap(); @@ -1879,7 +1879,7 @@ fn nested_calls() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let current_call_frame = vm.current_call_frame_mut().unwrap(); @@ -1951,7 +1951,7 @@ fn staticcall_changes_callframe_is_static() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let mut current_call_frame = vm.call_frames[0].clone(); @@ -1973,7 +1973,7 @@ fn pop_on_empty_stack() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - let tx_report = vm.execute(&mut current_call_frame); + let tx_report = vm.execute(&mut current_call_frame).unwrap(); // result should be a Halt with error VMError::StackUnderflow @@ -1990,7 +1990,7 @@ fn pc_op() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2010,7 +2010,7 @@ fn pc_op_with_push_offset() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2070,7 +2070,7 @@ fn pc_op_with_push_offset() { // current_call_frame.to = Address::from_low_u64_be(U256::from(5).low_u64()); // let mut current_call_frame = vm.call_frames.pop().unwrap(); -// vm.execute(&mut current_call_frame); +// vm.execute(&mut current_call_frame).unwrap(); // let storage_slot = vm.cache.get_storage_slot( // Address::from_low_u64_be(U256::from(1).low_u64()), @@ -2134,7 +2134,7 @@ fn pc_op_with_push_offset() { // current_call_frame.to = Address::from_low_u64_be(U256::from(5).low_u64()); // let mut current_call_frame = vm.call_frames.pop().unwrap(); -// vm.execute(&mut current_call_frame); +// vm.execute(&mut current_call_frame).unwrap(); // let storage_slot = vm.cache.get_storage_slot(callee_address, U256::zero()); // let slot = StorageSlot { @@ -2196,7 +2196,7 @@ fn pc_op_with_push_offset() { // current_call_frame.to = Address::from_low_u64_be(U256::from(5).low_u64()); // let mut current_call_frame = vm.call_frames.pop().unwrap(); -// vm.execute(&mut current_call_frame); +// vm.execute(&mut current_call_frame).unwrap(); // let current_call_frame = vm.current_call_frame_mut().unwrap(); @@ -2253,7 +2253,7 @@ fn pc_op_with_push_offset() { // ); // let mut current_call_frame = vm.call_frames.pop().unwrap(); -// vm.execute(&mut current_call_frame); +// vm.execute(&mut current_call_frame).unwrap(); // let current_call_frame = vm.call_frames[0].clone(); @@ -2286,7 +2286,7 @@ fn jump_position_bigger_than_program_bytecode_size() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - let tx_report = vm.execute(&mut current_call_frame); + let tx_report = vm.execute(&mut current_call_frame).unwrap(); assert!(matches!( tx_report.result, TxResult::Revert(VMError::InvalidJump) @@ -2308,7 +2308,7 @@ fn jumpi_not_zero() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2333,7 +2333,7 @@ fn jumpi_for_zero() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2404,7 +2404,7 @@ fn calldataload() { vm.current_call_frame_mut().unwrap().calldata = calldata; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let current_call_frame = vm.current_call_frame_mut().unwrap(); @@ -2477,7 +2477,7 @@ fn calldataload_being_set_by_parent() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let current_call_frame = vm.current_call_frame_mut().unwrap(); @@ -2502,7 +2502,7 @@ fn calldatasize() { vm.current_call_frame_mut().unwrap().calldata = calldata; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let current_call_frame = vm.current_call_frame_mut().unwrap(); let top_of_stack = current_call_frame.stack.pop().unwrap(); @@ -2525,7 +2525,7 @@ fn calldatacopy() { vm.current_call_frame_mut().unwrap().calldata = calldata; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let current_call_frame = vm.current_call_frame_mut().unwrap(); let memory = current_call_frame.memory.load_range(0, 2).unwrap(); @@ -2542,7 +2542,7 @@ fn returndatasize() { vm.current_call_frame_mut().unwrap().sub_return_data = returndata; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let current_call_frame = vm.current_call_frame_mut().unwrap(); let top_of_stack = current_call_frame.stack.pop().unwrap(); @@ -2565,7 +2565,7 @@ fn returndatacopy() { vm.current_call_frame_mut().unwrap().sub_return_data = returndata; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let current_call_frame = vm.current_call_frame_mut().unwrap(); let memory = current_call_frame.memory.load_range(0, 2).unwrap(); @@ -2614,7 +2614,7 @@ fn returndatacopy_being_set_by_parent() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let current_call_frame = vm.current_call_frame_mut().unwrap(); @@ -2651,7 +2651,7 @@ fn blockhash_op() { vm.env.block_number = current_block_number; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2683,7 +2683,7 @@ fn blockhash_same_block_number() { vm.env.block_number = current_block_number; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2719,7 +2719,7 @@ fn blockhash_block_number_not_from_recent_256() { vm.env.block_number = current_block_number; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2738,7 +2738,7 @@ fn coinbase_op() { vm.env.coinbase = Address::from_low_u64_be(coinbase_address); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2757,7 +2757,7 @@ fn timestamp_op() { vm.env.timestamp = timestamp; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2776,7 +2776,7 @@ fn number_op() { vm.env.block_number = block_number; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2795,7 +2795,7 @@ fn prevrandao_op() { vm.env.prev_randao = Some(prevrandao); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2814,7 +2814,7 @@ fn gaslimit_op() { vm.env.gas_limit = gas_limit; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2833,7 +2833,7 @@ fn chain_id_op() { vm.env.chain_id = chain_id; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2852,7 +2852,7 @@ fn basefee_op() { vm.env.base_fee_per_gas = base_fee_per_gas; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2871,7 +2871,7 @@ fn blobbasefee_op() { vm.env.block_blob_gas_used = Some(U256::zero()); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2890,7 +2890,7 @@ fn blobbasefee_minimum_cost() { vm.env.block_blob_gas_used = Some(U256::zero()); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2911,7 +2911,7 @@ fn pop_op() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2934,7 +2934,7 @@ fn jump_op() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -2957,7 +2957,7 @@ fn jump_not_jumpdest_position() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - let tx_report = vm.execute(&mut current_call_frame); + let tx_report = vm.execute(&mut current_call_frame).unwrap(); assert!(matches!( tx_report.result, TxResult::Revert(VMError::InvalidJump) @@ -2984,7 +2984,7 @@ fn sstore_op() { vm.current_call_frame_mut().unwrap().code_address = sender_address; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); // Convert key in U256 to H256 let mut bytes = [0u8; 32]; @@ -3010,7 +3010,7 @@ fn sstore_reverts_when_called_in_static() { let mut vm = new_vm_with_ops(&operations).unwrap(); vm.current_call_frame_mut().unwrap().is_static = true; let mut current_call_frame = vm.call_frames.pop().unwrap(); - let tx_report = vm.execute(&mut current_call_frame); + let tx_report = vm.execute(&mut current_call_frame).unwrap(); assert!(matches!( tx_report.result, @@ -3039,7 +3039,7 @@ fn sload_op() { vm.current_call_frame_mut().unwrap().msg_sender = sender_address; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( value, @@ -3060,7 +3060,7 @@ fn sload_untouched_key_of_storage() { vm.current_call_frame_mut().unwrap().msg_sender = sender_address; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( U256::zero(), @@ -3078,7 +3078,7 @@ fn sload_on_not_existing_account() { vm.current_call_frame_mut().unwrap().msg_sender = sender_address; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( U256::zero(), @@ -3102,7 +3102,7 @@ fn log0() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let logs = &vm.current_call_frame_mut().unwrap().logs; let data = [0xff_u8; 32].as_slice(); @@ -3132,7 +3132,7 @@ fn log1() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let logs = &vm.current_call_frame_mut().unwrap().logs; let data = [0xff_u8; 32].as_slice(); @@ -3165,7 +3165,7 @@ fn log2() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let logs = &vm.current_call_frame_mut().unwrap().logs; let data = [0xff_u8; 32].as_slice(); @@ -3204,7 +3204,7 @@ fn log3() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let logs = &vm.current_call_frame_mut().unwrap().logs; let data = [0xff_u8; 32].as_slice(); @@ -3250,7 +3250,7 @@ fn log4() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let logs = &vm.current_call_frame_mut().unwrap().logs; let data = [0xff_u8; 32].as_slice(); @@ -3284,7 +3284,7 @@ fn log_with_0_data_size() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let logs = &vm.current_call_frame_mut().unwrap().logs; assert_eq!(logs.len(), 1); @@ -3310,7 +3310,7 @@ fn cant_create_log_in_static_context() { let mut vm: VM = new_vm_with_ops(&operations).unwrap(); vm.current_call_frame_mut().unwrap().is_static = true; let mut current_call_frame = vm.call_frames.pop().unwrap(); - let tx_report = vm.execute(&mut current_call_frame); + let tx_report = vm.execute(&mut current_call_frame).unwrap(); assert!(matches!( tx_report.result, @@ -3334,7 +3334,7 @@ fn log_with_data_in_memory_smaller_than_size() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let logs = &vm.current_call_frame_mut().unwrap().logs; let mut data = vec![0_u8; 16]; @@ -3369,7 +3369,7 @@ fn multiple_logs_of_different_types() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let logs = &vm.current_call_frame_mut().unwrap().logs; let data = [0xff_u8; 32].as_slice(); @@ -3428,7 +3428,7 @@ fn logs_from_multiple_callers() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!(current_call_frame.logs.len(), 2) } @@ -3473,7 +3473,7 @@ fn logs_from_multiple_callers() { // vm.db.add_account(callee_address, callee_account); // let mut current_call_frame = vm.call_frames.pop().unwrap(); -// vm.execute(&mut current_call_frame); +// vm.execute(&mut current_call_frame).unwrap(); // assert_eq!( // vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -3486,7 +3486,7 @@ fn push0_ok() { let mut vm = new_vm_with_ops(&[Operation::Push0, Operation::Stop]).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.stack[0], @@ -3502,7 +3502,7 @@ fn push1_ok() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!(vm.current_call_frame_mut().unwrap().stack.stack[0], to_push); assert_eq!(vm.current_call_frame_mut().unwrap().pc(), 3); @@ -3515,7 +3515,7 @@ fn push5_ok() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!(vm.current_call_frame_mut().unwrap().stack.stack[0], to_push); assert_eq!(vm.current_call_frame_mut().unwrap().pc(), 7); @@ -3528,7 +3528,7 @@ fn push31_ok() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!(vm.current_call_frame_mut().unwrap().stack.stack[0], to_push); assert_eq!(vm.current_call_frame_mut().unwrap().pc(), 33); @@ -3541,7 +3541,7 @@ fn push32_ok() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!(vm.current_call_frame_mut().unwrap().stack.stack[0], to_push); assert_eq!(vm.current_call_frame_mut().unwrap().pc(), 34); @@ -3558,7 +3558,7 @@ fn dup1_ok() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let stack_len = vm.current_call_frame_mut().unwrap().stack.len(); @@ -3584,7 +3584,7 @@ fn dup16_ok() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let stack_len = vm.current_call_frame_mut().unwrap().stack.len(); @@ -3606,7 +3606,7 @@ fn dup_halts_if_stack_underflow() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - let tx_report = vm.execute(&mut current_call_frame); + let tx_report = vm.execute(&mut current_call_frame).unwrap(); assert!(matches!( tx_report.result, @@ -3626,7 +3626,7 @@ fn swap1_ok() { ]; let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!(vm.current_call_frame_mut().unwrap().stack.len(), 2); assert_eq!(vm.current_call_frame_mut().unwrap().pc(), 6); @@ -3646,7 +3646,7 @@ fn swap16_ok() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let stack_len = vm.current_call_frame_mut().unwrap().stack.len(); assert_eq!(stack_len, 17); @@ -3667,7 +3667,7 @@ fn swap_halts_if_stack_underflow() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - let tx_report = vm.execute(&mut current_call_frame); + let tx_report = vm.execute(&mut current_call_frame).unwrap(); assert!(matches!( tx_report.result, @@ -3694,7 +3694,7 @@ fn transient_store() { assert!(current_call_frame.transient_storage.is_empty()); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let current_call_frame = vm.current_call_frame_mut().unwrap(); @@ -3719,7 +3719,7 @@ fn transient_store_stack_underflow() { .is_empty()); let mut current_call_frame = vm.call_frames.pop().unwrap(); - let tx_report = vm.execute(&mut current_call_frame); + let tx_report = vm.execute(&mut current_call_frame).unwrap(); assert!(matches!( tx_report.result, @@ -3748,7 +3748,7 @@ fn transient_load() { .insert((caller, key), value); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( *vm.current_call_frame_mut() @@ -3794,7 +3794,7 @@ fn create_happy_path() { vm.current_call_frame_mut().unwrap().msg_sender = sender_addr; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let call_frame = vm.current_call_frame_mut().unwrap(); let returned_address = call_frame.stack.pop().unwrap(); @@ -3838,7 +3838,7 @@ fn cant_create_with_size_longer_than_max_code_size() { vm.current_call_frame_mut().unwrap().msg_sender = sender_addr; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let call_frame = vm.current_call_frame_mut().unwrap(); let create_return_value = call_frame.stack.pop().unwrap(); @@ -3873,7 +3873,7 @@ fn cant_create_on_static_contexts() { vm.current_call_frame_mut().unwrap().is_static = true; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let call_frame = vm.current_call_frame_mut().unwrap(); let create_return_value = call_frame.stack.pop().unwrap(); @@ -3907,7 +3907,7 @@ fn cant_create_if_transfer_value_bigger_than_balance() { vm.current_call_frame_mut().unwrap().msg_sender = sender_addr; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let call_frame = vm.current_call_frame_mut().unwrap(); let create_return_value = call_frame.stack.pop().unwrap(); @@ -3941,7 +3941,7 @@ fn cant_create_if_sender_nonce_would_overflow() { vm.current_call_frame_mut().unwrap().msg_sender = sender_addr; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let call_frame = vm.current_call_frame_mut().unwrap(); let create_return_value = call_frame.stack.pop().unwrap(); @@ -3985,7 +3985,7 @@ fn cant_create_if_sender_nonce_would_overflow() { // vm.current_call_frame_mut().unwrap().msg_sender = sender_addr; // let mut current_call_frame = vm.call_frames.pop().unwrap(); -// vm.execute(&mut current_call_frame); +// vm.execute(&mut current_call_frame).unwrap(); // let call_frame = vm.current_call_frame_mut().unwrap(); @@ -4013,7 +4013,7 @@ fn cant_create_if_sender_nonce_would_overflow() { // new_vm.current_call_frame_mut().unwrap().msg_sender = sender_addr; // let mut current_call_frame = new_vm.call_frames.pop().unwrap(); -// new_vm.execute(&mut current_call_frame); +// new_vm.execute(&mut current_call_frame).unwrap(); // let call_frame = new_vm.current_call_frame_mut().unwrap(); // let return_of_created_callframe = call_frame.stack.pop().unwrap(); // assert_eq!(return_of_created_callframe, U256::from(REVERT_FOR_CREATE)); @@ -4063,7 +4063,7 @@ fn create2_happy_path() { vm.current_call_frame_mut().unwrap().msg_sender = sender_addr; let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); let call_frame = vm.current_call_frame_mut().unwrap(); let returned_address = call_frame.stack.pop().unwrap(); @@ -4105,7 +4105,7 @@ fn create2_happy_path() { // vm.current_call_frame_mut().unwrap().msg_sender = sender_addr; // let mut current_call_frame = vm.call_frames.pop().unwrap(); -// vm.execute(&mut current_call_frame); +// vm.execute(&mut current_call_frame).unwrap(); // assert_eq!(vm.db.accounts.len(), 4); // } @@ -4142,7 +4142,7 @@ fn caller_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -4184,7 +4184,7 @@ fn origin_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -4213,7 +4213,7 @@ fn balance_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -4253,7 +4253,7 @@ fn address_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -4299,7 +4299,7 @@ fn selfbalance_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -4342,7 +4342,7 @@ fn callvalue_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), @@ -4384,7 +4384,7 @@ fn codesize_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), U256::from(2) @@ -4425,7 +4425,7 @@ fn gasprice_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), U256::from(0x9876) @@ -4482,7 +4482,7 @@ fn codecopy_op() { .unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().memory.load(0).unwrap(), @@ -4512,7 +4512,7 @@ fn extcodesize_existing_account() { let mut vm = new_vm_with_ops_db(&operations, db).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), 23.into() @@ -4532,7 +4532,7 @@ fn extcodesize_non_existing_account() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), 0.into() @@ -4563,7 +4563,7 @@ fn extcodecopy_existing_account() { let mut vm = new_vm_with_ops_db(&operations, db).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut() .unwrap() @@ -4592,7 +4592,7 @@ fn extcodecopy_non_existing_account() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut() .unwrap() @@ -4619,7 +4619,7 @@ fn extcodehash_account_with_empty_code() { let mut vm = new_vm_with_ops_db(&operations, db).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470".into() @@ -4639,7 +4639,7 @@ fn extcodehash_non_existing_account() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!( vm.current_call_frame_mut().unwrap().stack.pop().unwrap(), "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470".into() @@ -4654,7 +4654,7 @@ fn invalid_opcode() { let mut vm = new_vm_with_ops(&operations).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - let tx_report = vm.execute(&mut current_call_frame); + let tx_report = vm.execute(&mut current_call_frame).unwrap(); assert!(matches!( tx_report.result, @@ -4677,7 +4677,7 @@ fn revert_opcode() { let mut vm = new_vm_with_ops(&ops).unwrap(); let mut current_call_frame = vm.call_frames.pop().unwrap(); - let tx_report = vm.execute(&mut current_call_frame); + let tx_report = vm.execute(&mut current_call_frame).unwrap(); assert_eq!(U256::from_big_endian(&tx_report.output), U256::from(0xA)); assert!(matches!( @@ -4708,7 +4708,7 @@ fn revert_sstore() { // Cache state before the SSTORE let cache_backup = vm.cache.clone(); - vm.execute(&mut current_call_frame); + vm.execute(&mut current_call_frame).unwrap(); assert_eq!(vm.cache, cache_backup); } diff --git a/crates/vm/vm.rs b/crates/vm/vm.rs index c45d809bd..36fe2b863 100644 --- a/crates/vm/vm.rs +++ b/crates/vm/vm.rs @@ -181,7 +181,11 @@ cfg_if::cfg_if! { gas_price, block_excess_blob_gas: block_header.excess_blob_gas.map(U256::from), block_blob_gas_used: block_header.blob_gas_used.map(U256::from), - tx_blob_hashes: None, + tx_blob_hashes: tx.blob_versioned_hashes(), + tx_max_priority_fee_per_gas: tx.max_priority_fee().map(U256::from), + tx_max_fee_per_gas: tx.max_fee_per_gas().map(U256::from), + tx_max_fee_per_blob_gas: tx.max_fee_per_blob_gas().map(U256::from), + block_gas_limit: block_header.gas_limit.into(), }; let mut vm = VM::new(