39 uint16_t num_prev_blocks_to_confirm )
const
53 SYS_ASSERT( itr->second < (
block_num+1) - num_prev_blocks_to_confirm, producer_double_confirm,
54 "producer ${prod} double-confirming known range",
55 (
"prod", proauth.producer_name)(
"num",
block_num+1)
56 (
"confirmed", num_prev_blocks_to_confirm)(
"last_produced", itr->second) );
61 result.timestamp = when;
62 result.confirmed = num_prev_blocks_to_confirm;
66 result.valid_block_signing_authority = proauth.authority;
67 result.producer = proauth.producer_name;
70 result.blockroot_merkle.append(
id );
73 static_assert(std::numeric_limits<uint8_t>::max() >= (config::max_producers * 2 / 3) + 1,
"8bit confirmations may not be able to hold all of the needed confirmations");
79 if(
confirm_count.size() < config::maximum_tracked_dpos_confirmations ) {
83 result.confirm_count.back() = (
uint8_t)required_confs;
87 result.confirm_count.back() = (
uint8_t)required_confs;
93 uint32_t blocks_to_confirm = num_prev_blocks_to_confirm + 1;
94 while( i >= 0 && blocks_to_confirm ) {
95 --result.confirm_count[i];
97 if( result.confirm_count[i] == 0 )
99 uint32_t block_num_for_i = result.block_num - (
uint32_t)(result.confirm_count.size() - 1 - i);
100 new_dpos_proposed_irreversible_blocknum = block_num_for_i;
103 if (i ==
static_cast<int32_t>(result.confirm_count.size() - 1)) {
104 result.confirm_count.resize(0);
106 memmove( &result.confirm_count[0], &result.confirm_count[i + 1], result.confirm_count.size() - i - 1);
107 result.confirm_count.resize( result.confirm_count.size() - i - 1 );
116 result.dpos_proposed_irreversible_blocknum = new_dpos_proposed_irreversible_blocknum;
126 flat_map<account_name,uint32_t> new_producer_to_last_produced;
128 for(
const auto& pro : result.active_schedule.producers ) {
129 if( pro.producer_name == proauth.producer_name ) {
130 new_producer_to_last_produced[pro.producer_name] = result.block_num;
134 new_producer_to_last_produced[pro.producer_name] = existing->second;
136 new_producer_to_last_produced[pro.producer_name] = result.dpos_irreversible_blocknum;
140 new_producer_to_last_produced[proauth.producer_name] = result.block_num;
142 result.producer_to_last_produced = std::move( new_producer_to_last_produced );
144 flat_map<account_name,uint32_t> new_producer_to_last_implied_irb;
146 for(
const auto& pro : result.active_schedule.producers ) {
147 if( pro.producer_name == proauth.producer_name ) {
152 new_producer_to_last_implied_irb[pro.producer_name] = existing->second;
154 new_producer_to_last_implied_irb[pro.producer_name] = result.dpos_irreversible_blocknum;
159 result.producer_to_last_implied_irb = std::move( new_producer_to_last_implied_irb );
161 result.was_pending_promoted =
true;
165 result.producer_to_last_produced[proauth.producer_name] = result.block_num;
238 const flat_set<digest_type>&,
244 SYS_ASSERT( h.
previous == previous, unlinkable_block_exception,
"previous mismatch" );
247 SYS_ASSERT( h.
schedule_version == active_schedule_version, producer_schedule_exception,
"schedule_version in signed block is corrupted" );
251 std::optional<producer_authority_schedule> maybe_new_producer_schedule;
252 std::optional<digest_type> maybe_new_producer_schedule_hash;
253 bool wtmsig_enabled =
false;
260 SYS_ASSERT(!wtmsig_enabled, producer_schedule_exception,
"Block header contains legacy producer schedule outdated by activation of WTMsig Block Signatures" );
262 SYS_ASSERT( !was_pending_promoted, producer_schedule_exception,
"cannot set pending producer schedule in the same block in which pending was promoted to active" );
265 SYS_ASSERT( new_producers.version == active_schedule.version + 1, producer_schedule_exception,
"wrong producer schedule version specified" );
266 SYS_ASSERT( prev_pending_schedule.schedule.producers.empty(), producer_schedule_exception,
267 "cannot set new pending producers until last pending is confirmed" );
270 maybe_new_producer_schedule.emplace(new_producers);
274 SYS_ASSERT(wtmsig_enabled, producer_schedule_exception,
"Block header producer_schedule_change_extension before activation of WTMsig Block Signatures" );
275 SYS_ASSERT( !was_pending_promoted, producer_schedule_exception,
"cannot set pending producer schedule in the same block in which pending was promoted to active" );
279 SYS_ASSERT( new_producer_schedule.version == active_schedule.version + 1, producer_schedule_exception,
"wrong producer schedule version specified" );
280 SYS_ASSERT( prev_pending_schedule.schedule.producers.empty(), producer_schedule_exception,
281 "cannot set new pending producers until last pending is confirmed" );
283 maybe_new_producer_schedule_hash.emplace(
digest_type::hash(new_producer_schedule));
284 maybe_new_producer_schedule.emplace(new_producer_schedule);
291 validator( timestamp, prev_activated_protocol_features->protocol_features, new_protocol_features );
293 new_activated_protocol_features = std::make_shared<protocol_feature_activation_set>(
294 *prev_activated_protocol_features,
295 new_protocol_features
298 new_activated_protocol_features = std::move( prev_activated_protocol_features );
302 auto block_number = block_num;
309 result.header_exts = std::move(exts);
311 if( maybe_new_producer_schedule ) {
312 result.pending_schedule.schedule = std::move(*maybe_new_producer_schedule);
313 result.pending_schedule.schedule_hash = std::move(*maybe_new_producer_schedule_hash);
314 result.pending_schedule.schedule_lib_num = block_number;
316 if( was_pending_promoted ) {
317 result.pending_schedule.schedule.version = prev_pending_schedule.schedule.version;
319 result.pending_schedule.schedule = std::move( prev_pending_schedule.schedule );
321 result.pending_schedule.schedule_hash = std::move( prev_pending_schedule.schedule_hash );
322 result.pending_schedule.schedule_lib_num = prev_pending_schedule.schedule_lib_num;
325 result.activated_protocol_features = std::move( new_activated_protocol_features );