Skip to content

Commit

Permalink
GH-2142 Sign the correct block and store in the correct signed_block_…
Browse files Browse the repository at this point in the history
…header
  • Loading branch information
heifner committed Feb 17, 2024
1 parent d558816 commit 89c65ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions libraries/chain/block_header_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,15 @@ block_header_state block_header_state::next(block_header_state_input& input) con

// header
// ------
result.header = signed_block_header {
block_header {
result.header = {
.timestamp = input.timestamp, // [greg todo] do we have to do the slot++ stuff from the legacy version?
.producer = input.producer,
.confirmed = 0,
.previous = input.parent_id,
.transaction_mroot = input.transaction_mroot,
.action_mroot = input.action_mroot,
.schedule_version = header.schedule_version
}};
};

// activated protocol features
// ---------------------------
Expand Down
6 changes: 3 additions & 3 deletions libraries/chain/block_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ block_state::block_state(const block_header_state& prev, signed_block_ptr b, con
{
// ASSUMPTION FROM controller_impl::apply_block = all untrusted blocks will have their signatures pre-validated here
if( !skip_validate_signee ) {
auto sigs = detail::extract_additional_signatures(b);
auto sigs = detail::extract_additional_signatures(block);
verify_signee(sigs);
}
}
Expand Down Expand Up @@ -218,7 +218,7 @@ void block_state::sign( const signer_callback_type& signer ) {
auto sigs = signer( block_id );

EOS_ASSERT(!sigs.empty(), no_block_signatures, "Signer returned no signatures");
header.producer_signature = sigs.back();
block->producer_signature = sigs.back();
sigs.pop_back();

verify_signee(sigs);
Expand All @@ -237,7 +237,7 @@ void block_state::verify_signee(const std::vector<signature_type>& additional_si
);

std::set<public_key_type> keys;
keys.emplace(fc::crypto::public_key( header.producer_signature, block_id, true ));
keys.emplace(fc::crypto::public_key( block->producer_signature, block_id, true ));

for (const auto& s: additional_signatures) {
auto res = keys.emplace(s, block_id, true);
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/block_header_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct block_header_state_core {
struct block_header_state {
// ------ data members ------------------------------------------------------------
block_id_type block_id;
signed_block_header header;
block_header header;
protocol_feature_activation_set_ptr activated_protocol_features;

block_header_state_core core;
Expand Down

0 comments on commit 89c65ab

Please sign in to comment.