Skip to content

Commit

Permalink
l1tx: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
delbonis authored and Bibek Pandey committed Feb 6, 2025
1 parent a9391fd commit 16b29d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 113 deletions.
106 changes: 0 additions & 106 deletions crates/l1tx/src/filter/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,112 +73,6 @@ fn index_tx<V: TxVisitor>(
visitor.finalize()
}

/*
/// Interface to extract relevant information from a block.
pub trait BlockIndexer {
/// Output from the indexing pass.
type Output;
/// Indexes the block and produces the output.
fn index_block(&self, block: &Block) -> Self::Output;
}
/// Indexes `ProtocolTxEntry`s, `DepositRequestInfo`s and `DaEntry`s from a bitcoin block.
///
/// Currently, this is used from two contexts: rollup node and prover node, each of which will have
/// different `TxIndexer`s which determine what and how something is extracted from a transaction.
pub struct TxOpIndexer<'a, T: TxVisitor, F: Fn() -> T> {
/// The actual logic of what and how something is extracted from a transaction.
tx_indexer_fn: F,
/// The config that's used to filter transactions and extract data. This has a lifetime
/// parameter for two reasons: 1) It is used in prover context so using Arc might incur some
/// overheads, 2) We can be sure that the config won't change during indexing of a l1 block.
filter_config: &'a TxFilterConfig,
/// `ProtocolTxEntry`s will be accumulated here.
relevant_txs: Vec<IndexedTxEntry<T::Output>>,
}
impl<'a, T: TxVisitor, F: Fn() -> T> TxOpIndexer<'a, T, F> {
pub fn new(tx_indexer_fn: F, filter_config: &'a TxFilterConfig) -> Self {
Self {
tx_indexer_fn,
filter_config,
relevant_txs: Vec::new(),
dep_reqs: Vec::new(),
da_entries: Vec::new(),
}
}
pub fn tx_entries(&self) -> &[IndexedTxEntry<T::Output>] {
&self.relevant_txs
}
pub fn deposit_requests(&self) -> &[DepositRequestInfo] {
&self.dep_reqs
}
pub fn da_entries(&self) -> &[DaEntry] {
&self.da_entries
}
}
impl<T: TxVisitor, F: Fn() -> T> TxOpIndexer<'_, T, F> {
fn index_tx(&self, txidx: u32, tx: &Transaction) {
let mut tx_visitor = (self.tx_indexer_fn)();
for ckpt in parse_checkpoint_envelopes(tx, self.filter_config) {
tx_visitor.visit_checkpoint(ckpt);
}
for dp in parse_deposits(tx, self.filter_config) {
tx_visitor.visit_deposit(dp);
}
// TODO: remove this later when we do not require deposit request ops
for dr in parse_deposit_requests(tx, self.filter_config) {
tx_visitor.visit_deposit_request(dr);
}
for da in parse_da_blobs(tx, self.filter_config) {
tx_visitor.visit_da(da);
}
// Finalize the visitor. If there's nothing to report then return
// immeditately.
if let Some(summary) = tx_visitor.finalize() {
self.relevant_txs.push(IndexedTxEntry::new(txidx, summary));
}
self.dep_reqs.append(&mut deps);
self.da_entries.append(&mut das);
}
}
impl<T: TxVisitor, F: Fn() -> T> BlockIndexer for TxOpIndexer<'_, T, F> {
type Output = Vec<RelevantTxEntry>;
fn index_block(&self, block: &Block) -> Self::Output
where
Self: Sized,
{
let mut op_txs = Vec::new();
let mut deposit_reqs = Vec::new();
let mut da_entries = Vec::new();
for (i, tx) in block.txdata.iter().enumerate() {
self.index_tx(i as u32, tx);
}
// TODO
}
/*fn finalize(self) -> L1BlockExtract {
L1BlockExtract::new(self.tx_entries, self.dep_reqs, self.da_entries)
}*/
}*/

/// Generic no-op tx indexer that emits nothing for every tx but could
/// substitute for any type of visitor.
pub struct NopTxVisitorImpl<T>(::std::marker::PhantomData<T>);
Expand Down
9 changes: 2 additions & 7 deletions crates/l1tx/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum L1Event {
GenesisVerificationState(u64, HeaderVerificationState),
}

/// Indexed transaction entry taken from
/// Indexed transaction entry taken from a block.
#[derive(Clone, Debug, BorshDeserialize, BorshSerialize)]
pub struct IndexedTxEntry<T> {
/// Index of the transaction in the block
Expand Down Expand Up @@ -55,11 +55,6 @@ impl<T> IndexedTxEntry<T> {
}
}

/*
* Core protocol specific bitcoin transaction reference. A bitcoin transaction can have multiple
* operations relevant to protocol. This is used in the context of [`BlockData`].
*/

/// Container for the different kinds of messages that we could extract from a L1 tx.
#[derive(Clone, Debug)]
pub struct L1TxMessages {
Expand Down Expand Up @@ -110,7 +105,7 @@ impl L1TxMessages {
}
}

/// Da data retrieved from L1 transaction.
/// DA commitment and blob retrieved from L1 transaction.
#[derive(Clone, Debug)]
pub struct DaEntry {
#[allow(unused)]
Expand Down

0 comments on commit 16b29d2

Please sign in to comment.