Skip to content

Commit

Permalink
feat(prover): Witness change for snark wrapper, updated keys (#151)
Browse files Browse the repository at this point in the history
# What ❔

* Changed witness for snark wrapper - to pass the previous AUX and META
fields
* updated snark_wrapper_verification key to the latest version
* updated the vk_hash to match the newly generated JSON, and made sure
that it is being loaded at genesis.

## Why ❔

* to make boojnet work locally
mm-zk authored Oct 4, 2023

Verified

This commit was signed with the committer’s verified signature.
Mamaduka George Mamadashvili
1 parent 3930c5d commit 2a5c072
Showing 4 changed files with 134 additions and 101 deletions.
3 changes: 2 additions & 1 deletion core/lib/zksync_core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -139,8 +139,9 @@ pub async fn genesis_init(
recursion_circuits_set_vks_hash: contracts_config
.recursion_circuits_set_vks_hash,
},
// FIXME: we should have a flag to decide on the type of proofs at genesis.
recursion_scheduler_level_vk_hash: contracts_config
.recursion_scheduler_level_vk_hash,
.fri_recursion_scheduler_level_vk_hash,
},
},
)
2 changes: 1 addition & 1 deletion etc/env/base/contracts.toml
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ L2_WETH_TOKEN_IMPL_ADDR="0x5E6D086F5eC079ADFF4FB3774CDf3e8D6a34F7E9"
L2_WETH_TOKEN_PROXY_ADDR="0x5E6D086F5eC079ADFF4FB3774CDf3e8D6a34F7E9"
FRI_RECURSION_LEAF_LEVEL_VK_HASH ="0x72167c43a46cf38875b267d67716edc4563861364a3c03ab7aee73498421e828"
FRI_RECURSION_NODE_LEVEL_VK_HASH ="0x5a3ef282b21e12fe1f4438e5bb158fc5060b160559c5158c6389d62d9fe3d080"
FRI_RECURSION_SCHEDULER_LEVEL_VK_HASH ="0x201d4c7d8e781d51a3bbd451a43a8f45240bb765b565ae6ce69192d918c3563d"
FRI_RECURSION_SCHEDULER_LEVEL_VK_HASH ="0x4be443afd605a782b6e56d199df2460a025c81b3dea144e135bece83612563f2"

