Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into cycle_output_interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare committed Mar 4, 2024
2 parents effba5d + 106130e commit df3063f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Clean up logging output upon Kernel failure ([#74](https://github.com/0xPolygonZero/zk_evm/pull/74))
- Fix CPU Cycle display in logs during simulations ([#77](https://github.com/0xPolygonZero/zk_evm/pull/77))
- Fix blake2 precompile ([#78](https://github.com/0xPolygonZero/zk_evm/pull/78))

## [0.1.1] - 2024-03-01

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,47 @@ global precompile_blake2_f:
%checkpoint // Checkpoint
%increment_call_depth
// stack: (empty)
PUSH 0x100000000 // = 2^32 (is_kernel = true)
// stack: kexit_info

PUSH blake2_f_contd
// stack: blake2_f_contd, kexit_info

// Load inputs from calldata memory into stack.

%calldatasize
// stack: calldatasize, blake2_f_contd, kexit_info
// stack: calldatasize, blake2_f_contd
DUP1
// stack: calldatasize, calldatasize, blake2_f_contd, kexit_info
// stack: calldatasize, calldatasize, blake2_f_contd
%eq_const(213) ISZERO %jumpi(fault_exception)
// stack: calldatasize, blake2_f_contd, kexit_info
// stack: calldatasize, blake2_f_contd
%decrement
// stack: flag_addr=212, blake2_f_contd, kexit_info
// stack: flag_addr=212, blake2_f_contd
DUP1
// stack: flag_addr, flag_addr, blake2_f_contd, kexit_info
// stack: flag_addr, flag_addr, blake2_f_contd
PUSH @SEGMENT_CALLDATA
GET_CONTEXT
%build_address
// stack: addr, flag_addr, blake2_f_contd, kexit_info
// stack: addr, flag_addr, blake2_f_contd
MLOAD_GENERAL
// stack: flag, flag_addr, blake2_f_contd, kexit_info
// stack: flag, flag_addr, blake2_f_contd
DUP1
// stack: flag, flag, flag_addr, blake2_f_contd, kexit_info
// stack: flag, flag, flag_addr, blake2_f_contd
%gt_const(1) %jumpi(fault_exception) // Check flag < 2 (flag = 0 or flag = 1)
// stack: flag, flag_addr, blake2_f_contd, kexit_info
SWAP1
// stack: flag_addr, flag, blake2_f_contd, kexit_info

PUSH 0x100000000 // = 2^32 (is_kernel = true)
// stack: kexit_info, flag, flag_addr, blake2_f_contd

%stack () -> (@SEGMENT_CALLDATA, 4)
GET_CONTEXT
// stack: ctx, @SEGMENT_CALLDATA, 4, kexit_info, flag, flag_addr, blake2_f_contd
%build_address_no_offset
MLOAD_32BYTES
// stack: rounds, kexit_info, flag, flag_addr, blake2_f_contd
%charge_gas
// stack: kexit_info, flag, flag_addr, blake2_f_contd

%stack (kexit_info, flag, flag_addr, blake2_f_contd)
-> (flag_addr, flag, blake2_f_contd, kexit_info)

%sub_const(8)
// stack: t1_addr=flag_addr-8, flag, blake2_f_contd, kexit_info

Expand Down Expand Up @@ -106,12 +117,7 @@ global precompile_blake2_f:
// stack: ctx, @SEGMENT_CALLDATA, 4, h_0..h_7, m_0..m_15, t_0, t_1, flag, blake2_f_contd, kexit_info
%build_address_no_offset
MLOAD_32BYTES
// stack: rounds, h_0..h_7, m_0..m_15, t_0, t_1, flag, blake2_f_contd, kexit_info
DUP1
// stack: rounds, rounds, h_0..h_7, m_0..m_15, t_0, t_1, flag, blake2_f_contd, kexit_info
%charge_gas

// stack: rounds, h_0..h_7, m_0..m_15, t_0, t_1, flag, blake2_f_contd, kexit_info
%jump(blake2_f)
blake2_f_contd:
Expand Down

0 comments on commit df3063f

Please sign in to comment.