-
Notifications
You must be signed in to change notification settings - Fork 13
fix: impl Tx for the recently introduced blob sidecar enum variant #137
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,8 @@ use crate::{Block, Tx}; | |
| use alloy::{ | ||
| consensus::{ | ||
| transaction::{Recovered, SignerRecoverable}, | ||
| BlobTransactionSidecar, EthereumTxEnvelope, Signed, TxEip4844, TxEip4844WithSidecar, | ||
| TxEnvelope, TxType, | ||
| BlobTransactionSidecar, BlobTransactionSidecarVariant, EthereumTxEnvelope, Signed, | ||
| TxEip4844, TxEip4844WithSidecar, TxEnvelope, TxType, | ||
| }, | ||
| eips::eip7594::BlobTransactionSidecarEip7594, | ||
| primitives::U256, | ||
|
|
@@ -47,6 +47,7 @@ delegate_alloy_txs!(alloy::consensus::TxEip1559); | |
| delegate_alloy_txs!(alloy::consensus::TxEip4844); | ||
| delegate_alloy_txs!(alloy::consensus::TxEip4844WithSidecar<BlobTransactionSidecar>); | ||
| delegate_alloy_txs!(alloy::consensus::TxEip4844WithSidecar<BlobTransactionSidecarEip7594>); | ||
| delegate_alloy_txs!(alloy::consensus::TxEip4844WithSidecar<BlobTransactionSidecarVariant>); | ||
| delegate_alloy_txs!(alloy::consensus::TxEip4844Variant); | ||
| delegate_alloy_txs!(alloy::consensus::TxEip7702); | ||
|
|
||
|
|
@@ -56,6 +57,9 @@ delegate_alloy_txs!(@envelope EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransa | |
| delegate_alloy_txs!( | ||
| @envelope EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransactionSidecarEip7594>> | ||
| ); | ||
| delegate_alloy_txs!( | ||
| @envelope EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransactionSidecarVariant>> | ||
| ); | ||
|
|
||
| impl Tx for Recovered<&alloy::consensus::TxLegacy> { | ||
| fn fill_tx_env(&self, tx_env: &mut TxEnv) { | ||
|
|
@@ -197,42 +201,10 @@ impl Tx for Recovered<&alloy::consensus::TxEip4844> { | |
| } | ||
| } | ||
|
|
||
| impl Tx for Recovered<&alloy::consensus::TxEip4844WithSidecar<BlobTransactionSidecar>> { | ||
| fn fill_tx_env(&self, tx_env: &mut TxEnv) { | ||
| let TxEnv { | ||
| tx_type, | ||
| caller, | ||
| gas_limit, | ||
| gas_price, | ||
| kind, | ||
| value, | ||
| data, | ||
| nonce, | ||
| chain_id, | ||
| access_list, | ||
| gas_priority_fee, | ||
| blob_hashes, | ||
| max_fee_per_blob_gas, | ||
| authorization_list, | ||
| } = tx_env; | ||
| *tx_type = TxType::Eip4844 as u8; | ||
| *caller = self.signer(); | ||
| *gas_limit = self.inner().tx.gas_limit; | ||
| *gas_price = self.inner().tx.max_fee_per_gas; | ||
| *kind = self.inner().tx.to.into(); | ||
| *value = self.inner().tx.value; | ||
| *data = self.inner().tx.input.clone(); | ||
| *nonce = self.inner().tx.nonce; | ||
| *chain_id = Some(self.inner().tx.chain_id); | ||
| access_list.clone_from(&self.inner().tx.access_list); | ||
| *gas_priority_fee = Some(self.inner().tx.max_priority_fee_per_gas); | ||
| blob_hashes.clone_from(&self.inner().tx.blob_versioned_hashes); | ||
| *max_fee_per_blob_gas = self.inner().tx.max_fee_per_blob_gas; | ||
| authorization_list.clear(); | ||
| } | ||
| } | ||
|
|
||
| impl Tx for Recovered<&alloy::consensus::TxEip4844WithSidecar<BlobTransactionSidecarEip7594>> { | ||
| impl<T> Tx for Recovered<&alloy::consensus::TxEip4844WithSidecar<T>> | ||
| where | ||
| T: Send + Sync, | ||
| { | ||
| fn fill_tx_env(&self, tx_env: &mut TxEnv) { | ||
| let TxEnv { | ||
| tx_type, | ||
|
|
@@ -407,6 +379,28 @@ impl Tx for Recovered<&EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransactionSi | |
| } | ||
| } | ||
|
|
||
| impl Tx for Recovered<&EthereumTxEnvelope<TxEip4844WithSidecar<BlobTransactionSidecarVariant>>> { | ||
| fn fill_tx_env(&self, tx_env: &mut TxEnv) { | ||
| match self.inner() { | ||
| EthereumTxEnvelope::Legacy(t) => { | ||
| Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) | ||
| } | ||
| EthereumTxEnvelope::Eip2930(t) => { | ||
| Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) | ||
| } | ||
| EthereumTxEnvelope::Eip1559(t) => { | ||
| Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) | ||
| } | ||
| EthereumTxEnvelope::Eip4844(t) => { | ||
| Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) | ||
| } | ||
| EthereumTxEnvelope::Eip7702(t) => { | ||
| Recovered::new_unchecked(t, self.signer()).fill_tx_env(tx_env) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is also something that can be made generic, should i?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm on the fence about making these generic, as there's currently no trait bound to limit the typevar to something that's valid in context afaik I suppose it won't cause any issues to go more generic, and it does DRY the code. let's make this generic as well
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there was a problem with generics because of missing trait bound as you point out. but i added a macro instead. |
||
|
|
||
| impl Block for alloy::consensus::Header { | ||
| fn fill_block_env(&self, block_env: &mut BlockEnv) { | ||
| let BlockEnv { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.