mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 23:15:52 +00:00
Fix fees in Ledger construction
Conflicts: src/ripple/app/ledger/Ledger.cpp src/ripple/app/ledger/Ledger.h src/ripple/app/main/Application.cpp src/ripple/ledger/impl/View.cpp src/ripple/ledger/tests/View_test.cpp src/ripple/test/jtx/impl/Env.cpp
This commit is contained in:
@@ -33,18 +33,19 @@
|
|||||||
#include <ripple/basics/contract.h>
|
#include <ripple/basics/contract.h>
|
||||||
#include <ripple/basics/Log.h>
|
#include <ripple/basics/Log.h>
|
||||||
#include <ripple/basics/StringUtilities.h>
|
#include <ripple/basics/StringUtilities.h>
|
||||||
|
#include <ripple/core/LoadFeeTrack.h>
|
||||||
#include <ripple/core/Config.h>
|
#include <ripple/core/Config.h>
|
||||||
#include <ripple/core/DatabaseCon.h>
|
#include <ripple/core/DatabaseCon.h>
|
||||||
#include <ripple/core/LoadFeeTrack.h>
|
#include <ripple/core/LoadFeeTrack.h>
|
||||||
#include <ripple/core/JobQueue.h>
|
#include <ripple/core/JobQueue.h>
|
||||||
#include <ripple/core/SociDB.h>
|
#include <ripple/core/SociDB.h>
|
||||||
#include <ripple/json/to_string.h>
|
#include <ripple/json/to_string.h>
|
||||||
|
#include <ripple/nodestore/Database.h>
|
||||||
#include <ripple/protocol/digest.h>
|
#include <ripple/protocol/digest.h>
|
||||||
#include <ripple/protocol/Indexes.h>
|
#include <ripple/protocol/Indexes.h>
|
||||||
#include <ripple/protocol/JsonFields.h>
|
#include <ripple/protocol/JsonFields.h>
|
||||||
#include <ripple/protocol/SecretKey.h>
|
|
||||||
#include <ripple/protocol/PublicKey.h>
|
#include <ripple/protocol/PublicKey.h>
|
||||||
#include <ripple/nodestore/Database.h>
|
#include <ripple/protocol/SecretKey.h>
|
||||||
#include <ripple/protocol/HashPrefix.h>
|
#include <ripple/protocol/HashPrefix.h>
|
||||||
#include <ripple/protocol/types.h>
|
#include <ripple/protocol/types.h>
|
||||||
#include <beast/module/core/text/LexicalCast.h>
|
#include <beast/module/core/text/LexicalCast.h>
|
||||||
@@ -57,6 +58,8 @@ namespace ripple {
|
|||||||
|
|
||||||
create_genesis_t const create_genesis {};
|
create_genesis_t const create_genesis {};
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
class Ledger::txs_iter_impl
|
class Ledger::txs_iter_impl
|
||||||
: public txs_type::iter_base
|
: public txs_type::iter_base
|
||||||
{
|
{
|
||||||
@@ -119,7 +122,6 @@ Ledger::Ledger (create_genesis_t, Config const& config)
|
|||||||
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
||||||
, stateMap_ (std::make_shared <SHAMap> (SHAMapType::STATE,
|
, stateMap_ (std::make_shared <SHAMap> (SHAMapType::STATE,
|
||||||
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
||||||
, fees_ (getFees(*this, getConfig()))
|
|
||||||
{
|
{
|
||||||
info_.seq = 1;
|
info_.seq = 1;
|
||||||
info_.drops = SYSTEM_CURRENCY_START;
|
info_.drops = SYSTEM_CURRENCY_START;
|
||||||
@@ -136,6 +138,7 @@ Ledger::Ledger (create_genesis_t, Config const& config)
|
|||||||
updateHash();
|
updateHash();
|
||||||
setClosed();
|
setClosed();
|
||||||
setAccepted();
|
setAccepted();
|
||||||
|
setFees(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ledger::Ledger (uint256 const& parentHash,
|
Ledger::Ledger (uint256 const& parentHash,
|
||||||
@@ -147,15 +150,14 @@ Ledger::Ledger (uint256 const& parentHash,
|
|||||||
int closeFlags,
|
int closeFlags,
|
||||||
int closeResolution,
|
int closeResolution,
|
||||||
std::uint32_t ledgerSeq,
|
std::uint32_t ledgerSeq,
|
||||||
bool& loaded)
|
bool& loaded,
|
||||||
|
Config const& config)
|
||||||
: mImmutable (true)
|
: mImmutable (true)
|
||||||
, txMap_ (std::make_shared <SHAMap> (
|
, txMap_ (std::make_shared <SHAMap> (
|
||||||
SHAMapType::TRANSACTION, transHash, getApp().family(),
|
SHAMapType::TRANSACTION, transHash, getApp().family(),
|
||||||
deprecatedLogs().journal("SHAMap")))
|
deprecatedLogs().journal("SHAMap")))
|
||||||
, stateMap_ (std::make_shared <SHAMap> (SHAMapType::STATE, accountHash,
|
, stateMap_ (std::make_shared <SHAMap> (SHAMapType::STATE, accountHash,
|
||||||
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
||||||
// VFALCO Needs audit
|
|
||||||
, fees_(getFees(*this, getConfig()))
|
|
||||||
{
|
{
|
||||||
info_.seq = ledgerSeq;
|
info_.seq = ledgerSeq;
|
||||||
info_.parentCloseTime = parentCloseTime;
|
info_.parentCloseTime = parentCloseTime;
|
||||||
@@ -184,6 +186,7 @@ Ledger::Ledger (uint256 const& parentHash,
|
|||||||
|
|
||||||
txMap_->setImmutable ();
|
txMap_->setImmutable ();
|
||||||
stateMap_->setImmutable ();
|
stateMap_->setImmutable ();
|
||||||
|
setFees(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new ledger that's a snapshot of this one
|
// Create a new ledger that's a snapshot of this one
|
||||||
@@ -192,8 +195,7 @@ Ledger::Ledger (Ledger const& ledger,
|
|||||||
: mImmutable (!isMutable)
|
: mImmutable (!isMutable)
|
||||||
, txMap_ (ledger.txMap_->snapShot (isMutable))
|
, txMap_ (ledger.txMap_->snapShot (isMutable))
|
||||||
, stateMap_ (ledger.stateMap_->snapShot (isMutable))
|
, stateMap_ (ledger.stateMap_->snapShot (isMutable))
|
||||||
// VFALCO Needs audit
|
, fees_ (ledger.fees_)
|
||||||
, fees_(getFees(*this, getConfig()))
|
|
||||||
, info_ (ledger.info_)
|
, info_ (ledger.info_)
|
||||||
{
|
{
|
||||||
updateHash ();
|
updateHash ();
|
||||||
@@ -205,8 +207,7 @@ Ledger::Ledger (open_ledger_t, Ledger const& prevLedger)
|
|||||||
, txMap_ (std::make_shared <SHAMap> (SHAMapType::TRANSACTION,
|
, txMap_ (std::make_shared <SHAMap> (SHAMapType::TRANSACTION,
|
||||||
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
getApp().family(), deprecatedLogs().journal("SHAMap")))
|
||||||
, stateMap_ (prevLedger.stateMap_->snapShot (true))
|
, stateMap_ (prevLedger.stateMap_->snapShot (true))
|
||||||
// VFALCO Needs audit
|
, fees_(prevLedger.fees_)
|
||||||
, fees_(getFees(*this, getConfig()))
|
|
||||||
{
|
{
|
||||||
info_.open = true;
|
info_.open = true;
|
||||||
info_.seq = prevLedger.info_.seq + 1;
|
info_.seq = prevLedger.info_.seq + 1;
|
||||||
@@ -229,8 +230,8 @@ Ledger::Ledger (open_ledger_t, Ledger const& prevLedger)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ledger::Ledger (void const* data,
|
Ledger::Ledger (void const* data,
|
||||||
std::size_t size, bool hasPrefix)
|
std::size_t size, bool hasPrefix,
|
||||||
|
Config const& config)
|
||||||
: mImmutable (true)
|
: mImmutable (true)
|
||||||
, txMap_ (std::make_shared <SHAMap> (
|
, txMap_ (std::make_shared <SHAMap> (
|
||||||
SHAMapType::TRANSACTION, getApp().family(),
|
SHAMapType::TRANSACTION, getApp().family(),
|
||||||
@@ -241,10 +242,11 @@ Ledger::Ledger (void const* data,
|
|||||||
{
|
{
|
||||||
SerialIter sit (data, size);
|
SerialIter sit (data, size);
|
||||||
setRaw (sit, hasPrefix);
|
setRaw (sit, hasPrefix);
|
||||||
fees_ = getFees(*this, getConfig());
|
setFees(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ledger::Ledger (std::uint32_t ledgerSeq, std::uint32_t closeTime)
|
Ledger::Ledger (std::uint32_t ledgerSeq,
|
||||||
|
std::uint32_t closeTime, Config const& config)
|
||||||
: mImmutable (false)
|
: mImmutable (false)
|
||||||
, txMap_ (std::make_shared <SHAMap> (
|
, txMap_ (std::make_shared <SHAMap> (
|
||||||
SHAMapType::TRANSACTION, getApp().family(),
|
SHAMapType::TRANSACTION, getApp().family(),
|
||||||
@@ -252,12 +254,11 @@ Ledger::Ledger (std::uint32_t ledgerSeq, std::uint32_t closeTime)
|
|||||||
, stateMap_ (std::make_shared <SHAMap> (
|
, stateMap_ (std::make_shared <SHAMap> (
|
||||||
SHAMapType::STATE, getApp().family(),
|
SHAMapType::STATE, getApp().family(),
|
||||||
deprecatedLogs().journal("SHAMap")))
|
deprecatedLogs().journal("SHAMap")))
|
||||||
// VFALCO Needs audit
|
|
||||||
, fees_(getFees(*this, getConfig()))
|
|
||||||
{
|
{
|
||||||
info_.seq = ledgerSeq;
|
info_.seq = ledgerSeq;
|
||||||
info_.closeTime = closeTime;
|
info_.closeTime = closeTime;
|
||||||
info_.closeTimeResolution = ledgerDefaultTimeResolution;
|
info_.closeTimeResolution = ledgerDefaultTimeResolution;
|
||||||
|
setFees(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -635,7 +636,8 @@ loadLedgerHelper(std::string const& sqlSuffix)
|
|||||||
closeFlags.value_or(0),
|
closeFlags.value_or(0),
|
||||||
closeResolution.value_or(0),
|
closeResolution.value_or(0),
|
||||||
ledgerSeq,
|
ledgerSeq,
|
||||||
loaded);
|
loaded,
|
||||||
|
getConfig());
|
||||||
|
|
||||||
if (!loaded)
|
if (!loaded)
|
||||||
return std::make_tuple (Ledger::pointer (), ledgerSeq, ledgerHash);
|
return std::make_tuple (Ledger::pointer (), ledgerSeq, ledgerHash);
|
||||||
@@ -992,6 +994,32 @@ Ledger::rawTxInsert (uint256 const& key,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Ledger::setFees (Config const& config)
|
||||||
|
{
|
||||||
|
fees_.base = config.FEE_DEFAULT;
|
||||||
|
fees_.units = config.TRANSACTION_FEE_BASE;
|
||||||
|
fees_.reserve = config.FEE_ACCOUNT_RESERVE;
|
||||||
|
fees_.increment = config.FEE_OWNER_RESERVE;
|
||||||
|
auto const sle = read(keylet::fees());
|
||||||
|
if (sle)
|
||||||
|
{
|
||||||
|
// VFALCO NOTE Why getFieldIndex and not isFieldPresent?
|
||||||
|
|
||||||
|
if (sle->getFieldIndex (sfBaseFee) != -1)
|
||||||
|
fees_.base = sle->getFieldU64 (sfBaseFee);
|
||||||
|
|
||||||
|
if (sle->getFieldIndex (sfReferenceFeeUnits) != -1)
|
||||||
|
fees_.units = sle->getFieldU32 (sfReferenceFeeUnits);
|
||||||
|
|
||||||
|
if (sle->getFieldIndex (sfReserveBase) != -1)
|
||||||
|
fees_.reserve = sle->getFieldU32 (sfReserveBase);
|
||||||
|
|
||||||
|
if (sle->getFieldIndex (sfReserveIncrement) != -1)
|
||||||
|
fees_.increment = sle->getFieldU32 (sfReserveIncrement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<SLE>
|
std::shared_ptr<SLE>
|
||||||
Ledger::peek (Keylet const& k) const
|
Ledger::peek (Keylet const& k) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class TransactionMaster;
|
|||||||
|
|
||||||
class SqliteStatement;
|
class SqliteStatement;
|
||||||
|
|
||||||
struct create_genesis_t { };
|
struct create_genesis_t {};
|
||||||
extern create_genesis_t const create_genesis;
|
extern create_genesis_t const create_genesis;
|
||||||
|
|
||||||
/** Holds a ledger.
|
/** Holds a ledger.
|
||||||
@@ -102,13 +102,10 @@ public:
|
|||||||
uint256 const& accountHash,
|
uint256 const& accountHash,
|
||||||
std::uint64_t totDrops, std::uint32_t closeTime,
|
std::uint64_t totDrops, std::uint32_t closeTime,
|
||||||
std::uint32_t parentCloseTime, int closeFlags, int closeResolution,
|
std::uint32_t parentCloseTime, int closeFlags, int closeResolution,
|
||||||
std::uint32_t ledgerSeq, bool & loaded);
|
std::uint32_t ledgerSeq, bool & loaded, Config const& config);
|
||||||
|
|
||||||
// used for database ledgers
|
// Create a new ledger that's a snapshot of this one
|
||||||
Ledger (std::uint32_t ledgerSeq, std::uint32_t closeTime);
|
Ledger (Ledger const& target, bool isMutable);
|
||||||
|
|
||||||
Ledger (void const* data,
|
|
||||||
std::size_t size, bool hasPrefix);
|
|
||||||
|
|
||||||
/** Create a new open ledger
|
/** Create a new open ledger
|
||||||
|
|
||||||
@@ -118,8 +115,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
Ledger (open_ledger_t, Ledger const& previous);
|
Ledger (open_ledger_t, Ledger const& previous);
|
||||||
|
|
||||||
// Create a new ledger that's a snapshot of this one
|
Ledger (void const* data,
|
||||||
Ledger (Ledger const& target, bool isMutable);
|
std::size_t size, bool hasPrefix,
|
||||||
|
Config const& config);
|
||||||
|
|
||||||
|
// used for database ledgers
|
||||||
|
Ledger (std::uint32_t ledgerSeq,
|
||||||
|
std::uint32_t closeTime, Config const& config);
|
||||||
|
|
||||||
~Ledger();
|
~Ledger();
|
||||||
|
|
||||||
@@ -368,6 +370,9 @@ private:
|
|||||||
}
|
}
|
||||||
bool saveValidatedLedger (bool current);
|
bool saveValidatedLedger (bool current);
|
||||||
|
|
||||||
|
void
|
||||||
|
setFees (Config const& config);
|
||||||
|
|
||||||
std::shared_ptr<SLE>
|
std::shared_ptr<SLE>
|
||||||
peek (Keylet const& k) const;
|
peek (Keylet const& k) const;
|
||||||
|
|
||||||
|
|||||||
@@ -162,14 +162,14 @@ bool InboundLedger::tryLocal ()
|
|||||||
if (m_journal.trace) m_journal.trace <<
|
if (m_journal.trace) m_journal.trace <<
|
||||||
"Ledger header found in fetch pack";
|
"Ledger header found in fetch pack";
|
||||||
mLedger = std::make_shared<Ledger> (
|
mLedger = std::make_shared<Ledger> (
|
||||||
data.data(), data.size(), true);
|
data.data(), data.size(), true, getConfig());
|
||||||
getApp().getNodeStore ().store (
|
getApp().getNodeStore ().store (
|
||||||
hotLEDGER, std::move (data), mHash);
|
hotLEDGER, std::move (data), mHash);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mLedger = std::make_shared<Ledger>(
|
mLedger = std::make_shared<Ledger>(
|
||||||
node->getData().data(), node->getData().size(), true);
|
node->getData().data(), node->getData().size(), true, getConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mLedger->getHash () != mHash)
|
if (mLedger->getHash () != mHash)
|
||||||
@@ -762,7 +762,7 @@ bool InboundLedger::takeHeader (std::string const& data)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
mLedger = std::make_shared<Ledger>(
|
mLedger = std::make_shared<Ledger>(
|
||||||
data.data(), data.size(), false);
|
data.data(), data.size(), false, getConfig());
|
||||||
|
|
||||||
if (mLedger->getHash () != mHash)
|
if (mLedger->getHash () != mHash)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1177,7 +1177,7 @@ bool ApplicationImp::loadOldLedger (
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
loadLedger = std::make_shared<Ledger> (seq, closeTime);
|
loadLedger = std::make_shared<Ledger> (seq, closeTime, getConfig());
|
||||||
loadLedger->setTotalDrops(totalDrops);
|
loadLedger->setTotalDrops(totalDrops);
|
||||||
|
|
||||||
for (Json::UInt index = 0; index < ledger.get().size(); ++index)
|
for (Json::UInt index = 0; index < ledger.get().size(); ++index)
|
||||||
|
|||||||
@@ -741,11 +741,6 @@ CreateOffer::applyGuts (ApplyView& view, ApplyView& view_cancel)
|
|||||||
|
|
||||||
if (mPriorBalance < getAccountReserve (sleCreator))
|
if (mPriorBalance < getAccountReserve (sleCreator))
|
||||||
{
|
{
|
||||||
#if RIPPLE_OPEN_LEDGER
|
|
||||||
deprecatedLogs().journal("OpenLedger").error <<
|
|
||||||
"mPriorBalance < getAccountReserve(sleCreator)";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// If we are here, the signing account had an insufficient reserve
|
// If we are here, the signing account had an insufficient reserve
|
||||||
// *prior* to our processing. If something actually crossed, then
|
// *prior* to our processing. If something actually crossed, then
|
||||||
// we allow this; otherwise, we just claim a fee.
|
// we allow this; otherwise, we just claim a fee.
|
||||||
|
|||||||
@@ -55,10 +55,6 @@ enum FreezeHandling
|
|||||||
fhZERO_IF_FROZEN
|
fhZERO_IF_FROZEN
|
||||||
};
|
};
|
||||||
|
|
||||||
Fees
|
|
||||||
getFees (ReadView const& view,
|
|
||||||
Config const& config);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isGlobalFrozen (ReadView const& view,
|
isGlobalFrozen (ReadView const& view,
|
||||||
AccountID const& issuer);
|
AccountID const& issuer);
|
||||||
|
|||||||
@@ -44,38 +44,6 @@ namespace ripple {
|
|||||||
//
|
//
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
Fees
|
|
||||||
getFees (ReadView const& view,
|
|
||||||
Config const& config)
|
|
||||||
{
|
|
||||||
Fees f;
|
|
||||||
f.base = config.FEE_DEFAULT;
|
|
||||||
f.units = config.TRANSACTION_FEE_BASE;
|
|
||||||
f.reserve = config.FEE_ACCOUNT_RESERVE;
|
|
||||||
f.increment = config.FEE_OWNER_RESERVE;
|
|
||||||
auto const sle =
|
|
||||||
view.read(keylet::fees());
|
|
||||||
if (sle)
|
|
||||||
{
|
|
||||||
// VFALCO NOTE Why getFieldIndex and not isFieldPresent?
|
|
||||||
|
|
||||||
if (sle->getFieldIndex (sfBaseFee) != -1)
|
|
||||||
f.base = sle->getFieldU64 (sfBaseFee);
|
|
||||||
|
|
||||||
if (sle->getFieldIndex (sfReferenceFeeUnits) != -1)
|
|
||||||
f.units = sle->getFieldU32 (sfReferenceFeeUnits);
|
|
||||||
|
|
||||||
if (sle->getFieldIndex (sfReserveBase) != -1)
|
|
||||||
f.reserve = sle->getFieldU32 (sfReserveBase);
|
|
||||||
|
|
||||||
if (sle->getFieldIndex (sfReserveIncrement) != -1)
|
|
||||||
f.increment = sle->getFieldU32 (sfReserveIncrement);
|
|
||||||
}
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void addRaw (LedgerInfo const& info, Serializer& s)
|
void addRaw (LedgerInfo const& info, Serializer& s)
|
||||||
{
|
{
|
||||||
s.add32 (info.seq);
|
s.add32 (info.seq);
|
||||||
|
|||||||
Reference in New Issue
Block a user