Skip to content

Commit ebab970

Browse files
committed
Change Submitter to batch blocks.
1 parent 5c753e0 commit ebab970

File tree

7 files changed

+255
-286
lines changed

7 files changed

+255
-286
lines changed

robusta/src/lib.rs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ use timeboost_types::{BlockNumber, CertifiedBlock};
1818
use tokio::time::sleep;
1919
use tracing::{debug, warn};
2020

21-
use crate::types::{RecvBody, SendBody, TaggedBase64, TransactionsWithProof, VidCommonResponse, TX};
21+
use crate::types::{
22+
RecvBody, SendBody, TX, TaggedBase64, TransactionsWithProof, VidCommonResponse,
23+
};
2224

2325
pub use crate::multiwatcher::Multiwatcher;
2426
pub use crate::types::Height;
@@ -58,7 +60,11 @@ impl Client {
5860
self.get_with_retry(u).await
5961
}
6062

61-
pub async fn submit<N>(&self, nsid: N, blocks: &[CertifiedBlock<Validated>]) -> Result<(), Error>
63+
pub async fn submit<N>(
64+
&self,
65+
nsid: N,
66+
blocks: &[CertifiedBlock<Validated>],
67+
) -> Result<(), Error>
6268
where
6369
N: Into<NamespaceId>,
6470
{
@@ -104,25 +110,23 @@ impl Client {
104110
}
105111
Either::Right(trxs.into_iter().flat_map(move |t| {
106112
match minicbor::decode::<RecvBody>(t.payload()) {
107-
Ok(body) => {
108-
Either::Right(body.blocks.into_iter().filter_map(|b| {
109-
let Some(c) = cvec.get(b.committee()) else {
110-
warn!(
111-
node = %self.config.label,
112-
height = %hdr.height(),
113-
committee = %b.committee(),
114-
"unknown committee"
115-
);
116-
return None;
117-
};
118-
if let Some(b) = b.validated(c) {
119-
Some(b.cert().data().num())
120-
} else {
121-
warn!(node = %self.config.label, height = %hdr.height(), "invalid block");
122-
None
123-
}
124-
}))
125-
}
113+
Ok(body) => Either::Right(body.blocks.into_iter().filter_map(|b| {
114+
let Some(c) = cvec.get(b.committee()) else {
115+
warn!(
116+
node = %self.config.label,
117+
height = %hdr.height(),
118+
committee = %b.committee(),
119+
"unknown committee"
120+
);
121+
return None;
122+
};
123+
if let Some(b) = b.validated(c) {
124+
Some(b.cert().data().num())
125+
} else {
126+
warn!(node = %self.config.label, height = %hdr.height(), "invalid block");
127+
None
128+
}
129+
})),
126130
Err(err) => {
127131
warn!(
128132
node = %self.config.label,

robusta/src/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ pub(crate) struct VidCommonResponse {
2828
#[cbor(map)]
2929
pub(crate) struct RecvBody {
3030
#[cbor(n(0))]
31-
pub(crate) blocks: Vec<CertifiedBlock<Unchecked>>
31+
pub(crate) blocks: Vec<CertifiedBlock<Unchecked>>,
3232
}
3333

3434
#[derive(Debug, Encode)]
3535
#[cbor(map)]
3636
pub(crate) struct SendBody<'a> {
3737
#[cbor(n(0))]
38-
pub(crate) blocks: &'a [CertifiedBlock<Validated>]
38+
pub(crate) blocks: &'a [CertifiedBlock<Validated>],
3939
}
4040

4141
macro_rules! Primitive {

timeboost-builder/src/metrics.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use metrics::{Gauge, Metrics, NoMetrics};
1+
use metrics::{Counter, Metrics, NoMetrics};
22

33
#[derive(Debug)]
44
#[non_exhaustive]
55
pub struct BuilderMetrics {
6-
pub block_submit: Box<dyn Gauge>,
7-
pub submit_tasks: Box<dyn Gauge>,
6+
pub blocks_submitted: Box<dyn Counter>,
7+
pub blocks_verified: Box<dyn Counter>,
88
}
99

1010
impl Default for BuilderMetrics {
@@ -16,8 +16,8 @@ impl Default for BuilderMetrics {
1616
impl BuilderMetrics {
1717
pub fn new<M: Metrics>(m: &M) -> Self {
1818
Self {
19-
block_submit: m.create_gauge("block_submit", None),
20-
submit_tasks: m.create_gauge("submit_tasks", None),
19+
blocks_submitted: m.create_counter("blocks_submitted", None),
20+
blocks_verified: m.create_counter("blocks_verified", None),
2121
}
2222
}
2323
}

0 commit comments

Comments
 (0)