Commit Graph
125 Commits
Author SHA1 Message Date
wborgeaud 564864eac3 Remove parts of the copy-on-write logic (#1096)
* Remove parts of the copy-on-write logic

* Minor
2023-06-14 14:46:49 +02:00
wborgeaud bde7fb5019 Various fixes to checkpoint logic (#1039)
* Stack of checkpoints

* Fixes

* Don't use macro in revert selfdestruct

* All stZeroCallsTest, stNonZeroCallsTest, stZeroCallsRevert passing

* Minor
2023-05-16 10:47:38 +02:00
wborgeaud bfd6834dc2 Journal of state changes + state reversion (#1028)
* Add segments and global metadata

* Add journal asm files

* Start revert

* Revert access lists

* Revert balance transfer

* Revert code change

* Revert nonce change

* Revert storage change

* Checkpoints

* Add some journal entries

* Add some journal entries

* Add some journal entries

* Fix revert

* Checkpoint in sys_call

* Minor

* PR feedback

* More checkpoints

* Fix checkpoint check

* Minor

* Checkpoints in precompiles

* Storage change checkpoint

* Add touched addresses

* Add touched addresses revert

* Add touched addresses journal events

* Delete all empty touch addresses

* Implement selfdestruct

* Update aggregator.rs
2023-05-12 13:04:46 +02:00
wborgeaud ab692252ba Minor fixes to context creation (#961) 2023-04-08 09:06:02 +02:00
wborgeaud 8e04cbfe8d Self-destruct list (#948) 2023-04-01 07:29:22 +02:00
wborgeaud 2ca00a9ad4 Selfdestruct gas and set (#947)
* Add new segment and global metadata

* Insert into self-destruct set

* Implement sys_selfdestruct

* PR feedback

* Fix stack underflow

* Forgot that NOT 1 ≠ 0. Added %not_bit macro for that.
2023-03-31 11:13:36 +02:00
wborgeaud ce22d94518 Access lists (#937)
* Working linear search

* Working linear search for storage keys

* Macros

* Gas for wextaccount

* Add origin and to to the access list

* Handle precompiles

* Fixes

* Other opcodes

* Access list SLOAD

* Minor

* Add TODO for SSTORE

* Comments

* Clippy

* Minor

* PR feedback: cold_access

* PR feedback: simplify insert_accessed_addresses_no_return macro

* Fix sys_selfdestruct

* Store length in global metadata and store arrays in kernel memory

* Truncate address in all *CALL syscalls
2023-03-23 20:22:25 +01:00
Dmitry Vagner be35111034 Merge branch 'main' of github.com:mir-protocol/plonky2 into non-inv 2023-02-16 19:31:16 -08:00
Dmitry Vagner bce867188c simplify ripe md test 2023-02-15 18:18:26 -08:00
Dmitry Vagner e2cac0bb0c Merge branch 'main' of github.com:mir-protocol/plonky2 into non-inv 2023-02-15 12:33:43 -08:00
Jacqueline Nabaglo f3946f75bf Gas constraints (#880)
* Gas constraints

* Bugfix

* make test pass post rebase
2023-02-14 22:30:19 -08:00
Dmitry Vagner d320fbfbca update curve add with ops 2023-02-13 13:21:47 -08:00
Dmitry Vagner 787cc8903b change segment 2023-02-13 12:32:40 -08:00
wborgeaud ac40bd5f5d Optimize ecMul precompile (scalar multiplication on BN254) (#852)
* windowed mul

* Working

* Window of 4 bits

* Fix

* Comments

* Unroll loop

* Unroll loop

* remove global

* Minor

* Minor

* Implement `CALLVALUE, CALLDATALOAD, CALLDATASIZE, CALLDATACOPY` in interpreter

* Minor

* Doesn't work

* Minor

* Minor

* wnaf msm

* Working hardcoded values: 28657 opcodes

* Working wnaf

* Small wnaf optim

* Precompute works

* Working together

* Bump to 129 bits

* Working glv decomposition

* Working MSM with GLV

* Almost working

* Working

* ECC test folder

* Working with real sig data

* Fix tests + Clippy

* Minor

* Cleaning

* Comments

* Cleaning

* Smaller glv test file

* Print opcode count at the end of interpreter run

* More constants

* Add z3 proof that the GLV scalars are 129-bit or less

* Minor change to z3 proof

* Move files and renaming fns

* Testing

* Fix BN GLV

* BN precompute table

* Working precompute

* Working bn tests

* Working

* Minor

* Minor

* Use MULFP254

* Minor

* Merge conflicts

* Remove unused asm file

* ECC fns renaming (#874)

* PR feedback
2023-02-13 20:11:32 +01:00
wborgeaud ca002aeafa Optimize ecrecover ASM (#840)
* windowed mul

* Working

* Window of 4 bits

* Fix

* Comments

* Unroll loop

* Unroll loop

* remove global

* Minor

* Minor

* Implement `CALLVALUE, CALLDATALOAD, CALLDATASIZE, CALLDATACOPY` in interpreter

* Minor

* Doesn't work

* Minor

* Minor

* wnaf msm

* Working hardcoded values: 28657 opcodes

* Working wnaf

* Small wnaf optim

* Precompute works

* Working together

* Bump to 129 bits

* Working glv decomposition

* Working MSM with GLV

* Almost working

* Working

* ECC test folder

* Working with real sig data

* Fix tests + Clippy

* Minor

* Cleaning

* Comments

* Cleaning

* Smaller glv test file

* Print opcode count at the end of interpreter run

* More constants

* Add z3 proof that the GLV scalars are 129-bit or less

* Minor change to z3 proof

* Minor

* Hamish's suggestion

* Working

* Cleaning

* Clippy

* PR feedback

* Minor PR feedback
2023-01-31 19:23:54 +01:00
Daniel Lubarov 137bc78565 Prep for publishing to crates.io 2023-01-30 13:18:06 -08:00
Daniel Lubarov 88f64072ef Comments 2022-12-09 08:56:49 -08:00
Daniel Lubarov 1c5590fb22 Add dummy reads to fill any large gaps in memory fields 2022-12-05 15:48:09 -08:00
Daniel Lubarov 1303a83f7f Misc witness generation fixes 2022-12-03 21:09:57 -08:00
Daniel Lubarov b8b2fefe52 Use Keccak sponge table for bootloading
And get rid of the deprecated Keccak memory table.
2022-12-03 11:21:31 -08:00
Daniel Lubarov 82d0f08193 clippies 2022-12-02 17:06:30 -08:00
Daniel Lubarov 05ab3d7933 Fixes 2022-12-01 16:23:39 -08:00
Daniel Lubarov 9bf47ef8ac Fixes 2022-12-01 12:46:14 -08:00
Daniel Lubarov afb3e4b1e1 Misc work on witness generation 2022-11-30 14:58:40 -08:00
Daniel Lubarov d23cecfcd8 Kernel code to do jumpdest analysis 2022-11-21 13:06:03 -08:00
Hamish Ivey-Law 1c87fbb712 EVM shift left/right operations (#801)
* First parts of shift implementation.

* Disable range check errors.

* Tidy up ASM.

* Update comments; fix some .sum() expressions.

* First full draft of shift left/right.

* Missed a +1.

* Clippy.

* Address Jacqui's comments.

* Add comment.

* Fix missing filter.

* Address second round of comments from Jacqui.
2022-11-09 10:47:15 +11:00
wborgeaud fd96d30e24 Minor 2022-10-27 14:57:17 +02:00
wborgeaud 6b4cce21d8 Start 2022-10-21 18:00:41 +02:00
Daniel Lubarov 7f366cdace Treat storage tries as sub-tries of the state trie
I.e. have leaves in the state trie point to the root of a storage trie
2022-10-16 20:26:37 -07:00
Daniel Lubarov 299aabf860 Fix branch hashing bug 2022-10-11 15:56:23 -07:00
Daniel Lubarov f2cb42bbe8 MPT logic to hash branch nodes 2022-10-05 20:46:49 -07:00
Daniel Lubarov b6d71a7008 Keccak benchmark
And reworking things a bit to include the timing data we want.
2022-09-23 10:54:17 -07:00
Jacqueline Nabaglo 084700a7f4 Memory channel for program counter (#717) 2022-09-22 18:09:23 -07:00
Daniel Lubarov aa87f2c3ba Public memory 2022-08-25 20:19:18 -07:00
Daniel Lubarov c38a98f9e4 Simpler CPU <-> memory CTL 2022-08-23 23:38:28 -07:00
Daniel Lubarov 6a7e8d0fb0 Trie related segments and metadata
Summary of the design:
- Tries are stored as immutable, copy-on-write trees
- All trie data is stored in the `TrieData` segment. Since it's immutable, data is never modified/deleted, new versions are just appended at the end.
- In order to support reverts, each context stores a pointer to the initial state trie version, plus the initial version of each storage trie.

One variation which may be worth considering is storing the whole state trie as one big trie (with sub-tries for storage). Reverts would then be simpler - we'd replace a single pointer. I thought that approach might make hashing the trie a bit more complex, as the node associated with an account would be a special type of node, rather than just another leaf. Either approach seems reasonable though.
2022-08-13 13:24:58 -07:00
Daniel Lubarov 137076c964 Revert "Add static"
This reverts commit 90c4e1b9d1.
2022-08-13 12:16:19 -07:00
Daniel Lubarov 90c4e1b9d1 Add static 2022-08-13 12:15:42 -07:00
Daniel Lubarov cc61c7211c Core transaction processing logic
With lots of TODOs to fill in afterward; this is just a start.
2022-08-12 17:20:18 -07:00
Nicholas Ward bbcb419521 fmt 2022-08-04 14:56:16 -04:00
Nicholas Ward bf4cf1c64f fix 2022-08-04 14:40:34 -04:00
Daniel Lubarov 3f08cca116 More constants for kernel ASM
- `GlobalMetadata` - offsets for global kernel variables in memory
- `ContextMetadata` - offsets for context-specific kernel variables in memory
- `GAS_CONSTANTS`, based on the yellowpaper

Also move constants to a separate module since `aggregator` was getting long.
2022-08-01 18:18:22 -07:00
Daniel Lubarov bb45c8c850 Merge pull request #629 from proxima-one/maybe-rayon
add rayon shim
2022-07-28 11:38:56 -07:00
wborgeaud ac68ce62c2 Merge conflicts 2022-07-27 10:16:04 +02:00
wborgeaud fbfe0ad62a Merge branch 'main' into interpreter_context_segments 2022-07-27 10:12:59 +02:00
wborgeaud e8ab92b115 PR feedback 2022-07-27 10:05:31 +02:00
wborgeaud 304299a007 Add assert to range check memory values 2022-07-25 10:39:51 +02:00
wborgeaud 715c350ee8 Implement mload/store_general 2022-07-25 10:34:18 +02:00
Sebastien La Duca e48bfa837f fmt 2022-07-24 18:06:03 -04:00
Sebastien La Duca c9d610ec10 use maybe_rayon in starky and evm 2022-07-24 17:47:14 -04:00