-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement EIP-4788 * Cleanup test suite * Fix tests * Apply comments * Update PROVER_INPUT opcode value (#42)
- Loading branch information
Showing
37 changed files
with
865 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/// EIP-4788: Beacon block root in the EVM | ||
/// <https://eips.ethereum.org/EIPS/eip-4788#pseudocode> | ||
|
||
global set_beacon_root: | ||
PUSH start_txn | ||
%timestamp | ||
// stack: timestamp, start_txns | ||
PUSH @HISTORY_BUFFER_LENGTH | ||
DUP2 | ||
// stack: timestamp, 8191, timestamp, start_txns | ||
MOD | ||
// stack: timestamp_idx, timestamp, start_txns | ||
PUSH write_beacon_roots_to_storage | ||
%parent_beacon_block_root | ||
// stack: calldata, write_beacon_roots_to_storage, timestamp_idx, timestamp, start_txns | ||
DUP3 | ||
%add_const(@HISTORY_BUFFER_LENGTH) | ||
// stack: root_idx, calldata, write_beacon_roots_to_storage, timestamp_idx, timestamp, start_txns | ||
|
||
write_beacon_roots_to_storage: | ||
// stack: slot, value, retdest | ||
// First we write the value to MPT data, and get a pointer to it. | ||
%get_trie_data_size | ||
// stack: value_ptr, slot, value, retdest | ||
SWAP2 | ||
// stack: value, slot, value_ptr, retdest | ||
%append_to_trie_data | ||
// stack: slot, value_ptr, retdest | ||
|
||
// Next, call mpt_insert on the current account's storage root. | ||
%stack (slot, value_ptr) -> (slot, value_ptr, after_beacon_roots_storage_insert) | ||
%slot_to_storage_key | ||
// stack: storage_key, value_ptr, after_beacon_roots_storage_insert, retdest | ||
PUSH 64 // storage_key has 64 nibbles | ||
%get_storage_trie(@BEACON_ROOTS_ADDRESS) | ||
// stack: storage_root_ptr, 64, storage_key, value_ptr, after_beacon_roots_storage_insert, retdest | ||
%jump(mpt_insert) | ||
|
||
after_beacon_roots_storage_insert: | ||
// stack: new_storage_root_ptr, retdest | ||
%get_account_data(@BEACON_ROOTS_ADDRESS) | ||
// stack: account_ptr, new_storage_root_ptr, retdest | ||
|
||
// Update the copied account with our new storage root pointer. | ||
%add_const(2) | ||
// stack: account_storage_root_ptr_ptr, new_storage_root_ptr, retdest | ||
%mstore_trie_data | ||
JUMP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.