diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 063329305e..cbdf4b11bd 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -35,7 +35,7 @@ The target readers could be future developers, reviewers, and auditors. By readi MUST: Reference the issue to resolve -### Single responsability +### Single responsibility Is RECOMMENDED to create single responsibility commits, but not mandatory. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ccc6688c4..4b52074856 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -274,3 +274,19 @@ jobs: run: cargo check --all-features - name: Cargo fmt run: cargo fmt --all -- --check + + typos-check: + needs: [skip_check] + if: | + github.event.pull_request.draft == false && + (github.event.action == 'ready_for_review' || needs.skip_check.outputs.should_skip != 'true') + name: TyposCheck + timeout-minutes: 5 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: crate-ci/typos@v1.22.7 + with: + config: ./typos.toml + isolated: true + diff --git a/Makefile b/Makefile index 74fe722647..47883bc0c3 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ clippy: ## Run clippy checks over all workspace members doc: ## Generate and tests docs including private items @cargo doc --no-deps --all --document-private-items -fmt: ## Check whether the code is formated correctly +fmt: ## Check whether the code is formatted correctly @cargo check --all-features @cargo fmt --all -- --check diff --git a/README.md b/README.md index 5f778ae51d..3363095706 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This is the zkEVM circuits used in Scroll Mainnet. It was forked from PSE zkevm- 2. RLP circuit / MPT circuit / Poseidon circuit 3. multi block chunking 4. proof aggregation -5. [>99.5% compatiblity](https://circuit-release.s3.us-west-2.amazonaws.com/testool/nightly.1695216104.47e2015.html) with [official EVM test vector](https://github.com/ethereum/tests) +5. [>99.5% compatibility](https://circuit-release.s3.us-west-2.amazonaws.com/testool/nightly.1695216104.47e2015.html) with [official EVM test vector](https://github.com/ethereum/tests) 6. Many optimizations like read/write memory in word instead of byte ## Docs diff --git a/aggregator/src/aggregation/decoder.rs b/aggregator/src/aggregation/decoder.rs index 6d1aed584d..fdf99153e9 100644 --- a/aggregator/src/aggregation/decoder.rs +++ b/aggregator/src/aggregation/decoder.rs @@ -5590,7 +5590,7 @@ mod tests { .set_pledged_src_size(Some(raw.len() as u64)) .expect("Encoder src_size: raw.len()"); - encoder.write_all(&raw).expect("Encoder wirte_all"); + encoder.write_all(&raw).expect("Encoder write_all"); encoder.finish().expect("Encoder success") }; @@ -5626,7 +5626,7 @@ mod tests { .expect("Encoder src_size: raw.len()"); // include the content size to know at decode time the expected size of decoded data. - encoder.write_all(&raw).expect("Encoder wirte_all"); + encoder.write_all(&raw).expect("Encoder write_all"); encoder.finish().expect("Encoder success") }; @@ -5672,7 +5672,7 @@ mod tests { .set_pledged_src_size(Some(batch_data.len() as u64)) .expect("Encoder src_size: raw.len()"); - encoder.write_all(&batch_data).expect("Encoder wirte_all"); + encoder.write_all(&batch_data).expect("Encoder write_all"); encoder.finish().expect("Encoder success") }; @@ -5716,7 +5716,7 @@ mod tests { .set_pledged_src_size(Some(raw.len() as u64)) .expect("Encoder src_size: raw.len()"); - encoder.write_all(&raw).expect("Encoder wirte_all"); + encoder.write_all(&raw).expect("Encoder write_all"); encoder.finish().expect("Encoder success") }; @@ -5759,7 +5759,7 @@ mod tests { encoder .write_all(&multi_batch_data) - .expect("Encoder wirte_all"); + .expect("Encoder write_all"); encoder.finish().expect("Encoder success") }; diff --git a/aggregator/src/aggregation/decoder/seq_exec.rs b/aggregator/src/aggregation/decoder/seq_exec.rs index d5248712ac..5a470dc20a 100644 --- a/aggregator/src/aggregation/decoder/seq_exec.rs +++ b/aggregator/src/aggregation/decoder/seq_exec.rs @@ -293,7 +293,7 @@ type ExportedCell = AssignedCell; impl SeqExecConfig { /// Construct the sequence instruction table - /// the maxium rotation is prev(2), next(1) + /// the maximum rotation is prev(2), next(1) pub fn configure( meta: &mut ConstraintSystem, challenges: Expression, @@ -408,7 +408,7 @@ impl SeqExecConfig { 1.expr() - s_lit_cp_phase_next.expr() - s_back_ref_phase_next.expr(); cb.condition(is_padding.expr(), |cb| { cb.require_equal( - "padding never change once actived", + "padding never change once activated", is_padding_next.expr(), is_padding.expr(), ); @@ -431,7 +431,7 @@ impl SeqExecConfig { ]), |cb| { cb.require_equal( - "phase can only be actived in inst border", + "phase can only be activated in inst border", is_inst_begin.expr(), 1.expr(), ); @@ -445,7 +445,7 @@ impl SeqExecConfig { ]), |cb| { cb.require_equal( - "phase must keep actived until block end", + "phase must keep activated until block end", s_last_lit_cp_phase_prev.expr(), s_last_lit_cp_phase.expr(), ); @@ -454,7 +454,7 @@ impl SeqExecConfig { cb.condition(s_last_lit_cp_phase.expr(), |cb| { cb.require_equal( - "lit cp must actived if last lit cp is actived", + "lit cp must activated if last lit cp is activated", s_lit_cp_phase.expr_at(meta, Rotation::cur()), 1.expr(), ); diff --git a/aggregator/src/aggregation/decoder/tables/bitstring.rs b/aggregator/src/aggregation/decoder/tables/bitstring.rs index e46ffb3f4f..d600588f7f 100644 --- a/aggregator/src/aggregation/decoder/tables/bitstring.rs +++ b/aggregator/src/aggregation/decoder/tables/bitstring.rs @@ -268,7 +268,7 @@ impl BitstringTable { let mut cb = BaseConstraintBuilder::default(); - // Columns that do not change in the chunk of 3 contigious bytes. + // Columns that do not change in the chunk of 3 contiguous bytes. for col in [ config.byte_idx_1, config.byte_idx_2, diff --git a/aggregator/src/aggregation/decoder/tables/fse.rs b/aggregator/src/aggregation/decoder/tables/fse.rs index f6dba39e73..aff3ffcee2 100644 --- a/aggregator/src/aggregation/decoder/tables/fse.rs +++ b/aggregator/src/aggregation/decoder/tables/fse.rs @@ -1294,7 +1294,7 @@ impl FseTable { /// Lookup table expressions for (symbol, symbol_count) tuple check. /// - /// This check is only done on the last occurence of a particular symbol, i.e. where: + /// This check is only done on the last occurrence of a particular symbol, i.e. where: /// - symbol_count == symbol_count_acc pub fn table_exprs_by_symbol(&self, meta: &mut VirtualCells) -> Vec> { vec![ @@ -1762,7 +1762,7 @@ impl FseSortedStatesTable { // - smallest_spot does not change // - last_baseline does not change // - symbol_count_acc increments by +1 - // - spot_acc accumlates based on the current spot + // - spot_acc accumulates based on the current spot // - baseline_mark can transition from 0 -> 1 only once // - baseline==0x00 if baseline_mark is set // - baseline==baseline::prev+spot::prev if baseline_mark is not set diff --git a/aggregator/src/aggregation/decoder/tables/seqinst_table.rs b/aggregator/src/aggregation/decoder/tables/seqinst_table.rs index bf567e9195..fdd1418c12 100644 --- a/aggregator/src/aggregation/decoder/tables/seqinst_table.rs +++ b/aggregator/src/aggregation/decoder/tables/seqinst_table.rs @@ -186,7 +186,7 @@ impl ChipContext { impl SeqInstTable { /// The sequence count should be lookuped by parsed bitstream, - /// used the block index and value for sequnce count tag to + /// used the block index and value for sequence count tag to /// lookup (`true`, `block_index`, 1, `value`) /// The table would be padded by increased block index to /// fill all rows being enabled @@ -247,7 +247,7 @@ impl SeqInstTable { } /// Construct the sequence instruction table - /// the maxium rotation is prev(1), next(1) + /// the maximum rotation is prev(1), next(1) pub fn configure(meta: &mut ConstraintSystem) -> Self { let q_enabled = meta.fixed_column(); let block_index = meta.advice_column(); @@ -347,7 +347,7 @@ impl SeqInstTable { }); // so, we enforce s_beginning enabled for valid block index - meta.create_gate("border constaints", |meta| { + meta.create_gate("border constraints", |meta| { let mut cb = BaseConstraintBuilder::default(); let s_beginning = s_beginning.expr_at(meta, Rotation::cur()); @@ -492,7 +492,7 @@ impl SeqInstTable { rep_offset_3.expr(), ); }); - // update mode 2 (offset == 2 / offet == 1 while lit_len != 0) + // update mode 2 (offset == 2 / offset == 1 while lit_len != 0) cb.condition(ref_update_mode_2.expr(), |cb| { cb.require_equal( "swap 1&2 for ref 2", @@ -510,7 +510,7 @@ impl SeqInstTable { rep_offset_3.expr(), ); }); - // update mode 3 (offset == 3 / offet == 2 while lit_len != 0) + // update mode 3 (offset == 3 / offset == 2 while lit_len != 0) cb.condition(ref_update_mode_3.expr(), |cb| { cb.require_equal( "rotate 3-1 for ref 3", @@ -554,7 +554,7 @@ impl SeqInstTable { ) }); - // the beginning of following rows must be constrainted + // the beginning of following rows must be constrained meta.enable_equality(block_index); meta.enable_equality(seq_index); meta.enable_equality(rep_offset_1); diff --git a/aggregator/src/aggregation/decoder/witgen/types.rs b/aggregator/src/aggregation/decoder/witgen/types.rs index 9a2acfc0c0..8e7daba86f 100644 --- a/aggregator/src/aggregation/decoder/witgen/types.rs +++ b/aggregator/src/aggregation/decoder/witgen/types.rs @@ -383,7 +383,7 @@ pub struct AddressTableRow { } impl AddressTableRow { - /// a debug helper, input datas in the form of example in + /// a debug helper, input data in the form of example in /// zstd spec: https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#repeat-offsets /// i.e. [offset, literal, rep_1, rep_2, rep_3] #[cfg(test)] diff --git a/aggregator/src/blob.rs b/aggregator/src/blob.rs index 2d99698ca4..55f83efcab 100644 --- a/aggregator/src/blob.rs +++ b/aggregator/src/blob.rs @@ -363,7 +363,7 @@ impl BatchData { // metadata bytes. let bytes = self.to_metadata_bytes(); - // accumulators represent the runnin linear combination of bytes. + // accumulators represent the running linear combination of bytes. let accumulators_iter = self .num_valid_chunks .to_be_bytes() diff --git a/bus-mapping/README.md b/bus-mapping/README.md index 342dbfc21b..c5da5d42fd 100644 --- a/bus-mapping/README.md +++ b/bus-mapping/README.md @@ -158,7 +158,7 @@ On that way, we would get something like this for the Memory ops: | `key` | `val` | `rw` | `gc` | Note | |:------:| ------------- | ------- | ---- | ---------------------------------------- | | `0x40` | `0` | `Write` | | Init | -| `0x40` | `0x80` | `Write` | 0 | Assume written at the begining of `code` | +| `0x40` | `0x80` | `Write` | 0 | Assume written at the beginning of `code`| | `0x40` | `0x80` | `Read` | 4 | `56 MLOAD` | | - | | | | | | `0x80` | `0` | `Write` | | Init | diff --git a/bus-mapping/src/circuit_input_builder/execution.rs b/bus-mapping/src/circuit_input_builder/execution.rs index 7291070ddd..4e022339e8 100644 --- a/bus-mapping/src/circuit_input_builder/execution.rs +++ b/bus-mapping/src/circuit_input_builder/execution.rs @@ -868,7 +868,7 @@ impl From<(Word, Word, Word)> for ExpStep { } } -/// Event representating an exponentiation `a ^ b == d (mod 2^256)`. +/// Event representing an exponentiation `a ^ b == d (mod 2^256)`. #[derive(Clone, Debug)] pub struct ExpEvent { /// Base `a` for the exponentiation. @@ -1428,7 +1428,7 @@ impl EcPairingOp { } } -/// Event representating an exponentiation `a ^ b == d (mod m)` in precompile modexp. +/// Event representing an exponentiation `a ^ b == d (mod m)` in precompile modexp. #[derive(Clone, Debug)] pub struct BigModExp { /// Base `a` for the exponentiation. @@ -1452,7 +1452,7 @@ impl Default for BigModExp { } } -/// Event representating an SHA256 hash in precompile sha256. +/// Event representing an SHA256 hash in precompile sha256. #[derive(Clone, Debug, Default)] pub struct SHA256 { /// input bytes diff --git a/bus-mapping/src/circuit_input_builder/input_state_ref.rs b/bus-mapping/src/circuit_input_builder/input_state_ref.rs index 37c65474f4..dd20af61dd 100644 --- a/bus-mapping/src/circuit_input_builder/input_state_ref.rs +++ b/bus-mapping/src/circuit_input_builder/input_state_ref.rs @@ -2424,7 +2424,7 @@ fn combine_copy_slot_bytes( copy_length: usize, src_data: &[impl Into + Clone], dst_memory: &mut Memory, - is_memory_copy: bool, // indicates memroy --> memory copy(mcopy) type. + is_memory_copy: bool, // indicates memory --> memory copy(mcopy) type. ) -> (MemoryWordRange, MemoryWordRange, Vec) { let mut src_range = MemoryWordRange::align_range(src_addr, copy_length); let mut dst_range = MemoryWordRange::align_range(dst_addr, copy_length); diff --git a/bus-mapping/src/circuit_input_builder/tracer_tests.rs b/bus-mapping/src/circuit_input_builder/tracer_tests.rs index 43b04b431c..5ce0db2a88 100644 --- a/bus-mapping/src/circuit_input_builder/tracer_tests.rs +++ b/bus-mapping/src/circuit_input_builder/tracer_tests.rs @@ -352,7 +352,7 @@ fn tracer_call_success() { #[test] fn tracer_err_address_collision() { - // We do CREATE2 twice with the same parameters, with a code_creater + // We do CREATE2 twice with the same parameters, with a code_creator // that outputs the same, which will lead to the same new // contract address. let code_creator = bytecode! { @@ -480,7 +480,7 @@ fn tracer_err_address_collision() { #[test] fn tracer_create_collision_free() { - // We do CREATE twice with the same parameters, with a code_creater + // We do CREATE twice with the same parameters, with a code_creator // that outputs not the same, which will lead to the different new // contract address. let code_creator = bytecode! { diff --git a/bus-mapping/src/circuit_input_builder/transaction.rs b/bus-mapping/src/circuit_input_builder/transaction.rs index 6e2439c534..56f7b8cb0e 100644 --- a/bus-mapping/src/circuit_input_builder/transaction.rs +++ b/bus-mapping/src/circuit_input_builder/transaction.rs @@ -17,7 +17,7 @@ use ethers_core::utils::get_contract_address; /// Precision of transaction L1 fee pub const TX_L1_FEE_PRECISION: u64 = 1_000_000_000; -/// Extra cost as the bytes of rlped tx commited to L1 (assume to non-zero, overestimated a bit) +/// Extra cost as the bytes of rlped tx committed to L1 (assume to non-zero, overestimated a bit) pub const TX_L1_COMMIT_EXTRA_COST: u64 = 64; #[derive(Debug, Default)] diff --git a/bus-mapping/src/evm/opcodes/begin_end_tx.rs b/bus-mapping/src/evm/opcodes/begin_end_tx.rs index b58846c40a..a8b46b378c 100644 --- a/bus-mapping/src/evm/opcodes/begin_end_tx.rs +++ b/bus-mapping/src/evm/opcodes/begin_end_tx.rs @@ -239,7 +239,7 @@ pub fn gen_begin_tx_steps(state: &mut CircuitInputStateRef) -> Result Opcode for CallOpcode { state.parse_call(geth_step)? } else { // if precheck not ok, the call won't appear in call trace since it never happens - // we need to increase the offset and mannually set the is_success + // we need to increase the offset and manually set the is_success state.tx_ctx.call_is_success_offset += 1; let mut call = state.parse_call_partial(geth_step)?; call.is_success = false; @@ -185,7 +185,7 @@ impl Opcode for CallOpcode { // read balance of caller to compare to value for insufficient_balance checking // in circuit, also use for callcode successful case check balance is // indeed larger than transfer value. for call opcode, it does in - // tranfer gadget implicitly. + // transfer gadget implicitly. state.account_read( &mut exec_step, callee_call.caller_address, diff --git a/bus-mapping/src/evm/opcodes/create.rs b/bus-mapping/src/evm/opcodes/create.rs index 7ab4dfac50..c3204a10cc 100644 --- a/bus-mapping/src/evm/opcodes/create.rs +++ b/bus-mapping/src/evm/opcodes/create.rs @@ -55,7 +55,7 @@ impl Opcode for Create { state.parse_call(geth_step)? } else { // if precheck not ok, the call won't appear in call trace since it never happens - // we need to increase the offset and mannually set the is_success + // we need to increase the offset and manually set the is_success state.tx_ctx.call_is_success_offset += 1; let mut call = state.parse_call_partial(geth_step)?; call.is_success = false; diff --git a/bus-mapping/src/evm/opcodes/error_write_protection.rs b/bus-mapping/src/evm/opcodes/error_write_protection.rs index 85bc2611ba..297895e462 100644 --- a/bus-mapping/src/evm/opcodes/error_write_protection.rs +++ b/bus-mapping/src/evm/opcodes/error_write_protection.rs @@ -45,7 +45,7 @@ impl Opcode for ErrorWriteProtection { .contains(&geth_step.op)); if geth_step.op == OpcodeId::CALL { - // get only the frist three stack elements since the third one is the value we + // get only the first three stack elements since the third one is the value we // want to check. for _i in 0..3 { let _v = state.stack_pop(&mut exec_step)?; diff --git a/bus-mapping/src/lib.rs b/bus-mapping/src/lib.rs index b3df190c71..e7a239ef0d 100644 --- a/bus-mapping/src/lib.rs +++ b/bus-mapping/src/lib.rs @@ -180,7 +180,7 @@ //! | `key` | `val` | `rw` | `gc` | Note | //! |:------:| ------------- | ------- | ---- | ---------------------------------------- | //! | `0x40` | `0` | `Write` | | Init | -//! | `0x40` | `0x80` | `Write` | 0 | Assume written at the begining of `code` | +//! | `0x40` | `0x80` | `Write` | 0 | Assume written at the beginning of `code`| //! | `0x40` | `0x80` | `Read` | 4 | `56 MLOAD` | //! | - | | | | | //! | `0x80` | `0` | `Write` | | Init | diff --git a/bus-mapping/src/mock.rs b/bus-mapping/src/mock.rs index 9133d3570a..57597c5ede 100644 --- a/bus-mapping/src/mock.rs +++ b/bus-mapping/src/mock.rs @@ -21,7 +21,7 @@ pub struct BlockData { /// chain id pub chain_id: u64, /// history hashes contains most recent 256 block hashes in history, where - /// the lastest one is at history_hashes[history_hashes.len() - 1]. + /// the latest one is at history_hashes[history_hashes.len() - 1]. pub history_hashes: Vec, /// Block from geth pub eth_block: eth_types::Block, diff --git a/bus-mapping/src/operation.rs b/bus-mapping/src/operation.rs index 0bbf26b8ec..dcee2cebf0 100644 --- a/bus-mapping/src/operation.rs +++ b/bus-mapping/src/operation.rs @@ -81,7 +81,7 @@ impl RWCounter { } } -/// Enum used to differenciate between EVM Stack, Memory and Storage operations. +/// Enum used to differentiate between EVM Stack, Memory and Storage operations. #[derive(Debug, Clone, PartialEq, Eq, Copy)] pub enum Target { /// Start is a padding operation. diff --git a/bus-mapping/src/operation/container.rs b/bus-mapping/src/operation/container.rs index b4eb3225af..0634acb44e 100644 --- a/bus-mapping/src/operation/container.rs +++ b/bus-mapping/src/operation/container.rs @@ -16,7 +16,7 @@ use itertools::Itertools; /// [`ExecStep`](crate::circuit_input_builder::ExecStep). /// /// Finally, the container also provides the capability of retrieving all of the -/// `Stack`, `Memory` or `Storage` operations ordered according to the criterias +/// `Stack`, `Memory` or `Storage` operations ordered according to the criteria /// they have specified. /// That serves as a way to get an input with which is easy to work with in /// order to construct the State proof. diff --git a/docs/EVM_Circuit.md b/docs/EVM_Circuit.md index 43c3ded33b..6cf8e09563 100644 --- a/docs/EVM_Circuit.md +++ b/docs/EVM_Circuit.md @@ -100,7 +100,7 @@ An API layer `constraint_builder` is developed on top of the backend proof syste - rw_lookup - ... ### split_expression (used to split high degree expression to deg 2) -### store_expression (store those splitted expressions) +### store_expression (store those split expressions) ### build - constraints - curr step constraints diff --git a/docs/MCOPY.md b/docs/MCOPY.md index 6d7accaff7..fa17762819 100644 --- a/docs/MCOPY.md +++ b/docs/MCOPY.md @@ -13,7 +13,7 @@ below describle three parts that implementation involves. ## buss mapping - generates stack read operations to get above mentioned parameters. `dst_offset`, `src_offset`, `length`. - - generates copy event in helper `gen_copy_steps_for_memory_to_memory` because it is a dynamic copy case. the copy steps generating follows all read steps + all wrtie steps pattern while normal existing copy steps follows read step + write step + read step + write step... pattern. this is to avoid copy range overlaps issue(destination copy range overlaps source copy range in the same memory context). copy event's `src_type` and `dst_type` are the same `CopyDataType::Memory`, copy event's `src_id` and `dst_id` are also the same since source and destination copy happens in one call context. + - generates copy event in helper `gen_copy_steps_for_memory_to_memory` because it is a dynamic copy case. the copy steps generating follows all read steps + all write steps pattern while normal existing copy steps follows read step + write step + read step + write step... pattern. this is to avoid copy range overlaps issue(destination copy range overlaps source copy range in the same memory context). copy event's `src_type` and `dst_type` are the same `CopyDataType::Memory`, copy event's `src_id` and `dst_id` are also the same since source and destination copy happens in one call context. - rw_counter of write steps start from half of total memory word count. @@ -34,14 +34,14 @@ below describle three parts that implementation involves. - error cases: - mcopy may encouter the following two error cases: + mcopy may encounter the following two error cases: - stack underflow: - - if stack has less than three element will encounter this error. existing `ErrorStackGadget` gadget handles it. have setted correct stack info for mcopy in helper `valid_stack_ptr_range`, which `ErrorStackGadget` takes use of it to do the constraint. + - if stack has less than three element will encounter this error. existing `ErrorStackGadget` gadget handles it. have set correct stack info for mcopy in helper `valid_stack_ptr_range`, which `ErrorStackGadget` takes use of it to do the constraint. - OOG memory copy: - there are two cases which result in this error: 1) remain gas left is indeed not sufficient. 2) source address(`src_add`) or destination address (`dst_address`) is u64 overflow. - - `ErrorOOGMemoryCopyGadget` gadget is reponsible for memory copy OOG cases, make OOG mcopy also take adantage of this gadget. + - `ErrorOOGMemoryCopyGadget` gadget is responsible for memory copy OOG cases, make OOG mcopy also take adantage of this gadget. - specially for mcopy, besdies existing constraints in `ErrorOOGMemoryCopyGadget` gadget. added source address(`src_add`) overflow case for mcopy in OOG condition constraint. diff --git a/docs/MPT_Circuit.md b/docs/MPT_Circuit.md index 049f83be29..a83fef4785 100644 --- a/docs/MPT_Circuit.md +++ b/docs/MPT_Circuit.md @@ -67,8 +67,8 @@ stateDiagram Claim --> Proof SMTTrace --> address_hash_traces address_hash_traces --> Proof - SMTTrace --> Leafs - Leafs --> Proof + SMTTrace --> Leaves + Leaves --> Proof SMTTrace --> old_account_hash_traces old_account_hash_traces --> Proof SMTTrace --> new_account_hash_traces @@ -102,7 +102,7 @@ In more detail, each `Proof` consists of the following components - `sibling`: `Fr` field element, sibling node's hash - `is_open_padding`: bool, true if this node is empty for old path - `is_close_padding`: bool, true if this node is empty for new path - - `leafs`: `[LeafNode; 2]`, for old and new path + - `leaves`: `[LeafNode; 2]`, for old and new path - `LeafNode` - `key` - `value_hash` @@ -232,7 +232,7 @@ There are 2 cases to constrain based on the path directed by the provided non-ex In this case, due to our construction of the old and new paths of `SMTTrace`, the old path (when inserting)/new path (when deleting) must be directed to this leaf node. The prefix key provided by the old/new path must end at a bit position before the last bit of the leaf key that is to be proved non-exist. So we constrain that the non-existing account/storage must have its key that is not equal to the key at this leaf node. Circuit columns `other_key`, `other_key_hash`, `other_leafnode_hash` and an IsEqualGadget `key_equals_other_key` are used to provide witness to these constraints and to constrain. - Type 2 non-existence proof (insert to fill/delete from fill): the path ended at an empty node. The illustration figure shown below: -![AccounNotExist_Empty](https://i.imgur.com/FLxg11Q.png) +![AccountNotExist_Empty](https://i.imgur.com/FLxg11Q.png) In this case, due to our construction of the old and new paths of `SMTTrace`, the old path (when inserting)/new path (when deleting) must be directed to this empty node. So we constrain the emptiness of these nodes. Circuit provides two IsZeroGadgets `old_hash_is_zero` and`new_hash_is_zero` to constrain this case. @@ -330,7 +330,7 @@ on rows with `MPTProofType::NonceChanged`: - `AccountLeaf1 -> AccountLeaf2` - `AccountLeaf2 -> AccountLeaf3` - `AccountLeaf3 -> Start` -- Constraints correspond to specific `SegumentType` for the particular row +- Constraints correspond to specific `SegmentType` for the particular row - `AccountLeaf0` - `direction==1` - `AccountLeaf1` @@ -377,7 +377,7 @@ on rows with `MPTProofType::PoisedonCodehashExists`: ### MPTProofType::CodehashExists on rows with `MPTProofType::CodehashExists`: -- Constraints correspond to specific SegumentType for the particular row +- Constraints correspond to specific SegmentType for the particular row - `Start`, `AccountTrie` - no constraint - `AccountLeaf0` @@ -413,7 +413,7 @@ In this case, the non-existence account to be proved shall have 0 value both bef ### MPTProofType::StorageChanged on rows with `MPTProofType::StorageChanged`: -- Constraints correspond to specific SegumentType for the particular row +- Constraints correspond to specific SegmentType for the particular row - `Start`, `AccountTrie`, - no constraint - `AccountLeaf0` @@ -451,7 +451,7 @@ On rows with `MPTProofType::StorageDoesNotExist`: - for type 1 non-existence: - `other_key_hash=poisedon(1, other_key)` - `old_hash == new_hash == poisedon(other_key_hash, other_leaf_data_hash)` -- Constraints correspond to specific SegumentType for the particular row +- Constraints correspond to specific SegmentType for the particular row - `AccountLeaf0` - `direction==1` - `AccountLeaf1` diff --git a/docs/Tx_Circuit.md b/docs/Tx_Circuit.md index 32c26b4428..8fb7a93326 100644 --- a/docs/Tx_Circuit.md +++ b/docs/Tx_Circuit.md @@ -64,7 +64,7 @@ Besides the above transaction data, some metadata are also available for the tx In the Tx Circuit, there are two pieces of tx related data that will be applied to the Keccak256 hash. They both correspond to some tx_tag fields ([`TxFieldTag`]): - (`TxHashLength`, `TxHashRLC`, `TxHash`): signed tx's data = `[Nonce, Gas, GasPrice, To, Value, CallData, v, r, s]`. `TxHashLength` stands for the length in bytes of `RLP([signed tx's data])`; `TxHashRLC` stands for the RLC in bytes of signed tx's data and `TxHash=Keccak256(RLP(signed tx's data))`. `TxHash` becomes the `hash` data field in tx data; -- (`TxSignLength`, `TxSignRLC`, `TxSignHash`): tx's data that needs to be signed = `[Nonce, Gas, GasPrice, To, Value, ChainID, CallData]`. `TxSignLenth` stands for the length in bytes of `RLP(tx's data that needs to be signed)`; `TxSignRLC` stands for the RLC in bytes of `RLP(tx's data that needs to be signed)` and `TxSignHash=Keccak256(RLP(tx's data that needs to be signed))`. `TxSignHash` is the same as the `msg_hash` data field that will be used to obtain the tx sender's signature `(v,r,s)`. +- (`TxSignLength`, `TxSignRLC`, `TxSignHash`): tx's data that needs to be signed = `[Nonce, Gas, GasPrice, To, Value, ChainID, CallData]`. `TxSignLength` stands for the length in bytes of `RLP(tx's data that needs to be signed)`; `TxSignRLC` stands for the RLC in bytes of `RLP(tx's data that needs to be signed)` and `TxSignHash=Keccak256(RLP(tx's data that needs to be signed))`. `TxSignHash` is the same as the `msg_hash` data field that will be used to obtain the tx sender's signature `(v,r,s)`. According to the [EllipticCurveDigitalSignatureAlgorithm] (ECDSA), the signatures `(r,s)` are calculated via ECDSA from `msg_hash` and a `public_key`. In the case of an ethereum tx, the scheme looks as follows @@ -130,7 +130,7 @@ This chip helps to check the correct decomposition of a binary number into an ar This chip helps to check if a value is zero. It uses one advice column to store this value and another advice column for its inverse. In Tx Circuit, this chip is applied to the following sub-configurations as `IsZeroConfig`: - `tx_id_is_zero`: this is used to check if `tx_id` is zero; -- `value_is_zero`: this is used to check if the `value` field for the current tx_tag is zero. This is applied when tx_tag is CallerAddress (if CallerAddress is zero, then skip sign verify); or is CallDataLenngth (if CallDataLength is zero, then skip lookup to tx table for call data); or is CallData (if CallData byte is zero, then gas cost is 4 otherwise 16). +- `value_is_zero`: this is used to check if the `value` field for the current tx_tag is zero. This is applied when tx_tag is CallerAddress (if CallerAddress is zero, then skip sign verify); or is CallDataLength (if CallDataLength is zero, then skip lookup to tx table for call data); or is CallData (if CallData byte is zero, then gas cost is 4 otherwise 16). #### IsEqualChip This chip helps to check the equality of two values by storing their difference into `IsZeroChip`. In Tx Circuit, this chip is applied to the following sub-configurations as `IsEqualConfig`: diff --git a/eth-types/src/evm_types/opcode_ids.rs b/eth-types/src/evm_types/opcode_ids.rs index 9400eb387d..252c4ef9c7 100644 --- a/eth-types/src/evm_types/opcode_ids.rs +++ b/eth-types/src/evm_types/opcode_ids.rs @@ -708,7 +708,7 @@ impl OpcodeId { let (min_stack_ptr, max_stack_ptr): (u32, u32) = match self { // `min_stack_pointer` 0 means stack overflow never happen, for example, `OpcodeId::ADD` // can only encounter underflow error, but never encounter overflow error. - // `max_stack_pointer` means max stack poniter for op code normally run. for example, + // `max_stack_pointer` means max stack pointer for op code normally run. for example, // `OpcodeId::ADD` 's max stack pointer is 1022, when actual sp > 1022, will // encounter underflow error. OpcodeId::STOP => (0, 1024), diff --git a/eth-types/src/geth_types.rs b/eth-types/src/geth_types.rs index 199495222c..9c534e8589 100644 --- a/eth-types/src/geth_types.rs +++ b/eth-types/src/geth_types.rs @@ -263,7 +263,7 @@ pub struct Transaction { pub nonce: Word, /// Gas Limit / Supplied gas pub gas_limit: Word, - /// Transfered value + /// Transferred value pub value: Word, /// Gas Price pub gas_price: Option, @@ -390,7 +390,7 @@ pub struct GethData { /// chain id pub chain_id: u64, /// history hashes contains most recent 256 block hashes in history, where - /// the lastest one is at history_hashes[history_hashes.len() - 1]. + /// the latest one is at history_hashes[history_hashes.len() - 1]. pub history_hashes: Vec, /// Block from geth pub eth_block: Block, diff --git a/eth-types/src/macros.rs b/eth-types/src/macros.rs index 4cd0b92e6b..ccb2bd1e6d 100644 --- a/eth-types/src/macros.rs +++ b/eth-types/src/macros.rs @@ -141,8 +141,8 @@ macro_rules! define_mul_assign_variants { /// Define Range indexing ops for the given type converting the ranges /// internally. macro_rules! define_range_index_variants { - (IN_RANGE = $inner_range:ty, OUT_RANGE = $out_range:ty, STRUCT_CONTAINER = $struc:ty, INDEX_OUTPUT = $output:ty) => { - impl core::ops::Index> for $struc { + (IN_RANGE = $inner_range:ty, OUT_RANGE = $out_range:ty, STRUCT_CONTAINER = $struct_container:ty, INDEX_OUTPUT = $output:ty) => { + impl core::ops::Index> for $struct_container { type Output = $output; #[inline] @@ -151,7 +151,7 @@ macro_rules! define_range_index_variants { } } - impl core::ops::Index for $struc { + impl core::ops::Index for $struct_container { type Output = $output; #[inline] @@ -160,7 +160,7 @@ macro_rules! define_range_index_variants { } } - impl core::ops::Index> for $struc { + impl core::ops::Index> for $struct_container { type Output = $output; #[inline] @@ -169,7 +169,7 @@ macro_rules! define_range_index_variants { } } - impl core::ops::Index> for $struc { + impl core::ops::Index> for $struct_container { type Output = $output; #[inline] @@ -178,7 +178,7 @@ macro_rules! define_range_index_variants { } } - impl core::ops::Index> for $struc { + impl core::ops::Index> for $struct_container { type Output = $output; #[inline] diff --git a/eth-types/src/sign_types.rs b/eth-types/src/sign_types.rs index c9dc50f59c..e81f9109c7 100644 --- a/eth-types/src/sign_types.rs +++ b/eth-types/src/sign_types.rs @@ -193,7 +193,7 @@ pub fn recover_pk2( ct_option_ok_or(Secp256k1Affine::from_xy(x, y), Error::Signature) } -/// Secp256k1 Curve Scalar. Referece: Section 2.4.1 (parameter `n`) in "SEC 2: Recommended +/// Secp256k1 Curve Scalar. Reference: Section 2.4.1 (parameter `n`) in "SEC 2: Recommended /// Elliptic Curve Domain Parameters" document at http://www.secg.org/sec2-v2.pdf pub static SECP256K1_Q: LazyLock = LazyLock::new(|| BigUint::from_bytes_le(&(Fq::zero() - Fq::one()).to_repr()) + 1u64); diff --git a/eth-types/src/state_db.rs b/eth-types/src/state_db.rs index b08104ad0a..f092cdfd27 100644 --- a/eth-types/src/state_db.rs +++ b/eth-types/src/state_db.rs @@ -187,7 +187,7 @@ impl StateDB { /// Even though this addr is still empty, an Account Rw {value_prev: 0x0, value: /// empty_code_hash} - // has already been applied. So furthur Account Write Rw is allowed. + // has already been applied. So further Account Write Rw is allowed. pub fn set_touched(&mut self, addr: &Address) -> bool { self.touched_account.insert(*addr) } diff --git a/external-tracer/src/lib.rs b/external-tracer/src/lib.rs index 9eb45bcf02..b1b5cf13e1 100644 --- a/external-tracer/src/lib.rs +++ b/external-tracer/src/lib.rs @@ -15,7 +15,7 @@ pub struct TraceConfig { /// chain id pub chain_id: u64, /// history hashes contains most recent 256 block hashes in history, where - /// the lastest one is at history_hashes[history_hashes.len() - 1]. + /// the latest one is at history_hashes[history_hashes.len() - 1]. pub history_hashes: Vec, /// block constants pub block_constants: BlockConstants, diff --git a/gadgets/src/is_zero.rs b/gadgets/src/is_zero.rs index 10f8928a39..3785a6bc69 100644 --- a/gadgets/src/is_zero.rs +++ b/gadgets/src/is_zero.rs @@ -61,7 +61,7 @@ impl IsZeroConfig { } } -/// Wrapper arround [`IsZeroConfig`] for which [`Chip`] is implemented. +/// Wrapper around [`IsZeroConfig`] for which [`Chip`] is implemented. #[derive(Clone, Debug)] pub struct IsZeroChip { config: IsZeroConfig, diff --git a/geth-utils/l1geth/trace.go b/geth-utils/l1geth/trace.go index a4615a326e..cc4e065813 100644 --- a/geth-utils/l1geth/trace.go +++ b/geth-utils/l1geth/trace.go @@ -130,7 +130,7 @@ type Transaction struct { type TraceConfig struct { ChainID uint64 `json:"chain_id"` // HistoryHashes contains most recent 256 block hashes in history, - // where the lastest one is at HistoryHashes[len(HistoryHashes)-1]. + // where the latest one is at HistoryHashes[len(HistoryHashes)-1]. HistoryHashes []*hexutil.Big `json:"history_hashes"` Block Block `json:"block_constants"` Accounts map[common.Address]Account `json:"accounts"` diff --git a/geth-utils/l2geth/trace.go b/geth-utils/l2geth/trace.go index 3fd37cc5a7..39f6ea377a 100644 --- a/geth-utils/l2geth/trace.go +++ b/geth-utils/l2geth/trace.go @@ -54,7 +54,7 @@ type TraceConfig struct { ChainID uint64 `json:"chain_id"` StartL1QueueIndex uint64 `json:"l1_queue_index"` // HistoryHashes contains most recent 256 block hashes in history, - // where the lastest one is at HistoryHashes[len(HistoryHashes)-1]. + // where the latest one is at HistoryHashes[len(HistoryHashes)-1]. HistoryHashes []*hexutil.Big `json:"history_hashes"` Block Block `json:"block_constants"` Accounts map[common.Address]Account `json:"accounts"` diff --git a/integration-tests/src/integration_test_circuits.rs b/integration-tests/src/integration_test_circuits.rs index 5decb69943..ef960ca86d 100644 --- a/integration-tests/src/integration_test_circuits.rs +++ b/integration-tests/src/integration_test_circuits.rs @@ -256,7 +256,7 @@ impl + Circuit> IntegrationTest { let transcript = Blake2bWrite::<_, G1Affine, Challenge255<_>>::init(vec![]); - // change instace to slice + // change instance to slice let instance: Vec<&[Fr]> = instance.iter().map(|v| v.as_slice()).collect(); let proof = test_gen_proof( diff --git a/integration-tests/tests/circuit_input_builder.rs b/integration-tests/tests/circuit_input_builder.rs index d7acf846ad..a8ee0a6c3f 100644 --- a/integration-tests/tests/circuit_input_builder.rs +++ b/integration-tests/tests/circuit_input_builder.rs @@ -73,7 +73,7 @@ macro_rules! declare_tests { } // This test builds the complete circuit inputs for the block where 1 ETH is -// transfered. +// transferred. declare_tests!(test_circuit_input_builder_block_transfer_0, "Transfer 0"); // This test builds the complete circuit inputs for the block where the Greeter // contract is deployed. diff --git a/integration-tests/tests/readme.md b/integration-tests/tests/readme.md index a47a5ef8c9..16424ebb88 100644 --- a/integration-tests/tests/readme.md +++ b/integration-tests/tests/readme.md @@ -6,7 +6,7 @@ Testings in `mainnet.rs` enable accessing a RPC node with debug API, and test an The running parameters are specified by environment variables: -* CIRCUIT: the circuit used to launch mocking proven, can be `super` (by default), `evm`, `copy`, `rlp`, `tx`, `state`, and we can use `none` to make a dry-run (no provding but only building of witness) +* CIRCUIT: the circuit used to launch mocking proven, can be `super` (by default), `evm`, `copy`, `rlp`, `tx`, `state`, and we can use `none` to make a dry-run (no providing but only building of witness) * GETH0_URL: the url of RPC node, like "https://eth-goerli.g.alchemy.com/v2/" For testing block, we specify blocks inside a range by `START_BLOCK` and `END_BLOCK`: @@ -29,7 +29,7 @@ To support most txs in mainnet some features are still missed: And for support most blocks in mainnet require more features: - [ ] Support >128 max txs for rlp / sig circuit -- [ ] large copy data (> 500,000 which is hardcoded currently, 1.5M is adviced) +- [ ] large copy data (> 500,000 which is hardcoded currently, 1.5M is advised) ### Note when testing with common rpc node provider -Currently most rpc node provider would provide their trace API from erigon ndoe instead of geth. You need to add `fix-refund` feature while running tests above: `--features=scroll,fix-refund` +Currently most rpc node provider would provide their trace API from erigon node instead of geth. You need to add `fix-refund` feature while running tests above: `--features=scroll,fix-refund` diff --git a/keccak256/src/arith_helpers.rs b/keccak256/src/arith_helpers.rs index c217e97535..6e9a7b2f09 100644 --- a/keccak256/src/arith_helpers.rs +++ b/keccak256/src/arith_helpers.rs @@ -109,7 +109,7 @@ pub fn convert_b2_to_b9(a: u64) -> Lane9 { /// Maps a sum of 12 bits to the XOR result of 12 bits. /// /// The input `x` is a chunk of a base 13 number and it represents the -/// arithmatic sum of 12 bits. Asking the result of the 12 bits XORed together +/// arithmetic sum of 12 bits. Asking the result of the 12 bits XORed together /// is equivalent of asking if `x` being an odd number. /// /// For example, if we have 5 bits set and 7 bits unset, then we have `x` as 5 @@ -119,10 +119,10 @@ pub fn convert_b13_coef(x: u8) -> u8 { x & 1 } -/// Maps the arithmatic result `2*a + b + 3*c + 2*d` to the bit operation result +/// Maps the arithmetic result `2*a + b + 3*c + 2*d` to the bit operation result /// `a ^ (~b & c) ^ d` /// -/// The input `x` is a chunk of a base 9 number and it represents the arithmatic +/// The input `x` is a chunk of a base 9 number and it represents the arithmetic /// result of `2*a + b + 3*c + 2*d`, where `a`, `b`, `c`, and `d` each is a bit. pub fn convert_b9_coef(x: u8) -> u8 { debug_assert!(x < 9); diff --git a/mock/src/test_ctx.rs b/mock/src/test_ctx.rs index dcf3877da3..e299b7b01b 100644 --- a/mock/src/test_ctx.rs +++ b/mock/src/test_ctx.rs @@ -1,4 +1,4 @@ -//! Mock types and functions to generate Test enviroments for ZKEVM tests +//! Mock types and functions to generate Test environments for ZKEVM tests use crate::{eth, MockAccount, MockBlock, MockTransaction, MOCK_WALLETS}; #[cfg(feature = "scroll")] @@ -89,7 +89,7 @@ pub struct TestContext { /// Account list pub accounts: [Account; NACC], /// history hashes contains most recent 256 block hashes in history, where - /// the lastest one is at history_hashes[history_hashes.len() - 1]. + /// the latest one is at history_hashes[history_hashes.len() - 1]. pub history_hashes: Vec, /// Block from geth pub eth_block: eth_types::Block, diff --git a/prover/src/lib.rs b/prover/src/lib.rs index 3c1147f08c..b0173b8b3c 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -8,7 +8,7 @@ /// layer4: compression circuit of "layer3". Final layer circuit currently. /// // TODO: don't always use "pub mod". -// We need to define which types and methods shoud be public carefully. +// We need to define which types and methods should be public carefully. pub mod aggregator; pub mod common; pub mod config; diff --git a/prover/src/proof/batch.rs b/prover/src/proof/batch.rs index df530a293c..a153fbbd91 100644 --- a/prover/src/proof/batch.rs +++ b/prover/src/proof/batch.rs @@ -73,7 +73,7 @@ impl BatchProof { dump_as_json(dir, &filename, &self) } - // Recover a `Proof` which follows halo2 sematic of "proof" and "instance", + // Recover a `Proof` which follows halo2 semantic of "proof" and "instance", // where "accumulators" are instance instead of proof, not like "onchain proof". pub fn proof_to_verify(self) -> Proof { // raw.proof is accumulator + proof diff --git a/prover/src/zkevm/circuit/builder.rs b/prover/src/zkevm/circuit/builder.rs index 515c564989..f118b9e991 100644 --- a/prover/src/zkevm/circuit/builder.rs +++ b/prover/src/zkevm/circuit/builder.rs @@ -177,7 +177,7 @@ pub fn finalize_builder(builder: &mut CircuitInputBuilder) -> Result { witness_block.apply_mpt_updates(state); log::debug!("apply_mpt_updates done"); } else { - // Empty state root means circuit capcity checking, or dummy witness block for key gen? + // Empty state root means circuit capacity checking, or dummy witness block for key gen? log::info!("empty state root, skip apply_mpt_updates"); } diff --git a/prover/src/zkevm/prover.rs b/prover/src/zkevm/prover.rs index b3c98751ab..895f84ba33 100644 --- a/prover/src/zkevm/prover.rs +++ b/prover/src/zkevm/prover.rs @@ -59,7 +59,7 @@ impl Prover { /// into this dir. /// chunk_identifier: /// used to distinguish different chunk files located in output_dir. - /// If it is not set, default vallue(first block number of this chuk) will be used. + /// If it is not set, default value(first block number of this chuk) will be used. /// id: /// TODO(zzhang). clean this. I think it can only be None or Some(0)... pub fn gen_chunk_proof( diff --git a/testool/Config.toml b/testool/Config.toml index cdd1f9c8bd..64c6a15f92 100644 --- a/testool/Config.toml +++ b/testool/Config.toml @@ -150,8 +150,8 @@ paths = [ "callToNonExistentFiller.json", "tackDepthLimitSECFiller.json", "ValueOverflowFiller", # weird 0x:biginteger 0x... - "result_mergeEnvConvertionFiller.json", # missing `currentDifficulty` - "result_cancunEnvConvertionFiller.json", # missing `currentDifficulty` + "result_mergeEnvConversionFiller.json", # missing `currentDifficulty` + "result_cancunEnvConversionFiller.json", # missing `currentDifficulty` "calldatacopy_dejavu2Filler.json", # missing comma "callDataCopyOffsetFiller.json" # missing comma ] diff --git a/testool/README.md b/testool/README.md index f8f84a32b0..00dc808aea 100644 --- a/testool/README.md +++ b/testool/README.md @@ -94,7 +94,7 @@ Sometimes there are some files or specific tests that we want to disable at all. When the command line parameter `--report` is defined, it automatically: - After the execution, a two files are created in the `report` folder. They are - - `-.hml` with the browseable results of the execution. + - `-.hml` with the browsable results of the execution. - `-.csv` with the raw results of the execution - The HTML file also contains the diff with the previous result. The previous result file is the more recent csv file with different commit from the current one diff --git a/testool/src/abi.rs b/testool/src/abi.rs index 525b2486f7..aec8f5041a 100644 --- a/testool/src/abi.rs +++ b/testool/src/abi.rs @@ -28,7 +28,7 @@ pub fn encode_funccall(spec: &str) -> Result { } else { func_name_params[1..func_name_params.len()].to_vec() }; - // transform func_params and args into the appropiate types + // transform func_params and args into the appropriate types let map_type = |t| match t { "uint" => ParamType::Uint(256), diff --git a/testool/src/main.rs b/testool/src/main.rs index e3119d2387..f91de184f9 100644 --- a/testool/src/main.rs +++ b/testool/src/main.rs @@ -169,7 +169,7 @@ fn go() -> Result<()> { let config = Config::load()?; log::info!("Using suite '{}'", args.suite); - log::info!("Parsing and compliling tests..."); + log::info!("Parsing and compiling tests..."); let compiler = Compiler::new(true, Some(PathBuf::from(CODEHASH_FILE)))?; let suite = config.suite(&args.suite)?.clone(); let mut state_tests = load_statetests_suite(&suite, config, compiler)?; diff --git a/testool/src/statetest/executor.rs b/testool/src/statetest/executor.rs index 3b319d0b06..065cd7ea4d 100644 --- a/testool/src/statetest/executor.rs +++ b/testool/src/statetest/executor.rs @@ -46,7 +46,7 @@ pub enum StateTestError { NonceMismatch { expected: U256, found: U256 }, #[error("CodeMismatch(expected: {expected:?}, found:{found:?})")] CodeMismatch { expected: Bytes, found: Bytes }, - #[error("StorgeMismatch(slot:{slot:?} expected:{expected:?}, found: {found:?})")] + #[error("StorageMismatch(slot:{slot:?} expected:{expected:?}, found: {found:?})")] StorageMismatch { slot: U256, expected: U256, @@ -634,7 +634,7 @@ pub fn run_test( // TODO: these codes are too difficult to maintain. // The correct way is to dump trace files, - // and use seperate tools to test trace files. + // and use separate tools to test trace files. #[cfg(feature = "inner-prove")] { eth_types::constants::set_env_coinbase(&st.env.current_coinbase); diff --git a/testool/src/statetest/json.rs b/testool/src/statetest/json.rs index de6aab6192..4730a069ea 100644 --- a/testool/src/statetest/json.rs +++ b/testool/src/statetest/json.rs @@ -119,7 +119,7 @@ impl<'a> JsonStateTestBuilder<'a> { Self { compiler } } - /// generates `StateTest` vectors from a ethereum josn test specification + /// generates `StateTest` vectors from a ethereum json test specification pub fn load_json(&mut self, path: &str, source: &str) -> Result> { let mut state_tests = Vec::new(); let tests: HashMap = serde_json::from_str(source).unwrap(); diff --git a/testool/src/statetest/results.rs b/testool/src/statetest/results.rs index 03f51805a4..2c71e42b3f 100644 --- a/testool/src/statetest/results.rs +++ b/testool/src/statetest/results.rs @@ -41,9 +41,9 @@ impl ResultLevel { use ResultLevel::*; match self { Panic => "💀PANIC", - Fail => "🔴FAILD", - Ignored => "🟠IGNOR", - Success => "🟢SUCCS", + Fail => "🔴FAILED", + Ignored => "🟠IGNORE", + Success => "🟢SUCCESS", } .to_string() } diff --git a/testool/src/statetest/yaml.rs b/testool/src/statetest/yaml.rs index 5ec4576ce7..22e10d0e30 100644 --- a/testool/src/statetest/yaml.rs +++ b/testool/src/statetest/yaml.rs @@ -50,7 +50,7 @@ impl<'a> YamlStateTestBuilder<'a> { /// generates `StateTest` vectors from a ethereum yaml test specification pub fn load_yaml(&mut self, path: &str, source: &str) -> Result> { - // Shoule be false for stEIP1153-transientStorage, + // Should be false for stEIP1153-transientStorage, // due to this bug https://github.com/ethereum/tests/issues/1369 if path.contains("stEIP1153-transientStorage") { abi::ENABLE_NORMALIZE.with_borrow_mut(|b| *b = false) diff --git a/typos.toml b/typos.toml new file mode 100644 index 0000000000..6fca30319a --- /dev/null +++ b/typos.toml @@ -0,0 +1,28 @@ +[files] +ignore-files = true +ignore-hidden = false +extend-exclude = [ + ".git/", + "go.mod", + "go.sum", + "go.work.sum", +] + + +[default] +extend-ignore-re=[ + '[Dd]atas', + # DUPn SWAPn + "Pn", + "[Aa]dvices", + "ABD", + "cafeb0ba", + # ./zkevm-circuits/src/table.rs:1789:19 that is a TODO to remove value_wrod_rlc + "wrod", + +] +check-filename = true + + + + diff --git a/zkevm-circuits/src/bytecode_circuit/circuit/to_poseidon_hash.rs b/zkevm-circuits/src/bytecode_circuit/circuit/to_poseidon_hash.rs index f5fcdb967c..a0b8440723 100644 --- a/zkevm-circuits/src/bytecode_circuit/circuit/to_poseidon_hash.rs +++ b/zkevm-circuits/src/bytecode_circuit/circuit/to_poseidon_hash.rs @@ -30,7 +30,7 @@ use super::{ /// basically the BytecodeCircuit include two parts: /// a) marking and proving bytcodetable for bytecodes /// b) mapping the bytes to keccaktable -/// and we re-useing the a) part and put additional +/// and we re-using the a) part and put additional /// controlling cols to enable lookup from poseidon table pub struct ToHashBlockCircuitConfig { base_conf: BytecodeCircuitConfig, @@ -56,7 +56,7 @@ impl ToHashBlockCircuitConfig ToHashBlockCircuitConfig| { let field_index = meta.query_advice(field_index, Rotation::cur()) - 1.expr(); [1.expr() - field_index.clone(), field_index] @@ -542,7 +542,7 @@ impl ToHashBlockCircuitConfig EccCircuit { powers_of_256: &[QuantumCell], op: &EcAddOp, ) -> EcAddDecomposed { - log::trace!("[ECC] ==> EcAdd Assignmnet START:"); + log::trace!("[ECC] ==> EcAdd Assignment START:"); log_context_cursor!(ctx); let (px, px_cells, px_valid, px_is_zero) = @@ -577,7 +577,7 @@ impl EccCircuit { ecc_chip.assert_equal(ctx, &rand_point, &sum3); - log::trace!("[ECC] EcAdd Assignmnet END:"); + log::trace!("[ECC] EcAdd Assignment END:"); log_context_cursor!(ctx); EcAddDecomposed { @@ -609,7 +609,7 @@ impl EccCircuit { powers_of_256: &[QuantumCell], op: &EcMulOp, ) -> EcMulDecomposed { - log::trace!("[ECC] ==> EcMul Assignmnet START:"); + log::trace!("[ECC] ==> EcMul Assignment START:"); log_context_cursor!(ctx); let (px, px_cells, px_valid, px_is_zero) = @@ -660,7 +660,7 @@ impl EccCircuit { let point_r_got = ecc_chip.select(ctx, &point_r_got, &infinity, &is_valid); ecc_chip.assert_equal(ctx, &point_r.ec_point, &point_r_got); - log::trace!("[ECC] EcMul Assignmnet END:"); + log::trace!("[ECC] EcMul Assignment END:"); log_context_cursor!(ctx); EcMulDecomposed { diff --git a/zkevm-circuits/src/evm_circuit/execution.rs b/zkevm-circuits/src/evm_circuit/execution.rs index 4b1d7e7bee..23141b50e3 100644 --- a/zkevm-circuits/src/evm_circuit/execution.rs +++ b/zkevm-circuits/src/evm_circuit/execution.rs @@ -538,7 +538,7 @@ impl ExecutionConfig { // the gadget value before being copied to the box is freed immediately after // the boxed gadget is returned. // We put each gadget in a box so that they stay in the heap to keep - // ExecutionConfig at a managable size. + // ExecutionConfig at a manageable size. (|| { Box::new(Self::configure_gadget( meta, diff --git a/zkevm-circuits/src/evm_circuit/execution/addmod.rs b/zkevm-circuits/src/evm_circuit/execution/addmod.rs index 49dac0a317..c75868a450 100644 --- a/zkevm-circuits/src/evm_circuit/execution/addmod.rs +++ b/zkevm-circuits/src/evm_circuit/execution/addmod.rs @@ -62,7 +62,7 @@ impl ExecutionGadget for AddModGadget { let n = cb.query_word_rlc(); let r = cb.query_word_rlc(); - // auxiliar witness + // auxiliary witness let k = cb.query_word_rlc(); let a_reduced = cb.query_word_rlc(); let d = cb.query_word_rlc(); @@ -155,7 +155,7 @@ impl ExecutionGadget for AddModGadget { .map(|idx| step.rw_indices[idx]) .map(|idx| block.rws[idx].stack_value()); - // assing a,b & n stack values + // assign a,b & n stack values self.a.assign(region, offset, Some(a.to_le_bytes()))?; self.b.assign(region, offset, Some(b.to_le_bytes()))?; self.n.assign(region, offset, Some(n.to_le_bytes()))?; diff --git a/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs b/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs index efb92489ab..fb49d8d67e 100644 --- a/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs +++ b/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs @@ -260,7 +260,7 @@ impl ExecutionGadget for BeginTxGadget { ConstantDivisionGadget::construct(cb, tx_call_data_length.expr() + 31.expr(), 32); // Use intrinsic gas - // TODO2: contrain calling precompile directly + // TODO2: constrain calling precompile directly let intrinsic_gas_cost = cb.query_cell(); cb.condition(not::expr(is_precompile.expr()), |cb| { @@ -543,7 +543,7 @@ impl ExecutionGadget for BeginTxGadget { Notice we need an additional copy event like we have done in the `CallOp` step We simply drop any checks to the output bytes which precompile would return, - since they are ommited as the return data from a transaction. + since they are omitted as the return data from a transaction. */ let (precompile_gadget, precompile_input_bytes_rlc) = cb.condition(is_precompile.expr(), |cb| { @@ -1254,7 +1254,7 @@ impl ExecutionGadget for BeginTxGadget { .context .ctxs .get(&tx.block_number) - .expect("cound not find block with number = {tx.block_number}") + .expect("could not find block with number = {tx.block_number}") .base_fee; self.tx_eip1559.assign( region, diff --git a/zkevm-circuits/src/evm_circuit/execution/calldatacopy.rs b/zkevm-circuits/src/evm_circuit/execution/calldatacopy.rs index acc2aaf8fa..56af9aba5b 100644 --- a/zkevm-circuits/src/evm_circuit/execution/calldatacopy.rs +++ b/zkevm-circuits/src/evm_circuit/execution/calldatacopy.rs @@ -112,7 +112,7 @@ impl ExecutionGadget for CallDataCopyGadget { CopyDataType::Memory.expr(), ); cb.condition(memory_address.has_length(), |cb| { - // Set source start to the minimun value of data offset and call data length. + // Set source start to the minimum value of data offset and call data length. let src_addr = call_data_offset.expr() + select::expr( data_offset.lt_cap(), diff --git a/zkevm-circuits/src/evm_circuit/execution/calldataload.rs b/zkevm-circuits/src/evm_circuit/execution/calldataload.rs index db3b5c7536..82bd445c12 100644 --- a/zkevm-circuits/src/evm_circuit/execution/calldataload.rs +++ b/zkevm-circuits/src/evm_circuit/execution/calldataload.rs @@ -132,7 +132,7 @@ impl ExecutionGadget for CallDataLoadGadget { }, ); - // Set source start to the minimun value of data offset and call data length. + // Set source start to the minimum value of data offset and call data length. let src_addr = call_data_offset.expr() + select::expr( data_offset.lt_cap(), diff --git a/zkevm-circuits/src/evm_circuit/execution/callop.rs b/zkevm-circuits/src/evm_circuit/execution/callop.rs index 4e37388fae..fb19aa291b 100644 --- a/zkevm-circuits/src/evm_circuit/execution/callop.rs +++ b/zkevm-circuits/src/evm_circuit/execution/callop.rs @@ -812,7 +812,7 @@ impl ExecutionGadget for CallOpGadget { let is_precheck_ok = depth.low_u64() < 1025 && (!(is_call || is_callcode) || caller_balance >= value); - // only call opcode do transfer in sucessful case. + // only call opcode do transfer in successful case. if is_call && is_precheck_ok && !value.is_zero() { let transfer_assign_result = self.transfer.assign_from_rws( region, diff --git a/zkevm-circuits/src/evm_circuit/execution/codecopy.rs b/zkevm-circuits/src/evm_circuit/execution/codecopy.rs index 78c27230f9..7c7495b34b 100644 --- a/zkevm-circuits/src/evm_circuit/execution/codecopy.rs +++ b/zkevm-circuits/src/evm_circuit/execution/codecopy.rs @@ -67,7 +67,7 @@ impl ExecutionGadget for CodeCopyGadget { cb.stack_pop(code_offset.original_word()); cb.stack_pop(size.expr()); - // Construct memory address in the destionation (memory) to which we copy code. + // Construct memory address in the destination (memory) to which we copy code. let dst_memory_addr = MemoryAddressGadget::construct(cb, dst_memory_offset, size); // Fetch the hash of bytecode running in current environment. @@ -88,7 +88,7 @@ impl ExecutionGadget for CodeCopyGadget { let copy_rwc_inc = cb.query_cell(); cb.condition(dst_memory_addr.has_length(), |cb| { - // Set source start to the minimun value of code offset and code size. + // Set source start to the minimum value of code offset and code size. let src_addr = select::expr( code_offset.lt_cap(), code_offset.valid_value(), diff --git a/zkevm-circuits/src/evm_circuit/execution/create.rs b/zkevm-circuits/src/evm_circuit/execution/create.rs index c7877b6e9c..d87edb38ed 100644 --- a/zkevm-circuits/src/evm_circuit/execution/create.rs +++ b/zkevm-circuits/src/evm_circuit/execution/create.rs @@ -923,7 +923,7 @@ mod test { code } - fn creater_bytecode_address_collision(initialization_bytecode: Bytecode) -> Bytecode { + fn creator_bytecode_address_collision(initialization_bytecode: Bytecode) -> Bytecode { let initialization_bytes = initialization_bytecode.code(); let mut code = bytecode! { PUSH32(Word::from_big_endian(&initialization_bytes)) @@ -1054,7 +1054,7 @@ mod test { #[test] fn test_create_address_collision_error() { let initialization_code = initialization_bytecode(false); - let root_code = creater_bytecode_address_collision(initialization_code); + let root_code = creator_bytecode_address_collision(initialization_code); let caller = Account { address: *CALLER_ADDRESS, code: root_code.into(), diff --git a/zkevm-circuits/src/evm_circuit/execution/error_invalid_jump.rs b/zkevm-circuits/src/evm_circuit/execution/error_invalid_jump.rs index 1ea09edb18..46fe5d9284 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_invalid_jump.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_invalid_jump.rs @@ -48,7 +48,7 @@ impl ExecutionGadget for ErrorInvalidJumpGadget { let phase2_condition = cb.query_cell_phase2(); cb.require_in_set( - "ErrorInvalidJump only happend in JUMP or JUMPI", + "ErrorInvalidJump only happened in JUMP or JUMPI", opcode.expr(), vec![OpcodeId::JUMP.expr(), OpcodeId::JUMPI.expr()], ); diff --git a/zkevm-circuits/src/evm_circuit/execution/error_invalid_opcode.rs b/zkevm-circuits/src/evm_circuit/execution/error_invalid_opcode.rs index 2b19ae0d60..290b536b51 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_invalid_opcode.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_invalid_opcode.rs @@ -159,7 +159,7 @@ mod test { txs[0] .from(accs[2].address) .to(accs[0].address) - // gas just over tx baisc gas(21000) + push gas(3), so oog for + // gas just over tx basic gas(21000) + push gas(3), so oog for // selfdestruct_opcode in normal geth, but treat as // invalidcode with scroll feature .gas(21003.into()); diff --git a/zkevm-circuits/src/evm_circuit/execution/extcodecopy.rs b/zkevm-circuits/src/evm_circuit/execution/extcodecopy.rs index a7370e8e1f..ec5cef1234 100644 --- a/zkevm-circuits/src/evm_circuit/execution/extcodecopy.rs +++ b/zkevm-circuits/src/evm_circuit/execution/extcodecopy.rs @@ -111,7 +111,7 @@ impl ExecutionGadget for ExtcodecopyGadget { let copy_rwc_inc = cb.query_cell(); cb.condition(memory_address.has_length(), |cb| { - // Set source start to the minimun value of code offset and code size. + // Set source start to the minimum value of code offset and code size. let src_addr = select::expr( code_offset.lt_cap(), code_offset.valid_value(), diff --git a/zkevm-circuits/src/evm_circuit/execution/logs.rs b/zkevm-circuits/src/evm_circuit/execution/logs.rs index a8716c22db..4eb68093fe 100644 --- a/zkevm-circuits/src/evm_circuit/execution/logs.rs +++ b/zkevm-circuits/src/evm_circuit/execution/logs.rs @@ -462,7 +462,7 @@ mod test { code.write_op(cur_op_code); // second log op code - // prepare additinal bytes for memory reading + // prepare additional bytes for memory reading code.append(&prepare_code(&pushdata, 0x20)); mstart = 0x00usize; // when mszie > 0x20 (32) needs multi copy steps diff --git a/zkevm-circuits/src/evm_circuit/execution/mcopy.rs b/zkevm-circuits/src/evm_circuit/execution/mcopy.rs index e6fa7d7228..15589331ea 100644 --- a/zkevm-circuits/src/evm_circuit/execution/mcopy.rs +++ b/zkevm-circuits/src/evm_circuit/execution/mcopy.rs @@ -59,7 +59,7 @@ impl ExecutionGadget for MCopyGadget { let memory_dest_address = MemoryAddressGadget::construct(cb, dest_offset.clone(), length.clone()); - // if no acutal copy happens, memory_word_size doesn't change. MemoryExpansionGadget handle + // if no actual copy happens, memory_word_size doesn't change. MemoryExpansionGadget handle // memory_word_size with MemoryAddressGadget. // more detailed: // when copy length is zero ( `length` == 0), MemoryAddressGadget set address offset to diff --git a/zkevm-circuits/src/evm_circuit/execution/memory.rs b/zkevm-circuits/src/evm_circuit/execution/memory.rs index afdf67cadf..4cd2f2dd73 100644 --- a/zkevm-circuits/src/evm_circuit/execution/memory.rs +++ b/zkevm-circuits/src/evm_circuit/execution/memory.rs @@ -30,7 +30,7 @@ pub(crate) struct MemoryGadget { address: MemoryWordAddress, mask: MemoryMask, // consider move to MemoryWordAddress ? - /// The value poped from or pushed to the stack. + /// The value popped from or pushed to the stack. value: Word, /// The left memory word read or written. value_left: Word, diff --git a/zkevm-circuits/src/evm_circuit/execution/origin.rs b/zkevm-circuits/src/evm_circuit/execution/origin.rs index 665799c434..3c2fedf5ae 100644 --- a/zkevm-circuits/src/evm_circuit/execution/origin.rs +++ b/zkevm-circuits/src/evm_circuit/execution/origin.rs @@ -74,7 +74,7 @@ impl ExecutionGadget for OriginGadget { ) -> Result<(), Error> { let origin = block.rws[step.rw_indices[1]].stack_value(); - // Assing TxId. + // Assign TxId. self.tx_id .assign(region, offset, Value::known(F::from(tx.id as u64)))?; diff --git a/zkevm-circuits/src/evm_circuit/execution/precompiles/modexp.rs b/zkevm-circuits/src/evm_circuit/execution/precompiles/modexp.rs index 85e6b81092..4d7148f4db 100755 --- a/zkevm-circuits/src/evm_circuit/execution/precompiles/modexp.rs +++ b/zkevm-circuits/src/evm_circuit/execution/precompiles/modexp.rs @@ -50,7 +50,7 @@ impl RandPowRepresent { .expect("same length") } - /// refere to a binary represent of exponent (like BinaryNumberGadget), can + /// refer to a binary represent of exponent (like BinaryNumberGadget), can /// link another expression so the expr is linked_val * r ** exponent pub fn configure( cb: &mut EVMConstraintBuilder, @@ -63,7 +63,7 @@ impl RandPowRepresent { cb.pow_of_rand_lookup(bits.value(), pow_lookup.expr()); let pow = linked_val.unwrap_or_else(|| 1.expr()) * pow_lookup.expr(); - // we would cache the pow expression in case degree is too larget + // we would cache the pow expression in case degree is too largest let cache_for_degree = if pow.degree() > Self::BIT_EXP_MAX_DEGREE { let cached_cell = cb.query_cell_phase2(); cb.require_equal( @@ -1609,10 +1609,10 @@ mod test { } } - // notice, "invalid" test would not actuall work until bus-mapping put calling fail case being + // notice, "invalid" test would not actually work until bus-mapping put calling fail case being // handle in normal CallOp, i.e. return None in // bus_mapping::circuit_input_builder::input_state_ref::CircuitInputStateRef::get_step_err - // for unsuccess (call.is_success is false) call + // for unsuccessful (call.is_success is false) call // current it is handled by the dummy "precompile error" gadget #[cfg(feature = "scroll")] #[test] diff --git a/zkevm-circuits/src/evm_circuit/execution/returndatacopy.rs b/zkevm-circuits/src/evm_circuit/execution/returndatacopy.rs index 35f0c522a9..4822da692d 100644 --- a/zkevm-circuits/src/evm_circuit/execution/returndatacopy.rs +++ b/zkevm-circuits/src/evm_circuit/execution/returndatacopy.rs @@ -64,7 +64,7 @@ impl ExecutionGadget for ReturnDataCopyGadget { let return_data_size: Cell = cb.query_cell(); let size: RandomLinearCombination = cb.query_word_rlc(); - // enusre no other out of bound errors occur, otherwise go to `ErrorReturnDataOutOfBound` + // ensure no other out of bound errors occur, otherwise go to `ErrorReturnDataOutOfBound` // state let check_overflow_gadget = CommonReturnDataCopyGadget::construct(cb, return_data_size.expr(), false.expr()); diff --git a/zkevm-circuits/src/evm_circuit/execution/sar.rs b/zkevm-circuits/src/evm_circuit/execution/sar.rs index dfd8fca43c..0af7a3a16b 100644 --- a/zkevm-circuits/src/evm_circuit/execution/sar.rs +++ b/zkevm-circuits/src/evm_circuit/execution/sar.rs @@ -117,7 +117,7 @@ impl ExecutionGadget for SarGadget { lt }); - // Merge contraints + // Merge constraints let shf_lo_div64_eq0 = IsZeroGadget::construct(cb, shf_div64.expr()); let shf_lo_div64_eq1 = IsEqualGadget::construct(cb, shf_div64.expr(), 1.expr()); let shf_lo_div64_eq2 = IsEqualGadget::construct(cb, shf_div64.expr(), 2.expr()); diff --git a/zkevm-circuits/src/evm_circuit/param.rs b/zkevm-circuits/src/evm_circuit/param.rs index fce9b07c73..bc7f537e05 100644 --- a/zkevm-circuits/src/evm_circuit/param.rs +++ b/zkevm-circuits/src/evm_circuit/param.rs @@ -117,7 +117,7 @@ pub(crate) const N_BITS_U8: usize = 8; pub(crate) const N_BYTES_ACCOUNT_ADDRESS: usize = 20; // Number of bytes that will be used of the memory address and size. -// If any of the other more signficant bytes are used it will always result in +// If any of the other more significant bytes are used it will always result in // an out-of-gas error. pub(crate) const N_BYTES_MEMORY_ADDRESS: usize = 5; pub(crate) const N_BYTES_MEMORY_WORD_SIZE: usize = 4; diff --git a/zkevm-circuits/src/evm_circuit/util.rs b/zkevm-circuits/src/evm_circuit/util.rs index 4592b72088..de1d561319 100644 --- a/zkevm-circuits/src/evm_circuit/util.rs +++ b/zkevm-circuits/src/evm_circuit/util.rs @@ -178,7 +178,7 @@ impl<'r, 'b, F: Field> CachedRegion<'r, 'b, F> { if offset - self.height_start < self.height_limit { let res = self.region.assign_advice(annotation, column, offset, &to); // Cache the value - // Note that the `value_field` in `AssignedCell` might be `Value::unkonwn` if + // Note that the `value_field` in `AssignedCell` might be `Value::unknown` if // the column has different phase than current one, so we call to `to` // again here to cache the value. if res.is_ok() { diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget.rs index 266ba2d1f0..228859e933 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget.rs @@ -178,7 +178,7 @@ impl RestoreContextGadget { // Update caller's last callee information // EIP-211 CREATE/CREATE2 call successful case should set RETURNDATASIZE = 0 // There is only one case where RETURNDATASIZE != 0: - // opcode is REVERT, and no stack/oog error occured. + // opcode is REVERT, and no stack/oog error occurred. // In other words, for RETURN opcode, RETURNDATASIZE is 0 for both successful // and fail case. let discard_return_data = cb.curr.state.is_create.expr() @@ -1106,7 +1106,7 @@ impl, const IS_SUCCESS_CAL let rd_address = MemAddrGadget::construct_self(cb); // Lookup values from stack - // `callee_address` is poped from stack and used to check if it exists in + // `callee_address` is popped from stack and used to check if it exists in // access list and get code hash. // For CALLCODE, both caller and callee addresses are `current_callee_address`. // For DELEGATECALL, caller address is `current_caller_address` and @@ -1759,7 +1759,7 @@ impl CommonReturnDataCopyGadget { from_bytes::expr(&remainder_end.cells[..N_BYTES_U64]), ); - // enusre it is expected overflow condition. + // ensure it is expected overflow condition. cb.require_equal( "check if [data_offset > u64::MAX, data_offset + size > U256::MAX, remainder_end > u64::MAX, remainder_end > return_data_length] occurs", or::expr([ diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget/curie.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget/curie.rs index 96172ebe1e..2d514fe2b1 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget/curie.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget/curie.rs @@ -39,7 +39,7 @@ impl CurieGadget { ); // TODO: refactor - // is_scoll_chain means (chain_id - 534352) * (chain_id - 222222) == 0 + // is_scroll_chain means (chain_id - 534352) * (chain_id - 222222) == 0 let is_scroll_chain = IsZeroGadget::construct( cb, (chain_id.expr() - SCROLL_MAINNET_CHAIN_ID.expr()) diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs index 041e597db9..eafc08bc63 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs @@ -232,7 +232,7 @@ impl TxL1FeeGadget { // l1 blob baseFee // commit scalar // blob scalar - // TODO: we could optimze the "overhead" and "scalar" for curie + // TODO: we could optimize the "overhead" and "scalar" for curie 3.expr() + is_curie.expr() * 3.expr() } diff --git a/zkevm-circuits/src/evm_circuit/util/instrumentation.rs b/zkevm-circuits/src/evm_circuit/util/instrumentation.rs index b2511a54e0..8a0fdcddf9 100644 --- a/zkevm-circuits/src/evm_circuit/util/instrumentation.rs +++ b/zkevm-circuits/src/evm_circuit/util/instrumentation.rs @@ -38,7 +38,7 @@ impl Instrument { self.states.push((execution_state, sizes)); } - /// Dissasembles the instrumentation data and returns a collection of + /// Disassembles the instrumentation data and returns a collection of /// `ExecStateReport`s. One for each EVM `ExecutionState`. pub(crate) fn analyze(&self) -> Vec { let mut report_collection = vec![]; diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/abs_word.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/abs_word.rs index 6f0ec63b61..2c0e89be62 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/abs_word.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/abs_word.rs @@ -187,7 +187,7 @@ mod tests { } #[test] - fn test_abs_unexpected_is_neg_for_negitive() { + fn test_abs_unexpected_is_neg_for_negative() { try_test!(AbsWordGadgetContainer, [Word::MAX, Word::from(1)], false); } } diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/lt_word.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/lt_word.rs index 2ccdaaac64..5182097afb 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/lt_word.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/lt_word.rs @@ -137,7 +137,7 @@ mod tests { } #[test] - fn test_ltword_unexpect() { + fn test_ltword_unexpected() { try_test!( LtWordTestContainer, [Word::from(1), Word::from(0)], diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/min_max.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/min_max.rs index e8a8882b30..8103f5c140 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/min_max.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/min_max.rs @@ -166,7 +166,7 @@ mod tests { } #[test] - fn test_minmax_unexpect_min_a() { + fn test_minmax_unexpected_min_a() { // min == b, max == a try_test!( MinMaxTestContainer, diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words.rs index 907455ab1f..639068d8f1 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words.rs @@ -333,7 +333,7 @@ mod tests { } #[test] - fn test_muladd_unexpect() { + fn test_muladd_unexpected() { // 10 * 1 + 1 != 3 try_test!( MulAddGadgetContainer, diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words512.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words512.rs index 327bb60d9f..1556a366e7 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words512.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words512.rs @@ -343,7 +343,7 @@ mod tests { } #[test] - fn test_muladd512_unexpect() { + fn test_muladd512_unexpected() { // 10 * 1 + 0 != 1 * 2**256 + 3 try_test!( MulAddWords512GadgetContainer, diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_word_u64.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_word_u64.rs index 1e306ca5dd..f5afd2d8f6 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_word_u64.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_word_u64.rs @@ -187,7 +187,7 @@ mod tests { } #[test] - fn test_mulwordu64_unexpect() { + fn test_mulwordu64_unexpected() { try_test!( MulWordByU64TestContainer, [Word::MAX, Word::from(1), Word::from(1)], diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/test_util.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/test_util.rs index a26549f106..1f6391f348 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/test_util.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/test_util.rs @@ -227,7 +227,7 @@ impl> Circuit for UnitTestMathGadgetBaseC )?; // assign fixed range tables only as they are the only tables referred by a - // specfic math gadget -- ConstantDivisionGadget. + // specific math gadget -- ConstantDivisionGadget. layouter.assign_region( || "fixed table", |mut region| { diff --git a/zkevm-circuits/src/modexp_circuit.rs b/zkevm-circuits/src/modexp_circuit.rs index c65bc4334f..e46d044e45 100644 --- a/zkevm-circuits/src/modexp_circuit.rs +++ b/zkevm-circuits/src/modexp_circuit.rs @@ -159,7 +159,7 @@ impl SubCircuit for ModExpCircuit { event_limit, ); exp_events.resize(event_limit, Default::default()); - log::info!("modexp circuit work with maxium {} entries", event_limit); + log::info!("modexp circuit work with maximum {} entries", event_limit); } Self(exp_events, Default::default()) diff --git a/zkevm-circuits/src/poseidon_circuit.rs b/zkevm-circuits/src/poseidon_circuit.rs index dac13b984a..ac270f57d3 100644 --- a/zkevm-circuits/src/poseidon_circuit.rs +++ b/zkevm-circuits/src/poseidon_circuit.rs @@ -100,7 +100,7 @@ impl SubCircuit for PoseidonCircuit { *map.entry(k).or_insert(0) += 1; }; for smt_trace in &block.mpt_updates.smt_traces { - // for a smt trace there are mutiple sources for hashes: + // for a smt trace there are multiple sources for hashes: // + account path, each layer (include the root) cost 1 hashes insert(&mut path_hash_counter, smt_trace.account_path[0].root.0); for node in &smt_trace.account_path[0].path { diff --git a/zkevm-circuits/src/sha256_circuit.rs b/zkevm-circuits/src/sha256_circuit.rs index 6b7129beaf..9433be8181 100644 --- a/zkevm-circuits/src/sha256_circuit.rs +++ b/zkevm-circuits/src/sha256_circuit.rs @@ -86,7 +86,7 @@ impl SHA256Circuit { let inputs = self.0.len(); let expected_rows = self.expected_rows(); log::info!( - "sha256 circuit work with {} input ({} bytes), set with maxium {} rows", + "sha256 circuit work with {} input ({} bytes), set with maximum {} rows", inputs, totalbytes, row_limit diff --git a/zkevm-circuits/src/sha256_circuit/README.md b/zkevm-circuits/src/sha256_circuit/README.md index 41d2349954..ae9a83fa2d 100644 --- a/zkevm-circuits/src/sha256_circuit/README.md +++ b/zkevm-circuits/src/sha256_circuit/README.md @@ -33,31 +33,31 @@ digest region (example for the hash of 'abc'): |s_final | | |*input_counter*|*hash_rlc*| | | 1 | | *input_rlc* | Note: -+ *Italic* indicate the cell is equality constrainted whie **bold** indicate the cell is constarinted with constant ++ *Italic* indicate the cell is equality constrained whie **bold** indicate the cell is constarinted with constant + We suppose the `random` value for rlc is `0x1000` -### Defination of the cols +### Definition of the cols + `copied_data` col is used to copy the cells with `u16` values from `table16`. + `trans_byte` expands each `u16` value copied from `table16` into two bytes across two adjacent rows, with the help of the selector `s_u16` + `s_padding` col marks whether the byte in current row is padding or input byte. + `bytes_rlc` accumulates bytes in `trans_byte` col to its RLC expression only if the byte in current row is not padding. Otherwise, it continues the value from the previous row if the current row is marked as padding. + `byte_counter` counts the total input bytes if byte in current row is not padding, Otherwise it continues the value from previous row if the current row is marked as padding. -+ `s_final_block` is a boolean advice col that identifies in each row of an input region, marking wether the current block is the last block -+ `helper` col has mutiple usage. In input region it calculate the acculumation of the last 8 bytes and represent the bit counts in the last row (if current block is the final one); in output region it copied the rlc of input bytes in the final row. ++ `s_final_block` is a boolean advice col that identifies in each row of an input region, marking whether the current block is the last block ++ `helper` col has multiple usage. In input region it calculate the accumulation of the last 8 bytes and represent the bit counts in the last row (if current block is the final one); in output region it copied the rlc of input bytes in the final row. The circuit contains fixed layouts of input and output regions, i.e. an input region is followed by a output region, handling one sha256 block (512 bits or 64 bytes), and the whole circuit would handle the fixed count of blocks. So it is possible to put fixed selector cols in the circuit: + `s_begin` is used to indicate the first row in both input and output region. -+ `s_enable` is used to indicate each row in regions the common gates must be actived ++ `s_enable` is used to indicate each row in regions the common gates must be activated + `s_final` is used to indicate the last row in both input and output region. + `s_assigned_u16` is used to indicate there is a copied u16 word in the cell of `copied_data` col. + `s_padding_size` and `s_common_bytes` is a pair of fixed selector to mark the the last 8 bytes in every input region. `s_padding_size` select the last 8 bytes while `s_common_bytes` select the other. They help to accumulate the last 8 bytes in input region and obtains the bit counts recorded in the tail of the padding, which is specified by SHA2. -### Defination in regions: +### Definition in regions: - The 256-bit state to start a new compression is stored in 16 cells extracted from the digest region (see below), each cell for a 16-bit part and is called a "dense state" in table16. Such a dense state is assigned into an initialization region of table16 and export a "working state" for the following compression step. The working state also contain another dense state inside it. The caller to this initialization entry of table16, that is, the sha256 circuit, has a response to constarint the input dense state with the output one. + The 256-bit state to start a new compression is stored in 16 cells extracted from the digest region (see below), each cell for a 16-bit part and is called a "dense state" in table16. Such a dense state is assigned into an initialization region of table16 and export a "working state" for the following compression step. The working state also contain another dense state inside it. The caller to this initialization entry of table16, that is, the sha256 circuit, has a response to constraint the input dense state with the output one. - Also, for the first compression step, circuit also constarint the dense state inside of the working state with the constants of the "Initiazation Vector" of sha256. + Also, for the first compression step, circuit also constraint the dense state inside of the working state with the constants of the "Initiazation Vector" of sha256. Each input region captures a 512-bit block and copies the 16 x 32-bit integers (in the form of a pair of assigned cells for their lo and hi 16-bit parts) inside of the `message schedule` region of table16. The region consists of 66 rows: 64 rows for 64 bytes representing the 512-bit block and 2 extra rows at the beginning. For the `s_final_block`, `byte_counter`, `s_padding` and `bytes_rlc` cols, the cells in last row (enabled by `s_last` selector) are connected by equality constraints to the first row of next input region for the subsequent 512-bit block. Additionally the `s_final_block` cells is also connected with the corresponding digest reion. @@ -65,18 +65,18 @@ The circuit contains fixed layouts of input and output regions, i.e. an input re Note that it is free to specify `s_final_block` in each block as either 0 or 1. If `s_final_block` is set to 1, the last row must satisfy the "final" constraint, that is the cell in `byte_counter` col has to equal the calculated bit size in `s_padding_size` cell. - There is exactly one digest region corresponding to each input region. This region captures the 256-bit digest of the 512-bit block and copies it from the `digest` region of table16. The region consists of 34 rows: 32 rows for bytes of digests, 1 extra row at the beginning, and 1 row at the bottom. The `s_final_block` is inherited from the input region, and the first row for `byte_counter`, `s_padding` and `bytes_rlc` cols are specified with 0 by constraints to a constant. The last row for digest bytes is also constarint the `s_padding` cell as 0, which also ensure there is no padding row existed in digest region. + There is exactly one digest region corresponding to each input region. This region captures the 256-bit digest of the 512-bit block and copies it from the `digest` region of table16. The region consists of 34 rows: 32 rows for bytes of digests, 1 extra row at the beginning, and 1 row at the bottom. The `s_final_block` is inherited from the input region, and the first row for `byte_counter`, `s_padding` and `bytes_rlc` cols are specified with 0 by constraints to a constant. The last row for digest bytes is also constraint the `s_padding` cell as 0, which also ensure there is no padding row existed in digest region. - Like input region, digest region calculated the RLC of digest bytes. The final row in digest copied `s_final_block` and `byte_counter` value inheirted from input region into the corresponding cols; `bytes_rlc` of the cell in previous cell (i.e. the RLC of digest); and the RLC of input into `helper` col. This row represents a row in SHA256 table used for looking up from evm circuit. + Like input region, digest region calculated the RLC of digest bytes. The final row in digest copied `s_final_block` and `byte_counter` value inherited from input region into the corresponding cols; `bytes_rlc` of the cell in previous cell (i.e. the RLC of digest); and the RLC of input into `helper` col. This row represents a row in SHA256 table used for looking up from evm circuit. ## Performance - Currently the SHA256 circuit can calculate SHA256 for 1k bytes within 4.891s (`k=17`), ~26% overhead to its `table16` core (3.854s), and verfication is 6.601ms, 6% overhead to `table16` (6.207ms). + Currently the SHA256 circuit can calculate SHA256 for 1k bytes within 4.891s (`k=17`), ~26% overhead to its `table16` core (3.854s), and verification is 6.601ms, 6% overhead to `table16` (6.207ms). - We have a [detailed performance for table16 and Brecht's sha256](https://www.notion.so/scrollzkp/Precompile-SHA256-7a0f519d5bbe4f52a9fa08ebff9a8118) (accessing priviledge required). + We have a [detailed performance for table16 and Brecht's sha256](https://www.notion.so/scrollzkp/Precompile-SHA256-7a0f519d5bbe4f52a9fa08ebff9a8118) (accessing privilege required). With `k=21`, SHA256-circuit can calculate the hashes for as much as 16KB bytes, which should be enough for the txs in mainnet. ## Known issue in table16 -+ Initialize state is not constrainted in table16 ++ Initialize state is not constrained in table16 diff --git a/zkevm-circuits/src/sha256_circuit/circuit.rs b/zkevm-circuits/src/sha256_circuit/circuit.rs index b533325ae4..76e15c63b5 100644 --- a/zkevm-circuits/src/sha256_circuit/circuit.rs +++ b/zkevm-circuits/src/sha256_circuit/circuit.rs @@ -15,7 +15,7 @@ type BlockState = >::State; /// u32 size for SHA256 digit pub const DIGEST_SIZE: usize = 8; -/// the defination for a sha256 table +/// the definition for a sha256 table pub trait SHA256Table { /// the cols has layout [s_enable, input_bytes, input_len, hashes, effect] fn cols(&self) -> [Column; 5]; @@ -27,21 +27,21 @@ pub trait SHA256Table { .try_into() .expect("must provide cols as expected layout") } - /// input_rlc show the RLC for input bytes, the first byte is multipled with R^(n-1) + /// input_rlc show the RLC for input bytes, the first byte is multiplied with R^(n-1) /// in which n is the length of bytes and R is random fn input_rlc(&self) -> Column { self.cols()[1] .try_into() .expect("must provide cols as expected layout") } - /// input_len show the accumulated lengh for input bytes + /// input_len show the accumulated length for input bytes fn input_len(&self) -> Column { self.cols()[2] .try_into() .expect("must provide cols as expected layout") } /// hashes_rlc show the RLC for the 32-bytes digest of input bytes, the first byte - /// is multipled with R^31 + /// is multiplied with R^31 fn hashes_rlc(&self) -> Column { self.cols()[3] .try_into() @@ -477,25 +477,25 @@ impl CircuitConfig { || "sha256 input", |mut region| { prev_block.s_final.copy_advice( - || "inheirt s_final", + || "inherit s_final", &mut region, self.s_final_block, 0, )?; prev_block.s_padding.copy_advice( - || "inheirt padding", + || "inherit padding", &mut region, self.s_padding, 0, )?; prev_block.bytes_rlc.copy_advice( - || "inheirt bytes rlc", + || "inherit bytes rlc", &mut region, self.bytes_rlc, 0, )?; prev_block.byte_counter.copy_advice( - || "inheirt byte counter", + || "inherit byte counter", &mut region, self.byte_counter, 0, @@ -668,7 +668,7 @@ impl CircuitConfig { || "sha256 digest", |mut region| { input_block.s_final.copy_advice( - || "inheirt s_final", + || "inherit s_final", &mut region, self.s_final_block, 0, diff --git a/zkevm-circuits/src/stats.rs b/zkevm-circuits/src/stats.rs index 5a5569d0c0..852dd32a61 100644 --- a/zkevm-circuits/src/stats.rs +++ b/zkevm-circuits/src/stats.rs @@ -241,7 +241,7 @@ pub(crate) fn print_circuit_stats_by_states( assert_eq!(ExecState::Op(opcode), step.exec_state); let height = fn_height(&builder.block, state, step_index); - // Substract 1 to step_index to remove the `BeginTx` step, which doesn't appear + // Subtract 1 to step_index to remove the `BeginTx` step, which doesn't appear // in the geth trace. let geth_step = &block.geth_traces[0].struct_logs[step_index - 1]; assert_eq!(opcode, geth_step.op); diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index 637eb50d11..2643eda4ec 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -2883,7 +2883,7 @@ impl ModExpTable { ret } - /// helper for devide a U256 into 3 108bit limbs + /// helper for divide a U256 into 3 108bit limbs pub fn split_u256_108bit_limbs(word: &Word) -> [u128; 3] { let bit108 = 1u128 << 108; let (next, limb0) = word.div_mod(U256::from(bit108)); diff --git a/zkevm-circuits/src/util.rs b/zkevm-circuits/src/util.rs index 29c4e6e317..7ce2b69e0e 100644 --- a/zkevm-circuits/src/util.rs +++ b/zkevm-circuits/src/util.rs @@ -49,7 +49,7 @@ pub(crate) fn rlc_be_bytes(bytes: &[u8], rand: Value) -> Value { } /// Wrap multiple challenges: -/// `construct`: the default consturct route to provide all challenges used in `SuperCircuit`. +/// `construct`: the default construct route to provide all challenges used in `SuperCircuit`. /// `construct_p1`: construct challenge up to second phase #[derive(Default, Clone, Copy, Debug)] pub struct Challenges { diff --git a/zkevm-circuits/src/witness/block.rs b/zkevm-circuits/src/witness/block.rs index b48b51be15..1afc5f717d 100644 --- a/zkevm-circuits/src/witness/block.rs +++ b/zkevm-circuits/src/witness/block.rs @@ -558,7 +558,7 @@ pub fn block_convert( ); } } else { - log::error!("withdraw root is not avaliable"); + log::error!("withdraw root is not available"); } let block = Block { diff --git a/zkevm-circuits/src/witness/mpt/witness.rs b/zkevm-circuits/src/witness/mpt/witness.rs index 4023537fd2..498c88b91d 100644 --- a/zkevm-circuits/src/witness/mpt/witness.rs +++ b/zkevm-circuits/src/witness/mpt/witness.rs @@ -148,8 +148,8 @@ impl WitnessGenerator { let old_value_in_trie = storage_before .as_ref() .ok() - .and_then(|(_, nd)| nd.as_ref()) - .and_then(|nd| nd.as_storage()) + .and_then(|(_, node)| node.as_ref()) + .and_then(|node| node.as_storage()) .unwrap_or_default(); assert_eq!(hex::encode(word_buf), hex::encode(old_value_in_trie), "for (address {address:?} key {key:?}): old value in proof != old value in partial trie", @@ -230,7 +230,7 @@ impl WitnessGenerator { let (account_path_before, account_data_before) = decode_proof_for_mpt_path(address_key, proofs).expect("unless the db is totally empty"); let account_data_before = account_data_before - .and_then(|nd| nd.as_account()) + .and_then(|node| node.as_account()) .map(AccountData::from); let account_data_after = update_account_data(account_data_before.as_ref()); diff --git a/zkevm-circuits/src/witness/rw.rs b/zkevm-circuits/src/witness/rw.rs index dd510de77b..93d55c24bc 100644 --- a/zkevm-circuits/src/witness/rw.rs +++ b/zkevm-circuits/src/witness/rw.rs @@ -512,7 +512,7 @@ impl Rw { } } - // At this moment is a helper for the EVM circuit until EVM challange API is + // At this moment is a helper for the EVM circuit until EVM challenge API is // applied pub(crate) fn table_assignment_aux(&self, randomness: F) -> RwRow { RwRow { diff --git a/zktrie/src/state.rs b/zktrie/src/state.rs index 46dbbc5a03..29da6d554d 100644 --- a/zktrie/src/state.rs +++ b/zktrie/src/state.rs @@ -68,9 +68,9 @@ impl ZktrieState { /// switch to another root state (trie snapshot) /// return true if the switch success, or false if db have not contain /// corresponding root yet - /// notice the cached key would not be clean if we can successfully swith to + /// notice the cached key would not be clean if we can successfully switch to /// new snapshot since we consider it is not need to send more nodes data - /// from storage trace for the updated leafs + /// from storage trace for the updated leaves pub fn switch_to(&mut self, new_root: ZkTrieHash) -> bool { let test_trie = self.zk_db.borrow_mut().new_trie(&new_root); if test_trie.is_none() {