-
Notifications
You must be signed in to change notification settings - Fork 298
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
Make gas fit in 2 limbs #1261
Make gas fit in 2 limbs #1261
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
I think this is fine to merge and, as you said, maybe we can revert it later on for a production release.
let gas_diff = nv.gas[1] * P::Scalar::from_canonical_u64(1 << 32) + nv.gas[0] | ||
- (lv.gas[1] * P::Scalar::from_canonical_u64(1 << 32) + lv.gas[0]); | ||
let constr = gas_diff - gas_used; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could overflowing the field size be an issue here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm could be. The largest gas_used in the EVM test suite is 53 bits long, so we'd be fine even in this extreme case.
Couldn't we just add a specific TODO here saying that before prod, this should be reverted to only 1 limb?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we just add a specific TODO here saying that before prod, this should be reverted to only 1 limb?
Yes sounds good 👍
This reverts commit 0f19cd0.
* 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]>
Following discussion in 0xPolygonZero/evm-tests#35, handle gas (limit/used) in two limbs.
The primary goal is for testing, as currently more than 7000 tests can't pass the check due to the recent zkEVM updates.
The additional CPU column is I think acceptable, given that we've already reduced the width by quite a bit (116 columns with this PR), and there are a few PRs opened or incoming which should bring it close to 100. In the worst case, we could always revert this PR once we get close to production-readiness?
If that's considered a too large overhead for what it brings, we could instead keep it up to date whenever there are consequent changes on
main
, and bind the test runner to this branch? Or we could go for the partial solution of just augmenting to 2 limbs gas limit.