feat: improve exex examples' validation (#8116)

This commit is contained in:
alpharush
2024-05-06 05:16:27 -05:00
committed by GitHub
parent 8f8b29b3ce
commit f83a872dd6
2 changed files with 26 additions and 7 deletions

View File

@ -3,7 +3,7 @@ use futures::Future;
use reth_exex::{ExExContext, ExExEvent};
use reth_node_api::FullNodeComponents;
use reth_node_ethereum::EthereumNode;
use reth_primitives::{Log, SealedBlockWithSenders, TransactionSigned};
use reth_primitives::{address, Address, Log, SealedBlockWithSenders, TransactionSigned};
use reth_provider::Chain;
use reth_tracing::tracing::info;
use rusqlite::Connection;
@ -11,6 +11,15 @@ use rusqlite::Connection;
sol!(L1StandardBridge, "l1_standard_bridge_abi.json");
use crate::L1StandardBridge::{ETHBridgeFinalized, ETHBridgeInitiated, L1StandardBridgeEvents};
const OP_BRIDGES: [Address; 6] = [
address!("3154Cf16ccdb4C6d922629664174b904d80F2C35"),
address!("3a05E5d33d7Ab3864D53aaEc93c8301C1Fa49115"),
address!("697402166Fbf2F22E970df8a6486Ef171dbfc524"),
address!("99C9fc46f92E8a1c0deC1b1747d010903E884bE1"),
address!("735aDBbE72226BD52e818E7181953f42E3b0FF21"),
address!("3B95bC951EE0f553ba487327278cAc44f29715E5"),
];
/// Initializes the ExEx.
///
/// Opens up a SQLite database and creates the tables (if they don't exist).
@ -213,8 +222,14 @@ fn decode_chain_into_events(
.zip(receipts.iter().flatten())
.map(move |(tx, receipt)| (block, tx, receipt))
})
// Get all logs
.flat_map(|(block, tx, receipt)| receipt.logs.iter().map(move |log| (block, tx, log)))
// Get all logs from expected bridge contracts
.flat_map(|(block, tx, receipt)| {
receipt
.logs
.iter()
.filter(|log| OP_BRIDGES.contains(&log.address))
.map(move |log| (block, tx, log))
})
// Decode and filter bridge events
.filter_map(|(block, tx, log)| {
L1StandardBridgeEvents::decode_raw_log(log.topics(), &log.data.data, true)

View File

@ -243,10 +243,14 @@ fn decode_chain_into_rollup_events(
.zip(receipts.iter().flatten())
.map(move |(tx, receipt)| (block, tx, receipt))
})
// Filter only transactions to the rollup contract
.filter(|(_, tx, _)| tx.to() == Some(ROLLUP_CONTRACT_ADDRESS))
// Get all logs
.flat_map(|(block, tx, receipt)| receipt.logs.iter().map(move |log| (block, tx, log)))
// Get all logs from rollup contract
.flat_map(|(block, tx, receipt)| {
receipt
.logs
.iter()
.filter(|log| log.address == ROLLUP_CONTRACT_ADDRESS)
.map(move |log| (block, tx, log))
})
// Decode and filter rollup events
.filter_map(|(block, tx, log)| {
RollupContractEvents::decode_raw_log(log.topics(), &log.data.data, true)