-
Notifications
You must be signed in to change notification settings - Fork 302
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
Add evmone t8n tool #552
Add evmone t8n tool #552
Conversation
First example to run:
|
The example isn't working currently because evmone does not produce expected transaction receipts (empty array in the result). The receipt is match with a transaction by transaction hash which evmone is not able to compute yet. |
766e42a
to
0a02e9d
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #552 +/- ##
==========================================
- Coverage 97.97% 96.98% -1.00%
==========================================
Files 63 64 +1
Lines 6031 6126 +95
==========================================
+ Hits 5909 5941 +32
- Misses 122 185 +63
Flags with carried forward coverage won't be shown. Click here to find out more.
|
namespace json = nlohmann; | ||
using namespace evmone; | ||
|
||
namespace evmone::state |
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.
Do we need this available there or can this be anonymous?
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.
Unfortunately it has to be there. Similar to statetest_runner.cpp
. In other case encode
template functions instantiation fails.
test/t8n/t8n.cpp
Outdated
txs_logs.insert(txs_logs.begin(), (*tx_logs).begin(), (*tx_logs).end()); | ||
auto& j_receipt = j_result["receipts"][j_result["receipts"].size()]; | ||
j_receipt["transactionHash"] = j_tx["hash"]; | ||
j_receipt["gasUsed"] = tu::shortest_hex(uint64_t(gas_used)); |
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 if int64_t gas_used
is negative (due to a failure)?
j_receipt["contractAddress"] = NULL_HEXSTRING_20; | ||
j_receipt["logsBloom"] = NULL_HEXSTRING_256; | ||
j_receipt["logs"] = json::json::array(); // FIXME: Add to_json<state:Log> | ||
j_receipt["root"] = ""; |
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 really expected to be empty?
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 minimal working version. A lot of fields are required by retesteth but never used.
} | ||
} // namespace evmone::state | ||
|
||
int main(int argc, const char* argv[]) |
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.
We should have a unit test for this (mostly for checking the input -> output mapping is unchanged). Question is: is it better to use a CLI test or make this into an internal library first?
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 would prefer the second. @chfast What do you think?
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 think we will add some unit testing later. I have some ideas for JSON loading.
Should remove |
Definitely configs should be moved to retesteth. I will remove them just before merging. They are useful when it's in progress. |
lib/evmone/baseline.cpp
Outdated
@@ -356,6 +356,11 @@ evmc_result execute(const VM& vm, ExecutionState& state, const CodeAnalysis& ana | |||
evmc_result execute(evmc_vm* c_vm, const evmc_host_interface* host, evmc_host_context* ctx, | |||
evmc_revision rev, const evmc_message* msg, const uint8_t* code, size_t code_size) noexcept | |||
{ | |||
if (rev >= EVMC_SHANGHAI && is_eof_code({code, code_size}) && |
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.
Why is this needed?
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.
For code equals 0xfe00
(EOF) function read_valid_eof1_header
(called by analyze
) assumes that there is something else but it's the whole code so it tries to read data from the outside of the code section.
lib/evmone/errors.hpp
Outdated
@@ -0,0 +1,80 @@ | |||
// evmone: Fast Ethereum Virtual Machine implementation |
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 file should go to test/state.
test/state/state.cpp
Outdated
|
||
if (rev >= EVMC_SHANGHAI && !tx.to.has_value() && tx.data.size() > max_initcode_size) | ||
return -1; // initcode size is limited by EIP-3860. | ||
return make_error_code(INIT_CODE_SIZE_LIMIT_EXCEEDED); // initcode size is limited by |
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.
Move comment before if
.
|
||
json::json j_result; | ||
// FIXME: Calculate difficulty properly | ||
j_result["currentDifficulty"] = "0x20000"; |
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 right?
} | ||
} // namespace evmone::state | ||
|
||
int main(int argc, const char* argv[]) |
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 think we will add some unit testing later. I have some ideas for JSON loading.
config/retesteth/evmone/config
Outdated
"socketType" : "tranition-tool", | ||
"socketAddress" : "start.sh", | ||
"transactionsAsJson" : true, | ||
"checkLogsHash" : 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.
Do you want to try this?
3b7a50e
to
72db700
Compare
Co-authored-by: Paweł Bylica <[email protected]>
The t8n is "state transition" CLI interface used to check and generate JSON tests. It reads and outputs specified JSON files. See https://ethereum-tests.readthedocs.io/en/develop/t8ntool-ref.html. Co-authored-by: Paweł Bylica <[email protected]>
The t8n is "state transition" CLI interface used to check and generate
JSON tests. It reads and outputs specified JSON files.
See https://ethereum-tests.readthedocs.io/en/develop/t8ntool-ref.html.