Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always create the FeeSettings object in genesis ledger #4319

Merged
merged 25 commits into from Mar 28, 2023

Conversation

ximinez
Copy link
Collaborator

@ximinez ximinez commented Oct 11, 2022

High Level Overview of Change

This is a follow-up to #4247. Reviewers do not need to concern themselves with those commits, and can start at "Always create the FeeSettings object in genesis ledger".

Inspired by this comment (and previous discussions), this refactors the genesis ledger creation process to always create and initialize a FeeSettings object. This simplifies some of the downstream initialization functions, and removes the need to pass a Config object in as many places.

This change does not require an amendment because it will have no meaningful effects processing transactions, syncing and staying up-to-date on any existing network, nor loading historical ledgers. In practical terms, it's more of a refactor that will slightly change the process for starting up a new network.

Type of Change

  • [X ] New feature (non-breaking change which adds functionality)
  • [X ] Refactor (non-breaking change that only restructures code)
  • [X ] Tests (You added tests for code that already exists, or your new feature included in this PR)

Test Plan

  • Ensure that servers running this version can continue to connect and function properly with existing networks.
  • Because this adds a new object to the genesis / start up ledger, any tests that examine the ledger after a fresh start will probably need to be modified to expect the FeeSettings object, initialized with the default fee values (10 drop base fee, 10 XRP account reserve, 2 XRP incremental reserve).

@ximinez ximinez added the Tech Debt Non-urgent improvements label Oct 11, 2022
@ximinez ximinez changed the title Ledgerinit Always create the FeeSettings object in genesis ledger Oct 12, 2022
@mDuo13
Copy link
Collaborator

mDuo13 commented Dec 12, 2022

I think this fixes #3734

@ximinez
Copy link
Collaborator Author

ximinez commented Dec 13, 2022

I think this fixes #3734

Not quite. This PR does create the FeeSettings object, but it still uses the "poorly documented" config values instead of the [voting] section. I think I can reasonably convert it over and get rid of the other values entirely. I'll do that in a separate commit sometime soon.

Reviewers: If you haven't started reviewing yet, please hold off until I can do that.

@@ -234,6 +234,11 @@ CONSTRUCT_TYPED_SFIELD(sfRippleEscrow, "RippleEscrow", AMOUNT,
CONSTRUCT_TYPED_SFIELD(sfDeliveredAmount, "DeliveredAmount", AMOUNT, 18);
CONSTRUCT_TYPED_SFIELD(sfNFTokenBrokerFee, "NFTokenBrokerFee", AMOUNT, 19);

// currency amount (fees)
CONSTRUCT_TYPED_SFIELD(sfBaseFeeDrops, "BaseFeeDrops", AMOUNT, 20);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number values here make a conflict with @RichardAH pull for Hooks values here: https://github.com/XRPLF/rippled/pull/4225/files#diff-24b5cf98b88491e906e2e365bfdbba35fffee45b36c1a52a1fb6dc539dd72023R239-R240

You should change the these values.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the values over in the base PR, #4247

* Introduces amendment `featureXRPFees`
* Includes Validations, Change transactions, the "Fees" ledger object,
  and subscription messages.
* For use with CDBC and sidechain projects that do not want to require
  fees.
* Note that fee escalation logic is still in place, which may cause the
  open ledger fee to rise if the network is busy. 0 drop transactions
  will still queue, and fee escalation can be effectively disabled by
  modifying the configuration on all nodes.
* Break featureXRPCheck logic into multiple blocks.
* Change default network reserves to match mainnet.
* Add a isLegalAmountSigned check
* Initialize with default values from the config. Removes the need to
  pass a Config down into the Ledger initialization functions,
  including setup().
* Because old mainnet ledgers (prior to 562177 - yes, I looked it up),
  don't have FeeSettings, some of the other ctors will default them to
  the config values before setup() tries to load the object.
* Update default Config fee values to match mainnet.
* Fix unit tests:
  * Updated fees: Some tests are converted to use computed
    values of fee object, but the default Env config was
    also updated to fix the rest.
  * Unit tests that check the structure of the ledger have updated
    hashes and counts.
* upstream/develop:
  Add a unit test for invalid memos (XRPLF#4287)
* upstream/develop:
  Make NodeToShardRPC a manual test (XRPLF#4379)
  Update build instructions (XRPLF#4376)
@ximinez
Copy link
Collaborator Author

ximinez commented Mar 1, 2023

what's the status of this PR? Is it ready for review/merge?

@intelliot I'm going to run a quick test of the changes I made to get rid of the undocumented config values while I grab some food, and I'll push if it looks good.

@ximinez
Copy link
Collaborator Author

ximinez commented Mar 1, 2023

Ok. I think it's really ready. @thejohnfreeman @nbougalis @intelliot

The last commit finally gets rid of the "poorly documented" config settings for reserves, and uses the [voting] section to initialize the configuration for new networks / standalone tests.

* upstream/develop:
  Set version to 1.10.0-rc4
  Rename 'NFT' to 'NFToken' in DisallowIncoming flags (XRPLF#4442)
  Update Docker.md (XRPLF#4432)
  Update package building scripts and images to use Conan (XRPLF#4435)
  Disable duplicate detector: (XRPLF#4438)
* upstream/develop:
  Set version to 1.10.0
* upstream/develop:
  docs: security bug bounty acknowledgements (XRPLF#4460)
* upstream/develop:
  Rectify the import paths of boost/iterator: (XRPLF#4293)
  Allow port numbers be be specified with a colon: (XRPLF#4328)
  Use <=> operator for base_uint, Issue, and Book: (XRPLF#4411)
  Reporting Mode: Do not attempt to acquire missing data from peer network (XRPLF#4458)
* upstream/develop:
  docs: update protocol README (4457)
  `fixNFTokenRemint`: prevent NFT re-mint: (4406)
  fix: support RPC markers for any ledger object: (4361)
  refactor: optimize NodeStore object conversion: (4353)
  fix(ValidatorSite): handle rare null pointer dereference in timeout: (4420)
  fix(gateway_balances): handle overflow exception: (4355)
  Set version to 1.10.1-b1
@intelliot
Copy link
Collaborator

@thejohnfreeman could you review this? (If not, please suggest 1-2 other potential reviewers.)

@@ -108,7 +108,8 @@ class RCLValidations_test : public beast::unit_test::suite
next->updateSkipList();
if (forceHash)
{
next->setImmutable(config);
BEAST_EXPECT(next->read(keylet::fees()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this expected only when forceHash is set? I didn't go into the details of this test but the fees is available regardless of forceHash.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I just put it there because I was changing the call to setImmutable. I'll move it.

@@ -2944,7 +2944,7 @@ class TxQ1_test : public beast::unit_test::suite
// we only see a reduction by 5.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this comment be updated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I'll make it more vague. 😄

Copy link
Collaborator

@gregtatcam gregtatcam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 I have two minor comments, which I assume would be addressed.

** Do not include this message in the squashed commit message
* Move one of the tests and update a comment.
@intelliot
Copy link
Collaborator

@ximinez please suggest a commit message for this PR (to use for the entire squashed changeset)

@ximinez ximinez added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label Mar 27, 2023
@ximinez
Copy link
Collaborator Author

ximinez commented Mar 27, 2023

please suggest a commit message for this PR (to use for the entire squashed changeset)

Refactor fee initialization and configuration (#4319):

* Create the FeeSettings object in genesis ledger.
* Initialize with default values from the config. Removes the need to
  pass a Config down into the Ledger initialization functions,
  including setup().
* Drop the undocumented fee config settings in favor of the [voting]
  section.
* Because old mainnet ledgers (prior to 562177 - yes, I looked it up),
  don't have FeeSettings, some of the other ctors will default them to
  the config values before setup() tries to load the object.
* Update default Config fee values to match mainnet.
* Fix unit tests:
  * Updated fees: Some tests are converted to use computed
    values of fee object, but the default Env config was
    also updated to fix the rest.
  * Unit tests that check the structure of the ledger have updated
    hashes and counts.

ximinez added a commit to ximinez/rippled that referenced this pull request Mar 28, 2023
* Create the FeeSettings object in genesis ledger.
* Initialize with default values from the config. Removes the need to
  pass a Config down into the Ledger initialization functions,
  including setup().
* Drop the undocumented fee config settings in favor of the [voting]
  section.
* Because old mainnet ledgers (prior to 562177 - yes, I looked it up),
  don't have FeeSettings, some of the other ctors will default them to
  the config values before setup() tries to load the object.
* Update default Config fee values to match mainnet.
* Fix unit tests:
  * Updated fees: Some tests are converted to use computed
    values of fee object, but the default Env config was
    also updated to fix the rest.
  * Unit tests that check the structure of the ledger have updated
    hashes and counts.
@intelliot intelliot merged commit 66627b2 into XRPLF:develop Mar 28, 2023
4 checks passed
@ximinez ximinez deleted the ledgerinit branch March 28, 2023 22:11
@ximinez ximinez mentioned this pull request May 22, 2023
intelliot pushed a commit that referenced this pull request May 23, 2023
This assert was put in the wrong place, but it only triggers if shards
are configured. This change moves the assert to the right place and
updates it to ensure correctness.

The assert could be hit after the server downloads some shards. It may
be necessary to restart after the shards are downloaded.

Note that asserts are normally checked only in debug builds, so release
packages should not be affected.

Introduced in: #4319 (66627b2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. Tech Debt Non-urgent improvements Testable Will Need Documentation
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

8 participants