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: Unification: add latest commit QC known to proposer to block extension (final part) #2090

Merged
merged 4 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion libraries/chain/block_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ block_state::block_state(const block_header_state& prev, signed_block_ptr b, con
{}

block_state::block_state(const block_header_state& bhs, deque<transaction_metadata_ptr>&& trx_metas,
deque<transaction_receipt>&& trx_receipts)
deque<transaction_receipt>&& trx_receipts, std::optional<quorum_certificate> qc)
: block_header_state(bhs)
, block(std::make_shared<signed_block>(signed_block_header{bhs.header})) // [greg todo] do we need signatures?
, pub_keys_recovered(true) // probably not needed
, cached_trxs(std::move(trx_metas))
{
block->transactions = std::move(trx_receipts);

if( qc ) {
emplace_extension(block->block_extensions, quorum_certificate_extension::extension_id(), fc::raw::pack( qc ));
}
}

// Used for transition from dpos to instant-finality
Expand Down
7 changes: 6 additions & 1 deletion libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,13 @@ struct assembled_block {
return completed_block{std::move(bsp)};
},
[&](assembled_block_if& ab) {
std::optional<quorum_certificate> qc;
if( ab.qc && ab.bhs.is_needed(*ab.qc ) ) {
qc = *ab.qc;
}

auto bsp = std::make_shared<block_state>(ab.bhs, std::move(ab.trx_metas),
std::move(ab.trx_receipts));
std::move(ab.trx_receipts), qc);
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(qc)

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I see no reason to copy it at all. Pass the ab.qc to block_state constructor as const std::optional<quorum_certificate>& and do the is_needed check in block_state constructor and pack *qc there.

Copy link
Member Author

Choose a reason for hiding this comment

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

Great!

return completed_block{std::move(bsp)};
}},
v);
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/block_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct block_state : public block_header_state { // block_header_state provi
const validator_t& validator, bool skip_validate_signee);

block_state(const block_header_state& bhs, deque<transaction_metadata_ptr>&& trx_metas,
deque<transaction_receipt>&& trx_receipts);
deque<transaction_receipt>&& trx_receipts, std::optional<quorum_certificate> qc);

explicit block_state(const block_state_legacy& bsp);
};
Expand Down