-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Implement Trusted Producer Light Validation #5631
Changes from 5 commits
ba4d5e4
0754e85
a972330
05bb716
c7a5a9e
56d7d27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1018,14 +1018,20 @@ struct controller_impl { | |
|
||
|
||
void push_block( const signed_block_ptr& b, controller::block_status s ) { | ||
// idump((fc::json::to_pretty_string(*b))); | ||
EOS_ASSERT(!pending, block_validate_exception, "it is not valid to push a block when there is a pending block"); | ||
|
||
auto reset_prod_light_validation = fc::make_scoped_exit([old_value=conf.trusted_producer_light_validation, this]() { | ||
conf.trusted_producer_light_validation = old_value; | ||
}); | ||
try { | ||
EOS_ASSERT( b, block_validate_exception, "trying to push empty block" ); | ||
EOS_ASSERT( s != controller::block_status::incomplete, block_validate_exception, "invalid block status for a completed block" ); | ||
emit( self.pre_accepted_block, b ); | ||
bool trust = !conf.force_all_checks && (s == controller::block_status::irreversible || s == controller::block_status::validated); | ||
auto new_header_state = fork_db.add( b, trust ); | ||
if (conf.trusted_producers.count(b->producer)) { | ||
conf.trusted_producer_light_validation = true; | ||
}; | ||
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. Instead of setting a flag, I wonder if we could just add this check in 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. I think that would be much more complicated (handling identifying if we are speculating or applying a block) and this gets called multiple times in a transaction pass, versus being called once for the block. |
||
emit( self.accepted_block_header, new_header_state ); | ||
// on replay irreversible is not emitted by fork database, so emit it explicitly here | ||
if( s == controller::block_status::irreversible ) | ||
|
@@ -1657,13 +1663,14 @@ bool controller::light_validation_allowed(bool replay_opts_disabled_by_policy) c | |
return false; | ||
} | ||
|
||
auto pb_status = my->pending->_block_status; | ||
const auto pb_status = my->pending->_block_status; | ||
|
||
// in a pending irreversible or previously validated block and we have forcing all checks | ||
bool consider_skipping_on_replay = (pb_status == block_status::irreversible || pb_status == block_status::validated) && !replay_opts_disabled_by_policy; | ||
const bool consider_skipping_on_replay = (pb_status == block_status::irreversible || pb_status == block_status::validated) && !replay_opts_disabled_by_policy; | ||
|
||
// OR in a signed block and in light validation mode | ||
bool consider_skipping_on_validate = (pb_status == block_status::complete && my->conf.block_validation_mode == validation_mode::LIGHT); | ||
const bool consider_skipping_on_validate = (pb_status == block_status::complete && | ||
(my->conf.block_validation_mode == validation_mode::LIGHT || my->conf.trusted_producer_light_validation)); | ||
|
||
return consider_skipping_on_replay || consider_skipping_on_validate; | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -74,6 +74,8 @@ namespace eosio { namespace chain { | |||
validation_mode block_validation_mode = validation_mode::FULL; | ||||
|
||||
flat_set<account_name> resource_greylist; | ||||
flat_set<account_name> trusted_producers; | ||||
bool trusted_producer_light_validation = false; | ||||
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. I dont really like this "implementation detail" exposed in the 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. also
|
||||
}; | ||||
|
||||
enum class block_status { | ||||
|
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 to see this reset to current value so it could be nested in the future.