-
Notifications
You must be signed in to change notification settings - Fork 1
fix: update to eip 7594 blob handling #202
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,16 +6,19 @@ use crate::{ | |
| tasks::{block::sim::SimResult, submit::SubmitPrep}, | ||
| }; | ||
| use alloy::{ | ||
| eips::Encodable2718, | ||
| consensus::{EthereumTxEnvelope, TxEip4844Variant}, | ||
| eips::{Encodable2718, eip7594::BlobTransactionSidecarEip7594}, | ||
| primitives::{Bytes, TxHash}, | ||
| providers::ext::MevApi, | ||
| rpc::types::mev::EthSendBundle, | ||
| }; | ||
| use eyre::OptionExt; | ||
| use init4_bin_base::{deps::metrics::counter, utils::signer::LocalOrAws}; | ||
| use tokio::{sync::mpsc, task::JoinHandle}; | ||
| use tracing::{Instrument, debug, debug_span, error, instrument}; | ||
|
|
||
| /// Type alias for a EIP 7594 compatible blob sidecar transaction envelope. | ||
| type SubmitEnvelope7594 = EthereumTxEnvelope<TxEip4844Variant<BlobTransactionSidecarEip7594>>; | ||
|
|
||
| /// Handles preparation and submission of simulated rollup blocks to the | ||
| /// Flashbots relay as MEV bundles. | ||
| #[derive(Debug)] | ||
|
|
@@ -84,7 +87,6 @@ impl FlashbotsTask { | |
| let txs = self.build_bundle_body(sim_result, tx_bytes); | ||
|
|
||
| // Create the MEV bundle (valid only in the specific host block) | ||
|
|
||
| Ok(EthSendBundle { | ||
| txs, | ||
| block_number: sim_result.host_block_number(), | ||
|
|
@@ -100,7 +102,7 @@ impl FlashbotsTask { | |
| async fn prepare_signed_transaction( | ||
| &self, | ||
| sim_result: &SimResult, | ||
| ) -> eyre::Result<alloy::consensus::TxEnvelope> { | ||
| ) -> eyre::Result<SubmitEnvelope7594> { | ||
| let prep = SubmitPrep::new( | ||
| &sim_result.block, | ||
| self.host_provider(), | ||
|
|
@@ -114,15 +116,22 @@ impl FlashbotsTask { | |
| .fill(tx.into_request()) | ||
| .instrument(tracing::debug_span!("fill_tx").or_current()) | ||
| .await?; | ||
| debug!(?sendable, "prepared signed rollup block transaction"); | ||
|
|
||
| let tx_envelope = sendable | ||
| .try_into_envelope()? | ||
| .try_into_7594() | ||
| .map_err(|e| eyre::eyre!("failed to map 4844 to 7594: {e:?}"))?; | ||
| debug!(?tx_envelope, "prepared signed rollup block transaction envelope"); | ||
|
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. don't trace out the envelope, it'll be 100kb+ i think |
||
|
|
||
| sendable.as_envelope().ok_or_eyre("failed to get envelope from filled tx").cloned() | ||
| Ok(tx_envelope) | ||
| } | ||
|
|
||
| /// Tracks the outbound transaction hash and increments submission metrics. | ||
| /// | ||
| /// Sends the transaction hash to the outbound channel for monitoring. | ||
| /// Logs a debug message if the channel is closed. | ||
| fn track_outbound_tx(&self, envelope: &alloy::consensus::TxEnvelope) { | ||
| fn track_outbound_tx(&self, envelope: &SubmitEnvelope7594) { | ||
| counter!("signet.builder.flashbots.").increment(1); | ||
| let hash = *envelope.tx_hash(); | ||
| if self.outbound.send(hash).is_err() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ use crate::{ | |
| utils, | ||
| }; | ||
| use alloy::{ | ||
| consensus::{Header, SimpleCoder}, | ||
| consensus::{BlobTransactionSidecar, Header, SimpleCoder}, | ||
| network::{TransactionBuilder, TransactionBuilder4844}, | ||
| primitives::{B256, Bytes, U256}, | ||
| providers::{Provider, WalletProvider}, | ||
|
|
@@ -92,8 +92,8 @@ impl<'a> SubmitPrep<'a> { | |
| self.quincey_resp().await.map(|resp| &resp.sig).map(utils::extract_signature_components) | ||
| } | ||
|
|
||
| /// Encodes the sidecar and then builds the 4844 blob transaction from the provided header and signature values. | ||
| async fn build_blob_tx(&self) -> eyre::Result<TransactionRequest> { | ||
| /// Build the sidecar and input data for the transaction. | ||
| async fn build_sidecar_and_data(&self) -> eyre::Result<(BlobTransactionSidecar, Vec<u8>)> { | ||
|
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. let's break these into two functions rather than return s tuple |
||
| let (v, r, s) = self.quincey_signature().await?; | ||
|
|
||
| let header = Zenith::BlockHeader { | ||
|
|
@@ -106,24 +106,24 @@ impl<'a> SubmitPrep<'a> { | |
| debug!(?header.hostBlockNumber, "built zenith block header"); | ||
|
|
||
| let data = Zenith::submitBlockCall { header, v, r, s, _4: Bytes::new() }.abi_encode(); | ||
|
|
||
| let sidecar = self.block.encode_blob::<SimpleCoder>().build()?; | ||
|
|
||
| Ok(TransactionRequest::default().with_blob_sidecar(sidecar).with_input(data)) | ||
| Ok((sidecar, data)) | ||
| } | ||
|
|
||
| /// Create a new transaction request for the host chain. | ||
| async fn new_tx_request(&self) -> eyre::Result<TransactionRequest> { | ||
| let nonce = | ||
| self.provider.get_transaction_count(self.provider.default_signer_address()).await?; | ||
|
|
||
| debug!(nonce, "assigned nonce to rollup block transaction"); | ||
|
|
||
| // Create a blob transaction with the blob header and signature values and return it | ||
| let tx = self | ||
| .build_blob_tx() | ||
| .await? | ||
| let (sidecar, data) = self.build_sidecar_and_data().await?; | ||
| let tx = TransactionRequest::default() | ||
| .with_blob_sidecar(sidecar) | ||
| .with_input(data) | ||
| .with_to(self.config.constants.host_zenith()) | ||
| .with_nonce(nonce); | ||
| debug!(?tx, "constructed rollup block transaction request"); | ||
|
|
||
|
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. don't trace the tx same reason as above |
||
| Ok(tx) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use wrap_err. The current code will erase context