Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add memory checks for prover_input, as well as range_checks for prover_input, syscalls/exceptions #1168

Merged
merged 11 commits into from
Nov 7, 2023

Conversation

LindaGuiga
Copy link
Contributor

This PR addresses the prover_input and syscalls/exceptions points from this issue.

  • STACK_BEHAVIORS is addressed to add stack constraints for prover_input.
  • CTLs and ArithmeticStark are updated to include range checks for prover_input, syscalls and exceptions in the CpuStark.

@LindaGuiga LindaGuiga force-pushed the cpu-range-checks-arith branch from e92ec32 to d417b78 Compare August 9, 2023 18:50
@LindaGuiga
Copy link
Contributor Author

The latest push was to rebase on main, since the PR had conflicts with this merged PR.

Copy link
Contributor

@nbgl nbgl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but the cross-table lookup could be made simpler and more efficient :)

evm/src/arithmetic/mod.rs Outdated Show resolved Hide resolved
evm/src/witness/operation.rs Outdated Show resolved Hide resolved
evm/src/cpu/cpu_stark.rs Outdated Show resolved Hide resolved
Comment on lines 114 to 115
cpu_stark::ctl_sys_exc_check_rows(),
cpu_stark::ctl_prover_input_check_rows(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each of these cross-table lookups adds an extra column to the CPU table, so ideally we'd like to have as few of them as possible. Luckily, we can just use the first CTL (cpu_stark::ctl_arithmetic_base_rows()) for range checks.

Comment on lines 131 to 184
pub fn ctl_sys_exc_check_rows<F: Field>() -> TableWithColumns<F> {
const OPS: [usize; 14] = [
COL_MAP.op.add,
COL_MAP.op.sub,
COL_MAP.op.mul,
COL_MAP.op.lt,
COL_MAP.op.gt,
COL_MAP.op.addfp254,
COL_MAP.op.mulfp254,
COL_MAP.op.subfp254,
COL_MAP.op.addmod,
COL_MAP.op.mulmod,
COL_MAP.op.submod,
COL_MAP.op.div,
COL_MAP.op.mod_,
COL_MAP.op.byte,
];
// Create the CPU Table whose columns are the gas value and the rest of the columns are 0.
let filter = Some(Column::sum([COL_MAP.op.syscall, COL_MAP.op.exception]));

TableWithColumns::new(
Table::Cpu,
ctl_data_sys_exc_range_check(&OPS, &EXTRA_OPS),
filter,
)
}

pub fn ctl_prover_input_check_rows<F: Field>() -> TableWithColumns<F> {
const OPS: [usize; 14] = [
COL_MAP.op.add,
COL_MAP.op.sub,
COL_MAP.op.mul,
COL_MAP.op.lt,
COL_MAP.op.gt,
COL_MAP.op.addfp254,
COL_MAP.op.mulfp254,
COL_MAP.op.subfp254,
COL_MAP.op.addmod,
COL_MAP.op.mulmod,
COL_MAP.op.submod,
COL_MAP.op.div,
COL_MAP.op.mod_,
COL_MAP.op.byte,
];
// Create the CPU Table whose columns are the gas value and the rest of the columns are 0.
let filter = Some(Column::single(COL_MAP.op.prover_input));

TableWithColumns::new(
Table::Cpu,
ctl_data_prover_input_range_check(&OPS, &EXTRA_OPS),
filter,
)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can be deleted: we can reuse the base arithmetic CTL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nbgl The reason why I didn't reuse the base arithmetic CTL here was because I only selected the useful columns in the CPU for prover_input and syscalls/exceptions. For prover_input, the logic would still work with the base arithmetic CTL, but since we only wanted to range check output[6] for syscalls and exceptions, I thought we had to create an additional ctl. Am I missing something?
What I also thought we could do to avoid adding a CPU column is to range check handler_addr0-2 and syscall_info/exc_info, since they're already in the columns selected by the base CTL, instead of only range checking the gas. What do you think?

@@ -114,7 +206,7 @@ pub fn ctl_arithmetic_base_rows<F: Field>() -> TableWithColumns<F> {
// the third input.
TableWithColumns::new(
Table::Cpu,
ctl_data_ternops(&OPS, false),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to add COL_MAP.op.syscall + COL_MAP.op.exception + COL_MAP.op.prover_input to the OPS list. This can be done with the Column::sum API, but will require a reworking of ctl_data_ternops.

This way we don't have to have a separate cross-table lookup just for range checks.

@LindaGuiga
Copy link
Contributor Author

@nbgl Thank you for your review!
I replaced the u32 values for range checks by U256 to simplify things, as you suggested.
Regarding the use of ctl_arithmetic_base_rows instead of additional CTLs, since the columns required, on the cpu side, for syscalls and exceptions are different from the other operations, I not only range checked the gas but also the handler addresses and syscall/exc_info, since they are also U256s and are already in the "correct" rows. What do you think of this approach?

@nbgl nbgl self-requested a review September 15, 2023 19:03
@LindaGuiga
Copy link
Contributor Author

LindaGuiga commented Oct 3, 2023

@nbgl I pushed a new version that does not introduce a new CTL for the range checks but instead adds a column OPCODE_COL in ArithmeticStark containing the opcode if the operation is a range check. This allows us to reuse ctl_arithmetic_rows for the range checks.
I constrained the new opcode column to be 0 when the operation is anything but a range check.
What do you think of this approach?

@Nashtare Nashtare added this to the EVM Audit Readiness milestone Oct 5, 2023
@LindaGuiga
Copy link
Contributor Author

@nbgl I pushed a new version that doesn't introduce a new CTL: the idea is that instead of range-checking the last memory channel for arithmetic operations, we check the next row's mem_channels[0] which should also contain the result (since it contains the new top of the stack). This enables us to check the new top of the stack for prover_inputs, syscalls and exceptions, which contains the values we want to range check. What do you think of this approach?

@pgebheim
Copy link
Collaborator

hey @nbgl -- What's the status on reviewing this?

@Nashtare Nashtare added the soundness Soundness related changes label Oct 23, 2023
@pgebheim
Copy link
Collaborator

pgebheim commented Nov 3, 2023

Hey @Nashtare -- are you going to be reviewing this to get it merged?

@Nashtare
Copy link
Collaborator

Nashtare commented Nov 3, 2023

@pgebheim yeah I can, though I didn't as @nbgl was assigned the review already

@Nashtare Nashtare mentioned this pull request Nov 6, 2023
5 tasks
Copy link
Contributor

@nbgl nbgl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Copy link

sonarcloud bot commented Nov 7, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@LindaGuiga LindaGuiga merged commit e41435e into 0xPolygonZero:main Nov 7, 2023
4 checks passed
wborgeaud pushed a commit that referenced this pull request Nov 14, 2023
…r_input, syscalls/exceptions (#1168)

* Add memory checks for prover_input and range_checks for prover_input, syscalls and exceptions

* Replace u32 by U256, and remove extra CTLs

* Add column in ArithmeticStark to use ctl_arithmetic_base_rows for is_range_check

* Fix CTLs and circuit constraint.

* Fix CTLs
pgebheim added a commit that referenced this pull request Nov 27, 2023
* Squashed commit of the following:

commit 4f854e6
Author: wborgeaud <[email protected]>
Date:   Fri Nov 3 13:48:23 2023 +0100

    Minor

commit fbd4c78
Merge: ad580c2 c70a785
Author: wborgeaud <[email protected]>
Date:   Fri Nov 3 13:42:45 2023 +0100

    Merge branch 'feat/type2' into type2/smt_deletion

    # Conflicts:
    #	evm/src/cpu/kernel/aggregator.rs
    #	evm/src/cpu/kernel/asm/mpt/storage/storage_write.asm
    #	evm/src/cpu/kernel/asm/smt/insert.asm
    #	evm/src/cpu/kernel/asm/smt/utils.asm
    #	evm/src/cpu/kernel/constants/mod.rs
    #	evm/src/cpu/kernel/tests/smt/mod.rs
    #	evm/tests/selfdestruct.rs

commit c70a785
Author: wborgeaud <[email protected]>
Date:   Fri Nov 3 13:37:19 2023 +0100

    Start of SMT implementation for Type 2 zkEVM (#1315)

    * Add SMT types

    * Progress

    * Progress

    * Working smt hashing

    * Minor

    * Fix hash

    * Working insert

    * Minor

    * Add insert test for storage trie

    * Add missing constraints for DUP/SWAP (#1310)

    * Refactor wcopy syscalls

    * Refactor memcpy

    * Working test_simple_transfer

    * Modify add11_yml.rs

    * Refactor codecopy

    * Fix

    * Fix calldatacopy

    * Fix test on interpreter side

    * Remove new_stack_top_channel from StackBehavior (#1296)

    * Working add11_yml.rs

    * All tests compile

    * Working test_balance

    * Minor

    * Working test_extcodesize

    * All non-ignored tests pass

    * Fix test_empty_txn_list

    * Clippy

    * smt_utils point to github

    * Comments

    * Fix kexit_info in test

    * Review

    * Update Cargo.toml

    * Move empty check inside final iteration

    * Remerge context flags (#1292)

    * Remerge context flags

    * Apply comments and revert some unwanted changes

    * Merge NOT and POP flags. (#1257)

    * Merge NOT and POP flags

    * Add comments

    * Disable remaining memory channels for POP

    * Apply comments

    * Fix stack

    * More of memcpy_bytes

    * Add some documentation in EVM crate (#1295)

    Co-authored-by: Linda Guiga <[email protected]>

    * Combine PUSH0 and PC flags. (#1256)

    * PR feedback

    * Add context constraints (#1260)

    * Combine JUMPDEST and KECCAK_GENERAL flags. (#1259)

    * Combine JUMPDEST and KECCAK_GENERAL flags.

    * Apply comments

    * Fix merging of jumpdest and keccak_general.

    * Add test for selfdestruct (#1321)

    * Add test for selfdestruct

    * Comment

    * Fix test

    ---------

    Co-authored-by: Hamy Ratoanina <[email protected]>
    Co-authored-by: Robin Salen <[email protected]>
    Co-authored-by: Linda Guiga <[email protected]>
    Co-authored-by: Robin Salen <[email protected]>
    Co-authored-by: Linda Guiga <[email protected]>
    Co-authored-by: Linda Guiga <[email protected]>

commit ad580c2
Author: wborgeaud <[email protected]>
Date:   Thu Nov 2 08:40:46 2023 +0100

    Clippy

commit fe5b8fd
Author: wborgeaud <[email protected]>
Date:   Thu Nov 2 08:39:26 2023 +0100

    s/mpt/smt in a bunch of places

commit 73dc262
Author: wborgeaud <[email protected]>
Date:   Thu Nov 2 08:15:56 2023 +0100

    Selfdestruct test passes

commit 539190f
Merge: e110941 f71f227
Author: wborgeaud <[email protected]>
Date:   Thu Nov 2 07:58:15 2023 +0100

    Merge branch 'main' into type2/smt_deletion

commit e110941
Author: wborgeaud <[email protected]>
Date:   Wed Nov 1 17:04:38 2023 +0100

    Minor

commit f7fba35
Author: wborgeaud <[email protected]>
Date:   Wed Nov 1 12:24:13 2023 +0100

    PR feedback

commit e528b89
Author: wborgeaud <[email protected]>
Date:   Mon Oct 30 09:11:25 2023 +0100

    Update Cargo.toml

commit 5eaf83e
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 12:34:52 2023 +0200

    Comments

commit ae9c443
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 11:51:16 2023 +0200

    smt_utils point to github

commit b3d61b7
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 11:49:33 2023 +0200

    Clippy

commit ccb3d7e
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 10:00:20 2023 +0200

    Fix test_empty_txn_list

commit 986b010
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 09:48:14 2023 +0200

    All non-ignored tests pass

commit 7bb0c02
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 09:44:40 2023 +0200

    Working test_extcodesize

commit b8a85d4
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 09:38:08 2023 +0200

    Minor

commit 2c01b05
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 09:37:05 2023 +0200

    Working test_balance

commit e370b62
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 09:13:36 2023 +0200

    All tests compile

commit f21bc5c
Author: wborgeaud <[email protected]>
Date:   Fri Oct 27 08:31:04 2023 +0200

    Working add11_yml.rs

commit 4e2b3f3
Author: wborgeaud <[email protected]>
Date:   Thu Oct 26 18:50:32 2023 +0200

    Modify add11_yml.rs

commit c324412
Author: wborgeaud <[email protected]>
Date:   Thu Oct 26 18:28:21 2023 +0200

    Working test_simple_transfer

commit df55e45
Author: wborgeaud <[email protected]>
Date:   Thu Oct 26 08:54:24 2023 +0200

    Add insert test for storage trie

commit ca0102f
Author: wborgeaud <[email protected]>
Date:   Thu Oct 26 08:42:03 2023 +0200

    Minor

commit dc27351
Author: wborgeaud <[email protected]>
Date:   Thu Oct 26 08:40:57 2023 +0200

    Working insert

commit f6c4067
Author: wborgeaud <[email protected]>
Date:   Wed Oct 25 08:07:31 2023 +0200

    Fix hash

commit c6e85eb
Author: wborgeaud <[email protected]>
Date:   Wed Oct 18 18:46:32 2023 +0200

    Minor

commit d95c430
Author: wborgeaud <[email protected]>
Date:   Wed Oct 18 18:32:05 2023 +0200

    Working smt hashing

commit fd09915
Author: wborgeaud <[email protected]>
Date:   Wed Oct 18 14:32:38 2023 +0200

    Progress

commit a706cda
Author: wborgeaud <[email protected]>
Date:   Wed Oct 18 07:37:26 2023 +0200

    Progress

commit 95e5cc1
Author: wborgeaud <[email protected]>
Date:   Fri Oct 13 09:19:45 2023 +0200

    Add SMT types

* Constrain uninitialized memory to 0 (#1318)

* Fix typos in comments

* Fix typos in comments

* Add test for ERC20 transfer (#1331)

* Working test

* Minor

* Cleaning

* Implement storage SMT

* Working ERC20 test

* Cleaning

* Remove `len` column in `KeccakSpongeStark` (#1334)

* Remove len column in KeccakSpongeStark

* Apply comment

Co-authored-by: Robin Salen <[email protected]>

---------

Co-authored-by: Robin Salen <[email protected]>

* Add withdrawals (#1322)

* Withdrawals

* Remove AllRecursiveCircuits in withdrawals test

* Fix ERC20 test

* Add memory checks for prover_input, as well as range_checks for prover_input, syscalls/exceptions (#1168)

* Add memory checks for prover_input and range_checks for prover_input, syscalls and exceptions

* Replace u32 by U256, and remove extra CTLs

* Add column in ArithmeticStark to use ctl_arithmetic_base_rows for is_range_check

* Fix CTLs and circuit constraint.

* Fix CTLs

* restore `no-std` support (#1335)

* perform test action on `x86_64-unknown-linux-gnu` and `wasm32-unknown-unknown`

Signed-off-by: muraca <[email protected]>

* make `plonky2` build on `wasm32-unknown-unknown`

Signed-off-by: muraca <[email protected]>

* make `starky` build on `wasm32-unknown-unknown`
small oversight on `plonky2` fixed

Signed-off-by: muraca <[email protected]>

* skip `evm` folder if target is `wasm32-unknown-unknown`

Signed-off-by: muraca <[email protected]>

* add `default: true` to toolchain

Signed-off-by: muraca <[email protected]>

* skip `test` if target is `wasm32-unknown-unknown`

Signed-off-by: muraca <[email protected]>

* single ticks instead of double

Signed-off-by: muraca <[email protected]>

* explicit target

Signed-off-by: muraca <[email protected]>

* wasm32 job

Signed-off-by: muraca <[email protected]>

* added `--no-default-features` to checks

Signed-off-by: muraca <[email protected]>

---------

Signed-off-by: muraca <[email protected]>

* Fix create_contract_account

* Fixes

* More fixes

* More fixes

* Minor

---------

Signed-off-by: muraca <[email protected]>
Co-authored-by: Paul Gebheim <[email protected]>
Co-authored-by: Hamy Ratoanina <[email protected]>
Co-authored-by: shuoer86 <[email protected]>
Co-authored-by: Robin Salen <[email protected]>
Co-authored-by: Linda Guiga <[email protected]>
Co-authored-by: Matteo Muraca <[email protected]>
Nashtare added a commit that referenced this pull request Feb 10, 2024
* Fix merging of jumpdest and keccak_general.

* Add test for selfdestruct (#1321)

* Add test for selfdestruct

* Comment

* Constrain uninitialized memory to 0 (#1318)

* Fix typos in comments

* Fix typos in comments

* Add test for ERC20 transfer (#1331)

* Working test

* Minor

* Cleaning

* Remove `len` column in `KeccakSpongeStark` (#1334)

* Remove len column in KeccakSpongeStark

* Apply comment

Co-authored-by: Robin Salen <[email protected]>

---------

Co-authored-by: Robin Salen <[email protected]>

* Add withdrawals (#1322)

* Withdrawals

* Remove AllRecursiveCircuits in withdrawals test

* Fix ERC20 test

* Add memory checks for prover_input, as well as range_checks for prover_input, syscalls/exceptions (#1168)

* Add memory checks for prover_input and range_checks for prover_input, syscalls and exceptions

* Replace u32 by U256, and remove extra CTLs

* Add column in ArithmeticStark to use ctl_arithmetic_base_rows for is_range_check

* Fix CTLs and circuit constraint.

* Fix CTLs

* restore `no-std` support (#1335)

* perform test action on `x86_64-unknown-linux-gnu` and `wasm32-unknown-unknown`

Signed-off-by: muraca <[email protected]>

* make `plonky2` build on `wasm32-unknown-unknown`

Signed-off-by: muraca <[email protected]>

* make `starky` build on `wasm32-unknown-unknown`
small oversight on `plonky2` fixed

Signed-off-by: muraca <[email protected]>

* skip `evm` folder if target is `wasm32-unknown-unknown`

Signed-off-by: muraca <[email protected]>

* add `default: true` to toolchain

Signed-off-by: muraca <[email protected]>

* skip `test` if target is `wasm32-unknown-unknown`

Signed-off-by: muraca <[email protected]>

* single ticks instead of double

Signed-off-by: muraca <[email protected]>

* explicit target

Signed-off-by: muraca <[email protected]>

* wasm32 job

Signed-off-by: muraca <[email protected]>

* added `--no-default-features` to checks

Signed-off-by: muraca <[email protected]>

---------

Signed-off-by: muraca <[email protected]>

* Move empty_check inside final iteration

* Remove logic for multiple txns at once (#1341)

* Have prover take only a single txn at most

* Update comment

* Apply review

* Constrain clock (#1343)

* Fix ranges in AllRecursiveCircuits initialization for log_opcode aggregation test (#1345)

* Root out some unwraps

* Range-check keccak sponge inputs to bytes (#1342)

* Range-check keccak sponge inputs to bytes

* Move outside of inner loop

* Apply review

* Charge gas for native instructions in interpreter (#1348)

* Charge gas for native instructions in interpreter

* Apply comment

* Format

* Remove unnecessary code duplication (#1349)

* Remove unnecessary code duplication

* Clippy

* Add run_syscall and tests for sload and sstore (#1344)

* Add run_syscall and tests for sload and sstore

* Replace panics with errors and address comments

* Apply comments

* Change last addr name in prepare_interpreter

* Fix kernel_mode in tests

* Minor cleanup

* Reduce visibility for a bunch of structs and methods in EVM crate (#1289)

* Reduce visibility for a bunch of structs and methods

* Remove redundant

* Remove values of last memory channel (#1291)

* Remove values of last memory channel

Co-authored-by: Linda Guiga <[email protected]>

* Fix merge

* Apply comments

* Fix ASM

* Top stack documentation (#7)

* Add doc file

* Apply comments

* Apply comments

* Fix visibility

* Fix visibility

---------

Co-authored-by: Linda Guiga <[email protected]>

* Fix MSTORE_32BYTES in interpreter (#1354)

* Fix parsing of non-legacy receipts (#1356)

* Fix parsing of non-legacy receipts

* Clippy

* Refactor JUMPDEST analysis (#1347)

* Use table for JUMPDEST

* Refactor jumpdest loop

* Update comment

---------

Co-authored-by: Robin Salen <[email protected]>

* Add push constraints (#1352)

* Add push constraints

* Fix ranges

* Add stack constraints

* Implement out of gas exception (#1328)

* Implement out of gas exception

* Use gas constants in gas_cost_for_opcode

* Remove comment

* Merge public values inside prove_aggreg (#1358)

* Constrain is_keccak_sponge (#1357)

* Revert "Make gas fit in 2 limbs (#1261)" (#1361)

* Revert "Make gas fit in 2 limbs (#1261)"

This reverts commit 0f19cd0.

* Comment

* Update Memory in specs (#1362)

* Update Memory specs

* Apply comment

Co-authored-by: Robin Salen <[email protected]>

---------

Co-authored-by: Robin Salen <[email protected]>

* Add doc for privileged instructions (#1355)

* Add doc for privileged instructions

* Comment

* Update specs for Logic and Arithmetic Tables (#1363)

* Update specs for Logic and Arithmetic

* Apply comments

* Reduce visibility (#1364)

* Add specs for KeccakSponge (#1366)

* Add specs for KeccakSponge

* Apply comments

* Update Keccak-f specs. (#1365)

* Update Keccak-f specs.

* Apply comments

* wip

* Create README.md

* Update README.md

* Update README.md

Link 2 EVM Tests Repo

* Update README.md

* Update README.md (#1371)

* CTL and range-check documentation (#1368)

* CTL and range-check documentation

* Apply comments

* Add exceptions to specs (#1372)

* Add exceptions to specs

* Apply comments

* Starting the specs for the CPU logic (#1377)

* Add CPU logic section to specs

* Add kernel specs

* Apply comments

---------

Co-authored-by: Hamy Ratoanina <[email protected]>

* Initialize blockhashes (#1370)

* Initialize blockhashes

* Update comment

* Check is_kernel_mode when halting (#1369)

* Add specs for BytePackingStark (#1373)

* Start

* Finish documenting BytePackingStark

* Apply comments

* Apply comment

---------

Co-authored-by: Robin Salen <[email protected]>

* Add range check constraints for the looked table (#1380)

* Add constraints to check that looked tables are well constructed for range checks

* Fix comments

* Explain difference between simple opcodes and syscalls (#1378)

* Explain difference between simple opcodes and syscalls

* Apply comment

* Add specs for the CPU table (#1375)

* Add specs for the CPU table

* Add general columns

* Apply comments

* Apply comments

* Backporting gas handling to the specs (#1379)

* Backporting gas handling to the specs

* Fix typo and syscall handling

* Add specs for stack handling (#1381)

* Add specs for stack handling

* Apply comments

* Add MPT specs

* Update evm/spec/mpts.tex

Co-authored-by: David <[email protected]>

* Update evm/spec/mpts.tex

Co-authored-by: David <[email protected]>

* Update evm/spec/mpts.tex

Co-authored-by: David <[email protected]>

* Update evm/spec/mpts.tex

Co-authored-by: David <[email protected]>

* Update evm/spec/mpts.tex

Co-authored-by: David <[email protected]>

* Update evm/spec/mpts.tex

Co-authored-by: David <[email protected]>

* Fix typo in evm/spec/mpts.tex

Co-authored-by: David <[email protected]>

* Address comment

* Remove redundant sect about MPT

* Update evm/spec/mpts.tex

Co-authored-by: wborgeaud <[email protected]>

* Fix genesis block number in `prove_block` (#1382)

* Fix genesis block number target

* Add consistency check

* Fix genesis block number

* Revert pruning

* Cleanup

* Update error message with hashes

* Fix and add comment

* Make comment more explicit

* Fix run_syscall in interpreter. (#1351)

* Fix syscall and change sload test to catch the error

* Update comment

* Cleanup

* comment

* Remove extra rows in BytePackingStark (#1388)

* Have at most one row per (un)packing operation in BytePackingStark

* Change specs

* Fix comment

* Fix tests and apply comments

* Fix log_opcodes

* Add upgradeability to `AllRecursiveCircuits` and output verifier data (#1387)

* Add upgradeable preprocessed sizes

* Add verifier data

* Changes in interpreter and implement interpreter version for add11 (#1359)

* Fix interpreter, turn syscall opcodes into actual syscalls, create interpreter test for add11

* Rename test_add11 to test_add11_yml

* Apply comments

* Cleanup add11_yml interpreter test

* Make stack_top() return a Result, and remove Result from add11_yml test

* Apply comment

* Move stack_len_bounds_aux to general columns (#1360)

* Move stack_len_bounds_aux to general columns

* Update specs

* Apply comments

* Apply comment

* VerifierCircuitData Clone,PartialEq,Eq

* chore: from_values takes ref

* Optimize `num_bytes` and `hex_prefix_rlp` (#1384)

* Compute num_bytes non-deterministically

* Optimize hex_prefix_rlp

* Clean code

* Clippy

* Apply suggestions

Co-authored-by: Robin Salen <[email protected]>

* Clean

* Add endline

* Change 1^256 to U256_MAX

* Apply suggestions from code review

Co-authored-by: Robin Salen <[email protected]>

---------

Co-authored-by: Robin Salen <[email protected]>

* Revert "chore: from_values takes ref"

This reverts commit 7cc123e.

* chore: Remove TODOs about `from_values` taking a reference

* Remove bootstrapping (#1390)

* Start removing bootstrapping

* Change the constraint for kernel code initializing

* Update specs

* Apply comments

* Add new global metadata to circuit methods

* Change zero-initializing constraint

* Apply comment

* Update circuit size range for recursive test

* Remove intermediary block bloom filters (#1395)

* Remove intermediary block blooms

* Update specs

* Regenerate pdf

* Apply comment, remove unneeded segment

* Fix kernel codehash discrepancy (#1400)

* Fix set_context constraints (#1401)

* Fix set_context constraints

* Apply comment

* Pacify clippy (#1403)

* Update stack op cost (#1402)

* Update stack op cost

* Update from review

* Use logUp for CTLs (#1398)

* Use LogUp for CTLs

* Update specs

* Invert in batch

* Reorder framework sections

* Implement `PublicValues` retrieval from public inputs (#1405)

* Implement PublicValues retrieval from public inputs

* Use utility method

* Remove generic argument

* Typo

* Make some functions const (#1407)

* Implement degree 2 filters (#1404)

* Implement degree 2 filters

* Apply comments

* Remove GenerationOutputs (#1408)

* Optimize asserts (#1411)

* Implement MPT preinitialization (#1406)

* Implement MPT preinitialization

* Apply comments

* Replace GlobalMetadata reads with stores in the kernel

* Change memory specs

* Remove trie data length as a prover input

* Preinitialize all code segments (#1409)

* Preinitialize all code segments

* Add zero writes after code_size

* Use preinitializing for extcodesize

* Fix gas calculation

* Extend logic to extcodecopy

* Apply comments

* Remove is_keccak_sponge (#1410)

* Remove is_keccak_sponge

* Apply comment

* Use mstore_32bytes to optimize decode_int_given_len (#1413)

* chore: fix some comment typos

* Merge MSTORE_32BYTES and MLOAD_32BYTES columns (#1414)

* Merge MSTORE_32BYTES and MLOAD_32BYTES columns

* Fix circuit functions

* Apply comments

* Check that limbs after the length are 0 (#1419)

* Check that limbs after the length are 0

* Update comments

* Update comments

* Add `Checkpoint` heights (#1418)

* typo fix

* typo fix

* minor typo fix

* typo fix

* Fix a minor typo in evm/spec/cpulogic.tex

* Merge `push` and  `prover_input` flags (#1417)

* Merge PUSH and PROVER_INPUT flags

* Apply comment

* Rebase to main

* Refactor run_next_jumpdest_table_proof

* Fix jumpdest analisys test

* Constrain MSTORE_32BYTES new offset limbs (#1415)

* Apply suggestions from code review

Co-authored-by: Robin Salen <[email protected]>

* fix: make `from_noncanonical_biguint` work for zero (#1427)

* Eliminate nested simulations

* Remove U256::as_u8 in comment

* Fix fmt

* Clippy

* Add aborting signal (#1429)

* Add aborting signal

* Clippy

* Update to Option following comment

* Add ERC721 test (#1425)

* Add ERC721 test

* Add IS_READ column to BytePacking CTL

* Apply comment

* Change context to current context for BN precompiles (#1428)

* Change context to current for BN precompiles

* Rename segments

* rustfmt

* Added a Discord badge to `README.md`

* Regenerate tries upon Kernel failure during `hash_final_tries` (#1424)

* Generate computed tries in case of failure

* Only output debug info when hashing final tries

* Clippy

* Apply comments

* Add exceptions handling to the interpreter (#1393)

* Add exceptions handling to the interpreter

* Apply comments

* Fix comments

* Filter range checks (#1433)

* Add filtering to range-checks

* Cleanup

* Fix Clippy

* Apply comment

* Constrain new top to loaded value in MLOAD_GENERAL (#1434)

* Minor cleanup (#1435)

* Improve proof generation

* Constrain first offset of a segment (#1397)

* Constrain first offset of a segment

* Apply comment, revert debugging code

* Modify specs

* Apply comments

* Remove aborts for invalid jumps

* Rebase to main

* Refactor run_next_jumpdest_table_proof

* Fix jumpdest analisys test

* Apply suggestions from code review

Co-authored-by: Robin Salen <[email protected]>

* Eliminate nested simulations

* Remove U256::as_u8 in comment

* Fix fmt

* Clippy

* Improve proof generation

* Remove aborts for invalid jumps

* Remove aborts for invalid jumps and Rebase

* Clippy

* add Debug trait to PartitionWitness to enable trace information output (#1437)

* Refactor encode_empty_node and encode_branch_node

Clean code

Not important

Restore jumpdets_analysis.asm

Refactor encode_empty_node and encode_branch_node

* Constrain partial_channel (#1436)

* Add alternative method to prove txs without pre-loaded table circuits (#1438)

* Rebase to main

Refactor encode_empty_node and encode_branch_node

Add constant and store encoded empty node in an other position

Remove child segment

Clean code

Apply suggestions from code review

Co-authored-by: Robin Salen <[email protected]>

Remive global label

Move encoded empty nodes

* Remove duplicated label

* Restore simple_transfer and Clippy

* Clippy

* Pacify latest clippy (#1442)

* Add initial constraint z polynomial (#1440)

* Prevent some lints from being allowed (#1443)

* Add packed verification

* Fix minor error

* Minor

* Apply suggestions from code review

Co-authored-by: Linda Guiga <[email protected]>
Co-authored-by: Robin Salen <[email protected]>

* Address comments

* Remove assertion in packed verif

* Remove assertion

* Add some more explicit doc on plonky2 crate

* Rustdoc

* Add comment

* Remove gas check in sys_stop (#1448)

* Address bundling (#1426)

* Start

* Scale TxnFields

* Speed-up

* Misc fixes

* Other fixes

* Fix

* Fix offset

* One more fix

* And one more fix

* Fix

* Fix

* Fix init

* More interpreter fixes

* Final fixes

* Add helper methods

* Clippy

* Apply suggestions

* Comments

* Update documentation

* Regenerate pdf

* minor

* Rename some macros for consistency

* Add utility method for unscaling segments and scaled metadata

* Address comments

* Remove unused macro

* Add crate-level documentation (#1444)

* Add crate-level documentation

* Revert change

* Skip

* Typo

* Apply comments

* Rephrase paragraph

* Apply comments

* Adress reviewer comments

* Add some more + module doc

* chore: fix typos (#1451)

* Some more

* Fix `after_mpt_delete_extension_branch` (#1449)

* Fix after_mpt_delete_extension_branch

* Rename test

* PR feedback

* Address review comments

* Improve some calls to `%mstore_rlp` (#1452)

* Improve some calls to mstore_rlp

* Remove comment

* Add Boolean constraints for `ArithmeticStark` (#1453)

* Constrain IS_READ to be boolean

* Constrain arithmetic flags to be boolean

* Comment on memory stark

* Implement CTL bundling (#1439)

* Implement CTL bundling

* Cleanup

* Clippy

* Preallocate memory

* Apply comments and remove unnecessary functions.

* Start removing clones

* Set columns and filters inside if condition.

* Remove extra CTL helper columns

* Add circuit version, with cleanup and fixes

* Remove some overhead

* Use refs

* Pacify clippy

---------

Co-authored-by: Robin Salen <[email protected]>

* Intra doc link

* chore(evm,field,plonky2):fix typos (#1454)

* Use current context in ecrecover (#1456)

* Apply suggestions from code review

Co-authored-by: Robin Salen <[email protected]>

* Address comments

* Missing review comments

* Free up some CPU cycles (#1457)

* Free up some cycles

* Comments

* Apply suggestions from code review

Co-authored-by: Linda Guiga <[email protected]>

* Constrain syscall/exceptions filter to be boolean (#1458)

* Adress review comments

* Update empty_txn_list

* Fix comment

* Apply review

* Interpreter GenerationInputs (#1455)

* Add initialization with GenerationInputs to the interpreter

* Add new_with_generation_inputs_and_kernel

* Apply comments

* Remove full memory channel (#1450)

* Remove a full memory channel

* Remove unnecessary uses

* Revert PDF change

* Apply comments

* Apply more comments

* Move disabling functions to cpu_stark.rs

* Apply comments

* Bumped `eth_trie_utils`

- Contains important fixes.

* Add files via upload

* Update README.md

Add License / Contributing to readme

* Update Cargo.toml

Add license field to cargo manifest

* Packed rlp prover inputs (#1460)

* Pack rlp prover inputs

* Fix endianness bug

* Remove debug info and fix clippy

* Fix clippy (#1464)

* Fix fill_gaps (#1465)

* Add math rendering with Katex (#1459)

* fix: make add_generators public (#1463)

* proofreading (#1466)

* Fix simulation for jumpdest analysis (#1467)

* Remove some CPU cycles (#1469)

* Amortize mload_packing

* Reduce stack overhead

* Amortize mstore_unpacking

* Speed-up stack operation in hash.asm

* Misc

* Small tweaks

* Misc small optims

* Fix comments

* Fix main access to withdrawals

* Fix stack description

* minor: rename label

* Comments

---------

Co-authored-by: Linda Guiga <[email protected]>

* Remove some more CPU cycles (#1472)

* Speed-up some mload/mstore calls

* Misc

* Improve logs loop

* Speed-up bloom

* Speed-up access_lists loops

* Fix

* Speed up selfdestruct loop

* Speed-up touched_addresses loop

* Speed-up receipt loop

* Skip rep loop

* Fix

* Misc

* Review

* Fix touched_addresses removal (#1473)

* chore: update ci workflow (#1475)

* chore: bump `actions/checkout` and `actions/cache`

* chore: use `dtolnay/rust-toolchain` and `Swatinem/rust-cache` instead of outdated github actions

* chore: use `cargo test`

* chore: remove `actions-rs/cargo`

* fix: typo

* chore: enable to cancel in-progress jobs

* chore: add job timeouts

* Fix typos (#1479)

* Fix interpreter jumps (#1471)

* Fix interpreter jumps

* Apply comments

* Improve SHA2 precompile (#1480)

* Improve SHA2 precompile

* Review

* Add removed global label

* Improve `blake2f` call (#1477)

* Improve on blake2 operations

* Comments

* Remove swap_mstore calls by changing stack macros

* Speed-up `bn254` pairing operation (#1476)

* Speed-up bn254 operations

* Add comment for write_fp254_12_unit macro

* Refactor some macros

* nit: comment

* Add newline

* Improve `BIGNUM` operations (#1482)

* Fix bugs in jumpdest analysis (#1474)

* Fix simulation for jumpdest analysis

* Fix bugs in jumpdest analysis

* Update evm/src/cpu/kernel/asm/core/jumpdest_analysis.asm

Co-authored-by: Robin Salen <[email protected]>

* Address reviews

---------

Co-authored-by: Robin Salen <[email protected]>

* Fix circuit sizes (#1484)

* Use web_time crate instead of std::time (#1481)

* Use usize::BITS and wrapping_shr in reverse_index_bits_in_place_small (#1478)

* Add LA audit report

* Cleanup imports (#1492)

* Fix BaseSumGenerator and BaseSplitGenerator Ids (#1494)

* fix: different ids for generators with different bases

required for correct serialisation

Signed-off-by: electron-team <[email protected]>

* fixing wasm32 build issue

Signed-off-by: electron-team <[email protected]>

* fix fmt issue

Signed-off-by: electron-team <[email protected]>

---------

Signed-off-by: electron-team <[email protected]>

* Make CTLs more generic (#1493)

* Make number of tables generic

* Remove dependency on Table in the CTL module

* Remove needless conversion

* Remove more needless conversion

* Clippy

* Apply reviews

* Reorganize lookup / ctl modules (#1495)

* Reorganize lookup / ctl modules

* Apply review

* Some cleanup (#1498)

* Remove StarkProofWithMetadata (#1497)

* Add missing constraints mentioned by auditors (#1499)

* Fix nightly version

* Fix workflow

* Switch permutation argument for logUp in `starky` (#1496)

* Switch permutation argument for logUp in starky

* Apply comments

* Refactor check_lookup_options

* Comments

* Add more visibility

* std -> core

* Revert "Add more visibility"

This reverts commit 2b4e50e.

* Add more visibility to lookup items

* Fix no-std tests and add corresponding jobs in the CI (#1501)

* Revert "Remove StarkProofWithMetadata (#1497)" (#1502)

This reverts commit af0259c.

* Update new tests for Cancun

---------

Signed-off-by: muraca <[email protected]>
Signed-off-by: electron-team <[email protected]>
Co-authored-by: Linda Guiga <[email protected]>
Co-authored-by: wborgeaud <[email protected]>
Co-authored-by: Hamy Ratoanina <[email protected]>
Co-authored-by: shuoer86 <[email protected]>
Co-authored-by: Linda Guiga <[email protected]>
Co-authored-by: Matteo Muraca <[email protected]>
Co-authored-by: David Palm <[email protected]>
Co-authored-by: Paul Gebheim <[email protected]>
Co-authored-by: Chris Tian <[email protected]>
Co-authored-by: 4l0n50 <[email protected]>
Co-authored-by: puma314 <[email protected]>
Co-authored-by: yanziseeker <[email protected]>
Co-authored-by: Ben <[email protected]>
Co-authored-by: Pioua <[email protected]>
Co-authored-by: Ayush Shukla <[email protected]>
Co-authored-by: BGluth <[email protected]>
Co-authored-by: Icer <[email protected]>
Co-authored-by: vuittont60 <[email protected]>
Co-authored-by: Ratan Kaliani <[email protected]>
Co-authored-by: Ursulafe <[email protected]>
Co-authored-by: Léo Vincent <[email protected]>
Co-authored-by: Thabokani <[email protected]>
Co-authored-by: Vivek Pandya <[email protected]>
Co-authored-by: Daniel Lubarov <[email protected]>
Co-authored-by: Utsav Jain <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
soundness Soundness related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants