Skip to content

Commit a89f9d7

Browse files
committed
feat(coprocessor): add ZK proof gauges to txn-sender
These cover both txn sending by `transaction-sender` and `zkproof-worker` operation. Also make `--host-chain-url` a long-only argument for compatibility with `-h` for help.
1 parent 92bd912 commit a89f9d7

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

coprocessor/fhevm-engine/transaction-sender/src/bin/transaction_sender.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct Conf {
5050
#[arg(short, long)]
5151
gateway_url: Url,
5252

53-
#[arg(short, long)]
53+
#[arg(long)]
5454
host_chain_url: Url,
5555

5656
#[arg(short, long, value_enum, default_value = "private-key")]

coprocessor/fhevm-engine/transaction-sender/src/metrics.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,22 @@ pub(crate) static ADD_CIPHERTEXT_MATERIAL_UNSENT: LazyLock<IntGauge> = LazyLock:
9494
.unwrap()
9595
});
9696

97+
pub(crate) static VERIFY_PROOF_RESP_UNSENT_TXN: LazyLock<IntGauge> = LazyLock::new(|| {
98+
register_int_gauge!(
99+
"coprocessor_verify_proof_resp_unsent_txn_gauge",
100+
"Number of unsent verify proof response transactions"
101+
)
102+
.unwrap()
103+
});
104+
105+
pub(crate) static VERIFY_PROOF_PENDING: LazyLock<IntGauge> = LazyLock::new(|| {
106+
register_int_gauge!(
107+
"coprocessor_verify_proof_pending_gauge",
108+
"Number of pending verify proof requests"
109+
)
110+
.unwrap()
111+
});
112+
97113
pub fn spawn_gauge_update_routine(period: std::time::Duration, db_pool: PgPool) -> JoinHandle<()> {
98114
tokio::spawn(async move {
99115
loop {
@@ -127,6 +143,34 @@ pub fn spawn_gauge_update_routine(period: std::time::Duration, db_pool: PgPool)
127143
}
128144
}
129145

146+
match sqlx::query_scalar("SELECT COUNT(*) FROM verify_proofs WHERE verified IS NULL")
147+
.fetch_one(&db_pool)
148+
.await
149+
{
150+
Ok(count) => {
151+
info!(verify_proof_pending = %count, "Fetched pending verify proofs count");
152+
VERIFY_PROOF_PENDING.set(count);
153+
}
154+
Err(e) => {
155+
error!(error = %e, "Failed to fetch pending verify proofs count");
156+
}
157+
}
158+
159+
match sqlx::query_scalar(
160+
"SELECT COUNT(*) FROM verify_proofs WHERE verified IS NOT NULL",
161+
)
162+
.fetch_one(&db_pool)
163+
.await
164+
{
165+
Ok(count) => {
166+
info!(verify_proof_resp_unsent_txn = %count, "Fetched unsent verify proof response count");
167+
VERIFY_PROOF_RESP_UNSENT_TXN.set(count);
168+
}
169+
Err(e) => {
170+
error!(error = %e, "Failed to fetch unsent verify proof response count");
171+
}
172+
}
173+
130174
sleep(period).await;
131175
}
132176
})

docs/metrics/metrics.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ Note that recommendations assume a smoke test that runs transactions/requests at
5858
- **Alarm**: If the gauge value exceeds a predefined threshold.
5959
- **Recommendation**: more than 100 unsent over 2 minutes, i.e. `min_over_time(gauge[2m]) > 100`.
6060

61+
#### Metric Name: `coprocessor_verify_proof_resp_unsent_txn_gauge`
62+
- **Type**: Gauge
63+
- **Description**: Tracks the number of unsent verify proof response transactions in the transaction-sender.
64+
- **Alarm**: If the gauge value exceeds a predefined threshold.
65+
- **Recommendation**: more than 100 unsent over 2 minutes, i.e. `min_over_time(gauge[2m]) > 100`.
66+
67+
#### Metric Name: `coprocessor_verify_proof_pending_gauge`
68+
- **Type**: Gauge
69+
- **Description**: Tracks the number of pending verify proofs (pending on the zkproof-worker).
70+
- **Alarm**: If the gauge value exceeds a predefined threshold.
71+
- **Recommendation**: more than 100 pending over 2 minutes, i.e. `min_over_time(gauge[2m]) > 100`.
72+
6173
### gw-listener
6274

6375
#### Metric Name: `coprocessor_gw_listener_verify_proof_success_counter`
@@ -125,7 +137,7 @@ Note that recommendations assume a smoke test that runs transactions/requests at
125137

126138
### zkproof-worker
127139

128-
Metrics for zkproof-worker are to be added in future releases.
140+
Metrics for zkproof-worker are to be added in future releases, if/when needed. Currently, the transaction-sender handles ZK proof related metrics, please see its section.
129141

130142
### sns-worker
131143

0 commit comments

Comments
 (0)