From 7ca53225d2cf80e2d362dbd2c1453b6050c2b7dd Mon Sep 17 00:00:00 2001 From: Scott Schurr Date: Mon, 5 Jun 2023 13:42:19 -0700 Subject: [PATCH 1/3] Add comments for NFToken-related invariants --- src/ripple/app/tx/impl/InvariantCheck.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/ripple/app/tx/impl/InvariantCheck.h b/src/ripple/app/tx/impl/InvariantCheck.h index c3bb0216426..50c422f938a 100644 --- a/src/ripple/app/tx/impl/InvariantCheck.h +++ b/src/ripple/app/tx/impl/InvariantCheck.h @@ -318,6 +318,17 @@ class ValidNewAccountRoot beast::Journal const&); }; +/** + * @brief Invariant: Validates several invariants for NFToken pages. + * + * The following checks are made: + * - The page is correctly associated with the owner. + * - The page is correctly ordered between the next and previous links. + * - The page contains a valid number of NFTokens. + * - The NFTokens on this page do not belong on a lower or higher page. + * - The NFTokens are correctly sorted on the page. + * - Each URI, if present, is not empty. + */ class ValidNFTokenPage { bool badEntry_ = false; @@ -342,6 +353,19 @@ class ValidNFTokenPage beast::Journal const&); }; +/** + * @brief Invariant: Validates counts of NFTokens after all transaction types. + * + * The following checks are made: + * - The number of minted or burned tokens may only be changed by + * NFTokenMint or NFTokenBurn transactions. + * - A successful NFTokenMint must increase the number of NFTokens. + * - A failed NFTokenMint must not change the number of minted NFTokens. + * - An NFTokenMint transaction may not change the number of burned NFTokens, + * - A successful NFTokenBurn must increase the number of burned NFTokens. + * - A failed NFTokenBurn must not change the number of burned NFTokens. + * - An NFTokenBurn transaction may not change the number of minted NFTokens. + */ class NFTokenCountTracking { std::uint32_t beforeMintedTotal = 0; From 8301c729a89e027e17ed58cfcb51e3a459d074cc Mon Sep 17 00:00:00 2001 From: Scott Schurr Date: Mon, 5 Jun 2023 14:46:08 -0700 Subject: [PATCH 2/3] [FOLD] Change "may" to "can" and "may not" to "cannot" --- src/ripple/app/tx/impl/InvariantCheck.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ripple/app/tx/impl/InvariantCheck.h b/src/ripple/app/tx/impl/InvariantCheck.h index 50c422f938a..c835ece7075 100644 --- a/src/ripple/app/tx/impl/InvariantCheck.h +++ b/src/ripple/app/tx/impl/InvariantCheck.h @@ -357,14 +357,14 @@ class ValidNFTokenPage * @brief Invariant: Validates counts of NFTokens after all transaction types. * * The following checks are made: - * - The number of minted or burned tokens may only be changed by + * - The number of minted or burned NFTokens can only be changed by * NFTokenMint or NFTokenBurn transactions. * - A successful NFTokenMint must increase the number of NFTokens. * - A failed NFTokenMint must not change the number of minted NFTokens. - * - An NFTokenMint transaction may not change the number of burned NFTokens, + * - An NFTokenMint transaction cannot change the number of burned NFTokens. * - A successful NFTokenBurn must increase the number of burned NFTokens. * - A failed NFTokenBurn must not change the number of burned NFTokens. - * - An NFTokenBurn transaction may not change the number of minted NFTokens. + * - An NFTokenBurn transaction cannot change the number of minted NFTokens. */ class NFTokenCountTracking { From 4f40b8a86eab24f65ec4dacfac04bc5607fad960 Mon Sep 17 00:00:00 2001 From: Scott Schurr Date: Wed, 7 Jun 2023 10:33:39 -0700 Subject: [PATCH 3/3] [FOLD] Respond to further review comments --- src/ripple/app/tx/impl/InvariantCheck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ripple/app/tx/impl/InvariantCheck.h b/src/ripple/app/tx/impl/InvariantCheck.h index c835ece7075..fe17db44fa7 100644 --- a/src/ripple/app/tx/impl/InvariantCheck.h +++ b/src/ripple/app/tx/impl/InvariantCheck.h @@ -324,7 +324,7 @@ class ValidNewAccountRoot * The following checks are made: * - The page is correctly associated with the owner. * - The page is correctly ordered between the next and previous links. - * - The page contains a valid number of NFTokens. + * - The page contains at least one and no more than 32 NFTokens. * - The NFTokens on this page do not belong on a lower or higher page. * - The NFTokens are correctly sorted on the page. * - Each URI, if present, is not empty.