Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::chain::pending_block_header_state Struct Reference

#include <block_header_state.hpp>

Inheritance diagram for sysio::chain::pending_block_header_state:
Collaboration diagram for sysio::chain::pending_block_header_state:

Public Member Functions

signed_block_header make_block_header (const checksum256_type &transaction_mroot, const checksum256_type &action_mroot, const std::optional< producer_authority_schedule > &new_producers, vector< digest_type > &&new_protocol_feature_activations, const protocol_feature_set &pfs, const std::optional< s_header > &s_header) const
 
block_header_state finish_next (const signed_block_header &h, vector< signature_type > &&additional_signatures, const protocol_feature_set &pfs, const std::function< void(block_timestamp_type, const flat_set< digest_type > &, const vector< digest_type > &)> &validator, bool skip_validate_signee=false) &&
 
block_header_state finish_next (signed_block_header &h, const protocol_feature_set &pfs, const std::function< void(block_timestamp_type, const flat_set< digest_type > &, const vector< digest_type > &)> &validator, const signer_callback_type &signer) &&
 

Public Attributes

protocol_feature_activation_set_ptr prev_activated_protocol_features
 
detail::schedule_info prev_pending_schedule
 
bool was_pending_promoted = false
 
block_id_type previous
 
account_name producer
 
block_timestamp_type timestamp
 
uint32_t active_schedule_version = 0
 
uint16_t confirmed = 1
 
- Public Attributes inherited from sysio::chain::detail::block_header_state_common
uint32_t block_num = 0
 
uint32_t dpos_proposed_irreversible_blocknum = 0
 
uint32_t dpos_irreversible_blocknum = 0
 
producer_authority_schedule active_schedule
 
incremental_merkle blockroot_merkle
 
flat_map< account_name, uint32_tproducer_to_last_produced
 
flat_map< account_name, uint32_tproducer_to_last_implied_irb
 
block_signing_authority valid_block_signing_authority
 
vector< uint8_tconfirm_count
 

Protected Member Functions

block_header_state _finish_next (const signed_block_header &h, const protocol_feature_set &pfs, const std::function< void(block_timestamp_type, const flat_set< digest_type > &, const vector< digest_type > &)> &validator) &&
 

Detailed Description

Definition at line 75 of file block_header_state.hpp.

Member Function Documentation

◆ _finish_next()

block_header_state sysio::chain::pending_block_header_state::_finish_next ( const signed_block_header & h,
const protocol_feature_set & pfs,
const std::function< void(block_timestamp_type, const flat_set< digest_type > &, const vector< digest_type > &)> & validator ) &&
protected

Definition at line 234 of file block_header_state.cpp.

242 {
243 SYS_ASSERT( h.timestamp == timestamp, block_validate_exception, "timestamp mismatch" );
244 SYS_ASSERT( h.previous == previous, unlinkable_block_exception, "previous mismatch" );
245 SYS_ASSERT( h.confirmed == confirmed, block_validate_exception, "confirmed mismatch" );
246 SYS_ASSERT( h.producer == producer, wrong_producer, "wrong producer specified" );
247 SYS_ASSERT( h.schedule_version == active_schedule_version, producer_schedule_exception, "schedule_version in signed block is corrupted" );
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
255 if (h.new_producers || exts.count(producer_schedule_change_extension::extension_id()) > 0 ) {
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;
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" );
268
269 maybe_new_producer_schedule_hash.emplace(digest_type::hash(new_producers));
270 maybe_new_producer_schedule.emplace(new_producers);
271 }
272
273 if ( exts.count(producer_schedule_change_extension::extension_id()) > 0 ) {
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
277 const auto& new_producer_schedule = std::get<producer_schedule_change_extension>(exts.lower_bound(producer_schedule_change_extension::extension_id())->second);
278
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" );
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
287 protocol_feature_activation_set_ptr new_activated_protocol_features;
288 { // handle protocol_feature_activation
289 if( exts.count(protocol_feature_activation::extension_id() > 0) ) {
290 const auto& new_protocol_features = std::get<protocol_feature_activation>(exts.lower_bound(protocol_feature_activation::extension_id())->second).protocol_features;
291 validator( timestamp, prev_activated_protocol_features->protocol_features, new_protocol_features );
292
293 new_activated_protocol_features = std::make_shared<protocol_feature_activation_set>(
295 new_protocol_features
296 );
297 } else {
298 new_activated_protocol_features = std::move( prev_activated_protocol_features );
299 }
300 }
301
302 auto block_number = block_num;
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 {
317 result.pending_schedule.schedule.version = prev_pending_schedule.schedule.version;
318 } else {
319 result.pending_schedule.schedule = std::move( prev_pending_schedule.schedule );
320 }
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;
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,...)
Definition exceptions.hpp:7
static sha256 hash(const char *d, uint32_t dlen)
Definition sha256.cpp:44
bool is_builtin_activated(const protocol_feature_activation_set_ptr &pfa, const protocol_feature_set &pfs, builtin_protocol_feature_t feature_codename)
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
digest_type schedule_hash
last irr block num
protocol_feature_activation_set_ptr prev_activated_protocol_features
uint32_t version
sequentially incrementing version number
Here is the call graph for this function:

◆ finish_next() [1/2]

block_header_state sysio::chain::pending_block_header_state::finish_next ( const signed_block_header & h,
vector< signature_type > && additional_signatures,
const protocol_feature_set & pfs,
const std::function< void(block_timestamp_type, const flat_set< digest_type > &, const vector< digest_type > &)> & validator,
bool skip_validate_signee = false ) &&

Definition at line 330 of file block_header_state.cpp.

339 {
340 if( !additional_signatures.empty() ) {
342
343 SYS_ASSERT(wtmsig_enabled, producer_schedule_exception, "Block contains multiple signatures before WTMsig block signatures are enabled" );
344 }
345
346 auto result = std::move(*this)._finish_next( h, pfs, validator );
347
348 if( !additional_signatures.empty() ) {
349 result.additional_signatures = std::move(additional_signatures);
350 }
351
352 // ASSUMPTION FROM controller_impl::apply_block = all untrusted blocks will have their signatures pre-validated here
353 if( !skip_validate_signee ) {
354 result.verify_signee( );
355 }
356
357 return result;
358 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ finish_next() [2/2]

block_header_state sysio::chain::pending_block_header_state::finish_next ( signed_block_header & h,
const protocol_feature_set & pfs,
const std::function< void(block_timestamp_type, const flat_set< digest_type > &, const vector< digest_type > &)> & validator,
const signer_callback_type & signer ) &&

Definition at line 360 of file block_header_state.cpp.

368 {
370
371 auto result = std::move(*this)._finish_next( h, pfs, validator );
372 result.sign( signer );
373 h.producer_signature = result.header.producer_signature;
374
375 if( !result.additional_signatures.empty() ) {
377 SYS_ASSERT(wtmsig_enabled, producer_schedule_exception, "Block was signed with multiple signatures before WTMsig block signatures are enabled" );
378 }
379
380 return result;
381 }
Here is the call graph for this function:

◆ make_block_header()

signed_block_header sysio::chain::pending_block_header_state::make_block_header ( const checksum256_type & transaction_mroot,
const checksum256_type & action_mroot,
const std::optional< producer_authority_schedule > & new_producers,
vector< digest_type > && new_protocol_feature_activations,
const protocol_feature_set & pfs,
const std::optional< s_header > & s_header ) const

Definition at line 173 of file block_header_state.cpp.

181 {
182 signed_block_header h;
183
184 h.timestamp = timestamp;
185 h.producer = producer;
186 h.confirmed = confirmed;
187 h.previous = previous;
188 h.transaction_mroot = transaction_mroot;
189 h.action_mroot = action_mroot;
190 h.schedule_version = active_schedule_version;
191
192 if( new_protocol_feature_activations.size() > 0 ) {
194 h.header_extensions,
196 fc::raw::pack( protocol_feature_activation{ std::move(new_protocol_feature_activations) } )
197 );
198 }
199
200 if (new_producers) {
202 // add the header extension to update the block schedule
204 h.header_extensions,
206 fc::raw::pack( producer_schedule_change_extension( *new_producers ) )
207 );
208 } else {
209 legacy::producer_schedule_type downgraded_producers;
210 downgraded_producers.version = new_producers->version;
211 for (const auto &p : new_producers->producers) {
212 std::visit([&downgraded_producers, &p](const auto& auth)
213 {
214 SYS_ASSERT(auth.keys.size() == 1 && auth.keys.front().weight == auth.threshold, producer_schedule_exception, "multisig block signing present before enabled!");
215 downgraded_producers.producers.emplace_back(legacy::producer_key{p.producer_name, auth.keys.front().key});
216 }, p.authority);
217 }
218 h.new_producers = std::move(downgraded_producers);
219 }
220 }
221
222 // Add s_root_extension to header extensions if present & relevant
223 if (s_header) {
225 h.header_extensions,
227 fc::raw::pack( s_root_extension ( *s_header ))
228 );
229 }
230
231 return h;
232 }
const mie::Vuint & p
Definition bn.cpp:27
void pack(Stream &s, const std::deque< T > &value)
Definition raw.hpp:531
auto emplace_extension(extensions_type &exts, uint16_t eid, vector< char > &&data)
Definition types.hpp:264
static constexpr uint16_t extension_id()
Here is the call graph for this function:

Member Data Documentation

◆ active_schedule_version

uint32_t sysio::chain::pending_block_header_state::active_schedule_version = 0

Definition at line 82 of file block_header_state.hpp.

◆ confirmed

uint16_t sysio::chain::pending_block_header_state::confirmed = 1

Definition at line 83 of file block_header_state.hpp.

◆ prev_activated_protocol_features

protocol_feature_activation_set_ptr sysio::chain::pending_block_header_state::prev_activated_protocol_features

Definition at line 76 of file block_header_state.hpp.

◆ prev_pending_schedule

detail::schedule_info sysio::chain::pending_block_header_state::prev_pending_schedule

Definition at line 77 of file block_header_state.hpp.

◆ previous

block_id_type sysio::chain::pending_block_header_state::previous

Definition at line 79 of file block_header_state.hpp.

◆ producer

account_name sysio::chain::pending_block_header_state::producer

Definition at line 80 of file block_header_state.hpp.

◆ timestamp

block_timestamp_type sysio::chain::pending_block_header_state::timestamp

Definition at line 81 of file block_header_state.hpp.

◆ was_pending_promoted

bool sysio::chain::pending_block_header_state::was_pending_promoted = false

Definition at line 78 of file block_header_state.hpp.


The documentation for this struct was generated from the following files: