176 Commits

Author SHA1 Message Date
Hamy Ratoanina
3810bd1ae9
Charge gas for native instructions in interpreter (#1348)
* Charge gas for native instructions in interpreter

* Apply comment

* Format
2023-11-10 16:37:54 -05:00
Robin Salen
7447959fad
Fix kexit_info in test 2023-10-27 11:15:23 -04:00
Robin Salen
15a9e9928a
Fix test on interpreter side 2023-10-26 17:08:40 -04:00
Robin Salen
29005dc586
Use SUBMOD in Kernel 2023-10-21 11:44:23 -04:00
Hamy Ratoanina
1d60431992
Store top of the stack in memory channel 0 (#1215)
* Store top of the stack in memory channel 0

* Fix interpreter

* Apply comments

* Remove debugging code

* Merge commit

* Remove debugging comments

* Apply comments

* Fix witness generation for exceptions

* Fix witness generation for exceptions (again)

* Fix modfp254 constraint
2023-10-11 16:28:49 -04:00
Robin Salen
03a9558198
Handle additional panics (#1250)
* Remove some panic risks

* Remove more panics

* Handle jump with empty stack

* Handle last expect

* More panics

* Handle from_big_endian

* Handle from_little_endian

* Remove remaining risky as_usize()

* Remove explicit panic

* Clippy

* Handle unwrap

* Make error messages more explicit

* Simplify u256 to usize conversion
2023-09-26 11:13:57 -04:00
Robin Salen
5a1b05acfb
Remove risks of panic 2023-09-12 19:23:16 -04:00
Robin Salen
9508b49090
Move byte packing / unpacking to a distinct table (#1212)
* Duplicate Memory trace into BytePacking one

* Add mload_32bytes instruction

* Use dedicated ops for byte packing trace

* Change witness generation to reduce memory reads for MLOAD_32BYTES

* Remove segments

* Fix stack

* Fix extra product when fixing CTL for byte_packing

* Write output value in trace

* Add constraints for BYTE_PACKING table

* Add recursive constraints for BYTE_PACKING table

* Fix constraints

* Add address in trace and constraints

* Add timestamp and batch inputs into BytePackingOp struct

* Add extra column

* Fix BytePackingStark CTL

* Tiny fix in witness generation

* Fix the Memory CTL

* Add constraints for the new columns

* Remove 1 column

* Remove limb columns

* Fix

* Fix recursive circuit of BytePackingTable

* Fix constraints

* Fix endianness

* Add MSTORE_32BYTES instruction and move decomposition to packing table

* Add missing constraint

* Add range-check for all bytes

* Add extra constraint

* Cleanup

* Remove REMAINING_LEN column

* Add corresponding implementations in interpreter

* Fix recursive version

* Remove debug assertion because of CI

* Remove FILTER column

* Update new test from rebasing

* Reorder STARK modules to match TraceCheckPoint ordering

* Address comments

* Pacify clippy

* Add documentation to the packing module

* Fix doctest
2023-09-13 04:45:37 +10:00
Robin Salen
c0b4f155f4
Implement receipts and logs
Co-authored-by: Hamy Ratoanina <hamy.ratoanina@toposware.com>
Co-authored-by: Linda Guiga <lindaguiga3@gmail.com>
2023-08-22 20:00:49 +01:00
Nicholas Ward
975e9a49fa fmt 2023-06-20 12:51:55 -07:00
Nicholas Ward
8eeca9be95 undo dummy change 2023-06-20 12:48:38 -07:00
Nicholas Ward
2fa43121d7 dummy change to get tests to rerun :P 2023-06-20 12:48:21 -07:00
Nicholas Ward
9bb6da049e fmt 2023-06-20 12:30:37 -07:00
Nicholas Ward
afd4bd0406 cleanup 2023-06-20 12:02:45 -07:00
Nicholas Ward
bc53ddc56f fix 2023-06-20 12:01:24 -07:00
Jacqueline Nabaglo
cedeff5219 PUSH0 2023-06-13 13:29:30 -07:00
Robin Salen
9d60191d73
Implement returndatasize/returndatacopy for interpreter 2023-04-14 13:22:27 -04:00
Robin Salen
6946eacaca
Implement codesize/codecopy for interpreter 2023-04-14 11:41:39 -04:00
Robin Salen
0f3285c33b
Implement gasprice on the interpreter 2023-04-14 11:41:39 -04:00
Robin Salen
e9cc5632eb
Impl caller/address/origin opcodes for interpreter 2023-04-14 11:41:38 -04:00
Robin Salen
011ea8e49b
Fix from review 2023-04-11 07:46:22 -04:00
Robin Salen
3da8efa6ba
Implement sar in interpreter 2023-04-09 16:07:31 -04:00
Robin Salen
b943ddb0d2
Implement signextend in interpreter 2023-04-09 16:07:31 -04:00
Robin Salen
4db004417c
Implement sgt in interpreter 2023-04-09 10:28:43 -04:00
Robin Salen
ac2ccc1eb9
Implement slt in interpreter 2023-04-09 10:28:42 -04:00
Robin Salen
232832e34d
Implement smod in interpreter 2023-04-09 10:28:42 -04:00
Robin Salen
18d317b9cf
Implement sdiv in interpreter. 2023-04-09 10:28:42 -04:00
Robin Salen
2fae2fbcc0
Impl gaslimit opcode for interpreter 2023-04-08 14:28:59 -04:00
Robin Salen
9e6f284b26
Impl chain_id opcode for interpreter 2023-04-08 14:28:58 -04:00
Robin Salen
ae8ee27eb8
Impl coinbase opcode for interpreter 2023-04-08 14:28:58 -04:00
Robin Salen
e3572f1d10
Impl basefee opcode for interpreter 2023-04-08 14:28:58 -04:00
Robin Salen
86bd055b5f
Impl difficulty opcode for interpreter 2023-04-08 14:28:58 -04:00
Robin Salen
60fed608ef
Impl number opcode for interpreter 2023-04-08 14:28:57 -04:00
Robin Salen
a17c6231a7
Impl timestamp opcode for interpreter 2023-04-08 14:28:57 -04:00
Nicholas Ward
d59fa59af8
Merge pull request #925 from mir-protocol/bignum-modexp
Bignum modexp
2023-04-04 13:37:48 -07:00
Nicholas Ward
6a4e9ab60e fix 2023-04-04 13:34:36 -07:00
Nicholas Ward
90f7ba9a23 addressed final comments 2023-04-04 13:33:20 -07:00
Daniel Lubarov
f71d364237
Merge pull request #945 from mir-protocol/remove_CONSUME_GAS
Remove `CONSUME_GAS`
2023-03-29 13:17:06 -07:00
Hamish Ivey-Law
9480cbed99
Signed operations as syscalls (#933)
* Implement syscalls for BYTE, SIGNEXTEND, SAR, SLT and SGT.

* Implement SDIV and SMOD; minor documentation and tidying.

* Implement EXP.

* Add sys_byte to the syscall jumptable.

* Test suite for signed syscalls.

* Handle `EXIT_KERNEL` "properly".

* Add gas charges; rename label.

* Uppercase all opcodes.

* Add test for BYTE; fix bug in BYTE.

* Calculate and charge gas for calling `EXP`.

* Fix gas calculation for `exponent = 0`.

* Address Jacqui's comments.

* Remove BYTE syscall as it will be implemented natively.

* Oops, forgot to remove this bit.
2023-03-30 05:56:01 +11:00
Daniel Lubarov
2d87c5d627 Remove CONSUME_GAS
Now that gas info is in `kexit_info`.
2023-03-29 11:28:05 -07:00
Nicholas Ward
c18377d12f Merge branch 'main' into bignum-modexp 2023-03-28 11:15:27 -07:00
Nicholas Ward
91fb4fc02e fix modexp test 2023-03-28 11:15:01 -07: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
7028b6ba74 comment 2023-03-22 18:48:02 -07:00
Nicholas Ward
e471818c2b comments 2023-03-22 09:48:17 -07:00
Dmitry Vagner
143225f449 finish 2023-03-21 19:19:02 -07:00
Nicholas Ward
d928423c63 cleanup 2023-03-21 16:18:53 -07:00
Nicholas Ward
d59501e6a7 fixes, testing, and in-progress debugging 2023-03-21 16:03:54 -07: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