Skip to content
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: Block header extension -- replace finalizer_policy_extension and proposal_info_extension with instant_finality_extension #2024

Merged
merged 15 commits into from
Jan 4, 2024

Conversation

linh2931
Copy link
Member

  • replaced finalizer_policy_extension and proposal_info_extension with instant_finality_extension
  • added tests for instant_finality_extension

Resolved #1911

@linh2931 linh2931 requested review from greg7mdp and heifner December 30, 2023 01:53
@ericpassmore
Copy link
Contributor

Note:start
group: IF
category: INTERNALS
summary: New block header extension including finalizer_policy and proposer_policy.
Note:end

finalizer_policy_extension::extension_id(),
fc::raw::pack( finalizer_policy_extension{ std::move(fin_pol) } )
instant_finality_extension::extension_id(),
fc::raw::pack( instant_finality_extension{ last_qc_block_num, is_last_qc_strong, std::move(fin_pol), new_proposer_policy } )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::move(new_proposer_policy)

libraries/chain/controller.cpp Show resolved Hide resolved
_active_finalizer_policy = std::move(std::get<finalizer_policy_extension>(*ext));
const auto& if_extension = std::get<instant_finality_extension>(*ext);
if (if_extension.new_finalizer_policy) {
_active_finalizer_policy = *if_extension.new_finalizer_policy;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use non-const and use std::move here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add a TODO for changing when finalizer policy change design is complete as this is not necessarily when we will change active finalizer policy.

static_assert( fc::raw::has_feature_reflector_init_on_unpacked_reflected_types,
"instant_finality_extension expects FC to support reflector_init" );
static_assert( extension_id() == 2, "instant_finality_extension extension id must be 2" );
static_assert( enforce_unique(), "instant_finality_extension must enforce uniqueness");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems odd to me to have a reflector_init that only has static_asserts. These static_assert could be anywhere. Also they are only asserting what is explicitly defined.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was intended as a placeholder for any additional validations which would be discovered during design. exension_id definitions are scattered around the code base; wanted to make sure it is not changed by accident. enforce_unique is not necessary.


instant_finality_extension() = default;
instant_finality_extension( uint32_t last_qc_block_num, bool is_last_qc_strong, std::optional<finalizer_policy> new_finalizer_policy, std::optional<proposer_policy> new_proposer_policy)
:last_qc_block_num( last_qc_block_num ), is_last_qc_strong( is_last_qc_strong ), new_finalizer_policy( new_finalizer_policy ), new_proposer_policy( new_proposer_policy )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::move both policies.

Comment on lines 21 to 22
std::optional<finalizer_policy> new_finalizer_policy {std::nullopt};
std::optional<proposer_policy> new_proposer_policy {std::nullopt};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No point adding the {std::nullopt} initializer, it is already the default for std::optional.

@@ -3876,13 +3876,15 @@ BOOST_AUTO_TEST_CASE(set_finalizer_test) { try {

// activate hotstuff
t.set_finalizers(finalizers);
auto block = t.produce_block(); // this block contains the header extension of the finalizer set
auto block = t.produce_block(); // this block contains the header extension of the instant finality
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto block = t.produce_block(); // this block contains the header extension of the instant finality
auto block = t.produce_block(); // this block contains the header extension for instant finality

unittests/block_header_tests.cpp Show resolved Hide resolved
unittests/block_header_tests.cpp Show resolved Hide resolved
@arhag arhag linked an issue Jan 3, 2024 that may be closed by this pull request
@linh2931 linh2931 requested review from heifner and greg7mdp January 3, 2024 22:55
Comment on lines 21 to 22
constexpr uint32_t last_qc_block_num {0};
constexpr bool is_last_qc_strong {false};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No big deal, but now indentation looks excessive :-).

@linh2931 linh2931 merged commit d86c721 into hotstuff_integration Jan 4, 2024
26 checks passed
@linh2931 linh2931 deleted the block_header_extension branch January 4, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IF: Unification: Add block header extension
4 participants