Skip to content

Conversation

@wlawt
Copy link
Contributor

@wlawt wlawt commented Sep 24, 2025

Overview

A successful validation of transaction is:

  • Not 4844
  • Not interop
  • If account is 7702 then is the transaction type 7702
  • If nonce >= latest nonce
  • If execution cost <= balance

TODO

  • l1 balance > execution + da fee

Tests

  • CI
  • Sending txn still works
  • Added unit tests

@wlawt wlawt force-pushed the transaction-validation branch from dff3678 to 4f8afcb Compare September 24, 2025 20:59
@wlawt wlawt force-pushed the transaction-validation branch from 8c87a6c to bd9e053 Compare September 25, 2025 13:51
}

// error if execution cost costs more than balance
if envelope.value() > account.balance {
Copy link
Contributor Author

@wlawt wlawt Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure if value() is correct here.

i also don't know if it's possible to get the cost() from an OpPooledTransaction or Op envelope since these functions are generated from a macro, it's hard to trace exactly what's available

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this is some combo of gasPrice * gasLimit + value. We should try and import and if not we can reimplement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will re-implement cost().

i tracked it down: for an EIP-1559 tx, the value() is amount being transferred https://github.com/alloy-rs/alloy/blob/d826a501ee96925c1e67ca87bd4fe819b807fbaf/crates/consensus/src/transaction/eip1559.rs#L64

@wlawt wlawt changed the title WIP [ingress] add transaction validation [ingress] add transaction validation Sep 25, 2025
@wlawt wlawt marked this pull request as ready for review September 25, 2025 18:04
@wlawt wlawt requested a review from danyalprout September 25, 2025 18:04
Copy link
Collaborator

@danyalprout danyalprout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, few small thoughts. would it be possible to add some tests to cover these cases too 🙏


// skip eip4844 transactions
if envelope.is_eip4844() {
return Err(anyhow::anyhow!("EIP-4844 transactions are not supported"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there typed errors for these?

Copy link
Contributor Author

@wlawt wlawt Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are, but it's spread across different enums like EthApiError, RpcInvalidTransactionError etc. but will consolidate some using the convenient RpcInvalidTransactionError::other available for error types not mentioned in the enum

}

// error if execution cost costs more than balance
if envelope.value() > account.balance {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this is some combo of gasPrice * gasLimit + value. We should try and import and if not we can reimplement

@wlawt wlawt requested a review from danyalprout September 26, 2025 19:49
Comment on lines 87 to 96
.map_err(|e| ErrorObject::owned(11, e.to_string(), Some(2)))?;

let account = self
.provider
.fetch_account_info(transaction.signer())
.await
.map_err(|e| ErrorObject::owned(11, e.to_string(), Some(2)))?;
validate_tx(account, &transaction, &data, &mut l1_block_info)
.await
.map_err(|e| ErrorObject::owned(11, e.to_string(), Some(2)))?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any typed errors/error codes that we could pull out here? This should match the node implementation as much as possible vs. just being 11

@wlawt wlawt requested a review from danyalprout September 29, 2025 17:28
@wlawt wlawt merged commit c686a62 into master Sep 29, 2025
10 checks passed
@wlawt wlawt deleted the transaction-validation branch September 29, 2025 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants