Skip to content

Commit daa1161

Browse files
authored
fix(eth-proof-manager): don't fail component if proof was incorrect (#4444)
## What ❔ <!-- What are the changes this PR brings about? --> <!-- Example: This PR adds a PR template to the repo. --> <!-- (For bigger PRs adding more context is appreciated) --> ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- The `Why` has to be clear to non-Matter Labs entities running their own ZK Chain --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## 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 165edea commit daa1161

File tree

3 files changed

+34
-37
lines changed

3 files changed

+34
-37
lines changed

core/node/eth_proof_manager/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ impl EthProofManager {
5151

5252
pub async fn run(&self, stop_receiver: watch::Receiver<bool>) -> anyhow::Result<()> {
5353
tokio::select! {
54-
_ = self.watcher.run(stop_receiver.clone()) => {
55-
tracing::info!("Watcher stopped");
54+
result = self.watcher.run(stop_receiver.clone()) => {
55+
tracing::info!("Watcher stopped: {:?}", result);
5656
},
57-
_ = self.sender.run(stop_receiver) => {
58-
tracing::info!("Sender stopped");
57+
result = self.sender.run(stop_receiver) => {
58+
tracing::info!("Sender stopped: {:?}", result);
5959
},
6060
}
6161
Ok(())

core/node/eth_proof_manager/src/sender/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ impl EthProofSender {
6464
);
6565

6666
tokio::select! {
67-
_ = proof_request_submitter.run(stop_receiver.clone()) => {
68-
tracing::error!("Proof request submitter stopped");
67+
result = proof_request_submitter.run(stop_receiver.clone()) => {
68+
tracing::error!("Proof request submitter stopped: {:?}", result);
6969
}
70-
_ = proof_validation_submitter.run(stop_receiver) => {
71-
tracing::error!("Proof validation result submitter stopped");
70+
result = proof_validation_submitter.run(stop_receiver) => {
71+
tracing::error!("Proof validation result submitter stopped: {:?}", result);
7272
}
7373
}
7474

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

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ impl EventHandler for ProofRequestProvenHandler {
116116
event.assigned_to,
117117
);
118118

119-
let proof = <L1BatchProofForL1 as StoredObject>::deserialize(proof)
120-
.map_err(|e| anyhow::anyhow!("Failed to deserialize proof: {}", e))?;
121-
122119
let batch_number = L1BatchNumber(event.block_number.as_u32());
123120

124121
let verification_result = match verify_proof(
@@ -129,38 +126,35 @@ impl EventHandler for ProofRequestProvenHandler {
129126
)
130127
.await
131128
{
132-
Ok(_) => {
129+
Ok(proof) => {
133130
tracing::info!("Proof for batch {} verified successfully", batch_number);
131+
132+
let proof_blob_url = self
133+
.blob_store
134+
.put(
135+
L1BatchProofForL1Key::Core((batch_number, proof.protocol_version())),
136+
&proof,
137+
)
138+
.await?;
139+
140+
self.connection_pool
141+
.connection()
142+
.await?
143+
.proof_generation_dal()
144+
.save_proof_artifacts_metadata(batch_number, &proof_blob_url)
145+
.await?;
146+
147+
METRICS.validated_batches[&ValidationResult::Success].inc();
148+
METRICS.proven_batches[&event.assigned_to].inc();
134149
true
135150
}
136151
Err(e) => {
137152
tracing::error!("Failed to verify proof for batch {}: {}", batch_number, e);
153+
METRICS.validated_batches[&ValidationResult::Failed].inc();
138154
false
139155
}
140156
};
141157

142-
if verification_result {
143-
let proof_blob_url = self
144-
.blob_store
145-
.put(
146-
L1BatchProofForL1Key::Core((batch_number, proof.protocol_version())),
147-
&proof,
148-
)
149-
.await?;
150-
151-
self.connection_pool
152-
.connection()
153-
.await?
154-
.proof_generation_dal()
155-
.save_proof_artifacts_metadata(batch_number, &proof_blob_url)
156-
.await?;
157-
158-
METRICS.validated_batches[&ValidationResult::Success].inc();
159-
METRICS.proven_batches[&event.assigned_to].inc();
160-
} else {
161-
METRICS.validated_batches[&ValidationResult::Failed].inc();
162-
}
163-
164158
tracing::info!(
165159
"Batch {}, chain_id: {}, assigned_to: {:?}, verification_result: {:?}",
166160
batch_number,
@@ -183,9 +177,12 @@ impl EventHandler for ProofRequestProvenHandler {
183177
async fn verify_proof(
184178
connection_pool: ConnectionPool<Core>,
185179
batch_number: L1BatchNumber,
186-
proof: L1BatchProofForL1,
180+
proof_bytes: Vec<u8>,
187181
verification_key: FflonkFinalVerificationKey,
188-
) -> anyhow::Result<()> {
182+
) -> anyhow::Result<L1BatchProofForL1> {
183+
let proof = <L1BatchProofForL1 as StoredObject>::deserialize(proof_bytes)
184+
.map_err(|e| anyhow::anyhow!("Failed to deserialize proof: {}", e))?;
185+
189186
let verification_result = match proof.inner() {
190187
TypedL1BatchProofForL1::Fflonk(proof) => {
191188
let proof = proof.scheduler_proof;
@@ -281,5 +278,5 @@ async fn verify_proof(
281278
));
282279
}
283280

284-
Ok(())
281+
Ok(proof)
285282
}

0 commit comments

Comments
 (0)