diff --git a/specs/error_state/ErrorInvalidJump.md b/specs/error_state/ErrorInvalidJump.md index 2ac21ce93..fca1aaf2b 100644 --- a/specs/error_state/ErrorInvalidJump.md +++ b/specs/error_state/ErrorInvalidJump.md @@ -7,7 +7,7 @@ This type of error only occurs when executing op code is `JUMP` or `JUMPI`. ### EVM behavior Pop one EVM word `dest` from the stack, then go to `ErrorInvalidJump` state when -one of the followings occurs: +one of the following occurs: - `dest` is not within code length range - `dest` is a not `JUMPDEST` code , or data section of PUSH* diff --git a/specs/opcode/09MULMOD.md b/specs/opcode/09MULMOD.md index e0e0d0f9e..f60ddc807 100644 --- a/specs/opcode/09MULMOD.md +++ b/specs/opcode/09MULMOD.md @@ -77,7 +77,7 @@ $$ ## Exceptions -1. stack undeflow: `1022 <= stack_pointer <= 1024`. +1. stack underflow: `1022 <= stack_pointer <= 1024`. 2. out of gas: Remaining gas is not enough. See `src/zkevm_specs/opcode/mulmod.py` diff --git a/specs/opcode/1bSHL_1cSHR.md b/specs/opcode/1bSHL_1cSHR.md index 63eb0601c..927e4ba5f 100644 --- a/specs/opcode/1bSHL_1cSHR.md +++ b/specs/opcode/1bSHL_1cSHR.md @@ -20,7 +20,7 @@ Based on different opcode cases, we constrain the stack pops and pushes as follo The opcode circuit also adds some extra constraints: -- contrain `shift == shift.cells[0]` when `divisor != 0`. +- constrain `shift == shift.cells[0]` when `divisor != 0`. - use a `LtWordGadget` to constrain `remainder < divisor` when `divisor != 0`. - if the opcode is SHL, constrain `remainder == 0`. - if the opcode is SHR, constrain `overflow == 0` in `MulAddWordsGadget`. diff --git a/specs/opcode/56JUMP.md b/specs/opcode/56JUMP.md index 1cd8b66ac..762066a6e 100644 --- a/specs/opcode/56JUMP.md +++ b/specs/opcode/56JUMP.md @@ -7,7 +7,7 @@ to use as the destination, which changes program counter to it. ### EVM behavior -Pop one EVM word `dest` from the stack. then do the followings: +Pop one EVM word `dest` from the stack. then do the following: - check `dest` is within code length range - check `dest` is a `JUMPDEST` and not data section of PUSH\* diff --git a/specs/opcode/57JUMPI.md b/specs/opcode/57JUMPI.md index 493338eb3..565bf1116 100644 --- a/specs/opcode/57JUMPI.md +++ b/specs/opcode/57JUMPI.md @@ -6,7 +6,7 @@ JUMPI is an op code regarding flow control of evm. it pops two values at the top ### EVM behavior -Pop two EVM words `dest` and `cond` from the stack. then do the followings: +Pop two EVM words `dest` and `cond` from the stack. then do the following: 1. check `cond` is zero diff --git a/specs/opcode/90SWAPX.md b/specs/opcode/90SWAPX.md index 5c34fa373..83e7ffd86 100644 --- a/specs/opcode/90SWAPX.md +++ b/specs/opcode/90SWAPX.md @@ -2,7 +2,7 @@ ## Procedure -Swapx represents op codes of swap1....swap16. which swaps the top of the stack with the 'x+1'th last element. For example, SWAP3 means swaping the top of the stack with the 4th last element +Swapx represents op codes of swap1....swap16. which swaps the top of the stack with the 'x+1'th last element. For example, SWAP3 means swapping the top of the stack with the 4th last element ## Constraints @@ -12,7 +12,7 @@ Swapx represents op codes of swap1....swap16. which swaps the top of the stack w stack_pointer\ pc + 1\ gas + 3 -3. lookups: 1 range lookup + 4 bussmapping lookups:\ +3. lookups: 1 range lookup + 4 busmapping lookups:\ position 'x' range from \[1..16\]\ first operand must come from top of stack\ second operand must come from position 'x+1' inside stack\ diff --git a/specs/public_inputs.md b/specs/public_inputs.md index 39dced833..e2acbbbd2 100644 --- a/specs/public_inputs.md +++ b/specs/public_inputs.md @@ -268,7 +268,7 @@ This is because: # PublicInputs Circuit -Before adapting advanced compression [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844), the preliminary compression strategy is via keccak on public data, i.e. `keccak(PublicInputsCircuit:raw_public_inputs)`, and the final hash digest will be provided on verifier side as public input. Digest will be verified in public circuit via lookup. Hashing digest is in 256 bits, so it's splitted into 2 field value namely, `digest[0:128]` as `pi_keccak.lo()`,`digest[128:256]` as `pi_keccak.hi()` respectively. +Before adapting advanced compression [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844), the preliminary compression strategy is via keccak on public data, i.e. `keccak(PublicInputsCircuit:raw_public_inputs)`, and the final hash digest will be provided on verifier side as public input. Digest will be verified in public circuit via lookup. Hashing digest is in 256 bits, so it's split into 2 field value namely, `digest[0:128]` as `pi_keccak.lo()`,`digest[128:256]` as `pi_keccak.hi()` respectively. ## Setup diff --git a/specs/tables.md b/specs/tables.md index 16f8e1a55..9c4ad4788 100644 --- a/specs/tables.md +++ b/specs/tables.md @@ -336,7 +336,7 @@ The exponentiation table consist of 11 columns, namely: 3. `is_last`: A boolean value to indicate the last row of the exponentiation trace's table assignments. 4. `base_limb[i]`: Four 64-bit limbs representing the integer base of the exponentiation operation. 5. `exponent_lo_hi[i]`: Two 128-bit low/high parts of an intermediate value that starts at the integer exponent. -6. `exponentiation_lo_hi[i]`: Two 128-bit low/high parts of an intermediate value that starts at the result of the exponentation operation. +6. `exponentiation_lo_hi[i]`: Two 128-bit low/high parts of an intermediate value that starts at the result of the exponentiation operation. The lookup entry is not a single row in the table, and not every row corresponds to a lookup entry. Instead, a lookup entry is constructed from the first 4 rows in each exponentiation event. For simplicity in the `specs` implementation, we combine all those rows into a single row. But in the `circuits` implementation, we try to lower the number of columns in exchange of increased number of rows. diff --git a/specs/transactions-proof.md b/specs/transactions-proof.md index 1ad95a98d..a23f7375e 100644 --- a/specs/transactions-proof.md +++ b/specs/transactions-proof.md @@ -201,7 +201,7 @@ Then the table continues: for each transaction: | | *TxContextFieldTag* | | | | $TxID | CallData | $ByteIndex | $value: raw | -These rows are repeated `MAX_CALLDATA_BYTES` times. When the total numer of +These rows are repeated `MAX_CALLDATA_BYTES` times. When the total number of bytes from all transactions' call data is less than `MAX_CALLDATA_BYTES`, the rows corresponding to unused transactions will use the `CallData` tag with `TxID = 0`. diff --git a/specs/withdrawal-proof.md b/specs/withdrawal-proof.md index abd8870f6..5cf2070bd 100644 --- a/specs/withdrawal-proof.md +++ b/specs/withdrawal-proof.md @@ -19,7 +19,7 @@ execution_payload_body_rlp = RLP([transactions, [], withdrawals]) ## Circuit behavior -For every withdrawal defined as the parameters `(withdrawal_index, validator_index, address, amount)` and the circuit verifies the followings: +For every withdrawal defined as the parameters `(withdrawal_index, validator_index, address, amount)` and the circuit verifies the following: 1. `withdrawalsData: bytes = rlp([withdrawal_index, validator_index, address, amount])` 2. `withdrawalDataHash: word = keccak(withdrawalsData)` diff --git a/src/zkevm_specs/evm_circuit/execution/begin_tx.py b/src/zkevm_specs/evm_circuit/execution/begin_tx.py index aa1ab2a07..d275fc168 100644 --- a/src/zkevm_specs/evm_circuit/execution/begin_tx.py +++ b/src/zkevm_specs/evm_circuit/execution/begin_tx.py @@ -90,7 +90,7 @@ def begin_tx(instruction: Instruction): tx_accesslist_gas = instruction.tx_context_lookup(tx_id, TxContextFieldTag.AccessListGasCost) tx_intrinsic_gas = tx_calldata_gas_cost.expr() + tx_cost_gas + tx_accesslist_gas.expr() - # check instrinsic gas + # check intrinsic gas MAX_N_BYTES = 31 gas_not_enough, _ = instruction.compare(tx_gas, tx_intrinsic_gas, MAX_N_BYTES) gas_left = tx_gas.expr() if gas_not_enough == 1 else tx_gas.expr() - tx_intrinsic_gas @@ -138,8 +138,8 @@ def begin_tx(instruction: Instruction): call_id=Transition.to(call_id), ) else: - # Expected behabeur - # - If initcode does not RETRUN, contract is created empty and value transferred + # Expected behavior + # - If initcode does not RETURN, contract is created empty and value transferred # - If initcode is invalid bytecode or reverts, contract is not created and value not transferred # Get code hash of tx calldata diff --git a/src/zkevm_specs/evm_circuit/execution/sar.py b/src/zkevm_specs/evm_circuit/execution/sar.py index e6b907577..3849d8f52 100644 --- a/src/zkevm_specs/evm_circuit/execution/sar.py +++ b/src/zkevm_specs/evm_circuit/execution/sar.py @@ -98,7 +98,7 @@ def check_witness( a64s_hi_lt_p_hi, _ = instruction.compare(a64s_hi[idx], p_hi, 16) instruction.constrain_equal(a64s_hi_lt_p_hi, FQ(1)) - # Merge contraints + # Merge constraints shf_div64_eq0 = shf_lt256 * instruction.is_zero(shf_div64) shf_div64_eq1 = shf_lt256 * instruction.is_zero(shf_div64 - 1) shf_div64_eq2 = shf_lt256 * instruction.is_zero(shf_div64 - 2) diff --git a/src/zkevm_specs/evm_circuit/instruction.py b/src/zkevm_specs/evm_circuit/instruction.py index 7d9cb954c..fa063d9d7 100644 --- a/src/zkevm_specs/evm_circuit/instruction.py +++ b/src/zkevm_specs/evm_circuit/instruction.py @@ -261,7 +261,7 @@ def constrain_step_state_transition(self, **kwargs: Transition): f"State {key} should transit to {transition.value}, but got {next}" ) else: - raise ValueError("Unreacheable") + raise ValueError("Unreachable") def step_state_transition_to_new_context( self, @@ -549,16 +549,16 @@ def abs_word(self, x: Word) -> Tuple[Word, FQ]: self.constrain_zero((x_abs_lo - x_lo) * (1 - is_neg)) self.constrain_zero((x_abs_hi - x_hi) * (1 - is_neg)) - # When `is_neg`, contrain `x + x_abs == 1 << 256`. Even if + # When `is_neg`, constrain `x + x_abs == 1 << 256`. Even if # `x = -(1 << 255)` that is signed overflow, and # `abs(-(1 << 255) = -(1 << 255)`. carry_lo, sum_lo = divmod(x_lo.n + x_abs_lo.n, 1 << 128) carry_hi, sum_hi = divmod(x_hi.n + x_abs_hi.n + carry_lo, 1 << 128) - # Contrain `sum([x_lo, x_abs_lo]) == sum_lo + carry_lo * 2^128`. + # Constrain `sum([x_lo, x_abs_lo]) == sum_lo + carry_lo * 2^128`. self.constrain_zero(FQ(sum_lo) + FQ(carry_lo) * FQ(1 << 128) - self.sum([x_lo, x_abs_lo])) - # Contrain `sum([x_hi, x_abs_hi]) + carry_lo == sum_hi + carry_hi * 2^128`. + # Constrain `sum([x_hi, x_abs_hi]) + carry_lo == sum_hi + carry_hi * 2^128`. self.constrain_zero( FQ(sum_hi) + FQ(carry_hi) * FQ(1 << 128) - FQ(carry_lo) - self.sum([x_hi, x_abs_hi]) ) diff --git a/src/zkevm_specs/evm_circuit/table.py b/src/zkevm_specs/evm_circuit/table.py index af8aba5d8..f840f6a06 100644 --- a/src/zkevm_specs/evm_circuit/table.py +++ b/src/zkevm_specs/evm_circuit/table.py @@ -100,7 +100,7 @@ def table_assignments(self) -> List[FixedTableRow]: for (execution_state, precompile_address, base_gas_cost) in precompile_info_pairs() ] else: - raise ValueError("Unreacheable") + raise ValueError("Unreachable") def range_table_tag(range: int) -> FixedTableTag: if range == 5: @@ -242,7 +242,7 @@ class CallContextFieldTag(IntEnum): CalleeAddress = auto() CallDataOffset = auto() CallDataLength = auto() - ReturnDataOffset = auto() # for callee to set return_data to caller's memeory + ReturnDataOffset = auto() # for callee to set return_data to caller's memory ReturnDataLength = auto() Value = auto() IsSuccess = auto() # to peek result in the future diff --git a/src/zkevm_specs/evm_circuit/typing.py b/src/zkevm_specs/evm_circuit/typing.py index 56de28a02..0e5a6641c 100644 --- a/src/zkevm_specs/evm_circuit/typing.py +++ b/src/zkevm_specs/evm_circuit/typing.py @@ -65,7 +65,7 @@ class Block: coinbase: U160 # Gas needs a lot arithmetic operation or comparison in EVM circuit, so we - # assume gas limit in the near futuer will not exceed U64, to reduce the + # assume gas limit in the near future will not exceed U64, to reduce the # implementation complexity. gas_limit: U64 @@ -85,7 +85,7 @@ class Block: # mpt root of withdrawals in a block withdrawal_root: U256 - # It contains most recent 256 block hashes in history, where the lastest + # It contains most recent 256 block hashes in history, where the latest # one is at history_hashes[-1]. history_hashes: Sequence[U256] diff --git a/src/zkevm_specs/state_circuit.py b/src/zkevm_specs/state_circuit.py index bebc275a2..1fcdb404d 100644 --- a/src/zkevm_specs/state_circuit.py +++ b/src/zkevm_specs/state_circuit.py @@ -330,7 +330,7 @@ def check_call_context(row: Row, row_prev: Row): assert row.address() == 0 assert row.storage_key() == Word(0) - # 5.1. field_tag is in CallContexFieldTag range + # 5.1. field_tag is in CallContextFieldTag range assert_in_range(row.field_tag(), 0, MAX_FIELD_TAG) # 5.2. First access for a set of all keys @@ -610,7 +610,7 @@ def keys_rwc_to_limbs_in_order(row: Row) -> List[FQ]: elif row.tag() == Tag.TxLog: check_tx_log(row, row_prev) else: - raise ValueError("Unreacheable") + raise ValueError("Unreachable") # State circuit operation superclass diff --git a/tests/test_bytecode_circuit.py b/tests/test_bytecode_circuit.py index 8893fbcc3..1606db0c8 100644 --- a/tests/test_bytecode_circuit.py +++ b/tests/test_bytecode_circuit.py @@ -230,7 +230,7 @@ def test_bytecode_invalid_is_code(): ) verify(k, [invalid], randomness_keccak, False) - # Mark the 4rd byte as data (is code) + # Mark the 4th byte as data (is code) invalid = deepcopy(unrolled) row = unrolled.rows[4] invalid.rows[4] = BytecodeTableRow(