From 4bb63e76ecaab3b2609e7fc258a14b522a7597fb Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 9 Aug 2017 18:00:14 -0500 Subject: [PATCH] Move validate_referenced_accounts call to block/push level Previously, validate_referenced_accounts was called during transaction application; however, account creation is one of those changes that doesn't really take effect until the end of the block, so we want to validate the referenced accounts for all transactions at the beginning of the block so that if trx A creates account joe, then trx B references joe, that reference will fail if A and B are in the same block. We also call it during push_transaction, as we do want to check it for pending transactions that aren't in a block yet. --- libraries/chain/chain_controller.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/chain/chain_controller.cpp b/libraries/chain/chain_controller.cpp index b1a5d8897..ffff7d970 100644 --- a/libraries/chain/chain_controller.cpp +++ b/libraries/chain/chain_controller.cpp @@ -246,6 +246,7 @@ ProcessedTransaction chain_controller::_push_transaction(const SignedTransaction _pending_tx_session = _db.start_undo_session(true); auto temp_session = _db.start_undo_session(true); + validate_referenced_accounts(trx); check_transaction_authorization(trx); auto pt = _apply_transaction(trx); _pending_transactions.push_back(trx); @@ -331,6 +332,7 @@ signed_block chain_controller::_generate_block( try { auto temp_session = _db.start_undo_session(true); + validate_referenced_accounts(tx); check_transaction_authorization(tx); _apply_transaction(tx); temp_session.squash(); @@ -441,8 +443,10 @@ void chain_controller::_apply_block(const signed_block& next_block) for (const auto& cycle : next_block.cycles) for (const auto& thread : cycle) - for (const auto& trx : thread.user_input) + for (const auto& trx : thread.user_input) { + validate_referenced_accounts(trx); check_transaction_authorization(trx); + } /* We do not need to push the undo state for each transaction * because they either all apply and are valid or the @@ -524,7 +528,6 @@ try { validate_expiration(trx); validate_uniqueness(trx); validate_tapos(trx); - validate_referenced_accounts(trx); } FC_CAPTURE_AND_RETHROW( (trx) ) } -- GitLab