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

Commit

Permalink
Merge pull request #3967 from EOSIO/check-for-no-receipt-added
Browse files Browse the repository at this point in the history
Better error reporting due to bad transactions in apply_block
  • Loading branch information
arhag authored Jun 8, 2018
2 parents a034551 + e556d94 commit 26ec83d
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,14 +792,33 @@ struct controller_impl {
FC_ASSERT( b->block_extensions.size() == 0, "no supported extensions" );
start_block( b->timestamp, b->confirmed, s );

transaction_trace_ptr trace;

for( const auto& receipt : b->transactions ) {
auto num_pending_receipts = pending->_pending_block_state->block->transactions.size();
if( receipt.trx.contains<packed_transaction>() ) {
auto& pt = receipt.trx.get<packed_transaction>();
auto mtrx = std::make_shared<transaction_metadata>(pt);
push_transaction( mtrx, fc::time_point::maximum(), false, receipt.cpu_usage_us );
trace = push_transaction( mtrx, fc::time_point::maximum(), false, receipt.cpu_usage_us );
} else if( receipt.trx.contains<transaction_id_type>() ) {
push_scheduled_transaction( receipt.trx.get<transaction_id_type>(), fc::time_point::maximum(), receipt.cpu_usage_us );
trace = push_scheduled_transaction( receipt.trx.get<transaction_id_type>(), fc::time_point::maximum(), receipt.cpu_usage_us );
} else {
EOS_ASSERT( false, block_validate_exception, "encountered unexpected receipt type" );
}

if( trace && trace->except ) {
edump((*trace));
throw *trace->except;
}

EOS_ASSERT( pending->_pending_block_state->block->transactions.size() > 0,
block_validate_exception, "expected a receipt",
("block", *b)("expected_receipt", receipt)
);
EOS_ASSERT( pending->_pending_block_state->block->transactions.size() == num_pending_receipts + 1,
block_validate_exception, "expected receipt was not added",
("block", *b)("expected_receipt", receipt)
);
const transaction_receipt_header& r = pending->_pending_block_state->block->transactions.back();
EOS_ASSERT( r == static_cast<const transaction_receipt_header&>(receipt),
block_validate_exception, "receipt does not match",
Expand Down

1 comment on commit 26ec83d

@466919153
Copy link

Choose a reason for hiding this comment

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

狼来了

Please sign in to comment.