Skip to content

Commit e7293b1

Browse files
authored
BM-266: Resubmitting merkle roots cleanup (github#83)
This PR allows for cheap resubmission of timed-out submit_merkle batches. It does so by checking if the root is already present and skipping to fulfill_batch. Most useful for manual triggering of re-submission of batches. It also adds docs on how to go about manual re-submission of orders in the Broker docs.
1 parent f30636d commit e7293b1

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

crates/broker/src/submitter.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,22 @@ where
103103
let batch_root = batch.root.context("Batch missing root digest")?;
104104
let root = B256::from_slice(batch_root.as_bytes());
105105

106-
tracing::info!("Submitting app merkle root: {root}");
107-
self.set_verifier
108-
.submit_merkle_root(root, batch_seal.into())
109-
.await
110-
.context("Failed to submit app merkle_root")?;
106+
let contains_root = match self.set_verifier.contains_root(root).await {
107+
Ok(res) => res,
108+
Err(err) => {
109+
tracing::error!("Failed to query if set-verifier contains the new root, trying to submit anyway {err:?}");
110+
false
111+
}
112+
};
113+
if !contains_root {
114+
tracing::info!("Submitting app merkle root: {root}");
115+
self.set_verifier
116+
.submit_merkle_root(root, batch_seal.into())
117+
.await
118+
.context("Failed to submit app merkle_root")?;
119+
} else {
120+
tracing::info!("Contract already contains root, skipping to fulfillment");
121+
}
111122

112123
let inclusion_params =
113124
SetInclusionReceiptVerifierParameters { image_id: self.set_builder_img_id };

docs/src/prover-manual/broker/operation.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,30 @@ RUST_LOG=info,boundless_market=debug cargo run --bin cli -- deposit ${BOUNDLESS
7575
2024-10-23T14:30:07.175994Z INFO cli: Deposited: 500000000000000000
7676
```
7777

78+
## Debugging
79+
80+
### Orders stuck in 'lockin' or submit_merkle confirmation timeouts
81+
82+
If on the indexer you see your broker having a high number of orders locked-in but not being fulfilled it might be due to TXN confirmation timeouts. Initially increasing the `txn_timeout` in the `broker.toml` file is a good start to try and ensure the fulfillment completes.
83+
84+
Additionally it is possible to re-drive orders that are "stuck" via the following:
85+
86+
1. Manually connect to the sqlite DB for broker. This can be done inside the broker container via `sqlite3 /db/broker.db` or by mounting the `broker-data` docker volume
87+
88+
2. Finding the batch that contains the order:
89+
90+
```bash
91+
SELECT id FROM batches WHERE data->>'orders' LIKE '%"TARGET_ORDER_ID"%';
92+
# Example: SELECT id FROM batches WHERE data->>'orders' LIKE '%"0x466acfc0f27bba9fbb7a8508f576527e81e83bd00000caa"%';
93+
```
94+
95+
3. Trigger a rerun of the submitter task:
96+
97+
```bash
98+
UPDATE batches SET data = json_set(data, '$.status', 'Complete') WHERE id = YOUR_BATCH_ID_FROM_STEP_2;
99+
# Example: UPDATE batches SET data = json_set(data, '$.status', 'Complete') WHERE id = 1;
100+
```
101+
78102
[page-broker-config]: ./configure.md
79103
[page-local-dev]: ../../market/local-development.md
80104
[page-bento-perf]: ../bento/performance.md

0 commit comments

Comments
 (0)