Skip to content

Commit

Permalink
Merge branch 'main' into deniallugo-chain-registrar
Browse files Browse the repository at this point in the history
  • Loading branch information
Deniallugo authored Nov 19, 2024
2 parents ed14e9d + eee7429 commit 06b373f
Show file tree
Hide file tree
Showing 22 changed files with 164 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/release-please/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"core": "25.1.0",
"prover": "17.0.0",
"prover": "17.1.0",
"zkstack_cli": "0.1.2"
}
12 changes: 8 additions & 4 deletions .github/workflows/build-docker-from-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ jobs:
build-push-core-images:
name: Build and push image
needs: [ setup ]
uses: ./.github/workflows/build-core-template.yml
uses: ./.github/workflows/new-build-core-template.yml
if: contains(github.ref_name, 'core')
secrets:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
with:
image_tag_suffix: ${{ needs.setup.outputs.image_tag_suffix }}
en_alpha_release: true
action: "push"

build-push-tee-prover-images:
name: Build and push images
Expand All @@ -73,37 +74,40 @@ jobs:
build-push-contract-verifier:
name: Build and push image
needs: [ setup ]
uses: ./.github/workflows/build-contract-verifier-template.yml
uses: ./.github/workflows/new-build-contract-verifier-template.yml
if: contains(github.ref_name, 'contract_verifier')
secrets:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
with:
image_tag_suffix: ${{ needs.setup.outputs.image_tag_suffix }}
action: "push"

build-push-prover-images:
name: Build and push image
needs: [ setup ]
uses: ./.github/workflows/build-prover-template.yml
uses: ./.github/workflows/new-build-prover-template.yml
if: contains(github.ref_name, 'prover')
with:
image_tag_suffix: ${{ needs.setup.outputs.image_tag_suffix }}
ERA_BELLMAN_CUDA_RELEASE: ${{ vars.ERA_BELLMAN_CUDA_RELEASE }}
CUDA_ARCH: "60;70;75;80;89"
action: "push"
secrets:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

build-push-witness-generator-image-avx512:
name: Build and push image
needs: [ setup ]
uses: ./.github/workflows/build-witness-generator-template.yml
uses: ./.github/workflows/new-build-witness-generator-template.yml
if: contains(github.ref_name, 'prover')
with:
image_tag_suffix: ${{ needs.setup.outputs.image_tag_suffix }}-avx512
ERA_BELLMAN_CUDA_RELEASE: ${{ vars.ERA_BELLMAN_CUDA_RELEASE }}
CUDA_ARCH: "60;70;75;80;89"
WITNESS_GENERATOR_RUST_FLAGS: "-Ctarget_feature=+avx512bw,+avx512cd,+avx512dq,+avx512f,+avx512vl"
action: "push"
secrets:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-prover-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
--base-token-price-denominator 1 \
--set-as-default true \
--ignore-prerequisites \
--evm-emulator=false
--evm-emulator false
ci_run zkstack ecosystem init --dev --verbose
ci_run zkstack prover init --dev --verbose
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ jobs:
name: Github Status Check
runs-on: ubuntu-latest
if: always() && !cancelled()
needs: [ ci-for-core-lint, ci-for-common, ci-for-core, ci-for-prover, ci-for-docs, build-core-images, build-contract-verifier, build-prover-images ]
needs: [ ci-for-core-lint, ci-for-common, ci-for-core, ci-for-prover, ci-for-docs, build-core-images, build-contract-verifier, build-prover-images, e2e-for-prover ]
steps:
- name: Status
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/protobuf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
ref: ${{ env.BASE }}
path: before
fetch-depth: 0 # fetches all branches and tags, which is needed to compute the LCA.
submodules: "recursive"
- name: checkout LCA
run:
git checkout $(git merge-base $BASE $HEAD) --recurse-submodules
Expand Down
8 changes: 7 additions & 1 deletion core/bin/zksync_tee_prover/src/tee_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ impl TeeProver {
let msg_to_sign = Message::from_slice(root_hash_bytes)
.map_err(|e| TeeProverError::Verification(e.into()))?;
let signature = self.config.signing_key.sign_ecdsa(msg_to_sign);
observer.observe();
let duration = observer.observe();
tracing::info!(
proof_generation_time = duration.as_secs_f64(),
l1_batch_number = %batch_number,
l1_root_hash = ?verification_result.value_hash,
"L1 batch verified",
);
Ok((signature, batch_number, verification_result.value_hash))
}
_ => Err(TeeProverError::Verification(anyhow::anyhow!(
Expand Down
2 changes: 1 addition & 1 deletion core/lib/basic_types/src/tee_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt;

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum TeeType {
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.

2 changes: 2 additions & 0 deletions core/lib/dal/migrations/20241108051505_sealed_at.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Add down migration script here
ALTER TABLE l1_batches DROP COLUMN IF EXISTS sealed_at;
2 changes: 2 additions & 0 deletions core/lib/dal/migrations/20241108051505_sealed_at.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- add a sealed_at column for metrics
ALTER TABLE l1_batches ADD COLUMN sealed_at TIMESTAMP;
24 changes: 24 additions & 0 deletions core/lib/dal/src/blocks_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{

use anyhow::Context as _;
use bigdecimal::{BigDecimal, FromPrimitive, ToPrimitive};
use sqlx::types::chrono::{DateTime, Utc};
use zksync_db_connection::{
connection::Connection,
error::{DalResult, SqlxContext},
Expand Down Expand Up @@ -742,6 +743,7 @@ impl BlocksDal<'_, '_> {
pubdata_input = $19,
predicted_circuits_by_type = $20,
updated_at = NOW(),
sealed_at = NOW(),
is_sealed = TRUE
WHERE
number = $1
Expand Down Expand Up @@ -2394,6 +2396,28 @@ impl BlocksDal<'_, '_> {
.flatten())
}

pub async fn get_batch_sealed_at(
&mut self,
l1_batch_number: L1BatchNumber,
) -> DalResult<Option<DateTime<Utc>>> {
Ok(sqlx::query!(
r#"
SELECT
sealed_at
FROM
l1_batches
WHERE
number = $1
"#,
i64::from(l1_batch_number.0)
)
.instrument("get_batch_sealed_at")
.with_arg("l1_batch_number", &l1_batch_number)
.fetch_optional(self.storage)
.await?
.and_then(|row| row.sealed_at.map(|d| d.and_utc())))
}

pub async fn set_protocol_version_for_pending_l2_blocks(
&mut self,
id: ProtocolVersionId,
Expand Down
1 change: 1 addition & 0 deletions core/lib/types/src/debug_flat_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct DebugCallFlat {
pub action: Action,
pub result: Option<CallResult>,
pub subtraces: usize,
pub error: Option<String>,
pub trace_address: Vec<usize>,
pub transaction_position: usize,
pub transaction_hash: H256,
Expand Down
16 changes: 10 additions & 6 deletions core/node/api_server/src/web3/namespaces/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,16 @@ impl DebugNamespace {
CallType::NearCall => unreachable!("We have to filter our near calls before"),
};

let result = if call.error.is_none() {
Some(CallResult {
output: web3::Bytes::from(call.output),
gas_used: U256::from(call.gas_used),
})
let (result, error) = if let Some(error) = call.revert_reason {
(None, Some(error))
} else {
None
(
Some(CallResult {
output: web3::Bytes::from(call.output),
gas_used: U256::from(call.gas_used),
}),
None,
)
};

calls.push(DebugCallFlat {
Expand All @@ -116,6 +119,7 @@ impl DebugNamespace {
},
result,
subtraces,
error,
trace_address: trace_address.clone(), // Clone the current trace address
transaction_position: meta.index_in_block,
transaction_hash: meta.tx_hash,
Expand Down
1 change: 1 addition & 0 deletions core/node/proof_data_handler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ keywords.workspace = true
categories.workspace = true

[dependencies]
chrono.workspace = true
vise.workspace = true
zksync_config.workspace = true
zksync_dal.workspace = true
Expand Down
23 changes: 22 additions & 1 deletion core/node/proof_data_handler/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use vise::{Histogram, Metrics};
use std::{fmt, time::Duration};

use vise::{EncodeLabelSet, EncodeLabelValue, Family, Histogram, Metrics, Unit};
use zksync_object_store::bincode;
use zksync_prover_interface::inputs::WitnessInputData;
use zksync_types::tee_types::TeeType;

const BYTES_IN_MEGABYTE: u64 = 1024 * 1024;

Expand All @@ -14,6 +17,24 @@ pub(super) struct ProofDataHandlerMetrics {
pub eip_4844_blob_size_in_mb: Histogram<u64>,
#[metrics(buckets = vise::Buckets::exponential(1.0..=2_048.0, 2.0))]
pub total_blob_size_in_mb: Histogram<u64>,
#[metrics(buckets = vise::Buckets::LATENCIES, unit = Unit::Seconds)]
pub tee_proof_roundtrip_time: Family<MetricsTeeType, Histogram<Duration>>,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash, EncodeLabelSet, EncodeLabelValue)]
#[metrics(label = "tee_type")]
pub(crate) struct MetricsTeeType(pub TeeType);

impl fmt::Display for MetricsTeeType {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(formatter)
}
}

impl From<TeeType> for MetricsTeeType {
fn from(value: TeeType) -> Self {
Self(value)
}
}

impl ProofDataHandlerMetrics {
Expand Down
29 changes: 23 additions & 6 deletions core/node/proof_data_handler/src/tee_request_processor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::sync::Arc;

use axum::{extract::Path, Json};
use chrono::Utc;
use zksync_config::configs::ProofDataHandlerConfig;
use zksync_dal::{ConnectionPool, Core, CoreDal};
use zksync_object_store::{ObjectStore, ObjectStoreError};
Expand All @@ -16,7 +17,7 @@ use zksync_prover_interface::{
use zksync_types::{tee_types::TeeType, L1BatchNumber, L2ChainId};
use zksync_vm_executor::storage::L1BatchParamsProvider;

use crate::errors::RequestProcessorError;
use crate::{errors::RequestProcessorError, metrics::METRICS};

#[derive(Clone)]
pub(crate) struct TeeRequestProcessor {
Expand Down Expand Up @@ -194,11 +195,6 @@ impl TeeRequestProcessor {
let mut connection = self.pool.connection_tagged("tee_request_processor").await?;
let mut dal = connection.tee_proof_generation_dal();

tracing::info!(
"Received proof {:?} for batch number: {:?}",
proof,
l1_batch_number
);
dal.save_proof_artifacts_metadata(
l1_batch_number,
proof.0.tee_type,
Expand All @@ -208,6 +204,27 @@ impl TeeRequestProcessor {
)
.await?;

let sealed_at = connection
.blocks_dal()
.get_batch_sealed_at(l1_batch_number)
.await?;

let duration = sealed_at.and_then(|sealed_at| (Utc::now() - sealed_at).to_std().ok());

let duration_secs_f64 = if let Some(duration) = duration {
METRICS.tee_proof_roundtrip_time[&proof.0.tee_type.into()].observe(duration);
duration.as_secs_f64()
} else {
f64::NAN
};

tracing::info!(
l1_batch_number = %l1_batch_number,
sealed_to_proven_in_secs = duration_secs_f64,
"Received proof {:?}",
proof
);

Ok(Json(SubmitProofResponse::Success))
}

Expand Down
18 changes: 18 additions & 0 deletions prover/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## [17.1.0](https://github.com/matter-labs/zksync-era/compare/prover-v17.0.0...prover-v17.1.0) (2024-11-18)


### Features

* Add min_replicas for SimpleScaler, apply_min_to_namespace config ([#3282](https://github.com/matter-labs/zksync-era/issues/3282)) ([bc00c4a](https://github.com/matter-labs/zksync-era/commit/bc00c4a44a212def3cc25567f3b271530d76b6a4))
* allow vm2 tracers to stop execution ([#3183](https://github.com/matter-labs/zksync-era/issues/3183)) ([9dae839](https://github.com/matter-labs/zksync-era/commit/9dae839935d82a1e73be220d17567f3382131039))
* **contract-verifier:** Support Solidity contracts with EVM bytecode in contract verifier ([#3225](https://github.com/matter-labs/zksync-era/issues/3225)) ([8a3a82c](https://github.com/matter-labs/zksync-era/commit/8a3a82ca16479183e96505bc91011fc07bfc6889))
* **prover:** Add cluster name autodetection ([#3227](https://github.com/matter-labs/zksync-era/issues/3227)) ([bd32aec](https://github.com/matter-labs/zksync-era/commit/bd32aecdf982c51202c1a69d12fcf1d878fe6d05))
* **prover:** Add queue metric to report autoscaler view of the queue. ([#3206](https://github.com/matter-labs/zksync-era/issues/3206)) ([2721396](https://github.com/matter-labs/zksync-era/commit/272139690e028d3bdebdb6bcb1824fec23cefd0f))
* ProverJobProcessor & circuit prover ([#3287](https://github.com/matter-labs/zksync-era/issues/3287)) ([98823f9](https://github.com/matter-labs/zksync-era/commit/98823f95c0b95feeb37eb9086cc88d4ac5220904))
* **prover:** Move prover_autoscaler config into crate ([#3222](https://github.com/matter-labs/zksync-era/issues/3222)) ([1b33b5e](https://github.com/matter-labs/zksync-era/commit/1b33b5e9ec04bea0010350798332a90413c482d3))


### Bug Fixes

* **prover:** Remove unneeded dependencies, add default for graceful_shutdown_timeout ([#3242](https://github.com/matter-labs/zksync-era/issues/3242)) ([1bfff0e](https://github.com/matter-labs/zksync-era/commit/1bfff0e007e2fb5a4b4b885cf5c69a5cd290888b))

## [17.0.0](https://github.com/matter-labs/zksync-era/compare/prover-v16.6.0...prover-v17.0.0) (2024-10-31)


Expand Down
Loading

0 comments on commit 06b373f

Please sign in to comment.