-
Notifications
You must be signed in to change notification settings - Fork 322
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
Tests for EIP2929 operations on precompiles #829
Conversation
That can't be right. I'll look into it
I don't think this is rirght. I assume that
I think it rejects your input. It's blake2f, it requires exactly 1-7 have always been precompiles |
So it's better to use e.g. EXTBALANCE for the coldness-check, then you don't get it mixed up with the per-precompile unique cost for the precompile itself. |
Also, we already have tests which touch the low accounts, at least that was my impression? |
Yes, but we didn't have tests for every action. For example, we didn't have tests for calling a precomp while sending it wei (the thing that broke openethereum)
The issue isn't that my call is rejected, I completely ignore the result. The issue is that first call to account 8 costs more gas than the second call.
Again, the issue isn't that my input is invalid. It is that a first call and a second call that should cost the same don't. |
That wasn't what broke it. The issue was that
I'll look into it. I think there's some mistake here |
If you know which indexes are relevant here, it'd be appreciated.. |
Possible source of error, AFAICT, you send all |
Thank you. I'll redo the test with fixed amounts to check Edit: Using a fixed amount of gas did fix the issues with 8 and 9. So two issues down, two to go. |
Which are still 'strange" ? |
|
It's the 25K cost to create an account in the trie. CALLCODE doesn't actually create a new account, so it's just a transfer to self, hence no 25K addon. If you were to "create" the precompiles in the 'state', then you wouldn't see this.
That sounds a bit odd. I'll look into it (any idea about what index I should look at?) |
Are precompiles "created" on mainnet's state? Or is this behavior consistent across clients so it doesn't matter?
In the latest version I committed, |
Hah, no, well, yes. They were incrementally created, as people sent money to their addresses. However, when Byzantium rolled in, and we were doing state cleanup by touching empty accounts, the ripemd precompile was touched, and the tx went OOG. It was a shitshow, and caused a still-remaining issue on how to treat empty precompile touches. If we ever get a new empty precompile, that would be a problem, but no, we never will, so it's theoretical. A lot of them were inited by this account (https://etherscan.io/address/0x8db98f07d8bec0038da3d13ed93adcf09316ef66) at least up to |
I trimmed away all but the Here's the trace right before the first As we execute the EXTCODECOPY, memory expansion is required: But for the last EXTCODECOPY, no further expansion is needed, so it's cheaper: |
Thank you. Sorry, I thought I dealt with it by touching the memory, but then I made the mistake of reading too much data. |
OK, so there's no chance of this issue being a problem in the real world. I'll keep the tests, but add a note about the reason. |
SGTM! Glad we cleared all the questions out! |
Thank you for answering them. |
Check which low address contracts (precompiles) are part of the EIP2929 access lists. This was the Berlin fork OpenEthereum bug (see https://twitter.com/ralexstokes/status/1382750525070868484 and https://twitter.com/ralexstokes/status/1382750938142629889).
According to EIP2929 (https://eips.ethereum.org/EIPS/eip-2929#abstract) precompiles are exempt from the opcode cost increases for the first (cold) access, they are always hot. However, this only happens with some operations in geth:
The expected results in this test are based on observed geth behavior.
Fixed by using a constant amount to gas as @holiman suggested: