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

XRPFees: Fee setting and handling improvements #4247

Merged
merged 11 commits into from Feb 3, 2023

Conversation

ximinez
Copy link
Collaborator

@ximinez ximinez commented Jul 21, 2022

High Level Overview of Change

This branch resolves #3932. The concept of "fee units" has been (almost) completely removed. It remains in a few places to preserve backward compatibility. Additionally, a new amendment, XRPFees has been introduced which, if enabled by the validators, will convert all representations of fees in the code, ledger, and protocol that are still raw numbers into XRPAmounts.

Additionally, it fixes an issue where a sidechain / test network is able to confirm a 0 drop base fee, but is unable to accept submissions of transactions with 0 drop fees. The transaction engine appears to be perfectly fine with such fees, but fee escalation logic had an unstated assumption that the base fee would never be 0. This fix works around that assumption while still enabling fee escalation to raise required fees when the network gets busy - it effectively treats the base fee as 1 drop for purposes of getting into the open ledger ONLY when fees are escalated. No amendment is required for this fix because it only affects transaction submission, not processing. I am reasonably sure this solution is complete, but I would encourage anybody dealing with the issue to test this branch to ensure I haven't missed any edge cases.

Type of Change

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

src/ripple/app/ledger/Ledger.cpp Show resolved Hide resolved
src/ripple/app/misc/FeeVote.h Outdated Show resolved Hide resolved
src/ripple/app/misc/FeeVoteImpl.cpp Outdated Show resolved Hide resolved
src/ripple/app/misc/FeeVoteImpl.cpp Show resolved Hide resolved
src/ripple/protocol/SystemParameters.h Show resolved Hide resolved
src/ripple/protocol/impl/STValidation.cpp Outdated Show resolved Hide resolved
@mDuo13
Copy link
Collaborator

mDuo13 commented Oct 24, 2022

Does this also fix the fact that the server (in some places?) serializes BaseFee in hexadecimal for some weird reason?

@ximinez
Copy link
Collaborator Author

ximinez commented Oct 25, 2022

Does this also fix the fact that the server (in some places?) serializes BaseFee in hexadecimal for some weird reason?

I'm not sure. Can you point me to some places where you see it?

@intelliot
Copy link
Collaborator

