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: address remaining spelling issues in dev comments and turns on dev_comments in cfg #827

Merged
merged 2 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion core/bin/block_reverter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum Command {
#[arg(long)]
l1_batch_number: u32,
/// Priority fee used for rollback Ethereum transaction.
// We operate only by priority fee because we want to use base fee from ethereum
// We operate only by priority fee because we want to use base fee from Ethereum
// and send transaction as soon as possible without any resend logic
#[arg(long)]
priority_fee_per_gas: Option<u64>,
Expand Down
2 changes: 1 addition & 1 deletion core/bin/contract-verifier/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ async fn main() -> anyhow::Result<()> {

let contract_verifier = ContractVerifier::new(verifier_config, pool);
let tasks = vec![
// todo PLA-335: Leftovers after the prover DB split.
// TODO PLA-335: Leftovers after the prover DB split.
// The prover connection pool is not used by the contract verifier, but we need to pass it
// since `JobProcessor` trait requires it.
tokio::spawn(contract_verifier.run(stop_receiver.clone(), opt.jobs_number)),
Expand Down
2 changes: 1 addition & 1 deletion core/bin/external_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ impl ExternalNodeConfig {
.context("Unable to fetch required config values from the main node")?;

// We can query them from main node, but it's better to set them explicitly
// as well to avoid connecting to wrong envs unintentionally.
// as well to avoid connecting to wrong environment variables unintentionally.
let eth_chain_id = HttpClientBuilder::default()
.build(required.eth_client_url()?)
.expect("Unable to build HTTP client for L1 client")
Expand Down
6 changes: 3 additions & 3 deletions core/bin/system-constants-generator/src/intrinsic_costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub(crate) fn l2_gas_constants() -> IntrinsicSystemGasConstants {
true,
);

// This price does not include the overhead for the transaction itself, but rather auxilary parts
// This price does not include the overhead for the transaction itself, but rather auxiliary parts
// that must be done by the transaction and it can not be enforced by the operator to not to accept
// the transaction if it does not cover the minimal costs.
let min_l1_tx_price = empty_l1_tx_result.gas_consumed - bootloader_intrinsic_gas;
Expand All @@ -107,7 +107,7 @@ pub(crate) fn l2_gas_constants() -> IntrinsicSystemGasConstants {

let delta_from_544_bytes = lengthier_tx_result.gas_consumed - empty_l1_tx_result.gas_consumed;

// The number of public data per factory dep should not depend on the size/structure of the factory
// The number of public data per factory dependencies should not depend on the size/structure of the factory
// dependency, since the dependency has already been published on L1.
let tx_with_more_factory_deps_result = execute_user_txs_in_test_gas_vm(
vec![get_l1_tx(
Expand Down Expand Up @@ -180,7 +180,7 @@ fn get_intrinsic_overheads_for_tx_type(tx_generator: &TransactionGenerator) -> I
let bootloader_intrinsic_pubdata = result_0.pubdata_published;

// For various small reasons the overhead for the first transaction and for all the subsequent ones
// might differ a bit, so we will calculate both and will use the maximum one as the result for l2 txs.
// might differ a bit, so we will calculate both and will use the maximum one as the result for L2 txs.

let (tx1_intrinsic_gas, tx1_intrinsic_pubdata) = get_intrinsic_price(result_0, result_1);
let (tx2_intrinsic_gas, tx2_intrinsic_pubdata) = get_intrinsic_price(result_1, result_2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl CallTracer {
let fat_data_pointer =
state.vm_local_state.registers[RET_IMPLICIT_RETURNDATA_PARAMS_REGISTER as usize];

// if fat_data_pointer is not a pointer then there is no output
// if `fat_data_pointer` is not a pointer then there is no output
let output = if fat_data_pointer.is_pointer {
let fat_data_pointer = FatPointer::from_u256(fat_data_pointer.value);
if !fat_data_pointer.is_trivial() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) struct BootloaderL2Block {
pub(crate) timestamp: u64,
pub(crate) txs_rolling_hash: H256, // The rolling hash of all the transactions in the miniblock
pub(crate) prev_block_hash: H256,
// Number of the first l2 block tx in l1 batch
// Number of the first L2 block tx in L1 batch
pub(crate) first_tx_index: usize,
pub(crate) max_virtual_blocks_to_create: u32,
pub(super) txs: Vec<BootloaderTx>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl BootloaderState {

pub(crate) fn set_refund_for_current_tx(&mut self, refund: u32) {
let current_tx = self.current_tx();
// We can't set the refund for the latest tx or using the latest l2_block for fining tx
// We can't set the refund for the latest tx or using the latest `l2_block` for fining tx
// Because we can fill the whole batch first and then execute txs one by one
let tx = self.find_tx_mut(current_tx);
tx.refund = refund;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub(super) fn apply_tx_to_memory(
};
apply_l2_block(memory, &bootloader_l2_block, tx_index);

// Note, +1 is moving for pointer
// Note, `+1` is moving for pointer
let compressed_bytecodes_offset = COMPRESSED_BYTECODES_OFFSET + 1 + compressed_bytecodes_size;

let encoded_compressed_bytecodes =
Expand All @@ -94,8 +94,8 @@ pub(crate) fn apply_l2_block(
bootloader_l2_block: &BootloaderL2Block,
txs_index: usize,
) {
// Since L2 block infos start from the TX_OPERATOR_L2_BLOCK_INFO_OFFSET and each
// L2 block info takes TX_OPERATOR_SLOTS_PER_L2_BLOCK_INFO slots, the position where the L2 block info
// Since L2 block information starts from the `TX_OPERATOR_L2_BLOCK_INFO_OFFSET` and each
// L2 block info takes `TX_OPERATOR_SLOTS_PER_L2_BLOCK_INFO slots`, the position where the L2 block info
// for this transaction needs to be written is:

let block_position =
Expand All @@ -120,12 +120,12 @@ pub(crate) fn apply_pubdata_to_memory(
pubdata_information: PubdataInput,
) {
// Skipping two slots as they will be filled by the bootloader itself:
// - One slot is for the selector of the call to the L1Messenger.
// - One slot is for the selector of the call to the `L1Messenger`.
// - The other slot is for the 0x20 offset for the calldata.
let l1_messenger_pubdata_start_slot = OPERATOR_PROVIDED_L1_MESSENGER_PUBDATA_OFFSET + 2;

// Need to skip first word as it represents array offset
// while bootloader expects only [len || data]
// while bootloader expects only `[len || data]`
let pubdata = ethabi::encode(&[ethabi::Token::Bytes(
pubdata_information.build_pubdata(true),
)])[32..]
Expand Down Expand Up @@ -156,8 +156,8 @@ pub(crate) fn apply_pubdata_to_memory(
/// For example, when checking validity, we don't want to actually execute transaction and have side effects.
///
/// Possible values:
/// - 0x00: validate & execute (normal mode)
/// - 0x02: execute but DO NOT validate
/// - `0x00`: validate & execute (normal mode)
/// - `0x02`: execute but DO NOT validate
///
/// - 31 byte (LSB): whether to execute transaction or not (at all).
pub(super) fn assemble_tx_meta(execution_mode: TxExecutionMode, execute_tx: bool) -> U256 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ impl<S: WriteStorage> Vm<S, crate::vm_latest::HistoryEnabled> {
pub(crate) fn make_snapshot_inner(&mut self) {
self.snapshots.push(VmSnapshot {
// Vm local state contains O(1) various parameters (registers/etc).
// The only "expensive" copying here is copying of the callstack.
// It will take O(callstack_depth) to copy it.
// The only "expensive" copying here is copying of the call stack.
// It will take `O(callstack_depth)` to copy it.
// So it is generally recommended to get snapshots of the bootloader frame,
// where the depth is 1.
local_state: self.state.local_state.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<H: HistoryMode> InMemoryEventSink<H> {
pub fn log_queries_after_timestamp(&self, from_timestamp: Timestamp) -> &[Box<LogQuery>] {
let events = self.frames_stack.forward().current_frame();

// Select all of the last elements where e.timestamp >= from_timestamp.
// Select all of the last elements where `e.timestamp >= from_timestamp`.
// Note, that using binary search here is dangerous, because the logs are not sorted by timestamp.
events
.rsplit(|e| e.timestamp < from_timestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ use zksync_utils::{h256_to_u256, u256_to_h256};
pub(crate) type MemoryWithHistory<H> = HistoryRecorder<MemoryWrapper, H>;
pub(crate) type IntFrameManagerWithHistory<T, H> = HistoryRecorder<FramedStack<T>, H>;

// Within the same cycle, timestamps in range timestamp..timestamp+TIME_DELTA_PER_CYCLE-1
// Within the same cycle, timestamps in range `timestamp..timestamp+TIME_DELTA_PER_CYCLE-1`
// can be used. This can sometimes violate monotonicity of the timestamp within the
// same cycle, so it should be normalized.
#[inline]
fn normalize_timestamp(timestamp: Timestamp) -> Timestamp {
let timestamp = timestamp.0;

// Making sure it is divisible by TIME_DELTA_PER_CYCLE
// Making sure it is divisible by `TIME_DELTA_PER_CYCLE`
Timestamp(timestamp - timestamp % zkevm_opcode_defs::TIME_DELTA_PER_CYCLE)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl<H: HistoryMode> Memory for SimpleMemory<H> {
let returndata_page = returndata_fat_pointer.memory_page;

for &page in current_observable_pages {
// If the page's number is greater than or equal to the base_page,
// If the page's number is greater than or equal to the `base_page`,
// it means that it was created by the internal calls of this contract.
// We need to add this check as the calldata pointer is also part of the
// observable pages.
Expand All @@ -299,15 +299,15 @@ impl<H: HistoryMode> Memory for SimpleMemory<H> {
}
}

// It is expected that there is some intersection between [word_number*32..word_number*32+31] and [start, end]
// It is expected that there is some intersection between `[word_number*32..word_number*32+31]` and `[start, end]`
fn extract_needed_bytes_from_word(
word_value: Vec<u8>,
word_number: usize,
start: usize,
end: usize,
) -> Vec<u8> {
let word_start = word_number * 32;
let word_end = word_start + 31; // Note, that at word_start + 32 a new word already starts
let word_end = word_start + 31; // Note, that at `word_start + 32` a new word already starts

let intersection_left = std::cmp::max(word_start, start);
let intersection_right = std::cmp::min(word_end, end);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,6 @@ impl<H: HistoryMode> PrecompilesProcessor for PrecompilesProcessorWithHistory<H>
}

fn finish_frame(&mut self, _panicked: bool) {
// there are no revertable precompile yes, so we are ok
// there are no revertible precompile yes, so we are ok
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub(crate) fn vm_may_have_ended_inner<S: WriteStorage, H: HistoryMode>(
}
(false, _) => None,
(true, l) if l == outer_eh_location => {
// check r1,r2,r3
// check `r1,r2,r3`
if vm.local_state.flags.overflow_or_less_than_flag {
Some(VmExecutionResult::Panic)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct StorageOracle<S: WriteStorage, H: HistoryMode> {
pub(crate) paid_changes: HistoryRecorder<HashMap<StorageKey, u32>, H>,

// The map that contains all the first values read from storage for each slot.
// While formally it does not have to be rollbackable, we still do it to avoid memory bloat
// While formally it does not have to be rolled back, we still do it to avoid memory bloat
// for unused slots.
pub(crate) initial_values: HistoryRecorder<HashMap<StorageKey, U256>, H>,

Expand Down Expand Up @@ -212,7 +212,7 @@ impl<S: WriteStorage, H: HistoryMode> StorageOracle<S, H> {
let required_pubdata =
self.base_price_for_write(&key, first_slot_value, current_slot_value);

// We assume that "prepaid_for_slot" represents both the number of pubdata published and the number of bytes paid by the previous transactions
// We assume that `prepaid_for_slot` represents both the number of pubdata published and the number of bytes paid by the previous transactions
// as they should be identical.
let prepaid_for_slot = self
.pre_paid_changes
Expand Down Expand Up @@ -292,7 +292,7 @@ impl<S: WriteStorage, H: HistoryMode> StorageOracle<S, H> {
) -> &[Box<StorageLogQuery>] {
let logs = self.frames_stack.forward().current_frame();

// Select all of the last elements where l.log_query.timestamp >= from_timestamp.
// Select all of the last elements where `l.log_query.timestamp >= from_timestamp`.
// Note, that using binary search here is dangerous, because the logs are not sorted by timestamp.
logs.rsplit(|l| l.log_query.timestamp < from_timestamp)
.next()
Expand Down Expand Up @@ -340,6 +340,7 @@ impl<S: WriteStorage, H: HistoryMode> VmStorageOracle for StorageOracle<S, H> {
_monotonic_cycle_counter: u32,
mut query: LogQuery,
) -> LogQuery {
//```
// tracing::trace!(
// "execute partial query cyc {:?} addr {:?} key {:?}, rw {:?}, wr {:?}, tx {:?}",
// _monotonic_cycle_counter,
Expand All @@ -349,6 +350,7 @@ impl<S: WriteStorage, H: HistoryMode> VmStorageOracle for StorageOracle<S, H> {
// query.written_value,
// query.tx_number_in_block
// );
//```
assert!(!query.rollback);
if query.rw_flag {
// The number of bytes that have been compensated by the user to perform this write
Expand Down Expand Up @@ -443,7 +445,7 @@ impl<S: WriteStorage, H: HistoryMode> VmStorageOracle for StorageOracle<S, H> {
);

// Additional validation that the current value was correct
// Unwrap is safe because the return value from write_inner is the previous value in this leaf.
// Unwrap is safe because the return value from `write_inner` is the previous value in this leaf.
// It is impossible to set leaf value to `None`
assert_eq!(current_value, written_value);
}
Expand All @@ -457,7 +459,7 @@ impl<S: WriteStorage, H: HistoryMode> VmStorageOracle for StorageOracle<S, H> {

/// Returns the number of bytes needed to publish a slot.
// Since we need to publish the state diffs onchain, for each of the updated storage slot
// we basically need to publish the following pair: (<storage_key, compressed_new_value>).
// we basically need to publish the following pair: `(<storage_key, compressed_new_value>)`.
// For key we use the following optimization:
// - The first time we publish it, we use 32 bytes.
// Then, we remember a 8-byte id for this slot and assign it to it. We call this initial write.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub(crate) const AVERAGE_OPCODE_FRACTION: f32 =
MAIN_VM_CYCLE_FRACTION + RAM_PERMUTATION_CYCLE_FRACTION;

// Here "base" fraction is a fraction that will be used unconditionally.
// Usage of StorageApplication is being tracked separately as it depends on whether slot was read before or not.
// Usage of `StorageApplication` is being tracked separately as it depends on whether slot was read before or not.
pub(crate) const STORAGE_READ_BASE_FRACTION: f32 = MAIN_VM_CYCLE_FRACTION
+ RAM_PERMUTATION_CYCLE_FRACTION
+ LOG_DEMUXER_CYCLE_FRACTION
Expand All @@ -59,7 +59,7 @@ pub(crate) const EVENT_OR_L1_MESSAGE_FRACTION: f32 = MAIN_VM_CYCLE_FRACTION
+ 2.0 * EVENTS_OR_L1_MESSAGES_SORTER_CYCLE_FRACTION;

// Here "base" fraction is a fraction that will be used unconditionally.
// Usage of StorageApplication is being tracked separately as it depends on whether slot was written before or not.
// Usage of `StorageApplication` is being tracked separately as it depends on whether slot was written before or not.
pub(crate) const STORAGE_WRITE_BASE_FRACTION: f32 = MAIN_VM_CYCLE_FRACTION
+ RAM_PERMUTATION_CYCLE_FRACTION
+ 2.0 * LOG_DEMUXER_CYCLE_FRACTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub(crate) struct DefaultExecutionTracer<S: WriteStorage, H: HistoryMode> {
pub(crate) result_tracer: ResultTracer<S>,
// This tracer is designed specifically for calculating refunds. Its separation from the custom tracer
// ensures static dispatch, enhancing performance by avoiding dynamic dispatch overhead.
// Additionally, being an internal tracer, it saves the results directly to VmResultAndLogs.
// Additionally, being an internal tracer, it saves the results directly to `VmResultAndLogs`.
pub(crate) refund_tracer: Option<RefundsTracer<S>>,
// The pubdata tracer is responsible for inserting the pubdata packing information into the bootloader
// memory at the end of the batch. Its separation from the custom tracer
Expand Down Expand Up @@ -298,7 +298,7 @@ impl<S: WriteStorage, H: HistoryMode> DefaultExecutionTracer<S, H> {
}

fn current_frame_is_bootloader(local_state: &VmLocalState) -> bool {
// The current frame is bootloader if the callstack depth is 1.
// The current frame is bootloader if the call stack depth is 1.
// Some of the near calls inside the bootloader can be out of gas, which is totally normal behavior
// and it shouldn't result in `is_bootloader_out_of_gas` becoming true.
local_state.callstack.inner.len() == 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl<S: WriteStorage> PubdataTracer<S> {

impl<S: WriteStorage> PubdataTracer<S> {
// Packs part of L1 Messenger total pubdata that corresponds to
// L2toL1Logs sent in the block
// `L2toL1Logs` sent in the block
fn get_total_user_logs<H: HistoryMode>(
&self,
state: &ZkSyncVmState<S, H>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ impl<S: WriteStorage, H: HistoryMode> VmTracer<S, H> for RefundsTracer<S> {
#[vise::register]
static METRICS: vise::Global<RefundMetrics> = vise::Global::new();

// This means that the bootloader has informed the system (usually via VMHooks) - that some gas
// should be refunded back (see askOperatorForRefund in bootloader.yul for details).
// This means that the bootloader has informed the system (usually via `VMHooks`) - that some gas
// should be refunded back (see `askOperatorForRefund` in `bootloader.yul` for details).
if let Some(bootloader_refund) = self.requested_refund() {
assert!(
self.operator_refund.is_none(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<S> ResultTracer<S> {
}

fn current_frame_is_bootloader(local_state: &VmLocalState) -> bool {
// The current frame is bootloader if the callstack depth is 1.
// The current frame is bootloader if the call stack depth is 1.
// Some of the near calls inside the bootloader can be out of gas, which is totally normal behavior
// and it shouldn't result in `is_bootloader_out_of_gas` becoming true.
local_state.callstack.inner.len() == 1
Expand Down Expand Up @@ -150,7 +150,7 @@ impl<S: WriteStorage> ResultTracer<S> {
});
}
VmExecutionResult::Revert(output) => {
// Unlike VmHook::ExecutionResult, vm has completely finished and returned not only the revert reason,
// Unlike `VmHook::ExecutionResult`, vm has completely finished and returned not only the revert reason,
// but with bytecode, which represents the type of error from the bootloader side
let revert_reason = TxRevertReason::parse_error(&output);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl VmHook {

let value = data.src1_value.value;

// Only UMA opcodes in the bootloader serve for vm hooks
// Only `UMA` opcodes in the bootloader serve for vm hooks
if !matches!(opcode_variant.opcode, Opcode::UMA(UMAOpcode::HeapWrite))
|| heap_page != BOOTLOADER_HEAP_PAGE
|| fat_ptr.offset != VM_HOOK_POSITION * 32
Expand Down
Loading