Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Fix typos (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
rex4539 authored Feb 26, 2024
1 parent 163f3c0 commit b0e6a0a
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion specs/error_state/ErrorInvalidJump.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
2 changes: 1 addition & 1 deletion specs/opcode/09MULMOD.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
2 changes: 1 addition & 1 deletion specs/opcode/1bSHL_1cSHR.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion specs/opcode/56JUMP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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\*
Expand Down
2 changes: 1 addition & 1 deletion specs/opcode/57JUMPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions specs/opcode/90SWAPX.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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\
Expand Down
2 changes: 1 addition & 1 deletion specs/public_inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion specs/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion specs/transactions-proof.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion specs/withdrawal-proof.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`
Expand Down
6 changes: 3 additions & 3 deletions src/zkevm_specs/evm_circuit/execution/begin_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/zkevm_specs/evm_circuit/execution/sar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/zkevm_specs/evm_circuit/instruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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])
)
Expand Down
4 changes: 2 additions & 2 deletions src/zkevm_specs/evm_circuit/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/zkevm_specs/evm_circuit/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]

Expand Down
4 changes: 2 additions & 2 deletions src/zkevm_specs/state_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bytecode_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit b0e6a0a

Please sign in to comment.