Skip to content

Commit 1daed88

Browse files
authored
feat: add blob tx listener (#92)
1 parent d582de1 commit 1daed88

File tree

39 files changed

+1094
-394
lines changed

39 files changed

+1094
-394
lines changed

.sqlx/query-59468b64c24fb4c77a9b30428fd4682e9b4cfcba55c9535931edc7448ed88bfa.json

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-6fb27a4115a2cb07c21e7a47565a0436de31285492657bae6aaadc04115cea5d.json

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-9be45d22c0bb43deb53da5a8fe19f5554f2a901cabc730792d51baadd2460e44.json

+34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-9fad1eeaa60ea30606182ffef41d62900c0343c83e6258a2e9f287c2b4e0281e.json

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-b3e422ba5518d62297afe5fc97440249be2af4c93243b961f68b028232185992.json

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-bce910f42b45949e8ab08355c5b6d7679c267ef5946d7c360a24abfdefa1abe2.json

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/storage/.sqlx/query-3e2f4f0f3c019c8ee65865a83d799b5c152c9358ea2af38e4c267f326366afd2.json .sqlx/query-c6cffaf0718065ed45442c123f7aed85456bbbb9588ab0ed2be2d685ea09364e.json

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-daa42cdb26e7b8e6d1d586367cbe42d1defc42b001b71e53a86e47f91c521c69.json

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-f258b9822f1b060c13cd895fdbe61020fa605fdba844cb8c0071111f78342b5e.json

+48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

committer/src/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ pub struct App {
8585
/// How often to check the latest fuel block
8686
#[serde(deserialize_with = "human_readable_duration")]
8787
pub block_check_interval: Duration,
88+
/// Number of L1 blocks that need to pass to accept the tx as finalized
89+
pub num_blocks_to_finalize_tx: u64,
8890
}
8991

9092
fn human_readable_duration<'de, D>(deserializer: D) -> Result<Duration, D::Error>

committer/src/main.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ async fn main() -> Result<()> {
7070
listener_handle,
7171
];
7272

73-
// If the blob pool wallet key is set, we need to start the state committer and state importer
73+
// If the blob pool wallet key is set, we need to start
74+
// the state committer, state importer and state listener
7475
if config.eth.blob_pool_wallet_key.is_some() {
7576
let state_committer_handle = setup::state_committer(
76-
ethereum_rpc,
77+
ethereum_rpc.clone(),
7778
storage.clone(),
7879
&metrics_registry,
7980
cancel_token.clone(),
@@ -88,8 +89,12 @@ async fn main() -> Result<()> {
8889
&config,
8990
);
9091

92+
let state_listener_handle =
93+
setup::state_listener(ethereum_rpc, storage.clone(), cancel_token.clone(), &config);
94+
9195
handles.push(state_committer_handle);
9296
handles.push(state_importer_handle);
97+
handles.push(state_listener_handle);
9398
}
9499

95100
launch_api_server(

committer/src/setup.rs

+17
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,23 @@ pub fn state_importer(
105105
)
106106
}
107107

108+
pub fn state_listener(
109+
l1: L1,
110+
storage: impl Storage + 'static,
111+
cancel_token: CancellationToken,
112+
config: &config::Config,
113+
) -> tokio::task::JoinHandle<()> {
114+
let state_listener =
115+
services::StateListener::new(l1, storage, config.app.num_blocks_to_finalize_tx);
116+
117+
schedule_polling(
118+
config.app.block_check_interval,
119+
state_listener,
120+
"State Listener",
121+
cancel_token,
122+
)
123+
}
124+
108125
pub async fn l1_adapter(
109126
config: &config::Config,
110127
internal_config: &config::Internal,

configurations/development/config.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ block_producer_public_key = "0x73dc6cc8cc0041e4924954b35a71a22ccb520664c522198a6
1111
port = 8080
1212
host = "0.0.0.0"
1313
block_check_interval = "1s"
14+
num_blocks_to_finalize_tx = 12
1415

1516
[app.db]
1617
host = "localhost"

packages/eth/src/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use ethers::types::U256;
88
use futures::{stream::TryStreamExt, Stream};
99
use ports::{
1010
l1::{Api, Contract, EventStreamer, Result},
11-
types::{FuelBlockCommittedOnL1, L1Height, ValidatedFuelBlock},
11+
types::{FuelBlockCommittedOnL1, L1Height, TransactionResponse, ValidatedFuelBlock},
1212
};
1313
use websocket::EthEventStreamer;
1414

@@ -51,6 +51,13 @@ impl Api for WebsocketClient {
5151

5252
Ok(height)
5353
}
54+
55+
async fn get_transaction_response(
56+
&self,
57+
tx_hash: [u8; 32],
58+
) -> Result<Option<TransactionResponse>> {
59+
Ok(self.get_transaction_response(tx_hash).await?)
60+
}
5461
}
5562

5663
#[async_trait::async_trait]

packages/eth/src/websocket.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use ::metrics::{prometheus::core::Collector, HealthChecker, RegistersMetrics};
22
use ethers::types::{Address, Chain};
33
use ports::{
44
l1::Result,
5-
types::{ValidatedFuelBlock, U256},
5+
types::{TransactionResponse, ValidatedFuelBlock, U256},
66
};
77
use std::num::NonZeroU32;
88
use url::Url;
@@ -66,6 +66,13 @@ impl WebsocketClient {
6666
Ok(self.inner.get_block_number().await?)
6767
}
6868

69+
pub(crate) async fn get_transaction_response(
70+
&self,
71+
tx_hash: [u8; 32],
72+
) -> Result<Option<TransactionResponse>> {
73+
Ok(self.inner.get_transaction_response(tx_hash).await?)
74+
}
75+
6976
pub(crate) async fn balance(&self) -> Result<U256> {
7077
Ok(self.inner.balance().await?)
7178
}

0 commit comments

Comments
 (0)