-
Notifications
You must be signed in to change notification settings - Fork 331
EOF validation of subcontainer kinds #876
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #876 +/- ##
==========================================
- Coverage 95.15% 95.11% -0.04%
==========================================
Files 140 140
Lines 15805 15881 +76
==========================================
+ Hits 15039 15106 +67
- Misses 766 775 +9
Flags with carried forward coverage won't be shown. Click here to find out more.
|
e51ba64 to
7c4ee1e
Compare
9f3f46e to
e26fdad
Compare
e26fdad to
face250
Compare
face250 to
b6abd3e
Compare
0e48680 to
e406e19
Compare
ba1ced0 to
1380198
Compare
e406e19 to
dc1d74c
Compare
Refactoring pulled out of #876 Main idea: 1. Instruction validation returns the list of references to subcontainers (instruction, subcontainer_idx) 1.1. (Not directly related, but I moved returning accessed section list into returned `InstructionValidationResult` struct instead of non-const reference argument) 3. The check for `EOFCREATE` with truncated data is moved out of instruction validation into being done once for a referenced container, after it is already validated. 4. This way we don't need to split subcontainer header validation and instructions validation and the loop over containers gets simpler. Then it gets handy for additional container kind validation in #876.
1380198 to
9e8b3e1
Compare
| if (referenced_by_eofcreate) | ||
| return EOFValidationError::incompatible_container_kind; | ||
| } | ||
|
|
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.
Validation whether subcontainer is referenced by anything can be added here, or below in "enqueue subcontainers" loop, better in a separate PR.
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.
Add TODO.
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.
added
92e80be to
0a3b1e0
Compare
| return ContainerKind::runtime; | ||
| else if (s == "initcode") | ||
| return ContainerKind::initcode; | ||
| else if (s == "initcode_runtime") |
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.
Not sure it makes much sense to support this mode in the tests. If we don't then probably validate_eof() also shouldn't support it as input (should fail with special error?)
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 is proposed to remove this from the spec and #916 has a commit that implements the removal.
e5f5c92 to
783757c
Compare
|
Required ethereum/tests update:
cc @hugo-dc I'm also fine merging this PR with my "temporary" manual fix of thereum/tests. |
a601529 to
71afb81
Compare
I plan to do this. |
| throw std::invalid_argument{"code is invalid hex string"}; | ||
| o.code = *op_code; | ||
|
|
||
| if (const auto it_kind = j.find("kind"); it_kind != j.end()) |
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.
Is this standardized?
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.
No, this is not supported anywhere, but I plan to try to add this to EEST.
|
|
||
| expect.post[*tx.to].nonce = pre.get(*tx.to).nonce + 1; | ||
| expect.post[*tx.to].nonce = pre.get(*tx.to).nonce; | ||
| expect.post[*tx.to].storage[0x00_bytes32] = 0x00_bytes32; |
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 is not exactly void, the check is only done if a value is assigned to "expect". There are std::optionals.
| sstore(0, txcreate().initcode(keccak256(init_container)).salt(Salt)) + | ||
| sstore(1, txcreate().initcode(keccak256(init_container)).salt(Salt)) + // address collision | ||
| sstore(2, returndatasize()) + sstore(3, 1) + OP_STOP; | ||
| const auto factory_container = eof_bytecode(factory_code, 5).container(init_container); |
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.
What is this change about?
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 was a bug in original test, so it was failing for the wrong reason I guess.
lib/evmone/eof.cpp
Outdated
| else if (opcode == OP_RETURNCONTRACT) | ||
| subcontainer_referenced_by_returncontract[index] = true; | ||
| else | ||
| assert(false); |
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.
use intx::unreachable().
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.
changed.
Refactor validation API to include a parameter for required container kind of the top-level container.
Make container kind configurable in validation tests.
71afb81 to
d91990a
Compare
d91990a to
37ed902
Compare
Implementing ipsilon/eof#86
Depends on #888
TODO:
Check that container is initcontainer in creation transaction/TXCREATEContainerKind::runtime_initcodemode - after outside-in refactoring this requires* Disallow unreferenced subcontainers and subcontainers referenced by both EOFCREATE and RETURNCONTRACT #916 so will be done there.*if subcontainer is unreferenced, you cannot call its validation requiring neither runtime nor initcode mode.