-
Notifications
You must be signed in to change notification settings - Fork 298
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
state: Implement fake BLOCKHASH
resolution for testing
#698
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #698 +/- ##
=======================================
Coverage 97.56% 97.56%
=======================================
Files 92 92
Lines 8535 8547 +12
=======================================
+ Hits 8327 8339 +12
Misses 208 208
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Yes, since we decided that makes no sense. There should be no state tests using blockhash instruction as it is a blockchain logic. Otherwise it just tests a test logic. |
This is true, however goevmlab may generate a state test that uses |
I can't meaningfully review this, but it sounds good. A better description is here: NethermindEth/nethermind#4967 (comment)
goevmlab only generates tests with blocknumber |
Yes, this is handled already closer to the instruction implementation (i.e. EVM will not ask anything the Host in this situation). I noted this is not needed for regular state tests because they have a discipline to avoid However, for goevmlab this is required. But as mentioned goevmlab generated tests are always running at block 1 therefore the Host will only be asked for if (block_number == 0)
return 0x044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d_bytes32; |
I think this is the geth implementation so I will link to it. https://github.com/ethereum/go-ethereum/blob/v1.12.2/tests/state_test_util.go#L432 What is the preferred naming for this?
|
BLOCKHASH
for testingBLOCKHASH
resolution for testing
c025495
to
d5a1d0e
Compare
If explict block hashes are not provided, return predefined block hashes from `Host::get_block_hash()` as `keccak256(str(block_number))`. This is badly documented convention used in state tests. Note: the readability of block hash values from `BLOCKHASH` instruction still applies. I.e. you will get 0 if you ask for a block from the future or more than 256 blocks older than the current one.
d5a1d0e
to
51ccacb
Compare
If explict block hashes are not provided, return predefined block hashes from `Host::get_block_hash()` as `keccak256(str(block_number))`. This is badly documented convention used in state tests. Note: the readability of block hash values from `BLOCKHASH` instruction still applies. I.e. you will get 0 if you ask for a block from the future or more than 256 blocks older than the current one.
- Add `--trace-summary` CLI flag to output state root. - Make `_info` JSON section optional (goevmlab is not providing this field). - Implement convention for `Host::get_block_hash()` (done in #698).
If explict block hashes are not provided, return predefined block hashes from
Host::get_block_hash()
askeccak256(str(block_number))
. This is badly documented convention used in state tests.Note: the readability of block hash values from
BLOCKHASH
instruction still applies. I.e. you will get 0 if you ask for a block from the future or more than 256 blocks older than the current one.