Skip to content

Commit

Permalink
fix: rollup (#95)
Browse files Browse the repository at this point in the history
* Revert "restore to main values"

This reverts commit 8d9c1db.

* Format

* Remove unused import

* Merge tomls from main

* Change env variables

* Add internal_enforced_l1_gas_price

* Fix internal_enforced_l1_gas_price

* Fix not found

* Fix format

* Clean code
  • Loading branch information
jordibonet-lambdaclass authored Feb 2, 2024
1 parent 8d9c1db commit 872c566
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 65 deletions.
2 changes: 0 additions & 2 deletions core/tests/ts-integration/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export async function scaledGasPrice(wallet: ethers.Wallet | zksync.Wallet): Pro
* @returns Boolean that indicates whether it is Validium mode.
*/
export async function isValidium(): Promise<boolean> {

const filePath = `${process.env.ZKSYNC_HOME}/etc/env/dev.env`;

try {
Expand All @@ -128,4 +127,3 @@ export async function isValidium(): Promise<boolean> {
return false; // Return a default value or handle the error as needed
}
}

76 changes: 38 additions & 38 deletions etc/env/base/chain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,106 +2,106 @@

[chain.eth]
# Name of the used Ethereum network
network = "localhost"
network="localhost"
# Name of current zkSync network
# Used for Sentry environment
zksync_network = "localhost"
zksync_network="localhost"
# ID of current zkSync network treated as ETH network ID.
# Used to distinguish zkSync from other Web3-capable networks.
zksync_network_id = 270
zksync_network_id=270

[chain.state_keeper]
fee_account_addr = "0xde03a0B5963f75f1C8485B355fF6D30f3093BDE7"
fee_account_addr="0xde03a0B5963f75f1C8485B355fF6D30f3093BDE7"

# Denotes the amount of slots for transactions in the block.
transaction_slots = 250
transaction_slots=250

max_allowed_l2_tx_gas_limit = 4000000000
block_commit_deadline_ms = 2500
miniblock_commit_deadline_ms = 1000
miniblock_seal_queue_capacity = 10
max_allowed_l2_tx_gas_limit=4000000000
block_commit_deadline_ms=2500
miniblock_commit_deadline_ms=1000
miniblock_seal_queue_capacity=10
# Max gas that can used to include single block in aggregated operation
max_single_tx_gas = 6000000
max_single_tx_gas=6000000

# Configuration option for block to be sealed in case
# it takes more percentage of the max block capacity than this value.
close_block_at_geometry_percentage = 0.95
close_block_at_geometry_percentage=0.95
# Configuration option for block to be sealed in case
# it takes more percentage of the max block capacity than this value.
close_block_at_eth_params_percentage = 0.95
close_block_at_eth_params_percentage=0.95

# Configuration option for block to be sealed in case
# it takes more percentage of the max block capacity than this value.
close_block_at_gas_percentage = 0.95
close_block_at_gas_percentage=0.95

# Configuration option for tx to be rejected in case
# it takes more percentage of the block capacity than this value.
reject_tx_at_geometry_percentage = 0.95
reject_tx_at_geometry_percentage=0.95
# Configuration option for block to be sealed in case
# it takes more percentage of the max block capacity than this value.
reject_tx_at_eth_params_percentage = 0.95
reject_tx_at_eth_params_percentage=0.95

# Configuration option for block to be sealed in case
# it takes more percentage of the max block gas capacity than this value.
reject_tx_at_gas_percentage = 0.95
reject_tx_at_gas_percentage=0.95

# 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.
minimal_l2_gas_price = 100000000
minimal_l2_gas_price=100000000

# 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.
compute_overhead_part = 0.0
compute_overhead_part=0.0

# 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.
pubdata_overhead_part = 1.0
pubdata_overhead_part=1

# The constant amount of L1 gas that is used as the overhead for the batch. It includes the price for batch verification, etc.
batch_overhead_l1_gas = 800000
batch_overhead_l1_gas=800000

# The maximum amount of gas that can be used by the batch. This value is derived from the circuits limitation per batch.
max_gas_per_batch = 200000000
max_gas_per_batch=200000000

# 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.
max_pubdata_per_batch = 100000
max_pubdata_per_batch=100000

# The version of the fee model to use.
# 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.
fee_model_version = "V1"
fee_model_version="V2"

# Max number of computational gas that validation step is allowed to take.
validation_computational_gas_limit = 300000
save_call_traces = true
validation_computational_gas_limit=300000
save_call_traces=true

virtual_blocks_interval = 1
virtual_blocks_per_miniblock = 1
virtual_blocks_interval=1
virtual_blocks_per_miniblock=1

# WARNING! This slows down the statekeeper, forcing mempool to upload to GCS
# It is meant as a validation flag to be used in STAGING only.
# This variable should not be set to true in any customer facing environment.
upload_witness_inputs_to_gcs = false
upload_witness_inputs_to_gcs=false

[chain.operations_manager]
# Sleep time when there is no new input data
delay_interval = 100
delay_interval=100

[chain.mempool]
delay_interval = 100
sync_interval_ms = 10
delay_interval=100
sync_interval_ms=10
sync_batch_size = 1000
capacity = 10_000_000
stuck_tx_timeout = 86400 # 1 day in seconds
remove_stuck_txs = true
capacity=10_000_000
stuck_tx_timeout=86400 # 1 day in seconds
remove_stuck_txs=true

[chain.circuit_breaker]
sync_interval_ms = 30000
http_req_max_retry_number = 5
http_req_retry_interval_sec = 2
sync_interval_ms=30000
http_req_max_retry_number=5
http_req_retry_interval_sec=2
48 changes: 24 additions & 24 deletions etc/env/base/eth_sender.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,58 @@
# operator_commit_eth_addr is defined in the `private.toml`

# Amount of confirmations required to consider L1 transaction committed.
wait_confirmations = 1
wait_confirmations=1
# Amount of blocks we will wait before considering L1 transaction stuck.
expected_wait_time_block = 30
expected_wait_time_block=30
# Node polling period in seconds.
tx_poll_period = 1
tx_poll_period=1
# Aggregate txs polling period in seconds.
aggregate_tx_poll_period = 1
aggregate_tx_poll_period=1
# The maximum amount of simultaneously sent Ethereum transactions.
max_txs_in_flight = 30 # Safe in the local environment, do not repeat on prod (right now it will produce way too many extra calls to web3)
proof_sending_mode = "SkipEveryProof"
max_txs_in_flight=30 # Safe in the local environment, do not repeat on prod (right now it will produce way too many extra calls to web3)
proof_sending_mode="SkipEveryProof"

# Max L2 blocks to commit in one L1 transaction
max_aggregated_blocks_to_commit = 10
max_aggregated_blocks_to_commit=10
# Max L2 blocks to execute in one L1 transaction
max_aggregated_blocks_to_execute = 10
max_aggregated_blocks_to_execute=10

aggregated_block_commit_deadline = 1
aggregated_block_prove_deadline = 10
aggregated_block_execute_deadline = 10
aggregated_block_commit_deadline=1
aggregated_block_prove_deadline=10
aggregated_block_execute_deadline=10

timestamp_criteria_max_allowed_lag = 30
timestamp_criteria_max_allowed_lag=30

# Based on geth implementation max size of transaction is 128kb.
max_eth_tx_data_size = 120000
max_eth_tx_data_size=120000
# Aggregated proof sizes to be generated by server.
aggregated_proof_sizes = [1, 4]
aggregated_proof_sizes=[1,4]

# Max gas that can be used to execute aggregated operation
# for now (should be > 4kk which is max gas for one block commit/verify/execute)
max_aggregated_tx_gas = 4000000
max_aggregated_tx_gas=4000000

# Max gas that can used to include single block in aggregated operation
max_single_tx_gas = 6000000
max_single_tx_gas=6000000

# Max acceptable fee for sending tx to L1
max_acceptable_priority_fee_in_gwei = 100000000000
max_acceptable_priority_fee_in_gwei=100000000000

proof_loading_mode = "OldProofFromDb"
proof_loading_mode="OldProofFromDb"

[eth_sender.gas_adjuster]
# Priority fee to be used by GasAdjuster (in wei).
default_priority_fee_per_gas = 1_000_000_000
default_priority_fee_per_gas=1_000_000_000
# Max number of base fees from previous blocks to be used to correctly price transactions.
max_base_fee_samples = 10_000
max_base_fee_samples=10_000
# These two are parameters of the base_fee_per_gas formula in GasAdjuster.
# The possible formulas are:
# 1. base_fee_median * (A + B * time_in_mempool)
# 2. base_fee_median * A * B ^ time_in_mempool
# Currently the second is used.
# To confirm, see core/bin/zksync_core/src/eth_sender/gas_adjuster/mod.rs
pricing_formula_parameter_a = 1.5
pricing_formula_parameter_b = 1.0005
internal_l1_pricing_multiplier = 0.8
pricing_formula_parameter_a=1.5
pricing_formula_parameter_b=1.0005
internal_l1_pricing_multiplier=0.8
# Node polling period in seconds.
poll_period = 5
poll_period=5
55 changes: 54 additions & 1 deletion infrastructure/zk/src/init.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import chalk from 'chalk';
import path from 'path';
import { Command } from 'commander';
import * as utils from './utils';

Expand Down Expand Up @@ -35,6 +34,60 @@ export async function init(initArgs: InitArgs = DEFAULT_ARGS) {
fs.writeFileSync(process.env.ENV_FILE!, envFileContent);
await announced(`Initializing in ${validiumMode ? 'Validium mode' : 'Roll-up mode'}`);

const chainPath = 'etc/env/base/chain.toml';
const newParams = {
pubdata_overhead_part: validiumMode ? 0.0 : 1.0,
batch_overhead_l1_gas: validiumMode ? 1000000 : 800000,
max_pubdata_per_batch: validiumMode ? 1000000000000 : 100000
};

let chainContent = fs.readFileSync(chainPath, 'utf-8');
const lines = chainContent.split('\n');

for (let i = 0; i < lines.length; i++) {
const line = lines[i];
for (const [key, value] of Object.entries(newParams)) {
if (line.includes(`${key}=`)) {
lines[i] = `${key}=${value}`;
break;
}
}
}
chainContent = lines.join('\n');
fs.writeFileSync(chainPath, chainContent);

console.log(`The parameters have been updated in the ${chainPath} file.`);

const ethSenderPath = 'etc/env/base/eth_sender.toml';
const enforcedGasPrice = 'internal_enforced_l1_gas_price';
const newValue = 45_000_000_000;

let ethSenderToml = fs.readFileSync(ethSenderPath, 'utf-8');

const linesEthSender = ethSenderToml.split('\n');
let found = false;

for (let i = 0; i < linesEthSender.length; i++) {
const line = linesEthSender[i];
if (line.includes(`${enforcedGasPrice}=`)) {
linesEthSender[i] = validiumMode ? `${enforcedGasPrice}=${newValue}` : '';
found = true;
break;
}
}

if (!found) {
if (validiumMode) {
linesEthSender.push(`${enforcedGasPrice}=${newValue}`);
}
}

ethSenderToml = linesEthSender.join('\n');

fs.writeFileSync(ethSenderPath, ethSenderToml);

console.log(`The parameter "${enforcedGasPrice}" has been updated in the TOML file.`);

if (!process.env.CI && !skipEnvSetup) {
await announced('Pulling images', docker.pull());
await announced('Checking environment', checkEnv());
Expand Down

0 comments on commit 872c566

Please sign in to comment.