56 Commits

Author SHA1 Message Date
Jacqueline Nabaglo
0117541909
Merge pull request #1071 from mir-protocol/jacqui/bad-opcode-witness-generation
Error handling
2023-06-07 15:49:07 -07:00
wborgeaud
0f7e1c0b61
Call stack depth (#1081) 2023-06-07 18:54:06 +02:00
Jacqueline Nabaglo
448bc719d8 Lints 2023-06-03 18:46:24 -07:00
wborgeaud
1d804e46cc
Fix stack after precompiles (#1061)
* Fix precompiles stack

* Fix EXPMOD bugs (#1063)

* Fix expmod gas

* Overflow checks

* Many fixes

* Minor
2023-06-03 10:00:56 +02:00
Jacqueline Nabaglo
7ab0bba559
Merge branch 'main' into jacqui/bad-opcode-witness-generation 2023-06-02 21:34:52 -07:00
Jacqueline Nabaglo
b7220428b3 Error handling 2023-06-02 15:51:26 -07:00
wborgeaud
e6a7b8c5cb
Add contract creation flag (#1056)
* Add contract creation flag

* Minor

* Fix intrinsic gas test
2023-05-24 17:49:54 +02:00
wborgeaud
9b0092ab1d
Support for type-1 transactions (#1051)
* Type 1 txn

* Remove magic constants

* Remove useless stack element

* Read correct original value for sk

* EIP-3651

* Fix encoding when TO is 0

* Minor
2023-05-23 09:21:27 +02:00
wborgeaud
971bfba64a
EIP-2681: Limit account nonce to 2^64-1 (#1048)
* EIP-2681: Limit account nonce to 2^64-1

* Also for EOA

* Minor
2023-05-18 15:22:36 +02:00
wborgeaud
84c156066b
Minor fixes to returndata and create (#1043)
* Fix returndata

* Add AccountCreated event

* returndatacopy_afterFailing_create.json passes

* Fix
2023-05-17 10:06:12 +02:00
wborgeaud
244d5e9b3c
Add refund journal event and checkpoint after access address event (#1040) 2023-05-16 14:36:17 +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
944d4a2460
SSTORE refund (#1018)
* SSTORE refund

* SSTORE refund

* Minor
2023-05-11 14:18:34 +02:00
Dima V
ae21ef8fd1
Merge pull request #997 from mir-protocol/pairing-test
Restructure BN254 Pairing Precompile to fit EVM Test Spec
2023-04-28 22:11:56 -07:00
wborgeaud
4ad8520e34
SNARKV precompile (#1010)
* Serialize impls, and use in Fibonacci example

* seralizing

* cleanup

* don't serialize challenges

* deterministic build function

* cleanup

* cleanup

* cleanup

* fix

* cleanup

* fmt

* rename

* Unpacking and storing inputs

* Finish snarkv interface

* Failing test

* move serialization to separate example

* Imaginary part in front of real

* serialize ProofChallenges

* remove build_without_randomizing (no longer needed)

* fix

* Fix kernel peak

* Fix stack comments

* Minor

* SSTORE gas (#1007)

* Update storage access list and sload

* Add noop for sys_sstore

* Comments

* Fix access list test

* PR feedback

---------

Co-authored-by: Nicholas Ward <npward@berkeley.edu>
2023-04-27 19:21:26 +02:00
Nicholas Ward
9339847243 Merge branch 'precompile-fixes' into blake_precompile 2023-04-24 11:51:11 -07:00
Nicholas Ward
5f564b6782 initial work on blake precompile 2023-04-20 15:11:19 -07:00
Dmitry Vagner
4e0be66432 Merge branch 'main' of github.com:mir-protocol/plonky2 into pairing-test 2023-04-20 13:46:07 -07:00
wborgeaud
1a0a63003d
EIP170 (#1000) 2023-04-20 17:28:33 +02:00
Dmitry Vagner
b661a70904 twisted check 2023-04-19 23:06:02 -07:00
wborgeaud
b721236eb3
Precompiles interface (#983)
* Start

* Some sha256 test passing

* precompiles folder

* Files reorg

* Progress

* Minor

* Start of sha2 interface

* All call opcodes

* ecrec

* rip160

* Fix copy_returndata_to_mem

* id

* bn_add

* bn_mul

* TODOs for snarkv and blake2

* Comments

* Use charge_gas_const when possible

* Minor

* Minor

* Minor

* PR feedback
2023-04-14 12:20:28 +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
BGluth
3c7bc8835c Removed a type alias
- Was conflicting with the trait `PartialTrie` and also making the types
  harder to follow.
2023-03-28 14:38:58 -06:00
BGluth
60ad9e03ba Bumped eth_trie_utils to 0.5.0 2023-03-27 17:30:11 -06: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
Nicholas Ward
64c76e76dd Merge branch 'main' into bignum-basic 2023-03-19 22:19:54 -07:00
Daniel Lubarov
f717a40b85 Charge for memory expansion 2023-03-19 20:17:30 -07:00
Nicholas Ward
e8405effa1 Merge branch 'main' into bignum-basic 2023-03-19 17:29:51 -07:00
Daniel Lubarov
a05ed9fc3a Fix clobbering of RLP data memory 2023-03-19 11:49:15 -07:00
Nicholas Ward
c3ba7a8917 Merge branch 'main' into bignum-basic 2023-03-17 14:19:36 -07:00
Daniel Lubarov
8c692b72b0 Fix account cloning 2023-03-17 13:10:58 -07:00
Nicholas Ward
6f05a144cb Merge branch 'main' into bignum-basic 2023-03-13 10:17:43 -07:00
Daniel Lubarov
d5003b7cf2 Gas fees go to coinbase 2023-03-12 23:13:19 -07:00
Daniel Lubarov
84fbbbf410 Couple minor fixes 2023-03-10 17:02:15 -08:00
Nicholas Ward
fa605d7b22 basic bignum 2023-03-07 17:47:09 -08:00
Daniel Lubarov
e6aa62f3ab Some tooling for debugging tests where the updated tries are not correct 2023-03-06 08:26:54 -08:00
Daniel Lubarov
c558eedd65 Misc EVM fixes 2023-03-05 09:39:49 -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
f2e40541d9 Increment sender nonce + buy gas 2023-01-17 23:57:53 -08:00
Daniel Lubarov
df2ba7a384 Basic smart contract test 2023-01-14 21:18:58 -08:00
Nicholas Ward
29143fe5d3 fmt 2022-12-13 10:08:36 -08:00
Nicholas Ward
2e62ac1b63 cleanup 2022-12-13 10:08:36 -08:00
Nicholas Ward
779c46c7a3 clippy fix 2022-12-13 10:08:36 -08:00
Nicholas Ward
1367f9bcca fmt 2022-12-13 10:08:36 -08:00
Nicholas Ward
a1ea7ff930 progress 2022-12-13 10:08:16 -08:00
Daniel Lubarov
f4ab65f973 Fixes to get test_simple_transfer working 2022-12-08 23:27:20 -08:00
wborgeaud
9982d79999 Add msize 2022-10-20 19:23:01 +02:00