-
Notifications
You must be signed in to change notification settings - Fork 5
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
Process configchange event and save the parameters in some data structure. #190
Conversation
This reverts commit 70ef2e3.
src/channels.hpp
Outdated
std::vector<native_trx> transactions; | ||
}; | ||
|
||
struct consensus_parameter_event { |
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 structure used anywhere?
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.
forgot to delete. deleted
src/block_conversion_plugin.hpp
Outdated
@@ -19,6 +19,17 @@ struct evmtx_v0 { | |||
using evmtx_type = std::variant<evmtx_v0>; | |||
EOSIO_REFLECT(evmtx_v0, eos_evm_version, rlpx) | |||
|
|||
struct gas_parameter_data_v1 { |
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 replicate the types we have here until we have a place where to put all these interfaces
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.
Yeah, was copied from there back then. Didn't notice it was changed.
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.
fixed
src/block_conversion_plugin.cpp
Outdated
.gas_sset = std::visit([](auto&& arg) -> auto& { return arg.gas_parameter.gas_sset; }, new_config), | ||
} | ||
}); | ||
curr.consensus_parameter_index = curr.header.number; |
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 save here the consensus parameters to db
src/blockchain_plugin.cpp
Outdated
if (new_block->consensus_parameter_index) { | ||
if (*new_block->consensus_parameter_index == new_block->header.number) { | ||
// Parameters updated in this block. | ||
SILKWORM_ASSERT(new_block->consensus_parameters_cache.has_value()); | ||
update_consensus_parameters(exec_engine->get_tx(), new_block->header.number, *new_block->consensus_parameters_cache); | ||
last_consensus_parameters = new_block->consensus_parameters_cache; | ||
last_consensus_parameters_index = new_block->consensus_parameter_index; | ||
} | ||
else if (last_consensus_parameters_index && *last_consensus_parameters_index == *new_block->consensus_parameter_index) { | ||
// Copy over parameters for last block. | ||
SILKWORM_ASSERT(last_consensus_parameters.has_value()); | ||
new_block->consensus_parameters_cache = last_consensus_parameters; | ||
} else { | ||
// Parameter not cached, happen during startup or fork. | ||
new_block->consensus_parameters_cache = read_consensus_parameters(exec_engine->get_tx(), *new_block->consensus_parameter_index); | ||
// In such cases, the parameter MUST be in db. | ||
SILKWORM_ASSERT(new_block->consensus_parameters_cache.has_value()); | ||
|
||
last_consensus_parameters_index = new_block->consensus_parameter_index; | ||
last_consensus_parameters = new_block->consensus_parameters_cache; | ||
} | ||
} | ||
else { | ||
// Should only reach here if fork happens during version update. | ||
// TODO: Add guards according to eosevm versions. | ||
last_consensus_parameters_index = std::nullopt; | ||
last_consensus_parameters = std::nullopt; | ||
} | ||
|
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 don't need this and the last_consensus_parameters_index / last_consensus_parameters variables
src/blockchain_plugin.cpp
Outdated
std::optional<silkworm::BlockNum> last_consensus_parameters_index; | ||
std::optional<eosevm::ConsensusParameters> last_consensus_parameters; |
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 is not 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.
Resolve #186
The planned implementation is like this:
1 ship_receiver_plugin will check if it received a configchange event, if found, make sure it's the first related action in a block, save the new config in the resulting native_block/
2 block_conversion_plugin will make sure if there's a new config in the incoming native_block, it should be the first one native block for a resulting evm block. Then:
a save the new config in the resulting evm block
b change the evm block's consensus_parameter_index to it's own height.
3 blockchain_plugin will detect if there's new config coming in with the evm blocks. if so:
a save new parameters
b verify_chain for the blocks before if necessary
c insert the incoming blcok
d verify chain (may be not necessary)
-- EDIT: after some double thinking, we do not need this for blockchain_plugin, let's just try a normal process first.