Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: impl TryFrom<reth_rpc_types::Transaction> for Transaction #7551

Merged
merged 8 commits into from
Apr 12, 2024

Conversation

AbnerZheng
Copy link
Contributor

close #7214

}
Some(3u8) => {
// EIP-4844
Ok(Transaction::Eip4844(TxEip4844 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

yes, please update those docs

@shekhirin shekhirin added C-enhancement New feature or request A-rpc Related to the RPC implementation labels Apr 10, 2024
@DaniPopes DaniPopes requested a review from mattsse April 10, 2024 16:44
Copy link
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

cool, a few pedantic nits,

Ok(Transaction::Legacy(TxLegacy {
chain_id: tx.chain_id,
nonce: tx.nonce,
gas_price: tx.gas_price.ok_or(ConversionError::MissingGasPrice)?,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a bit dangerous, because gasprice is commonly set for all tx types, so this match arm should check if there are any 1559 fields present, if so return an error


fn try_from(tx: reth_rpc_types::Transaction) -> Result<Self, Self::Error> {
match tx.transaction_type {
None => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
None => {
None | Some(0u8) => {

value: tx.value,
access_list: tx.access_list.ok_or(ConversionError::MissingAccessList)?.into(),
input: tx.input,
blob_versioned_hashes: tx.blob_versioned_hashes.unwrap_or_default(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should also be an error ref alloy-rs/alloy#506

@mattsse
Copy link
Collaborator

mattsse commented Apr 12, 2024

also need to update evm-inspector rev pin...

@AbnerZheng AbnerZheng mentioned this pull request Apr 12, 2024
3 tasks
@mattsse mattsse added this pull request to the merge queue Apr 12, 2024
Merged via the queue into paradigmxyz:main with commit 234d258 Apr 12, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add reth_rpc_types::Transaction to reth_primitives::Transaction conversion util function
4 participants