Skip to content

Commit c9cb7f6

Browse files
Artemka374Deniallugo
authored andcommitted
fix(eth-proof-manager): verify protocol version and proving mode alignment (#4473)
## What ❔ Verify protocol version and proving mode alignment when receiving a proof. ## Why ❔ * Check whether proof has the same protocol version as the batch it was generated for * When getting batch to send validation result for - check whether the batch has proving_mode = proving_network. It prevents sending validation result for the batches that were generated by prover cluster. ## Is this a breaking change? - [ ] Yes - [ ] No ## Operational changes <!-- Any config changes? Any new flags? Any changes to any scripts? --> <!-- Please add anything that non-Matter Labs entities running their own ZK Chain may need to know --> ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`.
1 parent d22cd8e commit c9cb7f6

File tree

4 files changed

+48
-36
lines changed

4 files changed

+48
-36
lines changed

core/lib/dal/.sqlx/query-91914221cb4c892a6374da26883a072ae0b9a924365bed3c571d4f0e66f0c46c.json

Lines changed: 0 additions & 30 deletions
This file was deleted.

core/lib/dal/.sqlx/query-ff47bf6834ac0da5f133c3e8dd840d7a7dba16809c51f9ec82996e11ef7b89f2.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/lib/dal/src/eth_proof_manager_dal.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,18 @@ impl EthProofManagerDal<'_, '_> {
227227

228228
let result: Option<(L1BatchNumber, Option<bool>)> = sqlx::query!(
229229
r#"
230-
SELECT l1_batch_number, proof_validation_result
231-
FROM eth_proof_manager
230+
SELECT e.l1_batch_number, e.proof_validation_result
231+
FROM eth_proof_manager e
232+
JOIN proof_generation_details p
233+
ON e.l1_batch_number = p.l1_batch_number
232234
WHERE
233-
(status = $1 AND l1_batch_number <= $2)
234-
OR (status = $3 AND proof_validation_result = false)
235-
ORDER BY l1_batch_number ASC
236-
LIMIT 1
235+
(
236+
(e.status = $1 AND e.l1_batch_number <= $2)
237+
OR (e.status = $3 AND e.proof_validation_result = false)
238+
)
239+
AND p.proving_mode = 'proving_network'
240+
ORDER BY e.l1_batch_number ASC
241+
LIMIT 1;
237242
"#,
238243
EthProofManagerStatus::Proven.as_str(),
239244
i64::from(latest_proven_batch.0),

core/node/eth_proof_manager/src/watcher/events/proof_request_proven.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ async fn verify_proof(
224224
.protocol_version
225225
.unwrap_or_else(ProtocolVersionId::last_potentially_undefined);
226226

227+
if protocol_version != proof.protocol_version().minor {
228+
return Err(anyhow::anyhow!(
229+
"Protocol version doesn't match, server values: {protocol_version}, prover values: {}",
230+
proof.protocol_version()
231+
));
232+
}
233+
227234
let events_queue_state = l1_batch
228235
.metadata
229236
.events_queue_commitment

0 commit comments

Comments
 (0)