mirror of
https://github.com/XRPLF/rippled.git
synced 2026-09-27 23:38:08 +00:00
fix: Refuse to make an invalid SHAMap or Ledger immutable
SHAMap::setImmutable() now returns [[nodiscard]] bool and refuses a map already proven impossible. Every state change goes through trySetState(), the only writer of state_ past construction, so the order between the states is stated once: its compare-exchange can't leave Invalid however it interleaves with another thread's, and setInvalid() stores through the same funnel rather than behind its back. Invalid is stored unconditionally there, since only the map itself reaches that verdict and a walk that reaches it has to win against a thread settling the map; refusing to overwrite Immutable would leave a map proven impossible reporting itself sound, which is what nothing downstream could recover from. Ledger::setImmutable()/setAccepted() do the same one level up, checking mapsValid() before touching anything and settling both maps independently so neither is left mid-sync because the other refused. The map hashes are read before the maps are settled, since getHash() can unshare a dirty tree, but written to the header only once both maps have made it. A walk that invalidates a map in between therefore leaves the header describing what the ledger was built from rather than a map that has since been abandoned. Every call site now branches on the result. The two genesis paths and buildLedgerImpl() call logicError(), since consensus can't tolerate an invalid ledger; the load paths return early instead; InboundLedger and TransactionAcquire withdraw complete_ alongside the failure, since for them a refusal is an outcome a peer can produce. A test helper that cannot reach BEAST_EXPECT throws instead, so a refusal cannot hand a broken ledger to the assertions below.
This commit is contained in:
@@ -100,7 +100,7 @@ class RCLValidations_test : public beast::unit_test::Suite
|
||||
BEAST_EXPECT(next->read(keylet::feeSettings()));
|
||||
if (forceHash)
|
||||
{
|
||||
next->setImmutable();
|
||||
BEAST_EXPECT(next->setImmutable());
|
||||
forceHash = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user