@@ -1018,14 +1018,20 @@ struct controller_impl {
1018
1018
1019
1019
1020
1020
void push_block ( const signed_block_ptr& b, controller::block_status s ) {
1021
- // idump((fc::json::to_pretty_string(*b)));
1022
1021
EOS_ASSERT (!pending, block_validate_exception, " it is not valid to push a block when there is a pending block" );
1022
+
1023
+ auto reset_prod_light_validation = fc::make_scoped_exit ([this ]() {
1024
+ conf.trusted_producer_light_validation = false ;
1025
+ });
1023
1026
try {
1024
1027
EOS_ASSERT ( b, block_validate_exception, " trying to push empty block" );
1025
1028
EOS_ASSERT ( s != controller::block_status::incomplete, block_validate_exception, " invalid block status for a completed block" );
1026
1029
emit ( self.pre_accepted_block , b );
1027
1030
bool trust = !conf.force_all_checks && (s == controller::block_status::irreversible || s == controller::block_status::validated);
1028
1031
auto new_header_state = fork_db.add ( b, trust );
1032
+ if (conf.trusted_producers .count (b->producer )) {
1033
+ conf.trusted_producer_light_validation = true ;
1034
+ };
1029
1035
emit ( self.accepted_block_header , new_header_state );
1030
1036
// on replay irreversible is not emitted by fork database, so emit it explicitly here
1031
1037
if ( s == controller::block_status::irreversible )
@@ -1657,13 +1663,14 @@ bool controller::light_validation_allowed(bool replay_opts_disabled_by_policy) c
1657
1663
return false ;
1658
1664
}
1659
1665
1660
- auto pb_status = my->pending ->_block_status ;
1666
+ const auto pb_status = my->pending ->_block_status ;
1661
1667
1662
1668
// in a pending irreversible or previously validated block and we have forcing all checks
1663
- bool consider_skipping_on_replay = (pb_status == block_status::irreversible || pb_status == block_status::validated) && !replay_opts_disabled_by_policy;
1669
+ const bool consider_skipping_on_replay = (pb_status == block_status::irreversible || pb_status == block_status::validated) && !replay_opts_disabled_by_policy;
1664
1670
1665
1671
// OR in a signed block and in light validation mode
1666
- bool consider_skipping_on_validate = (pb_status == block_status::complete && my->conf .block_validation_mode == validation_mode::LIGHT);
1672
+ const bool consider_skipping_on_validate = (pb_status == block_status::complete &&
1673
+ (my->conf .block_validation_mode == validation_mode::LIGHT || my->conf .trusted_producer_light_validation ));
1667
1674
1668
1675
return consider_skipping_on_replay || consider_skipping_on_validate;
1669
1676
}
0 commit comments