Disallow open block for 0 (burning) account
This commit is contained in:
parent
ed72bd5b70
commit
3ad1f7e29d
3 changed files with 23 additions and 11 deletions
|
@ -1280,6 +1280,13 @@ rai::process_return rai::block_processor::process_receive_one (MDB_txn * transac
|
|||
BOOST_LOG (node.log) << boost::str (boost::format ("Account mismatch for: %1%") % block_a->hash ().to_string ());
|
||||
}
|
||||
}
|
||||
case rai::process_result::fork_burning:
|
||||
{
|
||||
if (node.config.logging.ledger_logging ())
|
||||
{
|
||||
BOOST_LOG (node.log) << boost::str (boost::format ("Fork of burning 0 account for: %1%") % block_a->hash ().to_string ());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -3360,16 +3360,20 @@ void ledger_processor::open_block (rai::open_block const & block_a)
|
|||
result.code = ledger.store.pending_get (transaction, key, pending) ? rai::process_result::unreceivable : rai::process_result::progress; // Has this source already been received (Malformed)
|
||||
if (result.code == rai::process_result::progress)
|
||||
{
|
||||
rai::account_info source_info;
|
||||
auto error (ledger.store.account_get (transaction, pending.source, source_info));
|
||||
assert (!error);
|
||||
ledger.store.pending_del (transaction, key);
|
||||
ledger.store.block_put (transaction, hash, block_a);
|
||||
ledger.change_latest (transaction, block_a.hashables.account, hash, hash, pending.amount.number (), info.block_count + 1);
|
||||
ledger.store.representation_add (transaction, hash, pending.amount.number ());
|
||||
ledger.store.frontier_put (transaction, hash, block_a.hashables.account);
|
||||
result.account = block_a.hashables.account;
|
||||
result.amount = pending.amount;
|
||||
result.code = block_a.hashables.account.is_zero () ? rai::process_result::fork_burning : rai::process_result::progress; // Is it burning 0 account? (Malicious)
|
||||
if (result.code == rai::process_result::progress)
|
||||
{
|
||||
rai::account_info source_info;
|
||||
auto error (ledger.store.account_get (transaction, pending.source, source_info));
|
||||
assert (!error);
|
||||
ledger.store.pending_del (transaction, key);
|
||||
ledger.store.block_put (transaction, hash, block_a);
|
||||
ledger.change_latest (transaction, block_a.hashables.account, hash, hash, pending.amount.number (), info.block_count + 1);
|
||||
ledger.store.representation_add (transaction, hash, pending.amount.number ());
|
||||
ledger.store.frontier_put (transaction, hash, block_a.hashables.account);
|
||||
result.account = block_a.hashables.account;
|
||||
result.amount = pending.amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -490,7 +490,8 @@ enum class process_result
|
|||
gap_previous, // Block marked as previous is unknown
|
||||
gap_source, // Block marked as source is unknown
|
||||
not_receive_from_send, // Receive does not have a send source
|
||||
account_mismatch // Account number in open block doesn't match send destination
|
||||
account_mismatch, // Account number in open block doesn't match send destination
|
||||
fork_burning // Malicious fork based on spending of burned amount
|
||||
};
|
||||
class process_return
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue