Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prover): Disallow state changes from successful #2233

Merged
merged 5 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/lib/basic_types/src/prover_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ pub struct RecursionTipWitnessGeneratorJobInfo {
pub error: Option<String>,
pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
pub number_of_final_node_jobs: Option<i32>,
pub number_of_final_node_jobs: i32,
pub protocol_version: Option<i32>,
pub picked_by: Option<String>,
}
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion etc/env/base/contracts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PRIORITY_TX_MAX_GAS_LIMIT = 72000000
DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT = 10000000
GENESIS_ROLLUP_LEAF_INDEX = "54"
GENESIS_PROTOCOL_VERSION = "24"
GENESIS_PROTOCOL_SEMANTIC_VERSION = "0.24.0"
GENESIS_PROTOCOL_SEMANTIC_VERSION = "0.24.1"
L1_WETH_BRIDGE_IMPL_ADDR = "0x5E6D086F5eC079ADFF4FB3774CDf3e8D6a34F7E9"
L1_WETH_BRIDGE_PROXY_ADDR = "0x5E6D086F5eC079ADFF4FB3774CDf3e8D6a34F7E9"
L1_WETH_TOKEN_ADDR = "0x5E6D086F5eC079ADFF4FB3774CDf3e8D6a34F7E9"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE recursion_tip_witness_jobs_fri ALTER COLUMN number_of_final_node_jobs DROP NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE recursion_tip_witness_jobs_fri ALTER COLUMN number_of_final_node_jobs SET NOT NULL;
23 changes: 5 additions & 18 deletions prover/prover_dal/src/fri_proof_compressor_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,6 @@ impl FriProofCompressorDal<'_, '_> {
.unwrap();
}

pub async fn skip_proof_compression_job(&mut self, block_number: L1BatchNumber) {
sqlx::query!(
r#"
INSERT INTO
proof_compression_jobs_fri (l1_batch_number, status, created_at, updated_at)
VALUES
($1, $2, NOW(), NOW())
ON CONFLICT (l1_batch_number) DO NOTHING
"#,
i64::from(block_number.0),
ProofCompressionJobStatus::Skipped.to_string(),
)
.fetch_optional(self.storage.conn())
.await
.unwrap();
}

pub async fn get_next_proof_compression_job(
&mut self,
picked_by: &str,
Expand Down Expand Up @@ -177,10 +160,14 @@ impl FriProofCompressorDal<'_, '_> {
updated_at = NOW()
WHERE
l1_batch_number = $3
AND status != $4
AND status != $5
"#,
ProofCompressionJobStatus::Failed.to_string(),
error,
i64::from(block_number.0)
i64::from(block_number.0),
ProofCompressionJobStatus::Successful.to_string(),
ProofCompressionJobStatus::SentToServer.to_string(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it would be worth it to log such occurances. This would make it easier to debug potential additional occurances.
You can make update return the number of affected rows and then compare with 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but we can already tell this by number of attempts in DB. Not opposing the idea.

)
.execute(self.storage.conn())
.await
Expand Down
44 changes: 3 additions & 41 deletions prover/prover_dal/src/fri_prover_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{collections::HashMap, convert::TryFrom, str::FromStr, time::Duration};

use zksync_basic_types::{
basic_fri_types::{AggregationRound, CircuitIdRoundTuple, JobIdentifiers},
protocol_version::{ProtocolSemanticVersion, ProtocolVersionId, VersionPatch},
protocol_version::{ProtocolSemanticVersion, ProtocolVersionId},
prover_dal::{
correct_circuit_id, FriProverJobMetadata, JobCountStatistics, ProverJobFriInfo,
ProverJobStatus, StuckJobs,
Expand Down Expand Up @@ -211,6 +211,7 @@ impl FriProverDal<'_, '_> {
updated_at = NOW()
WHERE
id = $2
AND status != 'successful'
"#,
error,
i64::from(id)
Expand Down Expand Up @@ -520,6 +521,7 @@ impl FriProverDal<'_, '_> {
updated_at = NOW()
WHERE
id = $2
AND status != 'successful'
"#,
status,
i64::from(id)
Expand All @@ -529,23 +531,6 @@ impl FriProverDal<'_, '_> {
.unwrap();
}

pub async fn save_successful_sent_proof(&mut self, l1_batch_number: L1BatchNumber) {
sqlx::query!(
r#"
UPDATE prover_jobs_fri
SET
status = 'sent_to_server',
updated_at = NOW()
WHERE
l1_batch_number = $1
"#,
i64::from(l1_batch_number.0)
)
.execute(self.storage.conn())
.await
.unwrap();
}

pub async fn get_scheduler_proof_job_id(
&mut self,
l1_batch_number: L1BatchNumber,
Expand Down Expand Up @@ -698,29 +683,6 @@ impl FriProverDal<'_, '_> {
.collect()
}

pub async fn protocol_version_for_job(&mut self, job_id: u32) -> ProtocolSemanticVersion {
let result = sqlx::query!(
r#"
SELECT
protocol_version,
protocol_version_patch
FROM
prover_jobs_fri
WHERE
id = $1
"#,
job_id as i32
)
.fetch_one(self.storage.conn())
.await
.unwrap();

ProtocolSemanticVersion::new(
ProtocolVersionId::try_from(result.protocol_version.unwrap() as u16).unwrap(),
VersionPatch(result.protocol_version_patch as u32),
)
}

pub async fn delete_prover_jobs_fri_batch_data(
&mut self,
l1_batch_number: L1BatchNumber,
Expand Down
Loading
Loading