Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

fix bug in apply_block that constructed and committed blocks with missing signatures in the protocol-feature-foundations branch #6856

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ struct controller_impl {

auto bsp = std::make_shared<block_state>(
std::move( ab._pending_block_header_state ),
std::move( ab._unsigned_block ),
b,
std::move( ab._trx_metas ),
true // signature should have already been verified (assuming untrusted) prior to apply_block
);
Expand Down
6 changes: 3 additions & 3 deletions libraries/chain/include/eosio/chain/block_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ namespace eosio { namespace chain {
);

block_state( pending_block_header_state&& cur,
signed_block_ptr&& b, // unsigned block
vector<transaction_metadata_ptr>&& trx_metas,
const std::function<signature_type(const digest_type&)>& signer
signed_block_ptr&& b, // unsigned block
vector<transaction_metadata_ptr>&& trx_metas,
const std::function<signature_type(const digest_type&)>& signer
);

block_state( pending_block_header_state&& cur,
Expand Down
39 changes: 39 additions & 0 deletions unittests/forked_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,45 @@ BOOST_AUTO_TEST_CASE( prune_remove_branch ) try {
} FC_LOG_AND_RETHROW()


/**
* Tests that a validating node does not accept a block which is considered invalid by another node.
*/
BOOST_AUTO_TEST_CASE( validator_accepts_valid_blocks ) try {

tester n1;
tester n2;
tester n3;

n1.produce_block();

auto id = n1.control->head_block_id();

block_state_ptr first_block;

auto c = n2.control->accepted_block.connect( [&]( const block_state_ptr& bsp) {
if( bsp->block_num == 2 ) {
first_block = bsp;
}
} );

push_blocks( n1, n2 );

BOOST_CHECK_EQUAL( n2.control->head_block_id(), id );

BOOST_REQUIRE( first_block );
first_block->verify_signee( first_block->signee() );
BOOST_CHECK_EQUAL( first_block->header.id(), first_block->block->id() );
BOOST_CHECK( first_block->header.producer_signature == first_block->block->producer_signature );

c.disconnect();

n3.push_block( first_block->block );

BOOST_CHECK_EQUAL( n3.control->head_block_id(), id );


} FC_LOG_AND_RETHROW()

BOOST_AUTO_TEST_CASE( read_modes ) try {
tester c;
c.produce_block();
Expand Down