-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IF: Fix double confirming test failure #2054
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1057d50
GH-2033 Port over some reference contract tests that provide coverage…
heifner 846c214
GH-2033 Revert to 5.0 implementation
heifner 42513fe
GH-2033 Move get_next_next_round_block_num from legacy to where it is…
heifner 2f7c127
GH-2033 Add head_active_producers() needed by tester
heifner c878aee
GH-2033 Update deep-mind test
heifner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,6 @@ | |
|
||
namespace eosio { namespace chain { | ||
|
||
#warning Add last_proposed_finalizer_policy_generation to snapshot_block_header_state_v3, see header file TODO | ||
|
||
namespace detail { | ||
bool is_builtin_activated( const protocol_feature_activation_set_ptr& pfa, | ||
const protocol_feature_set& pfs, | ||
|
@@ -15,12 +13,6 @@ namespace eosio { namespace chain { | |
const auto& protocol_features = pfa->protocol_features; | ||
return digest && protocol_features.find(*digest) != protocol_features.end(); | ||
} | ||
|
||
uint32_t get_next_next_round_block_num( block_timestamp_type t, uint32_t block_num ) { | ||
auto index = t.slot % config::producer_repetitions; // current index in current round | ||
// (increment to the end of this round ) + next round | ||
return block_num + (config::producer_repetitions - index) + config::producer_repetitions; | ||
} | ||
} | ||
|
||
producer_authority block_header_state_legacy::get_scheduled_producer( block_timestamp_type t )const { | ||
|
@@ -43,9 +35,6 @@ namespace eosio { namespace chain { | |
return blocknums[ index ]; | ||
} | ||
|
||
// create pending_block_header_state from this for `when` | ||
// If hotstuff_activated then use new consensus values and simpler active schedule update. | ||
// If notstuff is not activated then use previous pre-hotstuff consensus logic. | ||
pending_block_header_state_legacy block_header_state_legacy::next( block_timestamp_type when, | ||
uint16_t num_prev_blocks_to_confirm )const | ||
{ | ||
|
@@ -57,40 +46,36 @@ namespace eosio { namespace chain { | |
(when = header.timestamp).slot++; | ||
} | ||
|
||
auto proauth = get_scheduled_producer(when); | ||
|
||
auto itr = producer_to_last_produced.find( proauth.producer_name ); | ||
if( itr != producer_to_last_produced.end() ) { | ||
EOS_ASSERT( itr->second < (block_num+1) - num_prev_blocks_to_confirm, producer_double_confirm, | ||
"producer ${prod} double-confirming known range", | ||
("prod", proauth.producer_name)("num", block_num+1) | ||
("confirmed", num_prev_blocks_to_confirm)("last_produced", itr->second) ); | ||
} | ||
|
||
result.block_num = block_num + 1; | ||
result.previous = id; | ||
result.timestamp = when; | ||
result.confirmed = num_prev_blocks_to_confirm; | ||
result.active_schedule_version = active_schedule.version; | ||
result.prev_activated_protocol_features = activated_protocol_features; | ||
|
||
auto proauth = get_scheduled_producer(when); | ||
|
||
result.valid_block_signing_authority = proauth.authority; | ||
result.producer = proauth.producer_name; | ||
result.last_proposed_finalizer_policy_generation = last_proposed_finalizer_policy_generation; | ||
|
||
result.blockroot_merkle = blockroot_merkle; | ||
result.blockroot_merkle.append( id ); | ||
|
||
result.prev_pending_schedule = pending_schedule; | ||
|
||
auto itr = producer_to_last_produced.find( proauth.producer_name ); | ||
if( itr != producer_to_last_produced.end() ) { | ||
EOS_ASSERT( itr->second < (block_num+1) - num_prev_blocks_to_confirm, producer_double_confirm, | ||
"producer ${prod} double-confirming known range", | ||
("prod", proauth.producer_name)("num", block_num+1) | ||
("confirmed", num_prev_blocks_to_confirm)("last_produced", itr->second) ); | ||
} | ||
|
||
result.confirmed = num_prev_blocks_to_confirm; | ||
|
||
/// grow the confirmed count | ||
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"); | ||
|
||
// This uses the previous block active_schedule because thats the "schedule" that signs and therefore confirms _this_ block | ||
auto num_active_producers = 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 = confirm_count; | ||
|
@@ -107,37 +92,39 @@ namespace eosio { namespace chain { | |
int32_t i = (int32_t)(result.confirm_count.size() - 1); | ||
uint32_t blocks_to_confirm = num_prev_blocks_to_confirm + 1; /// confirm the head block too | ||
while( i >= 0 && blocks_to_confirm ) { | ||
--result.confirm_count[i]; | ||
//idump((confirm_count[i])); | ||
if( result.confirm_count[i] == 0 ) | ||
{ | ||
--result.confirm_count[i]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the space removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just copied over the 5.0 impl, including spaces |
||
//idump((confirm_count[i])); | ||
if( result.confirm_count[i] == 0 ) | ||
{ | ||
uint32_t block_num_for_i = result.block_num - (uint32_t)(result.confirm_count.size() - 1 - i); | ||
new_dpos_proposed_irreversible_blocknum = block_num_for_i; | ||
//idump((dpos2_lib)(block_num)(dpos_irreversible_blocknum)); | ||
|
||
if (i == static_cast<int32_t>(result.confirm_count.size() - 1)) { | ||
result.confirm_count.resize(0); | ||
} else { | ||
memmove( &result.confirm_count[0], &result.confirm_count[i + 1], result.confirm_count.size() - i - 1); | ||
result.confirm_count.resize( result.confirm_count.size() - i - 1 ); | ||
} | ||
|
||
break; | ||
} | ||
--i; | ||
--blocks_to_confirm; | ||
} | ||
--i; | ||
--blocks_to_confirm; | ||
} | ||
|
||
result.dpos_proposed_irreversible_blocknum = new_dpos_proposed_irreversible_blocknum; | ||
result.dpos_irreversible_blocknum = calc_dpos_last_irreversible( proauth.producer_name ); | ||
|
||
|
||
result.prev_pending_schedule = pending_schedule; | ||
|
||
if( pending_schedule.schedule.producers.size() && | ||
result.dpos_irreversible_blocknum >= pending_schedule.schedule_lib_num ) | ||
{ | ||
result.active_schedule = pending_schedule.schedule; | ||
|
||
flat_map<account_name,uint32_t> new_producer_to_last_produced; | ||
|
||
for( const auto& pro : result.active_schedule.producers ) { | ||
if( pro.producer_name == proauth.producer_name ) { | ||
new_producer_to_last_produced[pro.producer_name] = result.block_num; | ||
|
@@ -151,7 +138,7 @@ namespace eosio { namespace chain { | |
} | ||
} | ||
new_producer_to_last_produced[proauth.producer_name] = result.block_num; | ||
|
||
result.producer_to_last_produced = std::move( new_producer_to_last_produced ); | ||
|
||
flat_map<account_name,uint32_t> new_producer_to_last_implied_irb; | ||
|
@@ -168,9 +155,9 @@ namespace eosio { namespace chain { | |
} | ||
} | ||
} | ||
|
||
result.producer_to_last_implied_irb = std::move( new_producer_to_last_implied_irb ); | ||
|
||
result.was_pending_promoted = true; | ||
} else { | ||
result.active_schedule = active_schedule; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this in a new file in my PR so as not to duplicate, however we can checkin as-is and I'll remove in my PR.