Skip to content

Commit

Permalink
feat: Revisit base config values (#2532)
Browse files Browse the repository at this point in the history
## What ❔

- changes some values in base config
- removes `request_timeout`, `account_pks` as those are dead
- adds "override" config, it's not used by code but is helpful when
setting new chain

## Why ❔

- unify config values
- remove dead code

## 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 `zk fmt` and `zk lint`.
  • Loading branch information
perekopskiy authored Jul 30, 2024
1 parent 2fa6bf0 commit 3fac8ac
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 123 deletions.
16 changes: 1 addition & 15 deletions core/lib/config/src/configs/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{

use anyhow::Context as _;
use serde::{de, Deserialize, Deserializer};
use zksync_basic_types::{Address, H256};
use zksync_basic_types::Address;

pub use crate::configs::PrometheusConfig;

Expand Down Expand Up @@ -165,10 +165,6 @@ pub struct Web3JsonRpcConfig {
/// The multiplier to use when suggesting gas price. Should be higher than one,
/// otherwise if the L1 prices soar, the suggested gas price won't be sufficient to be included in block
pub gas_price_scale_factor: f64,
/// Timeout for requests (in s)
pub request_timeout: Option<u64>,
/// Private keys for accounts managed by node
pub account_pks: Option<Vec<H256>>,
/// The factor by which to scale the gasLimit
pub estimate_gas_scale_factor: f64,
/// The max possible number of gas that `eth_estimateGas` is allowed to overestimate.
Expand Down Expand Up @@ -239,8 +235,6 @@ impl Web3JsonRpcConfig {
pubsub_polling_interval: Some(200),
max_nonce_ahead: 50,
gas_price_scale_factor: 1.2,
request_timeout: Default::default(),
account_pks: Default::default(),
estimate_gas_scale_factor: 1.2,
estimate_gas_acceptable_overestimation: 1000,
max_tx_size: 1000000,
Expand Down Expand Up @@ -287,14 +281,6 @@ impl Web3JsonRpcConfig {
Duration::from_millis(self.pubsub_polling_interval.unwrap_or(200))
}

pub fn request_timeout(&self) -> Duration {
Duration::from_secs(self.request_timeout.unwrap_or(10))
}

pub fn account_pks(&self) -> Vec<H256> {
self.account_pks.clone().unwrap_or_default()
}

pub fn vm_concurrency_limit(&self) -> usize {
// The default limit is large so that it does not create a bottleneck on its own.
// VM execution can still be limited by Tokio runtime parallelism and/or the number
Expand Down
2 changes: 0 additions & 2 deletions core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ impl Distribution<configs::api::Web3JsonRpcConfig> for EncodeDist {
pubsub_polling_interval: self.sample(rng),
max_nonce_ahead: self.sample(rng),
gas_price_scale_factor: self.sample(rng),
request_timeout: self.sample_opt(|| self.sample(rng)),
account_pks: self.sample_opt(|| self.sample_range(rng).map(|_| rng.gen()).collect()),
estimate_gas_scale_factor: self.sample(rng),
estimate_gas_acceptable_overestimation: self.sample(rng),
max_tx_size: self.sample(rng),
Expand Down
9 changes: 1 addition & 8 deletions core/lib/env_config/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ mod tests {
use std::num::{NonZeroU32, NonZeroUsize};

use super::*;
use crate::test_utils::{addr, hash, EnvMutex};
use crate::test_utils::{addr, EnvMutex};

static MUTEX: EnvMutex = EnvMutex::new();

Expand All @@ -66,11 +66,6 @@ mod tests {
subscriptions_limit: Some(10000),
pubsub_polling_interval: Some(200),
max_nonce_ahead: 5,
request_timeout: Some(10),
account_pks: Some(vec![
hash("0x0000000000000000000000000000000000000000000000000000000000000001"),
hash("0x0000000000000000000000000000000000000000000000000000000000000002"),
]),
estimate_gas_scale_factor: 1.0f64,
gas_price_scale_factor: 1.2,
estimate_gas_acceptable_overestimation: 1000,
Expand Down Expand Up @@ -130,10 +125,8 @@ mod tests {
API_WEB3_JSON_RPC_PUBSUB_POLLING_INTERVAL=200
API_WEB3_JSON_RPC_MAX_NONCE_AHEAD=5
API_WEB3_JSON_RPC_GAS_PRICE_SCALE_FACTOR=1.2
API_WEB3_JSON_RPC_REQUEST_TIMEOUT=10
API_WEB3_JSON_RPC_API_NAMESPACES=debug
API_WEB3_JSON_RPC_EXTENDED_API_TRACING=true
API_WEB3_JSON_RPC_ACCOUNT_PKS="0x0000000000000000000000000000000000000000000000000000000000000001,0x0000000000000000000000000000000000000000000000000000000000000002"
API_WEB3_JSON_RPC_WHITELISTED_TOKENS_FOR_AA="0x0000000000000000000000000000000000000001,0x0000000000000000000000000000000000000002"
API_WEB3_JSON_RPC_ESTIMATE_GAS_SCALE_FACTOR=1.0
API_WEB3_JSON_RPC_ESTIMATE_GAS_ACCEPTABLE_OVERESTIMATION=1000
Expand Down
25 changes: 2 additions & 23 deletions core/lib/protobuf_config/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use zksync_protobuf::{
required,
};

use crate::{parse_h160, parse_h256, proto::api as proto};
use crate::{parse_h160, proto::api as proto};

impl ProtoRepr for proto::Api {
type Type = ApiConfig;
Expand All @@ -34,19 +34,6 @@ impl ProtoRepr for proto::Web3JsonRpc {
type Type = api::Web3JsonRpcConfig;

fn read(&self) -> anyhow::Result<Self::Type> {
let account_pks = self
.account_pks
.iter()
.enumerate()
.map(|(i, k)| parse_h256(k).context(i))
.collect::<Result<Vec<_>, _>>()
.context("account_pks")?;
let account_pks = if account_pks.is_empty() {
None
} else {
Some(account_pks)
};

let max_response_body_size_overrides_mb = self
.max_response_body_size_overrides
.iter()
Expand Down Expand Up @@ -91,8 +78,6 @@ impl ProtoRepr for proto::Web3JsonRpc {
max_nonce_ahead: *required(&self.max_nonce_ahead).context("max_nonce_ahead")?,
gas_price_scale_factor: *required(&self.gas_price_scale_factor)
.context("gas_price_scale_factor")?,
request_timeout: self.request_timeout,
account_pks,
estimate_gas_scale_factor: *required(&self.estimate_gas_scale_factor)
.context("estimate_gas_scale_factor")?,
estimate_gas_acceptable_overestimation: *required(
Expand Down Expand Up @@ -157,7 +142,7 @@ impl ProtoRepr for proto::Web3JsonRpc {
.enumerate()
.map(|(i, k)| parse_h160(k).context(i))
.collect::<Result<Vec<_>, _>>()
.context("account_pks")?,
.context("whitelisted_tokens_for_aa")?,
extended_api_tracing: self.extended_api_tracing.unwrap_or_default(),
api_namespaces,
})
Expand All @@ -178,12 +163,6 @@ impl ProtoRepr for proto::Web3JsonRpc {
pubsub_polling_interval: this.pubsub_polling_interval,
max_nonce_ahead: Some(this.max_nonce_ahead),
gas_price_scale_factor: Some(this.gas_price_scale_factor),
request_timeout: this.request_timeout,
account_pks: this
.account_pks
.as_ref()
.map(|keys| keys.iter().map(|k| format!("{:?}", k)).collect())
.unwrap_or_default(),
estimate_gas_scale_factor: Some(this.estimate_gas_scale_factor),
estimate_gas_acceptable_overestimation: Some(
this.estimate_gas_acceptable_overestimation,
Expand Down
4 changes: 2 additions & 2 deletions core/lib/protobuf_config/src/proto/config/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ message Web3JsonRpc {
optional uint64 pubsub_polling_interval = 8; // optional
optional uint32 max_nonce_ahead = 9; // required
optional double gas_price_scale_factor = 10; // required
optional uint64 request_timeout = 11; // seconds
repeated string account_pks = 12; // optional
optional double estimate_gas_scale_factor = 13; // required
optional uint32 estimate_gas_acceptable_overestimation = 14; // required
optional uint64 max_tx_size = 16; // required; B
Expand All @@ -43,6 +41,8 @@ message Web3JsonRpc {
repeated string api_namespaces = 32; // Optional, if empty all namespaces are available
optional bool extended_api_tracing = 33; // optional, default false
reserved 15; reserved "l1_to_l2_transactions_compatibility_mode";
reserved 11; reserved "request_timeout";
reserved 12; reserved "account_pks";
}


Expand Down
2 changes: 1 addition & 1 deletion core/tests/ts-integration/tests/contracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('Smart contract behavior checks', () => {
const expensiveContract = await deployContract(alice, contracts.expensive, []);

// First, check that the transaction that is too expensive would be rejected by the API server.
await expect(expensiveContract.expensive(3000)).toBeRejected();
await expect(expensiveContract.expensive(15000)).toBeRejected();

// Second, check that processable transaction may fail with "out of gas" error.
// To do so, we estimate gas for arg "1" and supply it to arg "20".
Expand Down
23 changes: 0 additions & 23 deletions etc/env/base/api.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,6 @@ pubsub_polling_interval = 200
threads_per_server = 128
max_nonce_ahead = 50
gas_price_scale_factor = 1.2
request_timeout = 10
account_pks = [
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
"0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a",
"0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6",
"0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a",
"0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba",
"0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e",
"0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356",
"0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97",
"0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6",
"0xf214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897",
"0x701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82",
"0xa267530f49f8280200edf313ee7af6b827f2a8bce2897751d06a843f644967b1",
"0x47c99abed3324a2707c28affff1267e45918ec8c3f20b8aa892e8b065d2942dd",
"0xc526ee95bf44d8fc405a158bb884d9d1238d99f0612e9f33d006bb0789009aaa",
"0x8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61",
"0xea6c44ac03bff858b476bba40716402b03e41b8e97e276d1baec7c37d42484a0",
"0x689af8efa8c651a91ad287602527f3af2fe9f6501a7ac4b061667b5a93e037fd",
"0xde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0",
"0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e"
]
estimate_gas_scale_factor = 1.2
estimate_gas_acceptable_overestimation = 1000
max_tx_size = 1000000
Expand Down
72 changes: 23 additions & 49 deletions etc/env/file_based/general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ postgres:
db:
state_keeper_db_path: ./db/main/state_keeper
merkle_tree:
multi_get_chunk_size: 1000
block_cache_size_mb: 32
memtable_capacity_mb: 512
stalled_writes_timeout_sec: 50
max_l1_batches_per_iter: 50
multi_get_chunk_size: 500
block_cache_size_mb: 128
memtable_capacity_mb: 256
stalled_writes_timeout_sec: 60
max_l1_batches_per_iter: 20
path: "./db/main/tree"
mode: FULL
experimental:
Expand All @@ -36,46 +36,20 @@ api:
filters_limit: 10000
subscriptions_limit: 10000
pubsub_polling_interval: 200
max_nonce_ahead: 50
gas_price_scale_factor: 1.2
request_timeout: 10
account_pks:
- 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
- 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
- 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a
- 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6
- 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a
- 0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba
- 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e
- 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356
- 0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97
- 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6
- 0xf214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897
- 0x701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82
- 0xa267530f49f8280200edf313ee7af6b827f2a8bce2897751d06a843f644967b1
- 0x47c99abed3324a2707c28affff1267e45918ec8c3f20b8aa892e8b065d2942dd
- 0xc526ee95bf44d8fc405a158bb884d9d1238d99f0612e9f33d006bb0789009aaa
- 0x8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61
- 0xea6c44ac03bff858b476bba40716402b03e41b8e97e276d1baec7c37d42484a0
- 0x689af8efa8c651a91ad287602527f3af2fe9f6501a7ac4b061667b5a93e037fd
- 0xde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0
- 0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e
estimate_gas_scale_factor: 1.2
estimate_gas_acceptable_overestimation: 1000
max_nonce_ahead: 20
gas_price_scale_factor: 1.5
estimate_gas_scale_factor: 1.3
estimate_gas_acceptable_overestimation: 5000
max_tx_size: 1000000
api_namespaces: [en,eth,net,web3,zks,pubsub,debug]
max_response_body_size_overrides:
- method: eth_getTransactionReceipt # no size specified, meaning no size limit
- method: zks_getProof
size_mb: 64
state_keeper:
transaction_slots: 250
max_allowed_l2_tx_gas_limit: 4000000000
transaction_slots: 8192
max_allowed_l2_tx_gas_limit: 15000000000
block_commit_deadline_ms: 2500
miniblock_commit_deadline_ms: 1000
miniblock_seal_queue_capacity: 10
miniblock_max_payload_size: 1000000
max_single_tx_gas: 6000000
max_single_tx_gas: 15000000
close_block_at_geometry_percentage: 0.95
close_block_at_eth_params_percentage: 0.95
close_block_at_gas_percentage: 0.95
Expand All @@ -87,33 +61,33 @@ state_keeper:
pubdata_overhead_part: 1
batch_overhead_l1_gas: 800000
max_gas_per_batch: 200000000
max_pubdata_per_batch: 100000
fee_model_version: V1
max_pubdata_per_batch: 500000
fee_model_version: V2
validation_computational_gas_limit: 300000
save_call_traces: true
max_circuits_per_batch: 24100
max_circuits_per_batch: 31100
protective_reads_persistence_enabled: true
mempool:
delay_interval: 100
sync_interval_ms: 10
sync_batch_size: 1000
capacity: 10000000
stuck_tx_timeout: 86400
stuck_tx_timeout: 172800
remove_stuck_txs: true

operations_manager:
delay_interval: 100
contract_verifier:
compilation_timeout: 30
compilation_timeout: 240
polling_interval: 1000
prometheus_port: 3314
port: 3070
url: http://127.0.0.1:3070
threads_per_server: 128

circuit_breaker:
sync_interval_ms: 30000
http_req_max_retry_number: 5
sync_interval_ms: 120000
http_req_max_retry_number: 10
replication_lag_limit_sec: 100
http_req_retry_interval_sec: 2
eth:
Expand All @@ -124,21 +98,21 @@ eth:
max_txs_in_flight: 30
proof_sending_mode: SKIP_EVERY_PROOF
max_aggregated_blocks_to_commit: 1
max_aggregated_blocks_to_execute: 10
max_aggregated_blocks_to_execute: 45
aggregated_block_commit_deadline: 1
aggregated_block_prove_deadline: 10
aggregated_block_execute_deadline: 10
timestamp_criteria_max_allowed_lag: 30
max_eth_tx_data_size: 120000
aggregated_proof_sizes: [1]
max_aggregated_tx_gas: 4000000
max_aggregated_tx_gas: 15000000
max_acceptable_priority_fee_in_gwei: 100000000000
pubdata_sending_mode: BLOBS
gas_adjuster:
default_priority_fee_per_gas: 1000000000
max_base_fee_samples: 10000
max_base_fee_samples: 100
pricing_formula_parameter_a: 1.5
pricing_formula_parameter_b: 1.0005
pricing_formula_parameter_b: 1.001
internal_l1_pricing_multiplier: 0.8
num_samples_for_blob_base_fee_estimate: 10
internal_pubdata_pricing_multiplier: 1.0
Expand Down
21 changes: 21 additions & 0 deletions etc/env/file_based/overrides/mainnet/general.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
state_keeper:
block_commit_deadline_ms: 3600000
minimal_l2_gas_price: 45250000
eth:
sender:
tx_poll_period: 20
aggregate_tx_poll_period: 2
max_txs_in_flight: 100
aggregated_block_commit_deadline: 300
aggregated_block_prove_deadline: 300
aggregated_block_execute_deadline: 300
timestamp_criteria_max_allowed_lag: 104000 # 29h
gas_adjuster:
pricing_formula_parameter_a: 1.06
internal_l1_pricing_multiplier: 1
internal_pubdata_pricing_multiplier: 1.50
poll_period: 60
observability:
log_directives: zksync=info,zksync_state_keeper=debug,zksync_core=debug,zksync_server=debug,zksync_contract_verifier=debug,zksync_dal=debug,zksync_state=debug,zksync_utils=debug,zksync_eth_sender=debug,loadnext=debug,dev_ticker=info,vm=info,block_sizes_test=info,setup_key_generator_and_server=info,zksync_queued_job_processor=debug,slot_index_consistency_checker=debug,zksync_health_check=debug,zksync_consensus_bft=debug,zksync_consensus_network=debug,zksync_consensus_storage=debug,zksync_consensus_executor=debug,

# remove eth_sender_wait_confirmations, eth_watcher_confirmations_for_eth_event variables
22 changes: 22 additions & 0 deletions etc/env/file_based/overrides/testnet/general.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
state_keeper:
block_commit_deadline_ms: 3600000
minimal_l2_gas_price: 25000000
eth:
sender:
tx_poll_period: 20
aggregate_tx_poll_period: 2
max_txs_in_flight: 100
aggregated_block_commit_deadline: 300
aggregated_block_prove_deadline: 300
aggregated_block_execute_deadline: 300
timestamp_criteria_max_allowed_lag: 104000 # 29h
gas_adjuster:
pricing_formula_parameter_a: 1.1
internal_l1_pricing_multiplier: 1
poll_period: 60
watcher:
confirmations_for_eth_event: 10
observability:
log_directives: zksync=info,zksync_state_keeper=debug,zksync_core=debug,zksync_server=debug,zksync_contract_verifier=debug,zksync_dal=debug,zksync_state=debug,zksync_utils=debug,zksync_eth_sender=debug,loadnext=debug,dev_ticker=info,vm=info,block_sizes_test=info,setup_key_generator_and_server=info,zksync_queued_job_processor=debug,slot_index_consistency_checker=debug,zksync_health_check=debug,zksync_consensus_bft=debug,zksync_consensus_network=debug,zksync_consensus_storage=debug,zksync_consensus_executor=debug,

# remove eth_sender_wait_confirmations variable
4 changes: 4 additions & 0 deletions zk_toolbox/crates/config/src/manipulations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ use crate::consts::{CONFIGS_PATH, WALLETS_FILE};
pub fn copy_configs(shell: &Shell, link_to_code: &Path, target_path: &Path) -> anyhow::Result<()> {
let original_configs = link_to_code.join(CONFIGS_PATH);
for file in shell.read_dir(original_configs)? {
if file.is_dir() {
continue;
}

if let Some(name) = file.file_name() {
// Do not copy wallets file
if name != WALLETS_FILE {
Expand Down

0 comments on commit 3fac8ac

Please sign in to comment.