Skip to content

Commit 0754e85

Browse files
Added flag to temporarily behave like the validation mode is set to light when a block is produced by a trusted producer. GH #5268
1 parent ba4d5e4 commit 0754e85

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

libraries/chain/controller.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,14 +1018,20 @@ struct controller_impl {
10181018

10191019

10201020
void push_block( const signed_block_ptr& b, controller::block_status s ) {
1021-
// idump((fc::json::to_pretty_string(*b)));
10221021
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+
});
10231026
try {
10241027
EOS_ASSERT( b, block_validate_exception, "trying to push empty block" );
10251028
EOS_ASSERT( s != controller::block_status::incomplete, block_validate_exception, "invalid block status for a completed block" );
10261029
emit( self.pre_accepted_block, b );
10271030
bool trust = !conf.force_all_checks && (s == controller::block_status::irreversible || s == controller::block_status::validated);
10281031
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+
};
10291035
emit( self.accepted_block_header, new_header_state );
10301036
// on replay irreversible is not emitted by fork database, so emit it explicitly here
10311037
if( s == controller::block_status::irreversible )
@@ -1657,13 +1663,14 @@ bool controller::light_validation_allowed(bool replay_opts_disabled_by_policy) c
16571663
return false;
16581664
}
16591665

1660-
auto pb_status = my->pending->_block_status;
1666+
const auto pb_status = my->pending->_block_status;
16611667

16621668
// 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;
16641670

16651671
// 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));
16671674

16681675
return consider_skipping_on_replay || consider_skipping_on_validate;
16691676
}

0 commit comments

Comments
 (0)