-
Notifications
You must be signed in to change notification settings - Fork 50
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 option to preload system contracts from file before execution #289
Conversation
3c20d32
to
956d925
Compare
I think as milestone 1, this should just replace the So it is only two pieces of code added here:
Later we can think about how to deploy and replace more. In milestone 1 it will be possible to:
|
4be85ee
to
a07f38e
Compare
Rebased. |
@axic updated this to override the code at runtime, without CREATEing system contracts |
604fcca
to
9149571
Compare
src/hera.cpp
Outdated
#endif | ||
|
||
//Check the "sys:" syntax by comparing substring | ||
if (evmc_option_raw.length() < 4 || evmc_option_raw.substr(0, 4).compare("sys:") != 0) { |
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.
Canno you just use evmc_option_raw.find("sys:") == 0
here?
Codecov Report
@@ Coverage Diff @@
## master #289 +/- ##
==========================================
- Coverage 72.06% 62.34% -9.72%
==========================================
Files 8 5 -3
Lines 970 964 -6
Branches 118 139 +21
==========================================
- Hits 699 601 -98
- Misses 241 331 +90
- Partials 30 32 +2 |
d749608
to
3be644c
Compare
src/hera.cpp
Outdated
@@ -61,6 +61,7 @@ struct hera_instance : evmc_instance { | |||
hera_wasm_engine wasm_engine = hera_wasm_engine::binaryen; | |||
hera_evm_mode evm_mode = hera_evm_mode::reject; | |||
bool metering = false; | |||
vector<pair<evmc_address, string>> contract_preload_list; |
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 not use a map
here?
src/hera.cpp
Outdated
#endif | ||
|
||
//Check the "sys:" syntax by comparing substring | ||
if (evmc_option_raw.length() < 4 || evmc_option_raw.find("sys:") != 0) { |
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 there isn't a need to check the length if using find
.
return pair<evmc_address, bool>(ret, true); | ||
} | ||
|
||
pair<evmc_address, bool> parse_preload_addr(const char *name) |
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 need a helper which does the entire string parsing and returns a pair<address, filename>
, where if either of them is empty that means it failed. This should not do alias resolution.
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.
address
is a string and can contain an alias or a hex string.
bc65111
to
09558f1
Compare
src/hera.cpp
Outdated
@@ -64,6 +64,7 @@ struct hera_instance : evmc_instance { | |||
hera_wasm_engine wasm_engine = hera_wasm_engine::binaryen; | |||
hera_evm_mode evm_mode = hera_evm_mode::reject; | |||
bool metering = false; | |||
vector<pair<evmc_address, string>> contract_preload_list; |
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 this should be vector<pair<evmc_address, vector<uint8_t>>>
so that the at runtime it doesn't need to be loaded every time.
b7db68a
to
435fcf6
Compare
Closes #288
Syntax:
--evmc sys:<address or alias>=<filepath>
Hex address must be formatted with a leading
0x
and must be 40 characters long (all nibbles must be explicitly specified, including leading zeroes).