Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::chain::controller Class Reference

#include <controller.hpp>

Collaboration diagram for sysio::chain::controller:

Classes

struct  config
 

Public Types

enum class  block_status { irreversible = 0 , validated = 1 , complete = 2 , incomplete = 3 }
 

Public Member Functions

 controller (const config &cfg, const chain_id_type &chain_id)
 
 controller (const config &cfg, protocol_feature_set &&pfs, const chain_id_type &chain_id)
 
 ~controller ()
 
void add_indices ()
 
void startup (std::function< void()> shutdown, std::function< bool()> check_shutdown, const snapshot_reader_ptr &snapshot)
 
void startup (std::function< void()> shutdown, std::function< bool()> check_shutdown, const genesis_state &genesis)
 
void startup (std::function< void()> shutdown, std::function< bool()> check_shutdown)
 
void preactivate_feature (const digest_type &feature_digest)
 
vector< digest_typeget_preactivated_protocol_features () const
 
void validate_protocol_features (const vector< digest_type > &features_to_activate) const
 
void start_block (block_timestamp_type time=block_timestamp_type(), uint16_t confirm_block_count=0)
 
void start_block (block_timestamp_type time, uint16_t confirm_block_count, const vector< digest_type > &new_protocol_feature_activations, const fc::time_point &deadline=fc::time_point::maximum())
 
vector< transaction_metadata_ptrabort_block ()
 
transaction_trace_ptr push_transaction (const transaction_metadata_ptr &trx, fc::time_point deadline, fc::microseconds max_transaction_time, uint32_t billed_cpu_time_us, bool explicit_billed_cpu_time, int64_t subjective_cpu_bill_us)
 
transaction_trace_ptr push_scheduled_transaction (const transaction_id_type &scheduled, fc::time_point block_deadline, fc::microseconds max_transaction_time, uint32_t billed_cpu_time_us, bool explicit_billed_cpu_time)
 
block_state_ptr finalize_block (const signer_callback_type &signer_callback)
 
void sign_block (const signer_callback_type &signer_callback)
 
void commit_block ()
 
std::future< block_state_ptrcreate_block_state_future (const block_id_type &id, const signed_block_ptr &b)
 
block_state_ptr create_block_state (const block_id_type &id, const signed_block_ptr &b) const
 
void push_block (const block_state_ptr &bsp, const forked_branch_callback &cb, const trx_meta_cache_lookup &trx_lookup)
 
boost::asio::io_context & get_thread_pool ()
 
const chainbase::databasedb () const
 
const fork_databasefork_db () const
 
const account_objectget_account (account_name n) const
 
const global_property_objectget_global_properties () const
 
const dynamic_global_property_objectget_dynamic_global_properties () const
 
const resource_limits_managerget_resource_limits_manager () const
 controller_impl
 
resource_limits_managerget_mutable_resource_limits_manager ()
 
const authorization_managerget_authorization_manager () const
 
authorization_managerget_mutable_authorization_manager ()
 
const protocol_feature_managerget_protocol_feature_manager () const
 
uint32_t get_max_nonprivileged_inline_action_size () const
 
const flat_set< account_name > & get_actor_whitelist () const
 
const flat_set< account_name > & get_actor_blacklist () const
 
const flat_set< account_name > & get_contract_whitelist () const
 
const flat_set< account_name > & get_contract_blacklist () const
 
const flat_set< pair< account_name, action_name > > & get_action_blacklist () const
 
const flat_set< public_key_type > & get_key_blacklist () const
 
void set_actor_whitelist (const flat_set< account_name > &)
 
void set_actor_blacklist (const flat_set< account_name > &)
 
void set_contract_whitelist (const flat_set< account_name > &)
 
void set_contract_blacklist (const flat_set< account_name > &)
 
void set_action_blacklist (const flat_set< pair< account_name, action_name > > &)
 
void set_key_blacklist (const flat_set< public_key_type > &)
 
void set_s_header (const s_header &)
 
uint32_t head_block_num () const
 
time_point head_block_time () const
 
block_id_type head_block_id () const
 
account_name head_block_producer () const
 
const block_headerhead_block_header () const
 
block_state_ptr head_block_state () const
 
uint32_t fork_db_head_block_num () const
 
block_id_type fork_db_head_block_id () const
 
time_point fork_db_head_block_time () const
 
account_name fork_db_head_block_producer () const
 
uint32_t fork_db_pending_head_block_num () const
 
block_id_type fork_db_pending_head_block_id () const
 
time_point fork_db_pending_head_block_time () const
 
account_name fork_db_pending_head_block_producer () const
 
time_point pending_block_time () const
 
account_name pending_block_producer () const
 
const block_signing_authoritypending_block_signing_authority () const
 
std::optional< block_id_typepending_producer_block_id () const
 
uint32_t pending_block_num () const
 
const vector< transaction_receipt > & get_pending_trx_receipts () const
 
const producer_authority_scheduleactive_producers () const
 
const producer_authority_schedulepending_producers () const
 
std::optional< producer_authority_scheduleproposed_producers () const
 
uint32_t last_irreversible_block_num () const
 
block_id_type last_irreversible_block_id () const
 
time_point last_irreversible_block_time () const
 
signed_block_ptr fetch_block_by_number (uint32_t block_num) const
 
signed_block_ptr fetch_block_by_id (block_id_type id) const
 
block_state_ptr fetch_block_state_by_number (uint32_t block_num) const
 
block_state_ptr fetch_block_state_by_id (block_id_type id) const
 
block_id_type get_block_id_for_num (uint32_t block_num) const
 
sha256 calculate_integrity_hash ()
 
void write_snapshot (const snapshot_writer_ptr &snapshot)
 
bool sender_avoids_whitelist_blacklist_enforcement (account_name sender) const
 
void check_actor_list (const flat_set< account_name > &actors) const
 
void check_contract_list (account_name code) const
 
void check_action_list (account_name code, action_name action) const
 
void check_key_list (const public_key_type &key) const
 
bool is_building_block () const
 
bool is_producing_block () const
 
bool is_ram_billing_in_notify_allowed () const
 
uint32_t configured_subjective_signature_length_limit () const
 
void add_resource_greylist (const account_name &name)
 
void remove_resource_greylist (const account_name &name)
 
bool is_resource_greylisted (const account_name &name) const
 
const flat_set< account_name > & get_resource_greylist () const
 
void validate_expiration (const transaction &t) const
 
void validate_tapos (const transaction &t) const
 
void validate_db_available_size () const
 
bool is_protocol_feature_activated (const digest_type &feature_digest) const
 
bool is_builtin_activated (builtin_protocol_feature_t f) const
 
bool is_known_unexpired_transaction (const transaction_id_type &id) const
 
int64_t set_proposed_producers (vector< producer_authority > producers)
 
bool light_validation_allowed () const
 
bool skip_auth_check () const
 
bool skip_trx_checks () const
 
bool skip_db_sessions () const
 
bool skip_db_sessions (block_status bs) const
 
bool is_trusted_producer (const account_name &producer) const
 
bool contracts_console () const
 
bool is_profiling (account_name name) const
 
chain_id_type get_chain_id () const
 
db_read_mode get_read_mode () const
 
validation_mode get_validation_mode () const
 
uint32_t get_terminate_at_block () const
 
void set_subjective_cpu_leeway (fc::microseconds leeway)
 
std::optional< fc::microsecondsget_subjective_cpu_leeway () const
 
void set_greylist_limit (uint32_t limit)
 
uint32_t get_greylist_limit () const
 
void add_to_ram_correction (account_name account, uint64_t ram_bytes)
 
bool all_subjective_mitigations_disabled () const
 
deep_mind_handlerget_deep_mind_logger () const
 
void enable_deep_mind (deep_mind_handler *logger)
 
uint32_t earliest_available_block_num () const
 
const apply_handlerfind_apply_handler (account_name contract, scope_name scope, action_name act) const
 
wasm_interfaceget_wasm_interface ()
 
std::optional< abi_serializerget_abi_serializer (account_name n, const abi_serializer::yield_function_t &yield) const
 
template<typename T >
fc::variant to_variant_with_abi (const T &obj, const abi_serializer::yield_function_t &yield) const
 
void replace_producer_keys (const public_key_type &key)
 
void replace_account_keys (name account, name permission, const public_key_type &key)
 

Static Public Member Functions

static std::optional< uint64_tconvert_exception_to_error_code (const fc::exception &e)
 
static chain_id_type extract_chain_id (snapshot_reader &snapshot)
 
static std::optional< chain_id_typeextract_chain_id_from_db (const path &state_dir)
 

Public Attributes

signal< void(uint32_t)> block_start
 
signal< void(const signed_block_ptr &)> pre_accepted_block
 
signal< void(const block_state_ptr &)> accepted_block_header
 
signal< void(const block_state_ptr &)> accepted_block
 
signal< void(const block_state_ptr &)> irreversible_block
 
signal< void(const transaction_metadata_ptr &)> accepted_transaction
 
signal< void(std::tuple< const transaction_trace_ptr &, const packed_transaction_ptr & >)> applied_transaction
 
signal< void(const int &)> bad_alloc
 

Friends

class apply_context
 
class transaction_context
 

Detailed Description

Definition at line 63 of file controller.hpp.

Member Enumeration Documentation

◆ block_status

Enumerator
irreversible 

this block has already been applied before by this node and is considered irreversible

validated 

this is a complete block signed by a valid producer and has been previously applied by this node and therefore validated but it is not yet irreversible

complete 

this is a complete block signed by a valid producer but is not yet irreversible nor has it yet been applied by this node

incomplete 

this is an incomplete block (either being produced by a producer or speculatively produced by a node)

Definition at line 106 of file controller.hpp.

106 {
107 irreversible = 0,
108 validated = 1,
109 complete = 2,
110 incomplete = 3,
111 };
@ incomplete
this is an incomplete block (either being produced by a producer or speculatively produced by a node)
@ irreversible
this block has already been applied before by this node and is considered irreversible
@ validated
this is a complete block signed by a valid producer and has been previously applied by this node and ...
@ complete
this is a complete block signed by a valid producer but is not yet irreversible nor has it yet been a...

Constructor & Destructor Documentation

◆ controller() [1/2]

sysio::chain::controller::controller ( const config & cfg,
const chain_id_type & chain_id )

Definition at line 2610 of file controller.cpp.

2611:my( new controller_impl( cfg, *this, protocol_feature_set{}, chain_id ) )
2612{
2613}

◆ controller() [2/2]

sysio::chain::controller::controller ( const config & cfg,
protocol_feature_set && pfs,
const chain_id_type & chain_id )

Definition at line 2615 of file controller.cpp.

2616:my( new controller_impl( cfg, *this, std::move(pfs), chain_id ) )
2617{
2618}

◆ ~controller()

sysio::chain::controller::~controller ( )

Definition at line 2620 of file controller.cpp.

2620 {
2621 my->abort_block();
2622 /* Shouldn't be needed anymore.
2623 //close fork_db here, because it can generate "irreversible" signal to this controller,
2624 //in case if read-mode == IRREVERSIBLE, we will apply latest irreversible block
2625 //for that we need 'my' to be valid pointer pointing to valid controller_impl.
2626 my->fork_db.close();
2627 */
2628}

Member Function Documentation

◆ abort_block()

vector< transaction_metadata_ptr > sysio::chain::controller::abort_block ( )
Returns
transactions applied in aborted block

Definition at line 2847 of file controller.cpp.

2847 {
2848 return my->abort_block();
2849}
Here is the caller graph for this function:

◆ active_producers()

const producer_authority_schedule & sysio::chain::controller::active_producers ( ) const

Definition at line 3179 of file controller.cpp.

3179 {
3180 if( !(my->pending) )
3181 return my->head->active_schedule;
3182
3183 if( std::holds_alternative<completed_block>(my->pending->_block_stage) )
3184 return std::get<completed_block>(my->pending->_block_stage)._block_state->active_schedule;
3185
3186 return my->pending->get_pending_block_header_state().active_schedule;
3187}
Here is the caller graph for this function:

◆ add_indices()

void sysio::chain::controller::add_indices ( )

Definition at line 2630 of file controller.cpp.

2630 {
2631 my->add_indices();
2632}

◆ add_resource_greylist()

void sysio::chain::controller::add_resource_greylist ( const account_name & name)

Definition at line 3421 of file controller.cpp.

3421 {
3422 my->conf.resource_greylist.insert(name);
3423}
std::string name
Here is the caller graph for this function:

◆ add_to_ram_correction()

void sysio::chain::controller::add_to_ram_correction ( account_name account,
uint64_t ram_bytes )

Definition at line 3438 of file controller.cpp.

3438 {
3439 auto ptr = my->db.find<account_ram_correction_object, by_name>( account );
3440 if( ptr ) {
3441 my->db.modify<account_ram_correction_object>( *ptr, [&]( auto& rco ) {
3442 rco.ram_correction += ram_bytes;
3443 } );
3444 } else {
3445 ptr = &my->db.create<account_ram_correction_object>( [&]( auto& rco ) {
3446 rco.name = account;
3447 rco.ram_correction = ram_bytes;
3448 } );
3449 }
3450
3451 if (auto dm_logger = get_deep_mind_logger()) {
3452 dm_logger->on_add_ram_correction(*ptr, ram_bytes);
3453 }
3454}
deep_mind_handler * get_deep_mind_logger() const
Here is the call graph for this function:

◆ all_subjective_mitigations_disabled()

bool sysio::chain::controller::all_subjective_mitigations_disabled ( ) const

Definition at line 3456 of file controller.cpp.

3456 {
3457 return my->conf.disable_all_subjective_mitigations;
3458}

◆ calculate_integrity_hash()

sha256 sysio::chain::controller::calculate_integrity_hash ( )

Definition at line 3119 of file controller.cpp.

3119 { try {
3120 return my->calculate_integrity_hash();
#define FC_LOG_AND_RETHROW()
Here is the caller graph for this function:

◆ check_action_list()

void sysio::chain::controller::check_action_list ( account_name code,
action_name action ) const

Definition at line 3320 of file controller.cpp.

3320 {
3321 my->check_action_list( code, action );
3322}
Here is the caller graph for this function:

◆ check_actor_list()

void sysio::chain::controller::check_actor_list ( const flat_set< account_name > & actors) const

Definition at line 3312 of file controller.cpp.

3312 {
3313 my->check_actor_list( actors );
3314}
Here is the caller graph for this function:

◆ check_contract_list()

void sysio::chain::controller::check_contract_list ( account_name code) const

Definition at line 3316 of file controller.cpp.

3316 {
3317 my->check_contract_list( code );
3318}
Here is the caller graph for this function:

◆ check_key_list()

void sysio::chain::controller::check_key_list ( const public_key_type & key) const

Definition at line 3324 of file controller.cpp.

3324 {
3325 my->check_key_list( key );
3326}

◆ commit_block()

void sysio::chain::controller::commit_block ( )

Definition at line 2842 of file controller.cpp.

2842 {
2844 my->commit_block(true);
2845}
void validate_db_available_size() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ configured_subjective_signature_length_limit()

uint32_t sysio::chain::controller::configured_subjective_signature_length_limit ( ) const

Definition at line 3342 of file controller.cpp.

3342 {
3343 return my->conf.maximum_variable_signature_length;
3344}
Here is the caller graph for this function:

◆ contracts_console()

bool sysio::chain::controller::contracts_console ( ) const

Definition at line 3265 of file controller.cpp.

3265 {
3266 return my->conf.contracts_console;
3267}
Here is the caller graph for this function:

◆ convert_exception_to_error_code()

std::optional< uint64_t > sysio::chain::controller::convert_exception_to_error_code ( const fc::exception & e)
static

Definition at line 3478 of file controller.cpp.

3478 {
3479 const chain_exception* e_ptr = dynamic_cast<const chain_exception*>( &e );
3480
3481 if( e_ptr == nullptr ) return {};
3482
3483 if( !e_ptr->error_code ) return static_cast<uint64_t>(system_error_code::generic_system_error);
3484
3485 return e_ptr->error_code;
3486}
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the caller graph for this function:

◆ create_block_state()

block_state_ptr sysio::chain::controller::create_block_state ( const block_id_type & id,
const signed_block_ptr & b ) const

Definition at line 2859 of file controller.cpp.

2859 {
2860 return my->create_block_state( id, b );
2861}
Here is the caller graph for this function:

◆ create_block_state_future()

std::future< block_state_ptr > sysio::chain::controller::create_block_state_future ( const block_id_type & id,
const signed_block_ptr & b )

Definition at line 2855 of file controller.cpp.

2855 {
2856 return my->create_block_state_future( id, b );
2857}

◆ db()

const chainbase::database & sysio::chain::controller::db ( ) const

Definition at line 2646 of file controller.cpp.

2646{ return my->db; }
Here is the caller graph for this function:

◆ earliest_available_block_num()

uint32_t sysio::chain::controller::earliest_available_block_num ( ) const

Definition at line 3469 of file controller.cpp.

3469 {
3470 return my->earliest_available_block_num();
3471}

◆ enable_deep_mind()

void sysio::chain::controller::enable_deep_mind ( deep_mind_handler * logger)

Definition at line 3464 of file controller.cpp.

3464 {
3465 SYS_ASSERT( logger != nullptr, misc_exception, "Invalid logger passed into enable_deep_mind, must be set" );
3466 my->deep_mind_logger = logger;
3467}
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
fc::logger logger

◆ extract_chain_id()

chain_id_type sysio::chain::controller::extract_chain_id ( snapshot_reader & snapshot)
static

Definition at line 3488 of file controller.cpp.

3488 {
3489 chain_snapshot_header header;
3490 snapshot.read_section<chain_snapshot_header>([&header]( auto &section ){
3491 section.read_row(header);
3492 header.validate();
3493 });
3494
3495 // check if this is a legacy version of the snapshot, which has a genesis state instead of chain id
3496 std::optional<genesis_state> genesis = controller_impl::extract_legacy_genesis_state(snapshot, header.version);
3497 if (genesis) {
3498 return genesis->compute_chain_id();
3499 }
3500
3501 chain_id_type chain_id;
3502
3503 using v4 = legacy::snapshot_global_property_object_v4;
3504 if (header.version <= v4::maximum_version) {
3505 snapshot.read_section<global_property_object>([&chain_id]( auto &section ){
3506 v4 global_properties;
3507 section.read_row(global_properties);
3508 chain_id = global_properties.chain_id;
3509 });
3510 }
3511 else {
3512 snapshot.read_section<global_property_object>([&chain_id]( auto &section ){
3513 snapshot_global_property_object global_properties;
3514 section.read_row(global_properties);
3515 chain_id = global_properties.chain_id;
3516 });
3517 }
3518
3519 return chain_id;
3520}
static std::optional< genesis_state > extract_legacy_genesis_state(snapshot_reader &snapshot, uint32_t version)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ extract_chain_id_from_db()

std::optional< chain_id_type > sysio::chain::controller::extract_chain_id_from_db ( const path & state_dir)
static

Definition at line 3522 of file controller.cpp.

3522 {
3523 try {
3525
3528
3530
3531 if( db.revision() < 1 ) return {};
3532
3533 return db.get<global_property_object>().chain_id;
3534 } catch( const bad_database_version_exception& ) {
3535 throw;
3536 } catch( ... ) {
3537 }
3538
3539 return {};
3540}
int64_t revision() const
const ObjectType & get(CompatibleKey &&key) const
const chainbase::database & db() const
chainbase::shared_multi_index_container< global_property_object, indexed_by< ordered_unique< tag< by_id >, > > > global_property_multi_index
chainbase::shared_multi_index_container< database_header_object, indexed_by< ordered_unique< tag< by_id >, BOOST_MULTI_INDEX_MEMBER(database_header_object, database_header_object::id_type, id)> > > database_header_multi_index
static auto validate_db_version(const chainbase::database &db)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fetch_block_by_id()

signed_block_ptr sysio::chain::controller::fetch_block_by_id ( block_id_type id) const

Definition at line 3066 of file controller.cpp.

3066 {
3067 auto state = my->fork_db.get_block(id);
3068 if( state && state->block ) return state->block;
3069 auto bptr = my->blog.read_block_by_num( block_header::num_from_id(id) );
3070 if( bptr && bptr->calculate_id() == id ) return bptr;
3071 return signed_block_ptr();
3072}
std::shared_ptr< signed_block > signed_block_ptr
Definition block.hpp:105
static uint32_t num_from_id(const block_id_type &id)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fetch_block_by_number()

signed_block_ptr sysio::chain::controller::fetch_block_by_number ( uint32_t block_num) const

Definition at line 3074 of file controller.cpp.

3074 { try {
3075 auto blk_state = fetch_block_state_by_number( block_num );
3076 if( blk_state ) {
3077 return blk_state->block;
3078 }
3079
3080 return my->blog.read_block_by_num(block_num);
3081} FC_CAPTURE_AND_RETHROW( (block_num) ) }
block_state_ptr fetch_block_state_by_number(uint32_t block_num) const
#define FC_CAPTURE_AND_RETHROW(...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fetch_block_state_by_id()

block_state_ptr sysio::chain::controller::fetch_block_state_by_id ( block_id_type id) const

Definition at line 3083 of file controller.cpp.

3083 {
3084 auto state = my->fork_db.get_block(id);
3085 return state;
3086}
Here is the caller graph for this function:

◆ fetch_block_state_by_number()

block_state_ptr sysio::chain::controller::fetch_block_state_by_number ( uint32_t block_num) const

Definition at line 3088 of file controller.cpp.

3088 { try {
3089 if( my->read_mode == db_read_mode::IRREVERSIBLE ) {
3090 return my->fork_db.search_on_branch( my->fork_db.pending_head()->id, block_num );
3091 } else {
3092 return my->fork_db.search_on_branch( my->fork_db.head()->id, block_num );
3093 }
3094} FC_CAPTURE_AND_RETHROW( (block_num) ) }
Here is the caller graph for this function:

◆ finalize_block()

block_state_ptr sysio::chain::controller::finalize_block ( const signer_callback_type & signer_callback)

Definition at line 2818 of file controller.cpp.

2818 {
2820
2821 my->finalize_block();
2822
2823 auto& ab = std::get<assembled_block>(my->pending->_block_stage);
2824
2825 auto bsp = std::make_shared<block_state>(
2826 std::move( ab._pending_block_header_state ),
2827 std::move( ab._unsigned_block ),
2828 std::move( ab._trx_metas ),
2829 my->protocol_features.get_protocol_feature_set(),
2830 []( block_timestamp_type timestamp,
2831 const flat_set<digest_type>& cur_features,
2832 const vector<digest_type>& new_features )
2833 {},
2834 signer_callback
2835 );
2836
2837 my->pending->_block_stage = completed_block{ bsp };
2838
2839 return bsp;
2840}
block_timestamp< config::block_interval_ms, config::block_timestamp_epoch > block_timestamp_type
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_apply_handler()

const apply_handler * sysio::chain::controller::find_apply_handler ( account_name contract,
scope_name scope,
action_name act ) const

Definition at line 3289 of file controller.cpp.

3290{
3291 auto native_handler_scope = my->apply_handlers.find( receiver );
3292 if( native_handler_scope != my->apply_handlers.end() ) {
3293 auto handler = native_handler_scope->second.find( make_pair( scope, act ) );
3294 if( handler != native_handler_scope->second.end() )
3295 return &handler->second;
3296 }
3297 return nullptr;
3298}
Here is the caller graph for this function:

◆ fork_db()

const fork_database & sysio::chain::controller::fork_db ( ) const

Definition at line 2650 of file controller.cpp.

2650{ return my->fork_db; }

◆ fork_db_head_block_id()

block_id_type sysio::chain::controller::fork_db_head_block_id ( ) const

Definition at line 2972 of file controller.cpp.

2972 {
2973 return my->fork_db.head()->id;
2974}

◆ fork_db_head_block_num()

uint32_t sysio::chain::controller::fork_db_head_block_num ( ) const

Definition at line 2968 of file controller.cpp.

2968 {
2969 return my->fork_db.head()->block_num;
2970}

◆ fork_db_head_block_producer()

account_name sysio::chain::controller::fork_db_head_block_producer ( ) const

Definition at line 2980 of file controller.cpp.

2980 {
2981 return my->fork_db.head()->header.producer;
2982}

◆ fork_db_head_block_time()

time_point sysio::chain::controller::fork_db_head_block_time ( ) const

Definition at line 2976 of file controller.cpp.

2976 {
2977 return my->fork_db.head()->header.timestamp;
2978}

◆ fork_db_pending_head_block_id()

block_id_type sysio::chain::controller::fork_db_pending_head_block_id ( ) const

Definition at line 2988 of file controller.cpp.

2988 {
2989 return my->fork_db.pending_head()->id;
2990}
Here is the caller graph for this function:

◆ fork_db_pending_head_block_num()

uint32_t sysio::chain::controller::fork_db_pending_head_block_num ( ) const

Definition at line 2984 of file controller.cpp.

2984 {
2985 return my->fork_db.pending_head()->block_num;
2986}
Here is the caller graph for this function:

◆ fork_db_pending_head_block_producer()

account_name sysio::chain::controller::fork_db_pending_head_block_producer ( ) const

Definition at line 2996 of file controller.cpp.

2996 {
2997 return my->fork_db.pending_head()->header.producer;
2998}

◆ fork_db_pending_head_block_time()

time_point sysio::chain::controller::fork_db_pending_head_block_time ( ) const

Definition at line 2992 of file controller.cpp.

2992 {
2993 return my->fork_db.pending_head()->header.timestamp;
2994}

◆ get_abi_serializer()

std::optional< abi_serializer > sysio::chain::controller::get_abi_serializer ( account_name n,
const abi_serializer::yield_function_t & yield ) const
inline

Definition at line 349 of file controller.hpp.

349 {
350 if( n.good() ) {
351 try {
352 const auto& a = get_account( n );
353 abi_def abi;
354 if( abi_serializer::to_abi( a.abi, abi ))
355 return abi_serializer( abi, yield );
356 } FC_CAPTURE_AND_LOG((n))
357 }
358 return std::optional<abi_serializer>();
359 }
const account_object & get_account(account_name n) const
#define FC_CAPTURE_AND_LOG(...)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
static bool to_abi(const Vec &abi_vec, abi_def &abi)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_account()

const account_object & sysio::chain::controller::get_account ( account_name n) const

Definition at line 3303 of file controller.cpp.

3304{ try {
3305 return my->db.get<account_object, by_name>(name);
Here is the caller graph for this function:

◆ get_action_blacklist()

const flat_set< pair< account_name, action_name > > & sysio::chain::controller::get_action_blacklist ( ) const

Definition at line 2902 of file controller.cpp.

2902 {
2903 return my->conf.action_blacklist;
2904}
Here is the caller graph for this function:

◆ get_actor_blacklist()

const flat_set< account_name > & sysio::chain::controller::get_actor_blacklist ( ) const

Definition at line 2893 of file controller.cpp.

2893 {
2894 return my->conf.actor_blacklist;
2895}
Here is the caller graph for this function:

◆ get_actor_whitelist()

const flat_set< account_name > & sysio::chain::controller::get_actor_whitelist ( ) const

Definition at line 2890 of file controller.cpp.

2890 {
2891 return my->conf.actor_whitelist;
2892}
Here is the caller graph for this function:

◆ get_authorization_manager()

const authorization_manager & sysio::chain::controller::get_authorization_manager ( ) const

Definition at line 2591 of file controller.cpp.

2592{
2593 return my->authorization;
2594}
Here is the caller graph for this function:

◆ get_block_id_for_num()

block_id_type sysio::chain::controller::get_block_id_for_num ( uint32_t block_num) const

Definition at line 3096 of file controller.cpp.

3096 { try {
3097 const auto& tapos_block_summary = db().get<block_summary_object>((uint16_t)block_num);
3098
3099 if( block_header::num_from_id(tapos_block_summary.block_id) == block_num )
3100 return tapos_block_summary.block_id;
3101
3102 const auto& blog_head = my->blog.head();
3103
3104 bool find_in_blog = (blog_head && block_num <= blog_head->block_num());
3105
3106 if( !find_in_blog ) {
3107 auto bsp = fetch_block_state_by_number( block_num );
3108 if( bsp ) return bsp->id;
3109 }
3110
3111 auto id = my->blog.read_block_id_by_num(block_num);
3112
3113 SYS_ASSERT( BOOST_LIKELY( id != block_id_type() ), unknown_block_exception,
3114 "Could not find block: ${block}", ("block", block_num) );
3115
3116 return id;
3117} FC_CAPTURE_AND_RETHROW( (block_num) ) }
uint64_t id
Definition code_cache.cpp:0
fc::sha256 block_id_type
Definition types.hpp:231
unsigned short uint16_t
Definition stdint.h:125
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_chain_id()

chain_id_type sysio::chain::controller::get_chain_id ( ) const

Definition at line 3273 of file controller.cpp.

3273 {
3274 return my->chain_id;
3275}
Here is the caller graph for this function:

◆ get_contract_blacklist()

const flat_set< account_name > & sysio::chain::controller::get_contract_blacklist ( ) const

Definition at line 2899 of file controller.cpp.

2899 {
2900 return my->conf.contract_blacklist;
2901}
Here is the caller graph for this function:

◆ get_contract_whitelist()

const flat_set< account_name > & sysio::chain::controller::get_contract_whitelist ( ) const

Definition at line 2896 of file controller.cpp.

2896 {
2897 return my->conf.contract_whitelist;
2898}
Here is the caller graph for this function:

◆ get_deep_mind_logger()

deep_mind_handler * sysio::chain::controller::get_deep_mind_logger ( ) const

Definition at line 3460 of file controller.cpp.

3460 {
3461 return my->get_deep_mind_logger();
3462}
Here is the caller graph for this function:

◆ get_dynamic_global_properties()

const dynamic_global_property_object & sysio::chain::controller::get_dynamic_global_properties ( ) const

Definition at line 3059 of file controller.cpp.

3059 {
3060 return my->db.get<dynamic_global_property_object>();
3061}
Here is the caller graph for this function:

◆ get_global_properties()

const global_property_object & sysio::chain::controller::get_global_properties ( ) const

Definition at line 3062 of file controller.cpp.

3062 {
3063 return my->db.get<global_property_object>();
3064}
Here is the caller graph for this function:

◆ get_greylist_limit()

uint32_t sysio::chain::controller::get_greylist_limit ( ) const

Definition at line 3417 of file controller.cpp.

3417 {
3418 return my->conf.greylist_limit;
3419}
Here is the caller graph for this function:

◆ get_key_blacklist()

const flat_set< public_key_type > & sysio::chain::controller::get_key_blacklist ( ) const

Definition at line 2905 of file controller.cpp.

2905 {
2906 return my->conf.key_blacklist;
2907}
Here is the caller graph for this function:

◆ get_max_nonprivileged_inline_action_size()

uint32_t sysio::chain::controller::get_max_nonprivileged_inline_action_size ( ) const

Definition at line 2605 of file controller.cpp.

2606{
2607 return my->conf.max_nonprivileged_inline_action_size;
2608}
Here is the caller graph for this function:

◆ get_mutable_authorization_manager()

authorization_manager & sysio::chain::controller::get_mutable_authorization_manager ( )

Definition at line 2595 of file controller.cpp.

2596{
2597 return my->authorization;
2598}
Here is the caller graph for this function:

◆ get_mutable_resource_limits_manager()

resource_limits_manager & sysio::chain::controller::get_mutable_resource_limits_manager ( )

Definition at line 2586 of file controller.cpp.

2587{
2588 return my->resource_limits;
2589}
Here is the caller graph for this function:

◆ get_pending_trx_receipts()

const vector< transaction_receipt > & sysio::chain::controller::get_pending_trx_receipts ( ) const

Definition at line 3041 of file controller.cpp.

3041 {
3042 SYS_ASSERT( my->pending, block_validate_exception, "no pending block" );
3043 return my->pending->get_trx_receipts();
3044}
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
Here is the caller graph for this function:

◆ get_preactivated_protocol_features()

vector< digest_type > sysio::chain::controller::get_preactivated_protocol_features ( ) const

Definition at line 2760 of file controller.cpp.

2760 {
2761 const auto& pso = my->db.get<protocol_state_object>();
2762
2763 if( pso.preactivated_protocol_features.size() == 0 ) return {};
2764
2765 vector<digest_type> preactivated_protocol_features;
2766
2767 for( const auto& f : pso.preactivated_protocol_features ) {
2768 preactivated_protocol_features.emplace_back( f );
2769 }
2770
2771 return preactivated_protocol_features;
2772}
Here is the caller graph for this function:

◆ get_protocol_feature_manager()

const protocol_feature_manager & sysio::chain::controller::get_protocol_feature_manager ( ) const

Definition at line 2600 of file controller.cpp.

2601{
2602 return my->protocol_features;
2603}
Here is the caller graph for this function:

◆ get_read_mode()

db_read_mode sysio::chain::controller::get_read_mode ( ) const

Definition at line 3277 of file controller.cpp.

3277 {
3278 return my->read_mode;
3279}
Here is the caller graph for this function:

◆ get_resource_greylist()

const flat_set< account_name > & sysio::chain::controller::get_resource_greylist ( ) const

Definition at line 3433 of file controller.cpp.

3433 {
3434 return my->conf.resource_greylist;
3435}
Here is the caller graph for this function:

◆ get_resource_limits_manager()

const resource_limits_manager & sysio::chain::controller::get_resource_limits_manager ( ) const

Definition at line 2582 of file controller.cpp.

2583{
2584 return my->resource_limits;
2585}
Here is the caller graph for this function:

◆ get_subjective_cpu_leeway()

std::optional< fc::microseconds > sysio::chain::controller::get_subjective_cpu_leeway ( ) const

Definition at line 3403 of file controller.cpp.

3403 {
3404 return my->subjective_cpu_leeway;
3405}

◆ get_terminate_at_block()

uint32_t sysio::chain::controller::get_terminate_at_block ( ) const

Definition at line 3285 of file controller.cpp.

3285 {
3286 return my->conf.terminate_at_block;
3287}
Here is the caller graph for this function:

◆ get_thread_pool()

boost::asio::io_context & sysio::chain::controller::get_thread_pool ( )

Definition at line 2851 of file controller.cpp.

2851 {
2852 return my->thread_pool.get_executor();
2853}

◆ get_validation_mode()

validation_mode sysio::chain::controller::get_validation_mode ( ) const

Definition at line 3281 of file controller.cpp.

3281 {
3282 return my->conf.block_validation_mode;
3283}
Here is the caller graph for this function:

◆ get_wasm_interface()

wasm_interface & sysio::chain::controller::get_wasm_interface ( )

Definition at line 3299 of file controller.cpp.

3299 {
3300 return my->wasmif;
3301}
Here is the caller graph for this function:

◆ head_block_header()

const block_header & sysio::chain::controller::head_block_header ( ) const

Definition at line 2961 of file controller.cpp.

2961 {
2962 return my->head->header;
2963}
Here is the caller graph for this function:

◆ head_block_id()

block_id_type sysio::chain::controller::head_block_id ( ) const

Definition at line 2955 of file controller.cpp.

2955 {
2956 return my->head->id;
2957}
Here is the caller graph for this function:

◆ head_block_num()

uint32_t sysio::chain::controller::head_block_num ( ) const

Definition at line 2949 of file controller.cpp.

2949 {
2950 return my->head->block_num;
2951}
Here is the caller graph for this function:

◆ head_block_producer()

account_name sysio::chain::controller::head_block_producer ( ) const

Definition at line 2958 of file controller.cpp.

2958 {
2959 return my->head->header.producer;
2960}

◆ head_block_state()

block_state_ptr sysio::chain::controller::head_block_state ( ) const

Definition at line 2964 of file controller.cpp.

2964 {
2965 return my->head;
2966}
Here is the caller graph for this function:

◆ head_block_time()

time_point sysio::chain::controller::head_block_time ( ) const

Definition at line 2952 of file controller.cpp.

2952 {
2953 return my->head->header.timestamp;
2954}
Here is the caller graph for this function:

◆ is_building_block()

bool sysio::chain::controller::is_building_block ( ) const

Definition at line 3328 of file controller.cpp.

3328 {
3329 return my->pending.has_value();
3330}
Here is the caller graph for this function:

◆ is_builtin_activated()

bool sysio::chain::controller::is_builtin_activated ( builtin_protocol_feature_t f) const

Definition at line 3385 of file controller.cpp.

3385 {
3386 uint32_t current_block_num = head_block_num();
3387
3388 if( my->pending ) {
3389 ++current_block_num;
3390 }
3391
3392 return my->protocol_features.is_builtin_activated( f, current_block_num );
3393}
uint32_t head_block_num() const
unsigned int uint32_t
Definition stdint.h:126
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_known_unexpired_transaction()

bool sysio::chain::controller::is_known_unexpired_transaction ( const transaction_id_type & id) const

Definition at line 3395 of file controller.cpp.

3395 {
3396 return db().find<transaction_object, by_trx_id>(id);
3397}
const ObjectType * find(CompatibleKey &&key) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_producing_block()

bool sysio::chain::controller::is_producing_block ( ) const

Definition at line 3332 of file controller.cpp.

3332 {
3333 if( !my->pending ) return false;
3334
3335 return (my->pending->_block_status == block_status::incomplete);
3336}
Here is the caller graph for this function:

◆ is_profiling()

bool sysio::chain::controller::is_profiling ( account_name name) const

Definition at line 3269 of file controller.cpp.

3269 {
3270 return my->conf.profile_accounts.find(account) != my->conf.profile_accounts.end();
3271}

◆ is_protocol_feature_activated()

bool sysio::chain::controller::is_protocol_feature_activated ( const digest_type & feature_digest) const

Definition at line 3377 of file controller.cpp.

3377 {
3378 if( my->pending )
3379 return my->pending->is_protocol_feature_activated( feature_digest );
3380
3381 const auto& activated_features = my->head->activated_protocol_features->protocol_features;
3382 return (activated_features.find( feature_digest ) != activated_features.end());
3383}
Here is the caller graph for this function:

◆ is_ram_billing_in_notify_allowed()

bool sysio::chain::controller::is_ram_billing_in_notify_allowed ( ) const

Definition at line 3338 of file controller.cpp.

3338 {
3339 return my->conf.disable_all_subjective_mitigations || !is_producing_block() || my->conf.allow_ram_billing_in_notify;
3340}
bool is_producing_block() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_resource_greylisted()

bool sysio::chain::controller::is_resource_greylisted ( const account_name & name) const

Definition at line 3429 of file controller.cpp.

3429 {
3430 return my->conf.resource_greylist.find(name) != my->conf.resource_greylist.end();
3431}
Here is the caller graph for this function:

◆ is_trusted_producer()

bool sysio::chain::controller::is_trusted_producer ( const account_name & producer) const

Definition at line 3261 of file controller.cpp.

3261 {
3262 return get_validation_mode() == chain::validation_mode::LIGHT || my->conf.trusted_producers.count(producer);
3263}
validation_mode get_validation_mode() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ last_irreversible_block_id()

block_id_type sysio::chain::controller::last_irreversible_block_id ( ) const

Definition at line 3050 of file controller.cpp.

3050 {
3051 return my->fork_db.root()->id;
3052}
Here is the caller graph for this function:

◆ last_irreversible_block_num()

uint32_t sysio::chain::controller::last_irreversible_block_num ( ) const

Definition at line 3046 of file controller.cpp.

3046 {
3047 return my->fork_db.root()->block_num;
3048}
Here is the caller graph for this function:

◆ last_irreversible_block_time()

time_point sysio::chain::controller::last_irreversible_block_time ( ) const

Definition at line 3054 of file controller.cpp.

3054 {
3055 return my->fork_db.root()->header.timestamp.to_time_point();
3056}
Here is the caller graph for this function:

◆ light_validation_allowed()

bool sysio::chain::controller::light_validation_allowed ( ) const

Definition at line 3219 of file controller.cpp.

3219 {
3220 if (!my->pending || my->in_trx_requiring_checks) {
3221 return false;
3222 }
3223
3224 const auto pb_status = my->pending->_block_status;
3225
3226 // in a pending irreversible or previously validated block and we have forcing all checks
3227 const bool consider_skipping_on_replay =
3228 (pb_status == block_status::irreversible || pb_status == block_status::validated) && !my->conf.force_all_checks;
3229
3230 // OR in a signed block and in light validation mode
3231 const bool consider_skipping_on_validate = (pb_status == block_status::complete &&
3232 (my->conf.block_validation_mode == validation_mode::LIGHT || my->trusted_producer_light_validation));
3233
3234 return consider_skipping_on_replay || consider_skipping_on_validate;
3235}
Here is the caller graph for this function:

◆ pending_block_num()

uint32_t sysio::chain::controller::pending_block_num ( ) const

Definition at line 3009 of file controller.cpp.

3009 {
3010 SYS_ASSERT( my->pending, block_validate_exception, "no pending block" );
3011
3012 if( std::holds_alternative<completed_block>(my->pending->_block_stage) )
3013 return std::get<completed_block>(my->pending->_block_stage)._block_state->header.block_num();
3014
3015 return my->pending->get_pending_block_header_state().block_num;
3016}

◆ pending_block_producer()

account_name sysio::chain::controller::pending_block_producer ( ) const

Definition at line 3018 of file controller.cpp.

3018 {
3019 SYS_ASSERT( my->pending, block_validate_exception, "no pending block" );
3020
3021 if( std::holds_alternative<completed_block>(my->pending->_block_stage) )
3022 return std::get<completed_block>(my->pending->_block_stage)._block_state->header.producer;
3023
3024 return my->pending->get_pending_block_header_state().producer;
3025}
Here is the caller graph for this function:

◆ pending_block_signing_authority()

const block_signing_authority & sysio::chain::controller::pending_block_signing_authority ( ) const

Definition at line 3027 of file controller.cpp.

3027 {
3028 SYS_ASSERT( my->pending, block_validate_exception, "no pending block" );
3029
3030 if( std::holds_alternative<completed_block>(my->pending->_block_stage) )
3031 return std::get<completed_block>(my->pending->_block_stage)._block_state->valid_block_signing_authority;
3032
3033 return my->pending->get_pending_block_header_state().valid_block_signing_authority;
3034}
Here is the caller graph for this function:

◆ pending_block_time()

time_point sysio::chain::controller::pending_block_time ( ) const

Definition at line 3000 of file controller.cpp.

3000 {
3001 SYS_ASSERT( my->pending, block_validate_exception, "no pending block" );
3002
3003 if( std::holds_alternative<completed_block>(my->pending->_block_stage) )
3004 return std::get<completed_block>(my->pending->_block_stage)._block_state->header.timestamp;
3005
3006 return my->pending->get_pending_block_header_state().timestamp;
3007}
Here is the caller graph for this function:

◆ pending_producer_block_id()

std::optional< block_id_type > sysio::chain::controller::pending_producer_block_id ( ) const

Definition at line 3036 of file controller.cpp.

3036 {
3037 SYS_ASSERT( my->pending, block_validate_exception, "no pending block" );
3038 return my->pending->_producer_block_id;
3039}
Here is the caller graph for this function:

◆ pending_producers()

const producer_authority_schedule & sysio::chain::controller::pending_producers ( ) const

Definition at line 3189 of file controller.cpp.

3189 {
3190 if( !(my->pending) )
3191 return my->head->pending_schedule.schedule;
3192
3193 if( std::holds_alternative<completed_block>(my->pending->_block_stage) )
3194 return std::get<completed_block>(my->pending->_block_stage)._block_state->pending_schedule.schedule;
3195
3196 if( std::holds_alternative<assembled_block>(my->pending->_block_stage) ) {
3197 const auto& new_prods_cache = std::get<assembled_block>(my->pending->_block_stage)._new_producer_authority_cache;
3198 if( new_prods_cache ) {
3199 return *new_prods_cache;
3200 }
3201 }
3202
3203 const auto& bb = std::get<building_block>(my->pending->_block_stage);
3204
3205 if( bb._new_pending_producer_schedule )
3206 return *bb._new_pending_producer_schedule;
3207
3208 return bb._pending_block_header_state.prev_pending_schedule.schedule;
3209}
Here is the caller graph for this function:

◆ preactivate_feature()

void sysio::chain::controller::preactivate_feature ( const digest_type & feature_digest)

Definition at line 2652 of file controller.cpp.

2652 {
2653 const auto& pfs = my->protocol_features.get_protocol_feature_set();
2654 auto cur_time = pending_block_time();
2655
2656 auto status = pfs.is_recognized( feature_digest, cur_time );
2657 switch( status ) {
2659 if( is_producing_block() ) {
2660 SYS_THROW( subjective_block_production_exception,
2661 "protocol feature with digest '${digest}' is unrecognized", ("digest", feature_digest) );
2662 } else {
2663 SYS_THROW( protocol_feature_bad_block_exception,
2664 "protocol feature with digest '${digest}' is unrecognized", ("digest", feature_digest) );
2665 }
2666 break;
2668 if( is_producing_block() ) {
2669 SYS_THROW( subjective_block_production_exception,
2670 "protocol feature with digest '${digest}' is disabled", ("digest", feature_digest) );
2671 } else {
2672 SYS_THROW( protocol_feature_bad_block_exception,
2673 "protocol feature with digest '${digest}' is disabled", ("digest", feature_digest) );
2674 }
2675 break;
2677 if( is_producing_block() ) {
2678 SYS_THROW( subjective_block_production_exception,
2679 "${timestamp} is too early for the earliest allowed activation time of the protocol feature with digest '${digest}'", ("digest", feature_digest)("timestamp", cur_time) );
2680 } else {
2681 SYS_THROW( protocol_feature_bad_block_exception,
2682 "${timestamp} is too early for the earliest allowed activation time of the protocol feature with digest '${digest}'", ("digest", feature_digest)("timestamp", cur_time) );
2683 }
2684 break;
2686 break;
2687 default:
2688 if( is_producing_block() ) {
2689 SYS_THROW( subjective_block_production_exception, "unexpected recognized_t status" );
2690 } else {
2691 SYS_THROW( protocol_feature_bad_block_exception, "unexpected recognized_t status" );
2692 }
2693 break;
2694 }
2695
2696 // The above failures depend on subjective information.
2697 // Because of deferred transactions, this complicates things considerably.
2698
2699 // If producing a block, we throw a subjective failure if the feature is not properly recognized in order
2700 // to try to avoid retiring into a block a deferred transacton driven by subjective information.
2701
2702 // But it is still possible for a producer to retire a deferred transaction that deals with this subjective
2703 // information. If they recognized the feature, they would retire it successfully, but a validator that
2704 // does not recognize the feature should reject the entire block (not just fail the deferred transaction).
2705 // Even if they don't recognize the feature, the producer could change their nodeop code to treat it like an
2706 // objective failure thus leading the deferred transaction to retire with soft_fail or hard_fail.
2707 // In this case, validators that don't recognize the feature would reject the whole block immediately, and
2708 // validators that do recognize the feature would likely lead to a different retire status which would
2709 // ultimately cause a validation failure and thus rejection of the block.
2710 // In either case, it results in rejection of the block which is the desired behavior in this scenario.
2711
2712 // If the feature is properly recognized by producer and validator, we have dealt with the subjectivity and
2713 // now only consider the remaining failure modes which are deterministic and objective.
2714 // Thus the exceptions that can be thrown below can be regular objective exceptions
2715 // that do not cause immediate rejection of the block.
2716
2717 SYS_ASSERT( !is_protocol_feature_activated( feature_digest ),
2718 protocol_feature_exception,
2719 "protocol feature with digest '${digest}' is already activated",
2720 ("digest", feature_digest)
2721 );
2722
2723 const auto& pso = my->db.get<protocol_state_object>();
2724
2725 SYS_ASSERT( std::find( pso.preactivated_protocol_features.begin(),
2726 pso.preactivated_protocol_features.end(),
2727 feature_digest
2728 ) == pso.preactivated_protocol_features.end(),
2729 protocol_feature_exception,
2730 "protocol feature with digest '${digest}' is already pre-activated",
2731 ("digest", feature_digest)
2732 );
2733
2734 auto dependency_checker = [&]( const digest_type& d ) -> bool
2735 {
2736 if( is_protocol_feature_activated( d ) ) return true;
2737
2738 return ( std::find( pso.preactivated_protocol_features.begin(),
2739 pso.preactivated_protocol_features.end(),
2740 d ) != pso.preactivated_protocol_features.end() );
2741 };
2742
2743 SYS_ASSERT( pfs.validate_dependencies( feature_digest, dependency_checker ),
2744 protocol_feature_exception,
2745 "not all dependencies of protocol feature with digest '${digest}' have been activated or pre-activated",
2746 ("digest", feature_digest)
2747 );
2748
2749 if (auto dm_logger = get_deep_mind_logger()) {
2750 const auto feature = pfs.get_protocol_feature(feature_digest);
2751
2752 dm_logger->on_preactivate_feature(feature);
2753 }
2754
2755 my->db.modify( pso, [&]( auto& ps ) {
2756 ps.preactivated_protocol_features.push_back( feature_digest );
2757 } );
2758}
#define SYS_THROW(exc_type, FORMAT,...)
bool is_protocol_feature_activated(const digest_type &feature_digest) const
time_point pending_block_time() const
checksum_type digest_type
Definition types.hpp:237
CK_ULONG d
Here is the call graph for this function:

◆ proposed_producers()

std::optional< producer_authority_schedule > sysio::chain::controller::proposed_producers ( ) const

Definition at line 3211 of file controller.cpp.

3211 {
3212 const auto& gpo = get_global_properties();
3213 if( !gpo.proposed_schedule_block_num )
3214 return std::optional<producer_authority_schedule>();
3215
3216 return producer_authority_schedule::from_shared(gpo.proposed_schedule);
3217}
const global_property_object & get_global_properties() const
static auto from_shared(const shared_producer_authority_schedule &src)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ push_block()

void sysio::chain::controller::push_block ( const block_state_ptr & bsp,
const forked_branch_callback & cb,
const trx_meta_cache_lookup & trx_lookup )
Parameters
bspblock to push
cbcalls cb with forked applied transactions for each forked block
trx_lookupuser provided lookup function for externally cached transaction_metadata

Definition at line 2863 of file controller.cpp.

2866{
2868 my->push_block( bsp, forked_branch_cb, trx_lookup );
2869}
Here is the call graph for this function:

◆ push_scheduled_transaction()

transaction_trace_ptr sysio::chain::controller::push_scheduled_transaction ( const transaction_id_type & scheduled,
fc::time_point block_deadline,
fc::microseconds max_transaction_time,
uint32_t billed_cpu_time_us,
bool explicit_billed_cpu_time )

Attempt to execute a specific transaction in our deferred trx database

Definition at line 2881 of file controller.cpp.

2884{
2885 SYS_ASSERT( get_read_mode() != db_read_mode::IRREVERSIBLE, transaction_type_exception, "push scheduled transaction not allowed in irreversible mode" );
2887 return my->push_scheduled_transaction( trxid, block_deadline, max_transaction_time, billed_cpu_time_us, explicit_billed_cpu_time );
2888}
db_read_mode get_read_mode() const
Here is the call graph for this function:

◆ push_transaction()

transaction_trace_ptr sysio::chain::controller::push_transaction ( const transaction_metadata_ptr & trx,
fc::time_point deadline,
fc::microseconds max_transaction_time,
uint32_t billed_cpu_time_us,
bool explicit_billed_cpu_time,
int64_t subjective_cpu_bill_us )

Definition at line 2871 of file controller.cpp.

2874 {
2876 SYS_ASSERT( get_read_mode() != db_read_mode::IRREVERSIBLE, transaction_type_exception, "push transaction not allowed in irreversible mode" );
2877 SYS_ASSERT( trx && !trx->implicit && !trx->scheduled, transaction_type_exception, "Implicit/Scheduled transaction not allowed" );
2878 return my->push_transaction(trx, block_deadline, max_transaction_time, billed_cpu_time_us, explicit_billed_cpu_time, subjective_cpu_bill_us );
2879}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_resource_greylist()

void sysio::chain::controller::remove_resource_greylist ( const account_name & name)

Definition at line 3425 of file controller.cpp.

3425 {
3426 my->conf.resource_greylist.erase(name);
3427}
Here is the caller graph for this function:

◆ replace_account_keys()

void sysio::chain::controller::replace_account_keys ( name account,
name permission,
const public_key_type & key )

Definition at line 3561 of file controller.cpp.

3561 {
3563 auto* perm = db().find<permission_object, by_owner>(boost::make_tuple(account, permission));
3564 if (!perm)
3565 return;
3566 int64_t old_size = (int64_t)(chain::config::billable_size_v<permission_object> + perm->auth.get_billable_size());
3567 mutable_db().modify(*perm, [&](auto& p) {
3568 p.auth = authority(key);
3569 });
3570 int64_t new_size = (int64_t)(chain::config::billable_size_v<permission_object> + perm->auth.get_billable_size());
3571 rlm.add_pending_ram_usage(account, new_size - old_size);
3572 rlm.verify_account_ram_usage(account);
3573}
const mie::Vuint & p
Definition bn.cpp:27
void modify(const ObjectType &obj, Modifier &&m)
resource_limits_manager & get_mutable_resource_limits_manager()
constexpr uint64_t billable_size_v
Definition config.hpp:147
signed __int64 int64_t
Definition stdint.h:135
Here is the call graph for this function:

◆ replace_producer_keys()

void sysio::chain::controller::replace_producer_keys ( const public_key_type & key)

Definition at line 3542 of file controller.cpp.

3542 {
3543 ilog("Replace producer keys with ${k}", ("k", key));
3544 mutable_db().modify( db().get<global_property_object>(), [&]( auto& gp ) {
3545 gp.proposed_schedule_block_num = {};
3546 gp.proposed_schedule.version = 0;
3547 gp.proposed_schedule.producers.clear();
3548 });
3549 auto version = my->head->pending_schedule.schedule.version;
3550 my->head->pending_schedule = {};
3551 my->head->pending_schedule.schedule.version = version;
3552 for (auto& prod: my->head->active_schedule.producers ) {
3553 ilog("${n}", ("n", prod.producer_name));
3554 std::visit([&](auto &auth) {
3555 auth.threshold = 1;
3556 auth.keys = {key_weight{key, 1}};
3557 }, prod.authority);
3558 }
3559}
#define ilog(FORMAT,...)
Definition logger.hpp:118
uint8_t key[16]
Definition yubico_otp.c:41
Here is the call graph for this function:

◆ sender_avoids_whitelist_blacklist_enforcement()

bool sysio::chain::controller::sender_avoids_whitelist_blacklist_enforcement ( account_name sender) const

Definition at line 3308 of file controller.cpp.

3308 {
3309 return my->sender_avoids_whitelist_blacklist_enforcement( sender );
3310}
Here is the caller graph for this function:

◆ set_action_blacklist()

void sysio::chain::controller::set_action_blacklist ( const flat_set< pair< account_name, action_name > > & new_action_blacklist)

Definition at line 2921 of file controller.cpp.

2921 {
2922 for (auto& act: new_action_blacklist) {
2923 SYS_ASSERT(act.first != account_name(), name_type_exception, "Action blacklist - contract name should not be empty");
2924 SYS_ASSERT(act.second != action_name(), action_type_exception, "Action blacklist - action name should not be empty");
2925 }
2926 my->conf.action_blacklist = new_action_blacklist;
2927}
sysio::chain::action_name action_name
name account_name
Definition types.hpp:120
Here is the caller graph for this function:

◆ set_actor_blacklist()

void sysio::chain::controller::set_actor_blacklist ( const flat_set< account_name > & new_actor_blacklist)

Definition at line 2912 of file controller.cpp.

2912 {
2913 my->conf.actor_blacklist = new_actor_blacklist;
2914}
Here is the caller graph for this function:

◆ set_actor_whitelist()

void sysio::chain::controller::set_actor_whitelist ( const flat_set< account_name > & new_actor_whitelist)

Definition at line 2909 of file controller.cpp.

2909 {
2910 my->conf.actor_whitelist = new_actor_whitelist;
2911}
Here is the caller graph for this function:

◆ set_contract_blacklist()

void sysio::chain::controller::set_contract_blacklist ( const flat_set< account_name > & new_contract_blacklist)

Definition at line 2918 of file controller.cpp.

2918 {
2919 my->conf.contract_blacklist = new_contract_blacklist;
2920}
Here is the caller graph for this function:

◆ set_contract_whitelist()

void sysio::chain::controller::set_contract_whitelist ( const flat_set< account_name > & new_contract_whitelist)

Definition at line 2915 of file controller.cpp.

2915 {
2916 my->conf.contract_whitelist = new_contract_whitelist;
2917}
Here is the caller graph for this function:

◆ set_greylist_limit()

void sysio::chain::controller::set_greylist_limit ( uint32_t limit)

Definition at line 3407 of file controller.cpp.

3407 {
3408 SYS_ASSERT( 0 < limit && limit <= chain::config::maximum_elastic_resource_multiplier,
3409 misc_exception,
3410 "Invalid limit (${limit}) passed into set_greylist_limit. "
3411 "Must be between 1 and ${max}.",
3412 ("limit", limit)("max", chain::config::maximum_elastic_resource_multiplier)
3413 );
3414 my->conf.greylist_limit = limit;
3415}
Here is the caller graph for this function:

◆ set_key_blacklist()

void sysio::chain::controller::set_key_blacklist ( const flat_set< public_key_type > & new_key_blacklist)

Definition at line 2928 of file controller.cpp.

2928 {
2929 my->conf.key_blacklist = new_key_blacklist;
2930}
Here is the caller graph for this function:

◆ set_proposed_producers()

int64_t sysio::chain::controller::set_proposed_producers ( vector< producer_authority > producers)

Definition at line 3128 of file controller.cpp.

3128 {
3129 const auto& gpo = get_global_properties();
3130 auto cur_block_num = head_block_num() + 1;
3131
3133 return -1;
3134 }
3135
3136 if( gpo.proposed_schedule_block_num ) {
3137 if( *gpo.proposed_schedule_block_num != cur_block_num )
3138 return -1; // there is already a proposed schedule set in a previous block, wait for it to become pending
3139
3140 if( std::equal( producers.begin(), producers.end(),
3141 gpo.proposed_schedule.producers.begin(), gpo.proposed_schedule.producers.end() ) )
3142 return -1; // the proposed producer schedule does not change
3143 }
3144
3145 producer_authority_schedule sch;
3146
3147 decltype(sch.producers.cend()) end;
3148 decltype(end) begin;
3149
3150 const auto& pending_sch = pending_producers();
3151
3152 if( pending_sch.producers.size() == 0 ) {
3153 const auto& active_sch = active_producers();
3154 begin = active_sch.producers.begin();
3155 end = active_sch.producers.end();
3156 sch.version = active_sch.version + 1;
3157 } else {
3158 begin = pending_sch.producers.begin();
3159 end = pending_sch.producers.end();
3160 sch.version = pending_sch.version + 1;
3161 }
3162
3163 if( std::equal( producers.begin(), producers.end(), begin, end ) )
3164 return -1; // the producer schedule would not change
3165
3166 sch.producers = std::move(producers);
3167
3168 int64_t version = sch.version;
3169
3170 ilog( "proposed producer schedule with version ${v}", ("v", version) );
3171
3172 my->db.modify( gpo, [&]( auto& gp ) {
3173 gp.proposed_schedule_block_num = cur_block_num;
3174 gp.proposed_schedule = sch.to_shared(gp.proposed_schedule.producers.get_allocator());
3175 });
3176 return version;
3177}
const producer_authority_schedule & pending_producers() const
bool is_builtin_activated(builtin_protocol_feature_t f) const
const producer_authority_schedule & active_producers() const
schedule config_dir_name data_dir_name p2p_port http_port file_size name name keys peers producers(dont_start)) FC_REFLECT(testnet_def
Here is the call graph for this function:

◆ set_s_header()

void sysio::chain::controller::set_s_header ( const s_header & s_header)

Definition at line 2931 of file controller.cpp.

2931 {
2932 // ilog("CONTROLLER - setting s header: ${s}", ("s", s_header.to_string()));
2933 SYS_ASSERT( my->pending, block_validate_exception, "it is not valid to set_s_header when there is no pending block");
2934 SYS_ASSERT( std::holds_alternative<building_block>(my->pending->_block_stage), block_validate_exception, "already called finalize_block");
2935 // SYS_ASSERT( std::get<assembled_block>(pending->_block_stage)._id == id, block_validate_exception, "mismatching block id" );
2936 // Try to set it first in the pending block
2937 auto& bb = std::get<building_block>(my->pending->_block_stage);
2938 bb._s_header = s_header; // Attempt to set s-header
2939 auto& check_s_header = std::get<building_block>(my->pending->_block_stage)._s_header;
2940 if (check_s_header){
2941 ilog("Pending building block s_header set: ${s_header}\n\t\tand matches what was passed: ${match}",
2942 ("s_header", check_s_header->to_string())("match", check_s_header == s_header));
2943 }
2944 else {
2945 ilog("Pending building block s_header NOT SET");
2946 }
2947}
Here is the caller graph for this function:

◆ set_subjective_cpu_leeway()

void sysio::chain::controller::set_subjective_cpu_leeway ( fc::microseconds leeway)

Definition at line 3399 of file controller.cpp.

3399 {
3400 my->subjective_cpu_leeway = leeway;
3401}
Here is the caller graph for this function:

◆ sign_block()

void sysio::chain::controller::sign_block ( const signer_callback_type & signer_callback)

◆ skip_auth_check()

bool sysio::chain::controller::skip_auth_check ( ) const

Definition at line 3238 of file controller.cpp.

3238 {
3239 return light_validation_allowed();
3240}
bool light_validation_allowed() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ skip_db_sessions() [1/2]

bool sysio::chain::controller::skip_db_sessions ( ) const

Definition at line 3253 of file controller.cpp.

3253 {
3254 if (my->pending) {
3255 return skip_db_sessions(my->pending->_block_status);
3256 } else {
3257 return false;
3258 }
3259}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ skip_db_sessions() [2/2]

bool sysio::chain::controller::skip_db_sessions ( block_status bs) const

Definition at line 3246 of file controller.cpp.

3246 {
3247 bool consider_skipping = bs == block_status::irreversible;
3248 return consider_skipping
3249 && !my->conf.disable_replay_opts
3250 && !my->in_trx_requiring_checks;
3251}

◆ skip_trx_checks()

bool sysio::chain::controller::skip_trx_checks ( ) const

Definition at line 3242 of file controller.cpp.

3242 {
3243 return light_validation_allowed();
3244}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_block() [1/2]

void sysio::chain::controller::start_block ( block_timestamp_type time,
uint16_t confirm_block_count,
const vector< digest_type > & new_protocol_feature_activations,
const fc::time_point & deadline = fc::time_point::maximum() )

Starts a new pending block session upon which new transactions can be pushed.

Definition at line 2803 of file controller.cpp.

2807{
2809
2810 if( new_protocol_feature_activations.size() > 0 ) {
2811 validate_protocol_features( new_protocol_feature_activations );
2812 }
2813
2814 my->start_block( when, confirm_block_count, new_protocol_feature_activations,
2815 block_status::incomplete, std::optional<block_id_type>(), deadline );
2816}
void validate_protocol_features(const vector< digest_type > &features_to_activate) const
Here is the call graph for this function:

◆ start_block() [2/2]

void sysio::chain::controller::start_block ( block_timestamp_type time = block_timestamp_type(),
uint16_t confirm_block_count = 0 )

Starts a new pending block session upon which new transactions can be pushed.

Will only activate protocol features that have been pre-activated.

Definition at line 2780 of file controller.cpp.

2781{
2783
2784 SYS_ASSERT( !my->pending, block_validate_exception, "pending block already exists" );
2785
2786 vector<digest_type> new_protocol_feature_activations;
2787
2788 const auto& pso = my->db.get<protocol_state_object>();
2789 if( pso.preactivated_protocol_features.size() > 0 ) {
2790 for( const auto& f : pso.preactivated_protocol_features ) {
2791 new_protocol_feature_activations.emplace_back( f );
2792 }
2793 }
2794
2795 if( new_protocol_feature_activations.size() > 0 ) {
2796 validate_protocol_features( new_protocol_feature_activations );
2797 }
2798
2799 my->start_block( when, confirm_block_count, new_protocol_feature_activations,
2800 block_status::incomplete, std::optional<block_id_type>(), fc::time_point::maximum() );
2801}
static constexpr time_point maximum()
Definition time.hpp:46
Here is the call graph for this function:
Here is the caller graph for this function:

◆ startup() [1/3]

void sysio::chain::controller::startup ( std::function< void()> shutdown,
std::function< bool()> check_shutdown )

Definition at line 2642 of file controller.cpp.

2642 {
2643 my->startup(shutdown, check_shutdown);
2644}

◆ startup() [2/3]

void sysio::chain::controller::startup ( std::function< void()> shutdown,
std::function< bool()> check_shutdown,
const genesis_state & genesis )

Definition at line 2638 of file controller.cpp.

2638 {
2639 my->startup(shutdown, check_shutdown, genesis);
2640}

◆ startup() [3/3]

void sysio::chain::controller::startup ( std::function< void()> shutdown,
std::function< bool()> check_shutdown,
const snapshot_reader_ptr & snapshot )

Definition at line 2634 of file controller.cpp.

2634 {
2635 my->startup(shutdown, check_shutdown, snapshot);
2636}

◆ to_variant_with_abi()

template<typename T >
fc::variant sysio::chain::controller::to_variant_with_abi ( const T & obj,
const abi_serializer::yield_function_t & yield ) const
inline

Definition at line 362 of file controller.hpp.

362 {
363 fc::variant pretty_output;
364 abi_serializer::to_variant( obj, pretty_output,
365 [&]( account_name n ){ return get_abi_serializer( n, yield ); }, yield );
366 return pretty_output;
367 }
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition variant.hpp:191
std::optional< abi_serializer > get_abi_serializer(account_name n, const abi_serializer::yield_function_t &yield) const
thread_local yield_t yield
Definition yield.hpp:52
static void to_variant(const T &o, fc::variant &vo, Resolver resolver, const yield_function_t &yield)
namespace sysio::chain::impl
Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_db_available_size()

void sysio::chain::controller::validate_db_available_size ( ) const

Definition at line 3371 of file controller.cpp.

3371 {
3372 const auto free = db().get_segment_manager()->get_free_memory();
3373 const auto guard = my->conf.state_guard_size;
3374 SYS_ASSERT(free >= guard, database_guard_exception, "database free: ${f}, guard size: ${g}", ("f", free)("g",guard));
3375}
pinnable_mapped_file::segment_manager * get_segment_manager()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_expiration()

void sysio::chain::controller::validate_expiration ( const transaction & t) const

Definition at line 3346 of file controller.cpp.

3346 { try {
3347 const auto& chain_configuration = get_global_properties().configuration;
3348
3349 SYS_ASSERT( time_point(trx.expiration) >= pending_block_time(),
3350 expired_tx_exception,
3351 "transaction has expired, "
3352 "expiration is ${trx.expiration} and pending block time is ${pending_block_time}",
3353 ("trx.expiration",trx.expiration)("pending_block_time",pending_block_time()));
3354 SYS_ASSERT( time_point(trx.expiration) <= pending_block_time() + fc::seconds(chain_configuration.max_transaction_lifetime),
3355 tx_exp_too_far_exception,
3356 "Transaction expiration is too far in the future relative to the reference time of ${reference_time}, "
3357 "expiration is ${trx.expiration} and the maximum transaction lifetime is ${max_til_exp} seconds",
3358 ("trx.expiration",trx.expiration)("reference_time",pending_block_time())
3359 ("max_til_exp",chain_configuration.max_transaction_lifetime) );
3360} FC_CAPTURE_AND_RETHROW((trx)) }
constexpr microseconds seconds(int64_t s)
Definition time.hpp:32
Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_protocol_features()

void sysio::chain::controller::validate_protocol_features ( const vector< digest_type > & features_to_activate) const

Definition at line 2774 of file controller.cpp.

2774 {
2775 my->check_protocol_features( my->head->header.timestamp,
2776 my->head->activated_protocol_features->protocol_features,
2777 features_to_activate );
2778}
Here is the caller graph for this function:

◆ validate_tapos()

void sysio::chain::controller::validate_tapos ( const transaction & t) const

Definition at line 3362 of file controller.cpp.

3362 { try {
3363 const auto& tapos_block_summary = db().get<block_summary_object>((uint16_t)trx.ref_block_num);
3364
3365 //Verify TaPoS block summary has correct ID prefix, and that this block's time is not past the expiration
3366 SYS_ASSERT(trx.verify_reference_block(tapos_block_summary.block_id), invalid_ref_block_exception,
3367 "Transaction's reference block did not match. Is this transaction from a different fork?",
3368 ("tapos_summary", tapos_block_summary));
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_snapshot()

void sysio::chain::controller::write_snapshot ( const snapshot_writer_ptr & snapshot)

Definition at line 3123 of file controller.cpp.

3123 {
3124 SYS_ASSERT( !my->pending, block_validate_exception, "cannot take a consistent snapshot with a pending block" );
3125 return my->add_to_snapshot(snapshot);
3126}
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ apply_context

friend class apply_context
friend

Definition at line 377 of file controller.hpp.

◆ transaction_context

friend class transaction_context
friend

Definition at line 378 of file controller.hpp.

Member Data Documentation

◆ accepted_block

signal<void(const block_state_ptr&)> sysio::chain::controller::accepted_block

Definition at line 329 of file controller.hpp.

◆ accepted_block_header

signal<void(const block_state_ptr&)> sysio::chain::controller::accepted_block_header

Definition at line 328 of file controller.hpp.

◆ accepted_transaction

signal<void(const transaction_metadata_ptr&)> sysio::chain::controller::accepted_transaction

Definition at line 331 of file controller.hpp.

◆ applied_transaction

signal<void(std::tuple<const transaction_trace_ptr&, const packed_transaction_ptr&>)> sysio::chain::controller::applied_transaction

Definition at line 332 of file controller.hpp.

◆ bad_alloc

signal<void(const int&)> sysio::chain::controller::bad_alloc

Definition at line 333 of file controller.hpp.

◆ block_start

signal<void(uint32_t)> sysio::chain::controller::block_start

Definition at line 326 of file controller.hpp.

◆ irreversible_block

signal<void(const block_state_ptr&)> sysio::chain::controller::irreversible_block

Definition at line 330 of file controller.hpp.

◆ pre_accepted_block

signal<void(const signed_block_ptr&)> sysio::chain::controller::pre_accepted_block

Definition at line 327 of file controller.hpp.


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