-
Notifications
You must be signed in to change notification settings - Fork 316
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
EOF validation of subcontainer kinds #876
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7464c55
Add validation of subcontainer kinds
gumb0 1a6c7ac
Remove initcode mode runtime checks from RETURNCONTRACT, RETURN, STOP
gumb0 c3df715
Fix validation tests
gumb0 baf2db0
Check that container is initcontainer in creation transaction/TXCREATE
gumb0 b294d38
Fix tests that use initcode in toplevel container
gumb0 96700b5
Container kind validation tests
gumb0 843878f
Support container kind field in json EOF validation tests
gumb0 37ed902
Update tests
gumb0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,23 +22,39 @@ | |
{ | ||
struct Expectation | ||
{ | ||
evmc_revision rev; | ||
bool result; | ||
evmc_revision rev = EVMC_PRAGUE; | ||
bool result = false; | ||
}; | ||
std::string name; | ||
evmc::bytes code; | ||
ContainerKind kind = ContainerKind::runtime; | ||
std::vector<Expectation> expectations; | ||
}; | ||
std::unordered_map<std::string, Case> cases; | ||
}; | ||
|
||
ContainerKind container_kind_from_string(std::string_view s) | ||
{ | ||
if (s == "runtime") | ||
return ContainerKind::runtime; | ||
else if (s == "initcode") | ||
return ContainerKind::initcode; | ||
else if (s == "initcode_runtime") | ||
return ContainerKind::initcode_runtime; | ||
else | ||
throw std::invalid_argument{"unknown container kind"}; | ||
} | ||
|
||
void from_json(const json::json& j, EOFValidationTest::Case& o) | ||
{ | ||
const auto op_code = evmc::from_hex(j.at("code").get<std::string>()); | ||
if (!op_code) | ||
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 commentThe 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 commentThe 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. |
||
o.kind = container_kind_from_string(it_kind->get<std::string>()); | ||
|
||
for (const auto& [rev, result] : j.at("results").items()) | ||
{ | ||
o.expectations.push_back({to_rev(rev), result.at("result").get<bool>()}); | ||
|
@@ -67,7 +83,7 @@ | |
{ | ||
for (const auto& expectation : cases.expectations) | ||
{ | ||
const auto result = evmone::validate_eof(expectation.rev, cases.code); | ||
const auto result = evmone::validate_eof(expectation.rev, cases.kind, cases.code); | ||
const bool b_result = (result == EOFValidationError::success); | ||
EXPECT_EQ(b_result, expectation.result) | ||
<< name << " " << expectation.rev << " " << hex(cases.code); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.