Skip to content

Commit

Permalink
Evm/housekeeping (#2445)
Browse files Browse the repository at this point in the history
* Fix comments and debugging log

* Fix py lint

* Fix rust lint
  • Loading branch information
sieniven authored Sep 14, 2023
1 parent a0751ee commit f4edb77
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
11 changes: 7 additions & 4 deletions lib/ain-evm/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,20 @@ impl EVMCoreService {
/// Validates a raw tx.
///
/// The validation checks of the tx before we consider it to be valid are:
/// 1. Account nonce check: verify that the tx nonce must be more than or equal to the account nonce.
/// 1. Account nonce check: verify that the tx nonce must equal to the account nonce (for validation)
/// 2. Gas price check: verify that the maximum gas price is minimally of the block initial base fee.
/// 3. Gas price and tx value check: verify that amount is within money range.
/// 4. Account balance check: verify that the account balance must minimally have the tx prepay gas fee.
/// 5. Intrinsic gas limit check: verify that the tx intrinsic gas is within the tx gas limit.
/// 6. Gas limit check: verify that the tx gas limit is not higher than the maximum gas per block.
/// 4. Intrinsic gas limit check: verify that the tx intrinsic gas is within the tx gas limit.
/// 5. Gas limit check: verify that the tx gas limit is not higher than the maximum gas per block.
/// 6. Verify if tx nonce is greater or less than current account nonce.
/// 7. Account balance check: verify that the account balance must minimally have the tx prepay gas fee.
///
/// # Arguments
///
/// * `tx` - The raw tx.
/// * `queue_id` - The queue_id queue number.
/// * `pre_validate` - Validate the raw tx with or without state context.
/// * `test_tx` - Test the validity of the raw transaction with block context.
///
/// # Returns
///
Expand Down
5 changes: 4 additions & 1 deletion lib/ain-evm/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,10 @@ impl EVMServices {
tx: QueueTx,
) -> Result<(SignedTx, U256, H256)> {
let state_root = self.core.tx_queues.get_latest_state_root_in(queue_id)?;
debug!("[validate_raw_tx] state_root : {:#?}", state_root);
debug!(
"[update_queue_state_from_tx] state_root : {:#?}",
state_root
);

// Has to be mutable to obtain new state root
let mut backend = self.core.get_backend(state_root)?;
Expand Down
7 changes: 5 additions & 2 deletions lib/ain-rs-exports/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ pub fn evm_unsafe_try_sub_balance_in_q(
/// * `result` - Result object
/// * `queue_id` - The EVM queue ID
/// * `tx` - The raw transaction string.
/// * `pre_validate` - Validate the raw transaction with or without state context.
/// * `test_tx` - Test the validity of the raw transaction with block context.
///
/// # Errors
///
Expand All @@ -453,8 +455,9 @@ pub fn evm_unsafe_try_sub_balance_in_q(
///
/// # Returns
///
/// Returns the transaction nonce, sender address, transaction fees, gas used and
/// updated state rooot if valid. Logs and set the error reason to result object otherwise.
/// Returns the transaction nonce, sender address, transaction hash, transaction prepay fees,
/// gas used, higher nonce flag and lower nonce flag. Logs and set the error reason to result
/// object otherwise.
pub fn evm_unsafe_try_validate_raw_tx_in_q(
result: &mut ffi::CrossBoundaryResult,
queue_id: u64,
Expand Down

0 comments on commit f4edb77

Please sign in to comment.