Don't infinitely recurse when block generation fails #261
This commit is contained in:
parent
e5ada2756a
commit
013033001f
2 changed files with 38 additions and 9 deletions
|
|
@ -242,7 +242,7 @@ signed_block database::generate_block(
|
||||||
signed_block result;
|
signed_block result;
|
||||||
with_skip_flags( skip, [&]()
|
with_skip_flags( skip, [&]()
|
||||||
{
|
{
|
||||||
result = _generate_block( when, witness_id, block_signing_private_key );
|
result = _generate_block( when, witness_id, block_signing_private_key, true );
|
||||||
} );
|
} );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -250,7 +250,8 @@ signed_block database::generate_block(
|
||||||
signed_block database::_generate_block(
|
signed_block database::_generate_block(
|
||||||
fc::time_point_sec when,
|
fc::time_point_sec when,
|
||||||
witness_id_type witness_id,
|
witness_id_type witness_id,
|
||||||
const fc::ecc::private_key& block_signing_private_key
|
const fc::ecc::private_key& block_signing_private_key,
|
||||||
|
bool retry_on_failure
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
@ -280,18 +281,45 @@ signed_block database::_generate_block(
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
try { push_block( tmp, skip ); }
|
try { push_block( tmp, skip ); }
|
||||||
catch ( const undo_database_exception& e ) { throw; }
|
catch ( const undo_database_exception& e ) { throw; }
|
||||||
catch ( const fc::exception& e ) { failed = true; }
|
catch ( const fc::exception& e )
|
||||||
|
{
|
||||||
|
if( !retry_on_failure )
|
||||||
|
{
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wlog( "Reason for block production failure: ${e}", ("e",e) );
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
if( failed )
|
if( failed )
|
||||||
{
|
{
|
||||||
|
uint32_t failed_tx_count = 0;
|
||||||
for( const auto& trx : tmp.transactions )
|
for( const auto& trx : tmp.transactions )
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
push_transaction( trx, skip );
|
{
|
||||||
} catch ( const fc::exception& e ) {
|
push_transaction( trx, skip );
|
||||||
wlog( "Transaction is no longer valid: ${trx}", ("trx",trx) );
|
}
|
||||||
|
catch ( const fc::exception& e )
|
||||||
|
{
|
||||||
|
wlog( "Transaction is no longer valid: ${trx}", ("trx",trx) );
|
||||||
|
failed_tx_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _generate_block( when, witness_id, block_signing_private_key );
|
if( failed_tx_count == 0 )
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// this is in generate_block() so this intensive logging
|
||||||
|
// (dumping a whole block) should be rate-limited
|
||||||
|
// to once per block production attempt
|
||||||
|
//
|
||||||
|
// TODO: Turn this off again once #261 is resolved.
|
||||||
|
//
|
||||||
|
wlog( "Block creation failed even though all tx's are still valid. Block: ${b}", ("b",tmp) );
|
||||||
|
}
|
||||||
|
return _generate_block( when, witness_id, block_signing_private_key, false );
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
} FC_CAPTURE_AND_RETHROW( (witness_id) ) }
|
} FC_CAPTURE_AND_RETHROW( (witness_id) ) }
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,8 @@ namespace graphene { namespace chain {
|
||||||
signed_block _generate_block(
|
signed_block _generate_block(
|
||||||
const fc::time_point_sec when,
|
const fc::time_point_sec when,
|
||||||
witness_id_type witness_id,
|
witness_id_type witness_id,
|
||||||
const fc::ecc::private_key& block_signing_private_key
|
const fc::ecc::private_key& block_signing_private_key,
|
||||||
|
bool retry_on_failure
|
||||||
);
|
);
|
||||||
|
|
||||||
void pop_block();
|
void pop_block();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue