-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Implement Trusted Producer Light Validation #5631
Implement Trusted Producer Light Validation #5631
Conversation
…ight when a block is produced by a trusted producer. GH EOSIO#5268
…anually produce blocks on the main chain and then manually pass the block to the validating_node. GH EOSIO#5268
…ted by a chain when the block was produced by a trusted producer. GH EOSIO#5268
libraries/chain/controller.cpp
Outdated
|
||
auto reset_prod_light_validation = fc::make_scoped_exit([this]() { | ||
conf.trusted_producer_light_validation = 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.
I would prefer to see this reset to current value so it could be nested in the future.
auto reset_prod_light_validation = fc::make_scoped_exit([old_value=conf.trusted_producer_light_validation, this]() {
conf.trusted_producer_light_validation = old_value;
});
libraries/chain/controller.cpp
Outdated
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 comment
The 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 light_validation_allowed
then the extra flag and reset would not be 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.
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.
…ack to original state. GH EOSIO#5268
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
I dont really like this "implementation detail" exposed in the config
structure (The bool
, the flat_set
is appropriate here). There doesn't seem to be a reason why an external system would ever need to know about this. I think I would prefer that be part of the controller_impl
class instead alongside in_trx_requiring_checks
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.
also trusted_producers
should be added to the reflection of this structure:
FC_REFLECT( eosio::chain::controller::config, |
…d added trusted_producer to reflection macro. GH EOSIO#5268
#5268
Added configuration options to set trusted producers in chain_plugin.
In controller_impl::push_block added setting (and resetting on exit) a flag that provides the same behavior as light validation.
Made changes to validating_tester to allow calling the main chain and then calling the validating_node separately.