(@mDuo13 whenever you have a chance - there's an open question above)

@mDuo13
Copy link
Collaborator

mDuo13 commented Nov 16, 2022

Does this also fix the fact that the server (in some places?) serializes BaseFee in hexadecimal for some weird reason?

I'm not sure. Can you point me to some places where you see it?

#3165

ledger_entry for the FeeSettings singleton object

2022-11-16_131217_373832466

@ximinez
Copy link
Collaborator Author

ximinez commented Nov 16, 2022

$ rippled -q feature XRPFees

{
   "result" : {
      "93E516234E35E08CA689FA33A6D38E103881F8DCB53023F728C307AA89D515A7" : {
         "enabled" : true,
         "name" : "XRPFees",
         "supported" : true,
         "vetoed" : false
      },
      "status" : "success"
   }
}

$ rippled -q ledger_entry 4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651

{
   "result" : {
      "index" : "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651",
      "ledger_current_index" : 3,
      "node" : {
         "BaseFeeDrops" : "10",
         "Flags" : 0,
         "LedgerEntryType" : "FeeSettings",
         "ReserveBaseDrops" : "10000000",
         "ReserveIncrementDrops" : "2000000",
         "index" : "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A651"
      },
      "status" : "success",
      "validated" : false
   }
}

Note that I ran this test using my ledgerinit branch, which is based off of this one, but creates the fee object on genesis, and just made it simpler for me.

@ximinez ximinez added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label Jan 19, 2023
@intelliot intelliot changed the title Fee setting and handling improvements XRPFees: Fee setting and handling improvements Jan 20, 2023
@intelliot
Copy link
Collaborator

@thejohnfreeman any last thoughts on this PR?

Copy link
Collaborator

@thejohnfreeman thejohnfreeman left a comment

Choose a reason for hiding this comment

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

Should we remove the section "Fee level" in src/ripple/app/misc/FeeEscalation.md and amend the rest of the documentation?

src/ripple/app/tx/impl/Change.cpp Outdated Show resolved Hide resolved
@ximinez
Copy link
Collaborator Author

ximinez commented Jan 24, 2023

Should we remove the section "Fee level" in src/ripple/app/misc/FeeEscalation.md and amend the rest of the documentation?

@thejohnfreeman I don't think so. Fee levels are not the same as fee units. I removed fee units here. Fee levels are still there and necessary for the transaction queue to work fairly. I'm hoping that after this is merged, there will be less confusion about the whole thing.

As for the rest of the documentation, I don't think "fee units" are really documented anywhere because the were a transparent implementation detail, but if there are, then yeah, that would need to be updated.

* Clarify comments explaining the ttFEE transaction field validation.
Comment on lines 96 to 98
// The ttFEE transaction format defines these fields as
// optional, but once the XRPFees feature is enabled, they are
// forbidden.
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are the required ones, right? Not forbidden? The code returns malformed if they are missing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, woops. Got those backwards.

Comment on lines 103 to 105
// The ttFEE transaction format defines these fields as
// optional, but once the XRPFees feature is enabled, they are
// required.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similarly, these are the forbidden ones.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, woops. Got those backwards.

@intelliot intelliot merged commit e4b17d1 into XRPLF:develop Feb 3, 2023
@ximinez ximinez deleted the feesettings branch February 3, 2023 16:34
ximinez added a commit to ximinez/rippled that referenced this pull request Feb 3, 2023
* upstream/develop:
  `XRPFees`: Fee setting and handling improvements (XRPLF#4247)
ximinez added a commit to ximinez/rippled that referenced this pull request Feb 3, 2023
* upstream/develop:
  `XRPFees`: Fee setting and handling improvements (XRPLF#4247)
ximinez added a commit to ximinez/rippled that referenced this pull request Feb 3, 2023
* upstream/develop:
  `XRPFees`: Fee setting and handling improvements (XRPLF#4247)
ximinez added a commit to ximinez/rippled that referenced this pull request Feb 3, 2023
* upstream/develop:
  `XRPFees`: Fee setting and handling improvements (XRPLF#4247)
ximinez added a commit to ximinez/rippled that referenced this pull request Feb 9, 2023
…tpage

* upstream/develop: (37 commits)
  Update documented pathfinding configuration defaults: (XRPLF#4409)
  Update dependency: grpc (XRPLF#4407)
  Introduce min/max observers for Number
  Optimize uint128_t division by 10 within Number.cpp
  Replace Number division algorithm
  Include rounding mode in XRPAmount to STAmount conversion.
  Remove undefined behavior * Taking the negative of a signed negative is UB, but   taking the negative of an unsigned is not.
  Silence warnings
  Introduce rounding modes for Number:
  Use Number for IOUAmount and STAmount arithmetic
  Add tests
  Add implicit conversion from STAmount to Number
  Add clip
  Add conversions between Number, XRPAmount and int64_t
  AMM Add Number class and associated algorithms
  Revise CONTRIBUTING (XRPLF#4382)
  `XRPFees`: Fee setting and handling improvements (XRPLF#4247)
  Update BUILD.md (XRPLF#4383)
  Make NodeToShardRPC a manual test (XRPLF#4379)
  Update build instructions (XRPLF#4376)
  ...
dangell7 pushed a commit to Transia-RnD/rippled that referenced this pull request Mar 5, 2023
* Introduces amendment `XRPFees`
* Convert fee voting and protocol messages to use XRPAmounts
* Includes Validations, Change transactions, the "Fees" ledger object,
  and subscription messages

* Improve handling of 0 drop reference fee with TxQ. For use with networks 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

* Change default network reserves to match Mainnet

* Name the new SFields *Drops (not *XRP)
* Reserve SField IDs for Hooks

* Clarify comments explaining the ttFEE transaction field validation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Amendment API Change Bug Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. Testable Will Need Documentation
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Simplify fee settings & related calculations
7 participants