From f2d37da4ca12b8e3f897a46e370e5defd58621f6 Mon Sep 17 00:00:00 2001 From: Gregory Tsipenyuk Date: Mon, 20 May 2024 16:33:01 -0400 Subject: [PATCH] Fix Oracle's token pair deterministic order: (#5021) Price Oracle data-series logic uses `unordered_map` to update the Oracle object. This results in different servers disagreeing on the order of that hash table. Consequently, the generated ledgers will have different hashes. The fix uses `map` instead to guarantee the order of the token pairs in the data-series. --- src/ripple/app/tx/impl/SetOracle.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ripple/app/tx/impl/SetOracle.cpp b/src/ripple/app/tx/impl/SetOracle.cpp index dcd00311475..d0987d26538 100644 --- a/src/ripple/app/tx/impl/SetOracle.cpp +++ b/src/ripple/app/tx/impl/SetOracle.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -97,10 +96,10 @@ SetOracle::preclaim(PreclaimContext const& ctx) ctx.tx.getAccountID(sfAccount), ctx.tx[sfOracleDocumentID])); // token pairs to add/update - hash_set> pairs; + std::set> pairs; // token pairs to delete. if a token pair doesn't include // the price then this pair should be deleted from the object. - hash_set> pairsDel; + std::set> pairsDel; for (auto const& entry : ctx.tx.getFieldArray(sfPriceDataSeries)) { if (entry[sfBaseAsset] == entry[sfQuoteAsset]) @@ -216,7 +215,7 @@ SetOracle::doApply() // the token pair that doesn't have their price updated will not // include neither price nor scale in the updated PriceDataSeries - hash_map, STObject> pairs; + std::map, STObject> pairs; // collect current token pairs for (auto const& entry : sle->getFieldArray(sfPriceDataSeries)) {