提交 9270660b 编写于 作者: B Bart Wyatt

clean up and organizational changes

上级 0aa56848
...@@ -85,7 +85,6 @@ namespace eosio { namespace chain { ...@@ -85,7 +85,6 @@ namespace eosio { namespace chain {
result.block_num = block_num + 1; result.block_num = block_num + 1;
result.producer_to_last_produced = producer_to_last_produced; result.producer_to_last_produced = producer_to_last_produced;
result.producer_to_last_produced[prokey.producer_name] = result.block_num; result.producer_to_last_produced[prokey.producer_name] = result.block_num;
// result.dpos_irreversible_blocknum = result.calc_dpos_last_irreversible();
result.blockroot_merkle = blockroot_merkle; result.blockroot_merkle = blockroot_merkle;
result.blockroot_merkle.append( id ); result.blockroot_merkle.append( id );
...@@ -114,20 +113,21 @@ namespace eosio { namespace chain { ...@@ -114,20 +113,21 @@ namespace eosio { namespace chain {
} }
/// grow the confirmed count /// grow the confirmed count
uint8_t required_confs = (result.active_schedule.producers.size() * 2 / 3) + 1; 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");
if( confirm_count.size() < 1024 ) { auto num_active_producers = result.active_schedule.producers.size();
uint32_t required_confs = (uint32_t)(num_active_producers * 2 / 3) + 1;
if( confirm_count.size() < config::maximum_tracked_dpos_confirmations ) {
result.confirm_count.reserve( confirm_count.size() + 1 ); result.confirm_count.reserve( confirm_count.size() + 1 );
result.confirm_count = confirm_count; result.confirm_count = confirm_count;
result.confirm_count.resize( confirm_count.size() + 1 ); result.confirm_count.resize( confirm_count.size() + 1 );
result.confirm_count.back() = required_confs; result.confirm_count.back() = (uint8_t)required_confs;
} else { } else {
result.confirm_count.resize( confirm_count.size() ); result.confirm_count.resize( confirm_count.size() );
memcpy( &result.confirm_count[0], &confirm_count[1], confirm_count.size() - 1 ); memcpy( &result.confirm_count[0], &confirm_count[1], confirm_count.size() - 1 );
result.confirm_count.back() = required_confs; result.confirm_count.back() = (uint8_t)required_confs;
} }
return result; return result;
} /// generate_next } /// generate_next
......
...@@ -22,16 +22,14 @@ struct block_header_state { ...@@ -22,16 +22,14 @@ struct block_header_state {
flat_map<account_name,uint32_t> producer_to_last_produced; flat_map<account_name,uint32_t> producer_to_last_produced;
public_key_type block_signing_key; public_key_type block_signing_key;
vector<uint8_t> confirm_count; vector<uint8_t> confirm_count;
vector<header_confirmation> confirmations;
block_header_state next( const signed_block_header& h )const; block_header_state next( const signed_block_header& h )const;
block_header_state generate_next( block_timestamp_type when )const; block_header_state generate_next( block_timestamp_type when )const;
void set_new_producers( producer_schedule_type next_pending ); void set_new_producers( producer_schedule_type next_pending );
void set_confirmed( uint16_t num_prev_blocks ); void set_confirmed( uint16_t num_prev_blocks );
void add_confirmation( const header_confirmation& c ); void add_confirmation( const header_confirmation& c );
vector<header_confirmation> confirmations;
bool has_pending_producers()const { return pending_schedule.producers.size(); } bool has_pending_producers()const { return pending_schedule.producers.size(); }
...@@ -57,8 +55,8 @@ struct block_header_state { ...@@ -57,8 +55,8 @@ struct block_header_state {
} } /// namespace eosio::chain } } /// namespace eosio::chain
FC_REFLECT( eosio::chain::block_header_state, FC_REFLECT( eosio::chain::block_header_state,
(id)(block_num)(header)(dpos_irreversible_blocknum) (id)(block_num)(header)(dpos_irreversible_blocknum)(bft_irreversible_blocknum)
(pending_schedule_lib_num)(pending_schedule_hash) (pending_schedule_lib_num)(pending_schedule_hash)
(pending_schedule)(active_schedule)(blockroot_merkle) (pending_schedule)(active_schedule)(blockroot_merkle)
(producer_to_last_produced)(block_signing_key) (producer_to_last_produced)(block_signing_key)
(bft_irreversible_blocknum)(confirmations) ) (confirm_count)(confirmations) )
...@@ -98,6 +98,11 @@ const static eosio::chain::wasm_interface::vm_type default_wasm_runtime = eosio: ...@@ -98,6 +98,11 @@ const static eosio::chain::wasm_interface::vm_type default_wasm_runtime = eosio:
* The number of sequential blocks produced by a single producer * The number of sequential blocks produced by a single producer
*/ */
const static int producer_repetitions = 12; const static int producer_repetitions = 12;
const static int max_producers = 125;
const static size_t maximum_tracked_dpos_confirmations = 1024; ///<
static_assert(maximum_tracked_dpos_confirmations >= ((max_producers * 2 / 3) + 1) * producer_repetitions, "Settings never allow for DPOS irreversibility" );
/** /**
* The number of blocks produced per round is based upon all producers having a chance * The number of blocks produced per round is based upon all producers having a chance
......
...@@ -145,6 +145,7 @@ class privileged_api : public context_aware_api { ...@@ -145,6 +145,7 @@ class privileged_api : public context_aware_api {
datastream<const char*> ds( packed_producer_schedule, datalen ); datastream<const char*> ds( packed_producer_schedule, datalen );
vector<producer_key> producers; vector<producer_key> producers;
fc::raw::unpack(ds, producers); fc::raw::unpack(ds, producers);
EOS_ASSERT(producers.size() <= config::max_producers, wasm_execution_error, "Producer schedule exceeds the maximum producer count for this chain");
// check that producers are unique // check that producers are unique
std::set<account_name> unique_producers; std::set<account_name> unique_producers;
for (const auto& p: producers) { for (const auto& p: producers) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册