From 3f7e15893e30ccf5319fa417d25d47d29f403304 Mon Sep 17 00:00:00 2001 From: Denis Angell Date: Sun, 3 Dec 2023 10:27:06 +0100 Subject: [PATCH] FXV1: Meta Amount (#225) ensure default-value amount fields are correctly recorded in metadata for created nodes (fixXahau1) --- src/ripple/ledger/impl/ApplyStateTable.cpp | 8 +++++++- src/ripple/protocol/Feature.h | 3 ++- src/ripple/protocol/impl/Feature.cpp | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ripple/ledger/impl/ApplyStateTable.cpp b/src/ripple/ledger/impl/ApplyStateTable.cpp index b944d0feb..85ce58482 100644 --- a/src/ripple/ledger/impl/ApplyStateTable.cpp +++ b/src/ripple/ledger/impl/ApplyStateTable.cpp @@ -130,6 +130,8 @@ ApplyStateTable::generateTxMeta( if (!hookEmission.empty()) meta.setHookEmissions(STArray{hookEmission, sfHookEmissions}); + bool const recordDefaultAmounts = to.rules().enabled(fixXahauV1); + Mods newMod; for (auto& item : items_) { @@ -232,8 +234,12 @@ ApplyStateTable::generateTxMeta( STObject news(sfNewFields); for (auto const& obj : *curNode) { + bool const shouldRecord = + (obj.getSType() == STI_AMOUNT && recordDefaultAmounts) || + !obj.isDefault(); + // save non-default values - if (!obj.isDefault() && + if (shouldRecord && obj.getFName().shouldMeta( SField::sMD_Create | SField::sMD_Always)) news.emplace_back(obj); diff --git a/src/ripple/protocol/Feature.h b/src/ripple/protocol/Feature.h index 14cb3c8a0..298648859 100644 --- a/src/ripple/protocol/Feature.h +++ b/src/ripple/protocol/Feature.h @@ -74,7 +74,7 @@ namespace detail { // Feature.cpp. Because it's only used to reserve storage, and determine how // large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than // the actual number of amendments. A LogicError on startup will verify this. -static constexpr std::size_t numFeatures = 66; +static constexpr std::size_t numFeatures = 67; /** Amendments that this server supports and the default voting behavior. Whether they are enabled depends on the Rules defined in the validated @@ -354,6 +354,7 @@ extern uint256 const featureImport; extern uint256 const featureXahauGenesis; extern uint256 const featureHooksUpdate1; extern uint256 const fixURITokenV1; +extern uint256 const fixXahauV1; } // namespace ripple diff --git a/src/ripple/protocol/impl/Feature.cpp b/src/ripple/protocol/impl/Feature.cpp index 8ccadef8e..42b123000 100644 --- a/src/ripple/protocol/impl/Feature.cpp +++ b/src/ripple/protocol/impl/Feature.cpp @@ -460,6 +460,7 @@ REGISTER_FEATURE(Import, Supported::yes, VoteBehavior::De REGISTER_FEATURE(XahauGenesis, Supported::yes, VoteBehavior::DefaultYes); REGISTER_FEATURE(HooksUpdate1, Supported::yes, VoteBehavior::DefaultYes); REGISTER_FIX (fixURITokenV1, Supported::yes, VoteBehavior::DefaultNo); +REGISTER_FIX (fixXahauV1, Supported::yes, VoteBehavior::DefaultNo); // The following amendments are obsolete, but must remain supported