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.
  * Fix #3734.
  * If you previously used fee_account_reserve and/or fee_owner_reserve,
    you should change to using the [voting] section instead. Example:

```
[voting]
account_reserve=10000000
owner_reserve=2000000
```

* 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.
This commit is contained in:
Ed Hennis
2023-03-28 09:03:25 -07:00
committed by GitHub
parent 7aad6e5127
commit 66627b26cf
34 changed files with 289 additions and 199 deletions

View File

@@ -1699,7 +1699,7 @@ ApplicationImp::fdRequired() const
void
ApplicationImp::startGenesisLedger()
{
std::vector<uint256> initialAmendments =
std::vector<uint256> const initialAmendments =
(config_->START_UP == Config::FRESH) ? m_amendmentTable->getDesired()
: std::vector<uint256>{};
@@ -1710,7 +1710,10 @@ ApplicationImp::startGenesisLedger()
auto const next =
std::make_shared<Ledger>(*genesis, timeKeeper().closeTime());
next->updateSkipList();
next->setImmutable(*config_);
assert(
next->info().seq < XRP_LEDGER_EARLIEST_FEES ||
next->read(keylet::fees()));
next->setImmutable();
openLedger_.emplace(next, cachedSLEs_, logs_->journal("OpenLedger"));
m_ledgerMaster->storeLedger(next);
m_ledgerMaster->switchLCL(next);
@@ -1728,7 +1731,10 @@ ApplicationImp::getLastFullLedger()
if (!ledger)
return ledger;
ledger->setImmutable(*config_);
assert(
ledger->info().seq < XRP_LEDGER_EARLIEST_FEES ||
ledger->read(keylet::fees()));
ledger->setImmutable();
if (getLedgerMaster().haveLedger(seq))
ledger->setValidated();
@@ -1879,8 +1885,11 @@ ApplicationImp::loadLedgerFromFile(std::string const& name)
loadLedger->stateMap().flushDirty(hotACCOUNT_NODE);
assert(
loadLedger->info().seq < XRP_LEDGER_EARLIEST_FEES ||
loadLedger->read(keylet::fees()));
loadLedger->setAccepted(
closeTime, closeTimeResolution, !closeTimeEstimated, *config_);
closeTime, closeTimeResolution, !closeTimeEstimated);
return loadLedger;
}