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

Add trait methods to alloy_network_primitives::TransactionResponse #1173

Closed
wants to merge 32 commits into from

Conversation

emhane
Copy link
Contributor

@emhane emhane commented Aug 21, 2024

Motivation

Removing the optimism feature from reth-rpc-types-compat in a simple way, requires implementing the conversion from a signed transaction into an rpc transaction object, into the crates that define the associated types of alloy_network::Network. Otherwise, we are not able to access the additional OP fields for example.

Moving into reth-optimsim-rpc is not an option, since neither the trait for conversion nor the <op_alloy_network::Optimism as Network>::TransactionResponse type are defined in the reth-optimsim-rpc crate

Solution

Adds trait methods to alloy_network_primitives::TransactionResponse for filling a alloy_network_primitives::Transaction from alloy_consensus::Signed<impl alloy_consensus::Transaction>.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@emhane emhane added the debt Tech debt which needs to be addressed label Aug 21, 2024
Copy link
Member

@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.

let's do the additional trait Transaction first and think about the TransactionResponse fn(&impl Transaction) functions separately

crates/network-primitives/src/traits.rs Outdated Show resolved Hide resolved
crates/network-primitives/src/traits.rs Show resolved Hide resolved
@emhane
Copy link
Contributor Author

emhane commented Aug 22, 2024

let's do the additional trait Transaction first and think about the TransactionResponse fn(&impl Transaction) functions separately

that's exactly how it is done. see base of prs. first pr: #1172

@emhane emhane requested a review from mattsse August 22, 2024 12:56
@mattsse
Copy link
Member

mattsse commented Aug 22, 2024

sorry I missed that pr

Base automatically changed from emhane/tx-trait to main August 22, 2024 20:05
@emhane
Copy link
Contributor Author

emhane commented Aug 23, 2024

re-request review @mattsse

crates/consensus/src/transaction/mod.rs Outdated Show resolved Hide resolved
@emhane emhane changed the base branch from main to emhane/signature August 26, 2024 18:15
@emhane
Copy link
Contributor Author

emhane commented Aug 26, 2024

extracted yet another bit #1198

Copy link
Member

@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.

we can't really solve this on the type trait, this is a server side problem because only there this type is created

crates/network-primitives/src/traits.rs Show resolved Hide resolved
crates/network-primitives/src/traits.rs Outdated Show resolved Hide resolved
@emhane
Copy link
Contributor Author

emhane commented Aug 27, 2024

we can't really solve this on the type trait, this is a server side problem because only there this type is created

how come? this would be following pattern https://github.com/paradigmxyz/reth/blob/e6dc947a3728637aa3b0f78c893e8f24dc468357/crates/transaction-pool/src/traits.rs#L812-L819

@emhane emhane requested a review from mattsse August 27, 2024 14:55
Base automatically changed from emhane/signature to main August 28, 2024 08:46
Copy link
Member

@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.

converting types from consensus to rpc can't really be solved like this because this constrains it to alloy_consensus::Transaction

Comment on lines +357 to +361
fn fill(
signed_tx: Signed<impl alloy_consensus::Transaction>,
signer: Address,
tx_info: TransactionInfo,
) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

these functions won't work, because they constrain type creation, we can not lock this in in the trait function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how come?

@emhane emhane requested a review from mattsse September 6, 2024 16:12
@mattsse
Copy link
Member

mattsse commented Sep 11, 2024

closing this, because we can't support the fill feature like this, because this conversion is type specific.

and the additional gas functions doesn't really make sense like this because this info should be encapsulated in the transaction itself, especially if we proceed with

#1169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debt Tech debt which needs to be addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants