Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

test_importRawBlock doesn't handle errors properly #5646

@gumb0

Description

@gumb0

It succeeds even if the block import failed.

@winsvega reports that this is what happens when importing invalid block:

WARN  06-30 14:53:01 aleth warn   
                                                                                
                                                                                
    Import Failure     /home/wins/Ethereum/cpp-ethereum/libethereum/Block.cpp(565): Throw in function dev::u256 dev::eth::Block::enact(const dev::eth::VerifiedBlockRef&, const dev::eth::BlockChain&)
Dynamic exception type: boost::exception_detail::clone_impl<dev::eth::UncleInChain>
[dev::tag_comment*] = Uncle in block already mentioned
[dev::eth::tag_uncleIndex*] = 1
[dev::eth::tag_unclesExcluded*] = { 9e38ab1792276d10df19067001684545b2c905a44423f6e50b1835b12b3ac3ef, 3874ace79c930a81d6c8e77c2eaec5c2d474678c120ce35c2aa3c5bf25bf8012, 250c192ac598dcc6d79142a983be39358eeba2547d689b91cab661da74aa5cfa, 5a39ed1020c04d4d84539975b893a4e7c53eab6c2965db8bc3468093a31bc5ae, 2b6e0badc6ea187cc798918e1515dcbe3f0e1cecec42dcd51e63a63cdf2f1e66 }
[dev::eth::tag_now*] = 1561895581
[dev::eth::tag_block*] = [ type: std::vector<unsigned char, std::allocator<unsigned char> >, size: 24, dump: d0 3b 05 b8 64 7f 00 00 2c 42 05 b8 64 7f 00 00 ]
[dev::tag_hash*] = 250c192ac598dcc6d79142a983be39358eeba2547d689b91cab661da74aa5cfa
    
                                                                                
                       Bad Block #00000003.2b6e0bad…                      
                                                                                
                                                                                
TRACE 06-30 14:53:01 aleth rpc    {"id":118,"jsonrpc":"2.0","result":"0x2b6e0badc6ea187cc798918e1515dcbe3f0e1cecec42dcd51e63a63cdf2f1e66"}

bool moreToImport = true;
while (moreToImport)
{
tie(ignore, moreToImport, ignore) = syncQueue(100000);
this_thread::sleep_for(chrono::milliseconds(100));
}
return blockHash;

The simple fix to try would be to look at fresh blocks returned as the first value from syncQueue. If blockHash was not returned there, it means it was rejected as bad block, and then we should throw exception in this case.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions