-
Notifications
You must be signed in to change notification settings - Fork 117
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
new(tests): port ethereum/tests calldataload opcode tests #1248
base: main
Are you sure you want to change the base?
new(tests): port ethereum/tests calldataload opcode tests #1248
Conversation
validation_contract = pre.deploy_contract( | ||
code=( | ||
Op.CALL( | ||
gas=0xFFFFFF, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Op.GAS. and if doesn't work on Frontier
Op.Sub(Op.Gas, 20_000) where 20_000 is the gas we reserve for all instructions after the call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please provide more details? I am curios about this, I could not pass the tests until the changes
Is it because EIP-150 was not yet been implemented in the Frontier
upgrade, causing the CALL
instruction to forward all available gas rather than reserving some for following operations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
untill Homestead if CALL have gas=100000 it will consume all of it.
after if CALL have gas = 100_000 it will only consume as much as it requires and will not OOG if you have lets say 50_000 and it consumed less then that. but will fail OOG if it consumes > than you have or > 100_000
I noticed a |
I analyze other PRs and found there is a specific setting for the
v, r, s = (
signature_bytes[64],
int.from_bytes(signature_bytes[0:32], byteorder="big"),
int.from_bytes(signature_bytes[32:64], byteorder="big"),
)
if self.ty == 0:
if self.protected:
v += 35 + (self.chain_id * 2)
else: # not protected
v += 27 I want to double check, is it for EIP-155 that prevents replay attack? |
Yes, protected is eip155 |
Squash commits when they are too many or affect many different files. So, not to deal with rebase conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Louis! Thanks for the PR, it looks pretty good!
Just a couple of comments though.
0xBCDEF00000000000000000000000000000000000000000000000000024000000, | ||
), | ||
], | ||
ids=["two_bytes", "word_n_byte", "34_bytes"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit more readable to do, e.g.:
pytest.param(
0x00,
Bytecode(Op.MSTORE8(offset=0x0, value=0x25) + Op.MSTORE8(offset=0x1, value=0x60)),
0x02,
0x2560000000000000000000000000000000000000000000000000000000000000,
id="two_bytes",
)
So basically use pytest.param
to have the parameters and the ID in the same place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I analyze similar test case before doing this PR, and I notice there is several instance that can also be refactored.
For parametrization
@pytest.mark.parametrize( |
For zero value in creating transaction
tx = Transaction( |
There are more instances, just to name few here
) | ||
|
||
tx = Transaction( | ||
data=b"\x01", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This data is not actually used right now, so we can remove it.
But... we could write a second test where test Op.CALLDATALOAD
on the first call stack level:
Right now we are testing on the second call stack level, simply because we are using the opcode on a second contract via Op.CALL
.
Another test could use this transaction field to test Op.CALLDATALOAD
using a single contract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be great, the calldata is loaded from the data provided in the transaction, I could add a few test cases for it.
Should I add the scenario in the current PR or create a new one? Which one do you prefer?
Hey @LouisTsai-Csie, thanks for the PR! Just a heads up, the failing Github Action Evmone Coverage Report is a separate issue unrelated to your test. It should be fixed with #1268. |
@marioevz Thanks for your review, I updated the file and left several comments. I wonder if I should use |
We don't have strict guidelines regarding how to merge commits in this repository, but usually we simply squash and merge a PR, which means the commit history is not normally preserved. For PRs containing only test changes like this one, squashing commits would be the approach, so don't worry too much about preserving every commit π An example of a PR we would like to preserve the history is one where not only tests are affected but it also contains framework changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last minor comment and we should be able to merge. Thanks!
I've updated the comment. Please let me know if it is clear. Thanks! |
need to check why this line coverage is lost
the other seem to be related to add opcode not being called anymore lost coverage line:
there used to be an account removed from state in original test. thats why coverage lost. |
ποΈ Description
Migrate
calldataload
test from ethereum/testsπ Related Issues
https://github.com/ethereum/execution-spec-tests/issues/972
β Checklist
mkdocs serve
locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.