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

feat(vm)!: fee model updates + 1.4.1 #791

Merged
merged 212 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 138 commits
Commits
Show all changes
212 commits
Select commit Hold shift + click to select a range
f7d2f4d
unit tests pass
StanislavBreadless Nov 15, 2023
72d05df
migrate core also
StanislavBreadless Nov 16, 2023
d70499b
short term fee model iteration
StanislavBreadless Nov 17, 2023
f1fd94e
use new contracts
StanislavBreadless Nov 17, 2023
4f6ce4d
new migration
StanislavBreadless Nov 17, 2023
e92f55a
adding field to the db
StanislavBreadless Nov 17, 2023
8bf8fb7
include proving costs in the sk
StanislavBreadless Nov 17, 2023
50189d2
more correct estimations on the server
StanislavBreadless Nov 17, 2023
9e46b7e
system tests are now passing
StanislavBreadless Nov 18, 2023
d613edb
fix web3 test
StanislavBreadless Nov 19, 2023
5bd96f7
all integration tests pass
StanislavBreadless Nov 19, 2023
97f9730
correct refunds
StanislavBreadless Nov 19, 2023
63f786e
use 80k for slot overhead
StanislavBreadless Nov 19, 2023
e85d0d1
use better system contracts
StanislavBreadless Nov 19, 2023
863bea1
use newest contracts
StanislavBreadless Nov 19, 2023
10eee93
upd contracts
StanislavBreadless Nov 19, 2023
b9fa50a
update contracts
StanislavBreadless Nov 20, 2023
babd2a4
restore fee test
StanislavBreadless Nov 20, 2023
5856724
use latest contracts
StanislavBreadless Nov 20, 2023
e8462c4
remove unneeded println
StanislavBreadless Nov 20, 2023
0bfa007
use latest contracts
StanislavBreadless Nov 21, 2023
a6a615f
use latest system contracts
StanislavBreadless Nov 22, 2023
f685e72
add tests for contracts
StanislavBreadless Nov 22, 2023
aee9ccf
correct trusted gas limit for l1->l2 transactions
StanislavBreadless Nov 22, 2023
0f9961d
add 1.4.1 contracts
StanislavBreadless Nov 25, 2023
7e20f34
porting v1.4.1 on top of main branch
StanislavBreadless Nov 26, 2023
2c08969
minimize cargo lock changes
StanislavBreadless Nov 26, 2023
f6c1b33
fmt
StanislavBreadless Nov 26, 2023
17da757
sync with 1.4.1
StanislavBreadless Nov 26, 2023
073b28b
use new contracts
StanislavBreadless Nov 26, 2023
c8f36e1
Update Cargo.toml to use era-zk_evm
AntonD3 Nov 29, 2023
a4d682d
Update contracts commit
AntonD3 Nov 29, 2023
ea26a31
Update contracts
AntonD3 Nov 29, 2023
43e0cfe
Merge pull request #561 from matter-labs/ad-1-4-1-use-public-vm
AntonD3 Nov 30, 2023
0b0008d
sync with main
StanislavBreadless Nov 30, 2023
ac0df4c
use latest contracts
StanislavBreadless Nov 30, 2023
000bc97
logs with params
StanislavBreadless Dec 1, 2023
638a0f8
add more logs + tests
StanislavBreadless Dec 6, 2023
3119037
wip
StanislavBreadless Dec 10, 2023
23d4d5c
wip
StanislavBreadless Dec 10, 2023
829bbdd
remove changes to db
StanislavBreadless Dec 10, 2023
3470589
use new param
StanislavBreadless Dec 10, 2023
63bca03
use smaller batch overhead
StanislavBreadless Dec 11, 2023
5e6503e
upd fee model
StanislavBreadless Dec 11, 2023
e8cb835
0.1 gwei by default
StanislavBreadless Dec 11, 2023
b49a811
tracing results
StanislavBreadless Dec 19, 2023
9fbd7a2
one tx per batch in the fee test
StanislavBreadless Dec 20, 2023
8bf31ef
use v19 contracts
StanislavBreadless Dec 22, 2023
54bea5f
remove allowlist from zk
StanislavBreadless Dec 22, 2023
5eaa471
add new bootloader for API
StanislavBreadless Dec 22, 2023
c582355
fix int tests
StanislavBreadless Dec 22, 2023
c67a7f1
fix path
StanislavBreadless Dec 22, 2023
b6cbd4c
sync with 1.4.1
StanislavBreadless Dec 25, 2023
496c8a0
partial sync with main
StanislavBreadless Dec 25, 2023
1b545de
Merge branch 'main' into releave-v19-remove-allowlist
StanislavBreadless Dec 25, 2023
6c99e09
make basic int tests pass
StanislavBreadless Dec 25, 2023
d1e53a5
sync with better structs
StanislavBreadless Dec 26, 2023
bd9feb7
mild refactor
StanislavBreadless Dec 26, 2023
0f91e6f
wip
StanislavBreadless Dec 27, 2023
d722015
wip2
StanislavBreadless Dec 27, 2023
dc72340
fix validation
StanislavBreadless Dec 29, 2023
dfe3567
some consistency fixes
StanislavBreadless Dec 30, 2023
890ef34
make en work
StanislavBreadless Dec 31, 2023
95c91f2
more work to make the API compatible with old VM
StanislavBreadless Jan 1, 2024
ca84104
more work on making things backwards compatible
StanislavBreadless Jan 1, 2024
b8102fb
partially fix errors in unit tests
StanislavBreadless Jan 2, 2024
961d1c7
run unit tests
StanislavBreadless Jan 2, 2024
5737f75
partially fix unit tests
StanislavBreadless Jan 2, 2024
3c3f24b
fix unit tests
StanislavBreadless Jan 2, 2024
256efb9
fix upgrade test
StanislavBreadless Jan 2, 2024
cba8188
apply cargo fix
StanislavBreadless Jan 2, 2024
b61afaa
partial polishing of the ts tests
StanislavBreadless Jan 2, 2024
2d66c46
sync with main
StanislavBreadless Jan 2, 2024
584f86d
add boojum integration folder
StanislavBreadless Jan 3, 2024
a697a48
separate boojum integration vm
StanislavBreadless Jan 3, 2024
9eb841a
make utils version-dependent
StanislavBreadless Jan 3, 2024
9d574b6
fix lint
StanislavBreadless Jan 3, 2024
a41da8b
fix metric
StanislavBreadless Jan 3, 2024
7317c10
fix metrics
StanislavBreadless Jan 3, 2024
1f477f3
Merge branch 'sb-separate-boojum-integration-vm' into sb-move-utils-out
StanislavBreadless Jan 3, 2024
b57d11f
respond to comments
StanislavBreadless Jan 3, 2024
0a793e9
use latest miniblock
StanislavBreadless Jan 3, 2024
3893ede
sync with main
StanislavBreadless Jan 3, 2024
baa8add
Merge branch 'sb-separate-boojum-integration-vm' into sb-move-utils-out
StanislavBreadless Jan 3, 2024
b6cd5a3
Merge branch 'main' into sb-separate-boojum-integration-vm
StanislavBreadless Jan 4, 2024
b41191f
wip
StanislavBreadless Jan 4, 2024
afe27ae
port the batch fee input struct
StanislavBreadless Jan 4, 2024
71c7108
make the interface a bit better
StanislavBreadless Jan 4, 2024
c688253
cargo fix
StanislavBreadless Jan 4, 2024
995ac65
fix lint
StanislavBreadless Jan 4, 2024
f524c79
take into account the original review
StanislavBreadless Jan 4, 2024
40006ed
remove unused imports
StanislavBreadless Jan 4, 2024
5831cdb
fix lint
StanislavBreadless Jan 4, 2024
6bbaa1f
improve comments
StanislavBreadless Jan 4, 2024
234120f
Merge branch 'sb-separate-boojum-integration-vm' into sb-move-utils-out
StanislavBreadless Jan 4, 2024
79d5608
return previous cargo lock
StanislavBreadless Jan 4, 2024
a262e7f
fix spellcheck
StanislavBreadless Jan 4, 2024
ca849b8
sync with main
StanislavBreadless Jan 5, 2024
f913ec9
sync with main
StanislavBreadless Jan 5, 2024
c2f399a
more extensive testing + partial renaming
StanislavBreadless Jan 5, 2024
f9ce654
respond to review
StanislavBreadless Jan 5, 2024
260e0cf
fix lint
StanislavBreadless Jan 5, 2024
1959e62
merge with main
StanislavBreadless Jan 5, 2024
6f4d37d
lint
StanislavBreadless Jan 5, 2024
2405445
fix spelling
StanislavBreadless Jan 5, 2024
a7512d4
Merge branch 'main' into sb-add-batch-input-abstraction
StanislavBreadless Jan 5, 2024
b18f180
Merge branch 'main' into sb-add-batch-input-abstraction
StanislavBreadless Jan 5, 2024
142d029
sync with new base
StanislavBreadless Jan 5, 2024
a2bfb8b
correct naming for vm 1.4.1
StanislavBreadless Jan 5, 2024
9590d73
fix tests
StanislavBreadless Jan 7, 2024
7a63a5e
resolve conflicts
StanislavBreadless Jan 8, 2024
277208c
fix comment for spellcheck
StanislavBreadless Jan 8, 2024
21f2161
sync with base
StanislavBreadless Jan 8, 2024
a5eff99
add configs
StanislavBreadless Jan 8, 2024
3737333
Explicitly use gas_per_pubdata_limit in miniblock header
StanislavBreadless Jan 8, 2024
80dd872
bootloader memory size as function
StanislavBreadless Jan 8, 2024
e406150
minor rename
StanislavBreadless Jan 9, 2024
52a10e2
sync with main
StanislavBreadless Jan 9, 2024
b11b58a
additional spelling fixes
StanislavBreadless Jan 9, 2024
ea206ba
sync with main
StanislavBreadless Jan 9, 2024
f4c93ba
add new version for API
StanislavBreadless Jan 9, 2024
2d07ee4
restore correct old api contracts
StanislavBreadless Jan 9, 2024
275a9b8
add config to choose the fee model version
StanislavBreadless Jan 9, 2024
b7ff6ad
fix sqlx
StanislavBreadless Jan 9, 2024
989aa74
Update SchedulerCircuit + dependencies
EmilLuta Jan 9, 2024
eadf65b
fix chain.toml
montekki Jan 9, 2024
4e0353b
use newer contracts
StanislavBreadless Jan 9, 2024
b5c6a9c
use latest contracts
StanislavBreadless Jan 10, 2024
cbcc826
Merge remote-tracking branch 'origin/sb-short-term-fee-model-1-4-1' i…
montekki Jan 10, 2024
81a8479
sync with main
StanislavBreadless Jan 10, 2024
20314f8
Merge remote-tracking branch 'origin/sb-short-term-fee-model-1-4-1' i…
montekki Jan 10, 2024
8b2e05f
add additional comments
StanislavBreadless Jan 10, 2024
29f2b50
fix review
StanislavBreadless Jan 10, 2024
c9a9bd3
Merge branch 'main' into sb-short-term-fee-model-1-4-1
StanislavBreadless Jan 10, 2024
804ffd4
make prover build
montekki Jan 10, 2024
545e947
update cargo.lock
montekki Jan 10, 2024
c30257c
another bump
montekki Jan 10, 2024
2370f56
use newest version
StanislavBreadless Jan 11, 2024
f938464
get back to using branch notation
StanislavBreadless Jan 11, 2024
00b6ba2
Merge branch 'sb-short-term-fee-model-1-4-1' into evl-update-prover-t…
StanislavBreadless Jan 11, 2024
3e023ac
remove incorrect line
StanislavBreadless Jan 11, 2024
5def90e
cargo fix
StanislavBreadless Jan 11, 2024
be834a8
fix lint
StanislavBreadless Jan 11, 2024
ecb8d54
add pessimistic overhead for L1->L2 transactions
StanislavBreadless Jan 11, 2024
1d4f577
add a new config param
StanislavBreadless Jan 11, 2024
a3a4e65
Merge branch 'main' into sb-short-term-fee-model-1-4-1
StanislavBreadless Jan 11, 2024
e973c2a
fix nits
StanislavBreadless Jan 11, 2024
8fb7e70
use real task name
StanislavBreadless Jan 11, 2024
833ce5b
bump it
montekki Jan 11, 2024
20ff013
temp move contracts dir
montekki Jan 11, 2024
a3beda0
lets pretend that we are in test_harness repo
montekki Jan 11, 2024
e9c3da9
remove files
montekki Jan 11, 2024
1193897
nop file
montekki Jan 11, 2024
577cfae
Update /witness_artifacts.json
perekopskiy Jan 12, 2024
1cf77e0
Merge branch 'sb-short-term-fee-model-1-4-1' into sb-introduce-compat…
StanislavBreadless Jan 12, 2024
648b2a8
add compatibility regarding gas price for boojum integration
StanislavBreadless Jan 12, 2024
ea62c8e
Merge branch 'sb-short-term-fee-model-1-4-1' into sb-introduce-compat…
StanislavBreadless Jan 12, 2024
eeb9168
bump deps on zkevm_circuits and zkevm_test_harness
montekki Jan 12, 2024
f00a708
bump deps on zkevm_circuits and zkevm_test_harness in prover
montekki Jan 12, 2024
ec4121f
Update zk_evm_abstractions
perekopskiy Jan 12, 2024
a829796
Update zk_evm_abstractions
perekopskiy Jan 12, 2024
c68839d
new newer contracts
StanislavBreadless Jan 15, 2024
fa73d51
Merge branch 'sb-short-term-fee-model-1-4-1' into sb-introduce-compat…
StanislavBreadless Jan 15, 2024
c746f1b
exclude contracts/lib from lint
StanislavBreadless Jan 15, 2024
f8cd6d5
sync with main
StanislavBreadless Jan 15, 2024
61ea89f
fix compilation
StanislavBreadless Jan 15, 2024
f706be8
Update deps
perekopskiy Jan 15, 2024
8f00238
update generated verification keys
zksync-admin-bot2 Jan 15, 2024
0de3bc6
fix sqlx
StanislavBreadless Jan 15, 2024
31b2ff5
Merge pull request #874 from matter-labs/update-generated-verificatio…
perekopskiy Jan 15, 2024
c6f8a24
update api
StanislavBreadless Jan 15, 2024
420ccc8
Merge branch 'main' into sb-short-term-fee-model-1-4-1
StanislavBreadless Jan 15, 2024
d03eee3
update setup-data keys
zksync-admin-bot2 Jan 15, 2024
ff40b35
Update CPU prover setup data keys
perekopskiy Jan 15, 2024
007c4d4
Merge pull request #875 from matter-labs/update-setup-data-keys-31b2ff5
perekopskiy Jan 15, 2024
829f7fd
Remove changes needed to generate VK
perekopskiy Jan 15, 2024
47030c4
Remove changes needed to generate VK
perekopskiy Jan 15, 2024
018a575
Merge branch 'sb-short-term-fee-model-1-4-1' into evl-update-prover-t…
perekopskiy Jan 15, 2024
7f30b8b
update test
StanislavBreadless Jan 15, 2024
87ea526
use latest contracts
StanislavBreadless Jan 15, 2024
7679ef4
fix spellcheck
StanislavBreadless Jan 15, 2024
396f879
use release contracts commit
StanislavBreadless Jan 16, 2024
233ee90
Update deps
perekopskiy Jan 16, 2024
f6df39e
temp
perekopskiy Jan 16, 2024
2f8b012
update generated verification keys
zksync-admin-bot2 Jan 16, 2024
ce77e57
Merge pull request #886 from matter-labs/update-generated-verificatio…
perekopskiy Jan 16, 2024
c7135af
Update deps
perekopskiy Jan 17, 2024
cff259e
update generated verification keys
zksync-admin-bot2 Jan 17, 2024
012ce13
Merge pull request #888 from matter-labs/update-generated-verificatio…
perekopskiy Jan 17, 2024
c6a2d45
Update deps
perekopskiy Jan 17, 2024
d87c66a
update generated verification keys
zksync-admin-bot2 Jan 17, 2024
8ef5506
Merge pull request #890 from matter-labs/update-generated-verificatio…
perekopskiy Jan 17, 2024
5a009d5
Clean up
perekopskiy Jan 17, 2024
c95e0d0
Merge branch 'sb-short-term-fee-model-1-4-1' into evl-update-prover-t…
perekopskiy Jan 17, 2024
aacdea6
update setup-data keys
zksync-admin-bot2 Jan 17, 2024
df4dc38
update GPU setup-data keys
zksync-admin-bot2 Jan 17, 2024
e381ff8
Merge pull request #892 from matter-labs/update-gpu-setup-data-keys-c…
perekopskiy Jan 17, 2024
476846f
Merge pull request #891 from matter-labs/update-setup-data-keys-c95e0d0
perekopskiy Jan 17, 2024
9c8eb3a
Merge pull request #834 from matter-labs/evl-update-prover-to-1.4.1
StanislavBreadless Jan 18, 2024
0862373
Merge pull request #858 from matter-labs/sb-introduce-compatibility-m…
StanislavBreadless Jan 18, 2024
eb2584f
Merge branch 'main' into sb-short-term-fee-model-1-4-1
StanislavBreadless Jan 18, 2024
950b036
update h2
StanislavBreadless Jan 18, 2024
c3b5e76
Merge remote-tracking branch 'origin/sb-short-term-fee-model-1-4-1' i…
StanislavBreadless Jan 18, 2024
1059b89
fix typo
StanislavBreadless Jan 18, 2024
40b6cfa
Update contracts
AntonD3 Jan 18, 2024
5c93949
Merge pull request #898 from matter-labs/ad-1-4-1-update-contracts
StanislavBreadless Jan 18, 2024
42ecd0f
Update config
perekopskiy Jan 18, 2024
85e482f
Merge branch 'main' into sb-short-term-fee-model-1-4-1
StanislavBreadless Jan 18, 2024
ade4b88
sync with main
StanislavBreadless Jan 18, 2024
4af24bf
fix compile
StanislavBreadless Jan 18, 2024
23cd276
fix lint
StanislavBreadless Jan 18, 2024
a833301
use cargo lock from previous commits
StanislavBreadless Jan 18, 2024
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
309 changes: 288 additions & 21 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts
Submodule contracts updated 138 files
17 changes: 2 additions & 15 deletions core/bin/external_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ use std::{env, time::Duration};
use anyhow::Context;
use serde::Deserialize;
use url::Url;
use zksync_basic_types::{Address, L1ChainId, L2ChainId, MiniblockNumber};
use zksync_basic_types::{Address, L1ChainId, L2ChainId};
use zksync_core::api_server::{
tx_sender::TxSenderConfig,
web3::{state::InternalApiConfig, Namespace},
};
use zksync_types::api::BridgeAddresses;
use zksync_web3_decl::{
jsonrpsee::http_client::{HttpClient, HttpClientBuilder},
namespaces::{EnNamespaceClient, EthNamespaceClient, ZksNamespaceClient},
namespaces::{EthNamespaceClient, ZksNamespaceClient},
};

#[cfg(test)]
Expand All @@ -30,8 +30,6 @@ pub struct RemoteENConfig {
pub l2_testnet_paymaster_addr: Option<Address>,
pub l2_chain_id: L2ChainId,
pub l1_chain_id: L1ChainId,

pub fair_l2_gas_price: u64,
}

impl RemoteENConfig {
Expand Down Expand Up @@ -63,15 +61,6 @@ impl RemoteENConfig {
.context("Failed to fetch L1 chain ID")?
.as_u64(),
);
let current_miniblock = client
.get_block_number()
.await
.context("Failed to fetch block number")?;
let block_header = client
.sync_l2_block(MiniblockNumber(current_miniblock.as_u32()), false)
.await
.context("Failed to fetch last miniblock header")?
.expect("Block is known to exist");

Ok(Self {
diamond_proxy_addr,
Expand All @@ -82,7 +71,6 @@ impl RemoteENConfig {
l2_weth_bridge_addr: bridges.l2_weth_bridge,
l2_chain_id,
l1_chain_id,
fair_l2_gas_price: block_header.l2_fair_gas_price,
})
}
}
Expand Down Expand Up @@ -527,7 +515,6 @@ impl From<ExternalNodeConfig> for TxSenderConfig {
.unwrap(),
gas_price_scale_factor: config.optional.gas_price_scale_factor,
max_nonce_ahead: config.optional.max_nonce_ahead,
fair_l2_gas_price: config.remote.fair_l2_gas_price,
vm_execution_cache_misses_limit: config.optional.vm_execution_cache_misses_limit,
// We set these values to the maximum since we don't know the actual values
// and they will be enforced by the main node anyway.
Expand Down
1 change: 1 addition & 0 deletions core/bin/snapshots_creator/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ async fn create_miniblock(
l1_tx_count: 0,
l2_tx_count: 0,
base_fee_per_gas: 0,
gas_per_pubdata_limit: 0,
batch_fee_input: Default::default(),
base_system_contracts_hashes: Default::default(),
protocol_version: Some(Default::default()),
Expand Down
15 changes: 7 additions & 8 deletions core/bin/system-constants-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fs;
use codegen::{Block, Scope};
use multivm::{
utils::{get_bootloader_encoding_space, get_bootloader_max_txs_in_batch},
vm_latest::constants::{BLOCK_OVERHEAD_GAS, BLOCK_OVERHEAD_L1_GAS, MAX_PUBDATA_PER_BLOCK},
vm_latest::constants::MAX_PUBDATA_PER_BLOCK,
};
use serde::{Deserialize, Serialize};
use zksync_types::{
Expand All @@ -15,9 +15,13 @@ use zksync_types::{
system_params::MAX_TX_ERGS_LIMIT,
},
IntrinsicSystemGasConstants, ProtocolVersionId, GUARANTEED_PUBDATA_IN_TX,
L1_GAS_PER_PUBDATA_BYTE, MAX_GAS_PER_PUBDATA_BYTE, MAX_NEW_FACTORY_DEPS,
L1_GAS_PER_PUBDATA_BYTE, MAX_NEW_FACTORY_DEPS, REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE,
};

// For configs we will use the default value of 800_000k to represent the rough amount of L1 gas
// needed to cover the batch expenses.
const BLOCK_OVERHEAD_L1_GAS: u32 = 800_000;

mod intrinsic_costs;
mod utils;

Expand All @@ -30,7 +34,6 @@ struct L1SystemConfig {
priority_tx_max_pubdata: u32,
fair_l2_gas_price: u64,
l1_gas_per_pubdata_byte: u32,
block_overhead_l2_gas: u32,
block_overhead_l1_gas: u32,
max_transactions_in_block: u32,
bootloader_tx_encoding_space: u32,
Expand All @@ -56,23 +59,21 @@ pub fn generate_l1_contracts_system_config(gas_constants: &IntrinsicSystemGasCon
priority_tx_max_pubdata: (L1_TX_DECREASE * (MAX_PUBDATA_PER_BLOCK as f64)) as u32,
fair_l2_gas_price: FAIR_L2_GAS_PRICE_ON_L1_CONTRACT,
l1_gas_per_pubdata_byte: L1_GAS_PER_PUBDATA_BYTE,
block_overhead_l2_gas: BLOCK_OVERHEAD_GAS,
block_overhead_l1_gas: BLOCK_OVERHEAD_L1_GAS,
max_transactions_in_block: get_bootloader_max_txs_in_batch(
ProtocolVersionId::latest().into(),
) as u32,
bootloader_tx_encoding_space: get_bootloader_encoding_space(
ProtocolVersionId::latest().into(),
),

l1_tx_intrinsic_l2_gas: gas_constants.l1_tx_intrinsic_gas,
l1_tx_intrinsic_pubdata: gas_constants.l1_tx_intrinsic_pubdata,
l1_tx_min_l2_gas_base: gas_constants.l1_tx_min_gas_base,
l1_tx_delta_544_encoding_bytes: gas_constants.l1_tx_delta_544_encoding_bytes,
l1_tx_delta_factory_deps_l2_gas: gas_constants.l1_tx_delta_factory_dep_gas,
l1_tx_delta_factory_deps_pubdata: gas_constants.l1_tx_delta_factory_dep_pubdata,
max_new_factory_deps: MAX_NEW_FACTORY_DEPS as u32,
required_l2_gas_price_per_pubdata: MAX_GAS_PER_PUBDATA_BYTE,
required_l2_gas_price_per_pubdata: REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE,
};

serde_json::to_string_pretty(&l1_contracts_config).unwrap()
Expand All @@ -85,7 +86,6 @@ struct L2SystemConfig {
guaranteed_pubdata_bytes: u32,
max_pubdata_per_block: u32,
max_transactions_in_block: u32,
block_overhead_l2_gas: u32,
block_overhead_l1_gas: u32,
l2_tx_intrinsic_gas: u32,
l2_tx_intrinsic_pubdata: u32,
Expand All @@ -106,7 +106,6 @@ pub fn generate_l2_contracts_system_config(gas_constants: &IntrinsicSystemGasCon
max_transactions_in_block: get_bootloader_max_txs_in_batch(
ProtocolVersionId::latest().into(),
) as u32,
block_overhead_l2_gas: BLOCK_OVERHEAD_GAS,
block_overhead_l1_gas: BLOCK_OVERHEAD_L1_GAS,
l2_tx_intrinsic_gas: gas_constants.l2_tx_intrinsic_gas,
l2_tx_intrinsic_pubdata: gas_constants.l2_tx_intrinsic_pubdata,
Expand Down
10 changes: 5 additions & 5 deletions core/bin/system-constants-generator/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ use std::{cell::RefCell, rc::Rc};

use multivm::{
interface::{
dyn_tracers::vm_1_4_0::DynTracer, tracer::VmExecutionStopReason, L1BatchEnv, L2BlockEnv,
dyn_tracers::vm_1_4_1::DynTracer, tracer::VmExecutionStopReason, L1BatchEnv, L2BlockEnv,
SystemEnv, TxExecutionMode, VmExecutionMode, VmInterface,
},
vm_latest::{
constants::{BLOCK_GAS_LIMIT, BOOTLOADER_HEAP_PAGE},
BootloaderState, HistoryEnabled, HistoryMode, SimpleMemory, ToTracerPointer, Vm, VmTracer,
ZkSyncVmState,
},
zk_evm_1_4_1::aux_structures::Timestamp,
};
use once_cell::sync::Lazy;
use zksync_contracts::{
Expand All @@ -20,10 +21,9 @@ use zksync_state::{InMemoryStorage, StorageView, WriteStorage};
use zksync_types::{
block::MiniblockHasher, ethabi::Token, fee::Fee, fee_model::BatchFeeInput, l1::L1Tx, l2::L2Tx,
utils::storage_key_for_eth_balance, AccountTreeId, Address, Execute, L1BatchNumber,
L1TxCommonData, L2ChainId, MiniblockNumber, Nonce, ProtocolVersionId, StorageKey, Timestamp,
Transaction, BOOTLOADER_ADDRESS, H256, SYSTEM_CONTEXT_ADDRESS,
SYSTEM_CONTEXT_GAS_PRICE_POSITION, SYSTEM_CONTEXT_TX_ORIGIN_POSITION, U256,
ZKPORTER_IS_AVAILABLE,
L1TxCommonData, L2ChainId, MiniblockNumber, Nonce, ProtocolVersionId, StorageKey, Transaction,
BOOTLOADER_ADDRESS, H256, SYSTEM_CONTEXT_ADDRESS, SYSTEM_CONTEXT_GAS_PRICE_POSITION,
SYSTEM_CONTEXT_TX_ORIGIN_POSITION, U256, ZKPORTER_IS_AVAILABLE,
};
use zksync_utils::{bytecode::hash_bytecode, bytes_to_be_words, u256_to_h256};

Expand Down
1 change: 1 addition & 0 deletions core/lib/commitment_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ categories = ["cryptography"]
zksync_types = { path = "../../lib/types" }
zksync_utils = { path = "../../lib/utils" }
zkevm_test_harness = { git = "https://github.com/matter-labs/era-zkevm_test_harness.git", branch = "v1.4.0" }
multivm = { path = "../../lib/multivm" }
32 changes: 21 additions & 11 deletions core/lib/commitment_utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
//! Utils for commitment calculation.
use multivm::utils::get_used_bootloader_memory_bytes;
use zkevm_test_harness::witness::utils::{
events_queue_commitment_fixed, initial_heap_content_commitment_fixed,
StanislavBreadless marked this conversation as resolved.
Show resolved Hide resolved
};
use zksync_types::{LogQuery, H256, U256, USED_BOOTLOADER_MEMORY_BYTES};
use zksync_types::{LogQuery, ProtocolVersionId, H256, U256};
use zksync_utils::expand_memory_contents;

pub fn events_queue_commitment(events_queue: &Vec<LogQuery>, is_pre_boojum: bool) -> Option<H256> {
(!is_pre_boojum).then(|| H256(events_queue_commitment_fixed(events_queue)))
pub fn events_queue_commitment(
events_queue: &Vec<LogQuery>,
protocol_version: ProtocolVersionId,
) -> Option<H256> {
(!protocol_version.is_pre_boojum()).then(|| H256(events_queue_commitment_fixed(events_queue)))
}

pub fn bootloader_initial_content_commitment(
initial_bootloader_contents: &[(usize, U256)],
is_pre_boojum: bool,
protocol_version: ProtocolVersionId,
) -> Option<H256> {
(!is_pre_boojum).then(|| {
let full_bootloader_memory =
expand_memory_contents(initial_bootloader_contents, USED_BOOTLOADER_MEMORY_BYTES);
H256(initial_heap_content_commitment_fixed(
&full_bootloader_memory,
))
})
let expanded_memory_size = if protocol_version.is_pre_boojum() {
return None;
} else {
get_used_bootloader_memory_bytes(protocol_version.into())
};

let full_bootloader_memory =
expand_memory_contents(initial_bootloader_contents, expanded_memory_size);
let commitment = H256(initial_heap_content_commitment_fixed(
&full_bootloader_memory,
));

Some(commitment)
}
49 changes: 46 additions & 3 deletions core/lib/config/src/configs/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ impl NetworkConfig {
}
}

/// An enum that represents the version of the fee model to use.
/// - `V1`, the first model that was used in zkSync Era. In this fee model, the pubdata price must be pegged to the L1 gas price.
/// Also, the fair L2 gas price is expected to only include the proving/computation price for the operator and not the costs that come from
/// processing the batch on L1.
/// - `V2`, the second model that was used in zkSync Era. There the pubdata price might be independent from the L1 gas price. Also,
/// The fair L2 gas price is expected to both the proving/computation price for the operator and the costs that come from
/// processing the batch on L1.
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq)]
pub enum FeeModelVersion {
V1,
V2,
}

impl Default for FeeModelVersion {
fn default() -> Self {
Self::V1
}
}

#[derive(Debug, Deserialize, Clone, PartialEq, Default)]
pub struct StateKeeperConfig {
/// The max number of slots for txs in a block before it should be sealed by the slots sealer.
Expand Down Expand Up @@ -63,8 +82,26 @@ pub struct StateKeeperConfig {

pub fee_account_addr: Address,

/// The price the operator spends on 1 gas of computation in wei.
pub fair_l2_gas_price: u64,
/// The minimal acceptable L2 gas price, i.e. the price that should include the cost of computation/proving as well
/// as potentially premium for congestion.
pub minimal_l2_gas_price: u64,
StanislavBreadless marked this conversation as resolved.
Show resolved Hide resolved
/// The constant that represents the possibility that a batch can be sealed because of overuse of computation resources.
/// It has range from 0 to 1. If it is 0, the compute will not depend on the cost for closing the batch.
/// If it is 1, the gas limit per batch will have to cover the entire cost of closing the batch.
pub compute_overhead_part: f64,
/// The constant that represents the possibility that a batch can be sealed because of overuse of pubdata.
/// It has range from 0 to 1. If it is 0, the pubdata will not depend on the cost for closing the batch.
/// If it is 1, the pubdata limit per batch will have to cover the entire cost of closing the batch.
pub pubdata_overhead_part: f64,
/// The constant amount of L1 gas that is used as the overhead for the batch. It includes the price for batch verification, etc.
pub batch_overhead_l1_gas: u64,
/// The maximum amount of gas that can be used by the batch. This value is derived from the circuits limitation per batch.
pub max_gas_per_batch: u64,
/// The maximum amount of pubdata that can be used by the batch. Note that if the calldata is used as pubdata, this variable should not exceed 128kb.
pub max_pubdata_per_batch: u64,

/// The version of the fee model to use.
pub fee_model_version: FeeModelVersion,

/// Max number of computational gas that validation step is allowed to take.
pub validation_computational_gas_limit: u32,
Expand Down Expand Up @@ -100,7 +137,13 @@ impl StateKeeperConfig {
close_block_at_gas_percentage: 0.95,
fee_account_addr: Address::from_str("0xde03a0B5963f75f1C8485B355fF6D30f3093BDE7")
.unwrap(),
fair_l2_gas_price: 250000000,
compute_overhead_part: 0.0,
pubdata_overhead_part: 1.0,
batch_overhead_l1_gas: 800_000,
max_gas_per_batch: 200_000_000,
max_pubdata_per_batch: 100_000,
minimal_l2_gas_price: 100000000,
fee_model_version: FeeModelVersion::V2,
validation_computational_gas_limit: 300000,
save_call_traces: true,
virtual_blocks_interval: 1,
Expand Down
8 changes: 3 additions & 5 deletions core/lib/constants/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ pub const MAX_NEW_FACTORY_DEPS: usize = 32;

pub const PAD_MSG_BEFORE_HASH_BITS_LEN: usize = 736;

/// The size of the bootloader memory in bytes which is used by the protocol.
/// While the maximal possible size is a lot higher, we restrict ourselves to a certain limit to reduce
/// the requirements on RAM.
pub const USED_BOOTLOADER_MEMORY_BYTES: usize = 1 << 24;
pub const USED_BOOTLOADER_MEMORY_WORDS: usize = USED_BOOTLOADER_MEMORY_BYTES / 32;
/// To avoid DDoS we limit the size of the transactions size.
/// TODO(X): remove this as a constant and introduce a config.
pub const MAX_ENCODED_TX_SIZE: usize = 1 << 24;
15 changes: 5 additions & 10 deletions core/lib/constants/src/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ pub const PRIORITY_EXPIRATION: u64 = 50000;
pub const MAX_L1_TRANSACTION_GAS_LIMIT: u64 = 300000;
pub static ETHEREUM_ADDRESS: Address = Address::zero();

/// This the number of pubdata such that it should be always possible to publish
/// from a single transaction. Note, that these pubdata bytes include only bytes that are
/// to be published inside the body of transaction (i.e. excluding of factory deps).
pub const GUARANTEED_PUBDATA_PER_L1_BATCH: u64 = 4000;

/// The maximum number of pubdata per L1 batch. This limit is due to the fact that the Ethereum
/// nodes do not accept transactions that have more than 128kb of pubdata.
/// The 18kb margin is left in case of any impreciseness of the pubdata calculation.
Expand All @@ -18,10 +13,10 @@ pub const MAX_PUBDATA_PER_L1_BATCH: u64 = 110000;
// TODO: import from `zkevm_opcode_defs` once `VM1.3` is supported
pub const MAX_L2_TX_GAS_LIMIT: u64 = 80000000;

// The users should always be able to provide `MAX_GAS_PER_PUBDATA_BYTE` gas per pubdata in their
// transactions so that they are able to send at least `GUARANTEED_PUBDATA_PER_L1_BATCH` bytes per
// transaction.
pub const MAX_GAS_PER_PUBDATA_BYTE: u64 = MAX_L2_TX_GAS_LIMIT / GUARANTEED_PUBDATA_PER_L1_BATCH;

// The L1->L2 are required to have the following gas per pubdata byte.
pub const REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE: u64 = 800;

// The default gas per pubdata byte for L2 transactions, that is used, for instance, when we need to
// insert some default value for type 2 transactions.
// It is a realistic value, but it is large enough to fill into any batch regardless of the pubdata price.
pub const DEFAULT_L2_TX_GAS_PER_PUBDATA_BYTE: u64 = 50_000;
StanislavBreadless marked this conversation as resolved.
Show resolved Hide resolved
20 changes: 19 additions & 1 deletion core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const IERC20_CONTRACT_FILE: &str =
const FAIL_ON_RECEIVE_CONTRACT_FILE: &str =
"contracts/l1-contracts/artifacts/cache/solpp-generated-contracts/zksync/dev-contracts/FailOnReceive.sol/FailOnReceive.json";
const L2_BRIDGE_CONTRACT_FILE: &str =
"contracts/l2-contracts/artifacts-zk/cache-zk/solpp-generated-contracts/bridge/interfaces/IL2Bridge.sol/IL2Bridge.json";
"contracts/l2-contracts/artifacts-zk/contracts-preprocessed/bridge/interfaces/IL2Bridge.sol/IL2Bridge.json";
const LOADNEXT_CONTRACT_FILE: &str =
"etc/contracts-test-data/artifacts-zk/contracts/loadnext/loadnext_contract.sol/LoadnextContract.json";
const LOADNEXT_SIMPLE_CONTRACT_FILE: &str =
Expand Down Expand Up @@ -147,6 +147,10 @@ pub fn deployer_contract() -> Contract {
load_sys_contract("ContractDeployer")
}

pub fn l1_messenger_contract() -> Contract {
load_sys_contract("L1Messenger")
}

pub fn eth_contract() -> Contract {
load_sys_contract("L2EthToken")
}
Expand Down Expand Up @@ -370,6 +374,13 @@ impl BaseSystemContracts {
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

pub fn playground_post_1_4_1() -> Self {
let bootloader_bytecode = read_zbin_bytecode(
"etc/multivm_bootloaders/vm_1_4_1/playground_batch.yul/playground_batch.yul.zbin",
);
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

/// BaseSystemContracts with playground bootloader - used for handling eth_calls.
pub fn estimate_gas() -> Self {
let bootloader_bytecode = read_bootloader_code("fee_estimate");
Expand Down Expand Up @@ -411,6 +422,13 @@ impl BaseSystemContracts {
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

pub fn estimate_gas_post_1_4_1() -> Self {
let bootloader_bytecode = read_zbin_bytecode(
"etc/multivm_bootloaders/vm_1_4_1/fee_estimate.yul/fee_estimate.yul.zbin",
);
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

pub fn hashes(&self) -> BaseSystemContractsHashes {
BaseSystemContractsHashes {
bootloader: self.bootloader.hash,
Expand Down
Loading
Loading