Skip to content

Commit

Permalink
feat: fix spelling in dev comments in core/lib/multivm - continued (#…
Browse files Browse the repository at this point in the history
…682)

**Series of PRs: This is a part in a series of PRs aimed at enhancing
spelling accuracy in this repository. See:**

- [ ] #681
- [ ] #683
- [ ] #684
- [ ] #685

Once merged, a final PR will enable the `dev_comments: true` in the
cargo-spellcheck config file.

## What ❔

<!-- What are the changes this PR brings about? -->
<!-- Example: This PR adds a PR template to the repo. -->
<!-- (For bigger PRs adding more context is appreciated) -->
- **Spelling Corrections in `core/lib/multivm`:** This PR focuses on
rectifying spelling errors in the developer comments within the
`core/lib/multivm` directory.
- Updates dictionary

## Why ❔

<!-- Why are these changes done? What goal do they contribute to? What
are the principles behind them? -->
<!-- Example: PR templates ensure PR reviewers, observers, and future
iterators are in context about the evolution of repos. -->
- **Enhancing Code Quality:** The `core/lib/multivm` directory currently
has several spelling mistakes in the developer comments. Correcting
these errors will enhance the readability and overall quality of our
code documentation.

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [x] 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.
- [x] Code has been formatted via `zk fmt` and `zk lint`.
- [x] Spellcheck has been run via `cargo spellcheck
--cfg=./spellcheck/era.cfg --code 1`.

---------

Co-authored-by: Fedor Sakharov <[email protected]>
  • Loading branch information
dutterbutter and montekki authored Jan 5, 2024
1 parent c4a86bb commit 3839d39
Show file tree
Hide file tree
Showing 129 changed files with 1,632 additions and 1,331 deletions.
2 changes: 1 addition & 1 deletion core/lib/multivm/src/glue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub trait GlueInto<T>: Sized {
fn glue_into(self) -> T;
}

// Blaknet `GlueInto` impl for any type that implements `GlueFrom`.
// Blanket `GlueInto` impl for any type that implements `GlueFrom`.
impl<T, U> GlueInto<U> for T
where
U: GlueFrom<T>,
Expand Down
8 changes: 4 additions & 4 deletions core/lib/multivm/src/glue/types/vm/tx_execution_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ impl GlueFrom<crate::interface::TxExecutionMode>
match value {
crate::interface::TxExecutionMode::VerifyExecute => Self::VerifyExecute,
crate::interface::TxExecutionMode::EstimateFee => Self::EstimateFee {
// We used it only for api services we don't have limit for storage invocation inside statekeeper
// We used it only for API services we don't have limit for storage invocation inside statekeeper
// It's impossible to recover this value for the vm integration after virtual blocks
missed_storage_invocation_limit: usize::MAX,
},
crate::interface::TxExecutionMode::EthCall => Self::EthCall {
// We used it only for api services we don't have limit for storage invocation inside statekeeper
// We used it only for API services we don't have limit for storage invocation inside statekeeper
// It's impossible to recover this value for the vm integration after virtual blocks
missed_storage_invocation_limit: usize::MAX,
},
Expand All @@ -39,12 +39,12 @@ impl GlueFrom<crate::interface::TxExecutionMode>
match value {
crate::interface::TxExecutionMode::VerifyExecute => Self::VerifyExecute,
crate::interface::TxExecutionMode::EstimateFee => Self::EstimateFee {
// We used it only for api services we don't have limit for storage invocation inside statekeeper
// We used it only for API services we don't have limit for storage invocation inside statekeeper
// It's impossible to recover this value for the vm integration after virtual blocks
missed_storage_invocation_limit: usize::MAX,
},
crate::interface::TxExecutionMode::EthCall => Self::EthCall {
// We used it only for api services we don't have limit for storage invocation inside statekeeper
// We used it only for API services we don't have limit for storage invocation inside statekeeper
// It's impossible to recover this value for the vm integration after virtual blocks
missed_storage_invocation_limit: usize::MAX,
},
Expand Down
2 changes: 1 addition & 1 deletion core/lib/multivm/src/glue/types/vm/vm_block_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
},
};

// Note: In version after vm VmVirtualBlocks the bootloader memory knowledge is encapsulated into the VM.
// Note: In version after vm `VmVirtualBlocks` the bootloader memory knowledge is encapsulated into the VM.
// But before it was a part of a public API.
// Bootloader memory required only for producing witnesses,
// and server doesn't need to generate witnesses for old blocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ impl GlueFrom<crate::vm_m5::vm_instance::VmPartialExecutionResult>
contracts_used: value.contracts_used,
cycles_used: value.cycles_used,
total_log_queries: value.logs.total_log_queries_count,
// There are no such fields in m5
// There are no such fields in `m5`
gas_used: 0,
// There are no such fields in m5
// There are no such fields in `m5`
computational_gas_used: 0,
pubdata_published: 0,
estimated_circuits_used: 0.0,
Expand Down
4 changes: 2 additions & 2 deletions core/lib/multivm/src/interface/types/errors/halt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::VmRevertReason;
/// Differentiates VM-specific issues from contract-related errors.
#[derive(Debug, Clone, PartialEq)]
pub enum Halt {
// Can only be returned in VerifyAndExecute
// Can only be returned in `VerifyAndExecute`
ValidationFailed(VmRevertReason),
PaymasterValidationFailed(VmRevertReason),
PrePaymasterPreparationFailed(VmRevertReason),
Expand All @@ -16,7 +16,7 @@ pub enum Halt {
FailedToChargeFee(VmRevertReason),
// Emitted when trying to call a transaction from an account that has not
// been deployed as an account (i.e. the `from` is just a contract).
// Can only be returned in VerifyAndExecute
// Can only be returned in `VerifyAndExecute`
FromIsNotAnAccount,
// Currently cannot be returned. Should be removed when refactoring errors.
InnerTxError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl TxRevertReason {
BootloaderErrorCode::UnacceptablePubdataPrice => {
Self::Halt(Halt::UnexpectedVMBehavior("UnacceptablePubdataPrice".to_owned()))
}
// This is different from AccountTxValidationFailed error in a way that it means that
// This is different from `AccountTxValidationFailed` error in a way that it means that
// the error was not produced by the account itself, but for some other unknown reason (most likely not enough gas)
BootloaderErrorCode::TxValidationError => Self::Halt(Halt::ValidationFailed(revert_reason)),
// Note, that `InnerTxError` is derived only after the actual tx execution, so
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl VmRevertReason {

pub fn to_user_friendly_string(&self) -> String {
match self {
// In case of `Unknown` reason we suppress it to prevent verbose Error function_selector = 0x{}
// In case of `Unknown` reason we suppress it to prevent verbose `Error function_selector = 0x{}`
// message shown to user.
VmRevertReason::Unknown { .. } => "".to_owned(),
_ => self.to_string(),
Expand Down
1 change: 0 additions & 1 deletion core/lib/multivm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// #![deny(unreachable_pub)]
#![deny(unused_crate_dependencies)]
#![warn(unused_extern_crates)]
#![warn(unused_imports)]
Expand Down
2 changes: 1 addition & 1 deletion core/lib/multivm/src/tracers/call_tracer/vm_latest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,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 @@ -140,7 +140,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 @@ -138,7 +138,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
12 changes: 6 additions & 6 deletions core/lib/multivm/src/tracers/validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<H> ValidationTracer<H> {
return true;
}

// The pair of MSG_VALUE_SIMULATOR_ADDRESS & L2_ETH_TOKEN_ADDRESS simulates the behavior of transferring ETH
// The pair of `MSG_VALUE_SIMULATOR_ADDRESS` & `L2_ETH_TOKEN_ADDRESS` simulates the behavior of transferring ETH
// that is safe for the DDoS protection rules.
if valid_eth_token_call(address, msg_sender) {
return true;
Expand Down Expand Up @@ -146,11 +146,11 @@ impl<H> ValidationTracer<H> {
let (potential_address_bytes, potential_position_bytes) = calldata.split_at(32);
let potential_address = be_bytes_to_safe_address(potential_address_bytes);

// If the validation_address is equal to the potential_address,
// then it is a request that could be used for mapping of kind mapping(address => ...).
// If the `validation_address` is equal to the `potential_address`,
// then it is a request that could be used for mapping of kind `mapping(address => ...).`
//
// If the potential_position_bytes were already allowed before, then this keccak might be used
// for ERC-20 allowance or any other of mapping(address => mapping(...))
// If the `potential_position_bytes` were already allowed before, then this keccak might be used
// for ERC-20 allowance or any other of `mapping(address => mapping(...))`
if potential_address == Some(validated_address)
|| self
.auxilary_allowed_slots
Expand Down Expand Up @@ -188,7 +188,7 @@ fn touches_allowed_context(address: Address, key: U256) -> bool {
return false;
}

// Only chain_id is allowed to be touched.
// Only `chain_id` is allowed to be touched.
key == U256::from(0u32)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use super::{BootloaderErrorCode, VmRevertReason};
// Reasons why the transaction executed inside the bootloader could fail.
#[derive(Debug, Clone, PartialEq)]
pub enum TxRevertReason {
// Can only be returned in EthCall execution mode (=ExecuteOnly)
// Can only be returned in EthCall execution mode `(=ExecuteOnly)`
EthCall(VmRevertReason),
// Returned when the execution of an L2 transaction has failed
TxReverted(VmRevertReason),
// Can only be returned in VerifyAndExecute
// Can only be returned in `VerifyAndExecute`
ValidationFailed(VmRevertReason),
PaymasterValidationFailed(VmRevertReason),
PrePaymasterPreparationFailed(VmRevertReason),
Expand All @@ -20,7 +20,7 @@ pub enum TxRevertReason {
FailedToChargeFee(VmRevertReason),
// Emitted when trying to call a transaction from an account that has not
// been deployed as an account (i.e. the `from` is just a contract).
// Can only be returned in VerifyAndExecute
// Can only be returned in `VerifyAndExecute`
FromIsNotAnAccount,
// Currently cannot be returned. Should be removed when refactoring errors.
InnerTxError,
Expand Down Expand Up @@ -101,7 +101,7 @@ impl TxRevertReason {
BootloaderErrorCode::UnacceptablePubdataPrice => {
Self::UnexpectedVMBehavior("UnacceptablePubdataPrice".to_owned())
}
// This is different from AccountTxValidationFailed error in a way that it means that
// This is different from `AccountTxValidationFailed` error in a way that it means that
// the error was not produced by the account itself, but for some other unknown reason (most likely not enough gas)
BootloaderErrorCode::TxValidationError => Self::ValidationFailed(revert_reason),
// Note, that `InnerTxError` is derived only after the actual tx execution, so
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl VmRevertReason {

pub fn to_user_friendly_string(&self) -> String {
match self {
// In case of `Unknown` reason we suppress it to prevent verbose Error function_selector = 0x{}
// In case of `Unknown` reason we suppress it to prevent verbose `Error function_selector = 0x{}`
// message shown to user.
VmRevertReason::Unknown { .. } => "".to_owned(),
_ => self.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion core/lib/multivm/src/versions/vm_1_3_2/event_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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
4 changes: 2 additions & 2 deletions core/lib/multivm/src/versions/vm_1_3_2/history_recorder.rs
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 type MemoryWithHistory<H> = HistoryRecorder<MemoryWrapper, H>;
pub 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
6 changes: 3 additions & 3 deletions core/lib/multivm/src/versions/vm_1_3_2/memory.rs
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 @@ -15,7 +15,7 @@ use crate::vm_1_3_2::history_recorder::{
HistoryEnabled, HistoryMode, HistoryRecorder, WithHistory,
};

/// The main job of the DecommiterOracle is to implement the DecommittmentProcessor trait - that is
/// The main job of the DecommiterOracle is to implement the DecommitmentProcessor trait - that is
/// used by the VM to 'load' bytecodes into memory.
#[derive(Debug)]
pub struct DecommitterOracle<S, const B: bool, H: HistoryMode> {
Expand Down
4 changes: 2 additions & 2 deletions core/lib/multivm/src/versions/vm_1_3_2/oracles/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use zk_evm_1_3_3::aux_structures::Timestamp;
// All the changes to the events in the DB will be applied after the tx is executed,
// so fow now it is fine.
// so for now it is fine.
pub use zk_evm_1_3_3::reference_impls::event_sink::InMemoryEventSink as EventSinkOracle;
// We will discard RAM as soon as the execution of a tx ends, so
// it is ok for now to use SimpleMemory
// it is ok for now to use `SimpleMemory`
pub use zk_evm_1_3_3::reference_impls::memory::SimpleMemory as RamOracle;
pub use zk_evm_1_3_3::testing::simple_tracer::NoopTracer;

Expand Down
12 changes: 7 additions & 5 deletions core/lib/multivm/src/versions/vm_1_3_2/oracles/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,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 @@ -208,13 +208,14 @@ impl<S: WriteStorage, H: HistoryMode> StorageOracle<S, H> {
}

impl<S: WriteStorage, H: HistoryMode> VmStorageOracle for StorageOracle<S, H> {
// Perform a storage read/write access by taking an partially filled query
// Perform a storage read / write access by taking an partially filled query
// and returning filled query and cold/warm marker for pricing purposes
fn execute_partial_query(
&mut self,
_monotonic_cycle_counter: u32,
query: LogQuery,
) -> LogQuery {
// ```
// tracing::trace!(
// "execute partial query cyc {:?} addr {:?} key {:?}, rw {:?}, wr {:?}, tx {:?}",
// _monotonic_cycle_counter,
Expand All @@ -224,6 +225,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 @@ -303,7 +305,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 @@ -317,8 +319,8 @@ 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, new_value>).
// While new_value is always 32 bytes long, for key we use the following optimization:
// we basically need to publish the following pair: `(<storage_key, new_value>)`.
// While `new_value` is always 32 bytes long, 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.
// - The second time we publish it, we will use this 8-byte instead of the 32 bytes of the entire key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<H: HistoryMode> PubdataSpentTracer<H> for BootloaderTracer<H> {

impl<H: HistoryMode> BootloaderTracer<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
Loading

0 comments on commit 3839d39

Please sign in to comment.