Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blockhash opcode #1208

Merged
merged 7 commits into from
Sep 7, 2023
Merged

Conversation

LindaGuiga
Copy link
Contributor

@LindaGuiga LindaGuiga commented Aug 31, 2023

This PR implements the BLOCKHASH opcode, following @wborgeaud's second suggestion in this issue. It includes links between proofs, a couple of unit tests and the challenger observing the additional public values (the previous and current block hashes).

closes #1173

Copy link
Contributor

@wborgeaud wborgeaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

// stack: cur_block_number, block_number, retdest
DUP1 DUP3 %increment GT %jumpi(zero_hash) // if block_number >= cur_block_number
// stack: cur_block_number, block_number, retdest
DUP2 PUSH 256 ADD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an addition with an overflow check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the following comments, I left this as is and added the overflow check on block_number directly.

evm/src/cpu/kernel/tests/block_hash.rs Outdated Show resolved Hide resolved
evm/src/get_challenges.rs Outdated Show resolved Hide resolved
evm/src/cpu/kernel/tests/block_hash.rs Show resolved Hide resolved
evm/src/recursive_verifier.rs Outdated Show resolved Hide resolved
@LindaGuiga LindaGuiga merged commit 180c209 into 0xPolygonZero:main Sep 7, 2023
2 checks passed
@Nashtare Nashtare deleted the blockhash_opcode branch September 8, 2023 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement BLOCKHASH opcode
2 participants