[contracts.test]
dummy_verifier=true
Original file line number Diff line number Diff line change
@@ -6,76 +6,76 @@
"gate_setup_commitments": [
{
"x": [
2224517667504888251,
5912818835784168526,
1111535000905649453,
319269576845656765
3134321788309977316,
10573132553967014755,
3001703164893106466,
381414913732862840
],
"y": [
11120788872048639870,
13123473843834118559,
11006337926588718399,
1693094874597911874
10023015411950883744,
6896159948336889230,
6414240783194755732,
872372229201319096
],
"infinity": false
},
{
"x": [
5457926983430946348,
1784628442640157138,
2074237947226170917,
3131060963334690615
13120971644342103937,
11793287663204294817,
3883340854702399708,
1610760885102732376
],
"y": [
18014312862553006877,
5243048625117866465,
6340542352833718166,
2320619889276266916
2272149790438908451,
16362277919451948034,
11222024348659324185,
769204936692720831
],
"infinity": false
},
{
"x": [
6347927895162865476,
5050704860500628368,
10361897337252099655,
2828521412425376780
17731804648385463364,
6957978511947926439,
554530057858945391,
1554116369209063151
],
"y": [
9661852756269533844,
10526327507022735828,
11278750718834251862,
1315379733045685397
11068663668443960791,
4165938511251890045,
9157185920319394352,
1356194940161196789
],
"infinity": false
},
{
"x": [
4042671629442164837,
11959950196860309953,
2078800086028040039,
94403960025997529
8019563329680255469,
10443600923825661309,
10066002756835006084,
2404912031772130651
],
"y": [
3135015680945171083,
12893163496512433740,
8699261953191062297,
3320226233593777137
11909280006603456147,
5818438825251413345,
15870199885834935123,
2757108579883054631
],
"infinity": false
},
{
"x": [
4177624058108552844,
7496286594337546064,
12327303478390769977,
1884447338697134452
9723414060399071945,
10180812700717519482,
7936340440930941206,
516257686460616129
],
"y": [
11592594644619014749,
1292793399956228893,
17148866035827453124,
2259449579930654777
567977185774136652,
4306281713268395827,
18140207600873092049,
3061955278209883828
],
"infinity": false
},
@@ -96,48 +96,48 @@
},
{
"x": [
16821965459015940209,
16502520825403405563,
4933134856324568875,
971914902671623933
15818628187542915298,
15402701417353228903,
4645743436884029384,
2409582523262225752
],
"y": [
8708758630145674281,
11568462267224108675,
15920534706957442557,
2205222521283673407
10225110015471016873,
3480449575574012457,
13646267911522236018,
3070086728021966273
],
"infinity": false
},
{
"x": [
13887807756011277977,
6633952600242750048,
12933639896153908639,
1634594860965316349
15593293662666768812,
17768691370516984644,
17174288836059912543,
2950415245130983093
],
"y": [
5219211762505995590,
3805451927973946744,
18239167495029817450,
1620516238642646611
10405941745355450827,
3865610534756768698,
563805946543955734,
1806918679491891699
],
"infinity": false
}
],
"gate_selectors_commitments": [
{
"x": [
9648237812026707665,
3394846795043056222,
4629068839178038498,
1935924284954725357
5354921692103962663,
10597914855112022168,
8283977291194706970,
1254033438787241395
],
"y": [
7429667519719510580,
9655284945806121212,
10303170318619716429,
1450391691397826178
17990692095059328463,
7491895001046969405,
17510882385599010078,
1762527058736778745
],
"infinity": false
},
@@ -160,61 +160,61 @@
"permutation_commitments": [
{
"x": [
14847495908726407963,
16855284351914487461,
18211889533001639981,
2155135400931744246
11073033365046587506,
17543366073703943346,
2925375977998636107,
411355966917613086
],
"y": [
10702169610220940865,
9956121846187196036,
8949798846882497976,
2163047794650360669
4634938960149933815,
10038620738808728516,
5260176309304737799,
14410327903164543
],
"infinity": false
},
{
"x": [
378831953168999386,
9293735894762022592,
14386665413246396021,
3071878788754443116
4505573069708166334,
3514663015240928368,
13885581324134225254,
2759554901468343883
],
"y": [
15896087542596050393,
17239768855300757555,
1302380423903460425,
1070516261187880368
14766134794032708062,
3419963379718679828,
14090109324006346322,
2080971354192483161
],
"infinity": false
},
{
"x": [
15681530546748660775,
15325947204107855582,
6169941741627651138,
1438247605769128980
10034756028637387237,
13956897381252459181,
17676764419229650887,
1786540180828440303
],
"y": [
1709841937332991257,
3205925128833409221,
10381982057624226277,
3302314191697651889
16234833038341145650,
1114974762353197748,
16711158590984748387,
961724704749485864
],
"infinity": false
},
{
"x": [
7915449484973597791,
14858122728404062261,
17806747946577351454,
1879592080912408858
13207237492056542947,
9498840683026707597,
13316073393799666368,
2265958217127439582
],
"y": [
15677256576208223457,
8628800709300512291,
18168431650113296999,
252714218130055622
9080715171198565366,
9520983963961194766,
7885036753736171049,
3318336507646038340
],
"infinity": false
}
38 changes: 35 additions & 3 deletions prover/witness_generator/src/basic_circuits.rs
Original file line number Diff line number Diff line change
@@ -496,6 +496,16 @@ async fn generate_witness(
.get_l1_batch_header(input.block_number)
.await
.unwrap().unwrap();

let previous_batch_with_metadata = connection
.blocks_dal()
.get_l1_batch_metadata(zksync_types::L1BatchNumber(
input.block_number.checked_sub(1).unwrap(),
))
.await
.unwrap()
.unwrap();

let bootloader_code_bytes = connection
.storage_dal()
.get_factory_dep(header.base_system_contracts_hashes.bootloader)
@@ -578,8 +588,17 @@ async fn generate_witness(

// The following part is CPU-heavy, so we move it to a separate thread.
let rt_handle = tokio::runtime::Handle::current();
tokio::task::spawn_blocking(move || {
let connection = rt_handle.block_on(connection_pool.access_storage()).unwrap();

let (
basic_circuits,
basic_circuits_public_inputs,
basic_circuits_public_compact_witness,
mut scheduler_witness,
block_aux_witness,
) = tokio::task::spawn_blocking(move || {
let connection = rt_handle
.block_on(connection_pool.access_storage())
.unwrap();
let storage = PostgresStorage::new(rt_handle, connection, last_miniblock_number, true);
let storage_view = StorageView::new(storage).to_rc_ptr();
let storage_oracle: StorageOracle<StorageView<PostgresStorage<'_>>, HistoryDisabled> =
@@ -600,7 +619,20 @@ async fn generate_witness(
)
})
.await
.unwrap()
.unwrap();

scheduler_witness.previous_block_meta_hash =
previous_batch_with_metadata.metadata.meta_parameters_hash.0;
scheduler_witness.previous_block_aux_hash =
previous_batch_with_metadata.metadata.aux_data_hash.0;

(
basic_circuits,
basic_circuits_public_inputs,
basic_circuits_public_compact_witness,
scheduler_witness,
block_aux_witness,
)
}

#[allow(clippy::too_many_arguments)]

0 comments on commit 2a5c072

Please sign in to comment.