242 {
244 SYS_ASSERT( h.previous ==
previous, unlinkable_block_exception,
"previous mismatch" );
246 SYS_ASSERT( h.producer == producer, wrong_producer,
"wrong producer specified" );
248
249 auto exts = h.validate_and_extract_header_extensions();
250
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;
254
257 }
258
259 if( h.new_producers ) {
260 SYS_ASSERT(!wtmsig_enabled, producer_schedule_exception,
"Block header contains legacy producer schedule outdated by activation of WTMsig Block Signatures" );
261
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" );
263
264 const auto& new_producers = *h.new_producers;
267 "cannot set new pending producers until last pending is confirmed" );
268
270 maybe_new_producer_schedule.emplace(new_producers);
271 }
272
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" );
276
278
281 "cannot set new pending producers until last pending is confirmed" );
282
283 maybe_new_producer_schedule_hash.emplace(
digest_type::hash(new_producer_schedule));
284 maybe_new_producer_schedule.emplace(new_producer_schedule);
285 }
286
288 {
292
293 new_activated_protocol_features = std::make_shared<protocol_feature_activation_set>(
295 new_protocol_features
296 );
297 } else {
299 }
300 }
301
303
304 block_header_state result( std::move( *static_cast<detail::block_header_state_common*>(this) ) );
305
306 result.id = h.calculate_id();
307 result.header = h;
308
309 result.header_exts = std::move(exts);
310
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;
315 } else {
318 } else {
320 }
323 }
324
325 result.activated_protocol_features = std::move( new_activated_protocol_features );
326
327 return result;
328 }
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
static sha256 hash(const char *d, uint32_t dlen)
bool is_builtin_activated(const protocol_feature_activation_set_ptr &pfa, const protocol_feature_set &pfs, builtin_protocol_feature_t feature_codename)
@ wtmsig_block_signatures
key Invalid authority Invalid transaction Invalid block ID Invalid packed transaction Invalid chain ID Invalid symbol Signature type is not a currently activated type Block can not be found block_validate_exception
std::shared_ptr< protocol_feature_activation_set > protocol_feature_activation_set_ptr
producer_authority_schedule schedule
uint32_t schedule_lib_num
digest_type schedule_hash
last irr block num
uint32_t version
sequentially incrementing version number
vector< producer_authority > producers
static constexpr uint16_t extension_id()
static constexpr uint16_t extension_id()