Autofill with x-queue-okay uses mult_max fee (RIPD-1194):

* Only relevant if escalated fee is larger than mult_max.
* Will improved queue position, giving tx more chance to succeed.
This commit is contained in:
Edward Hennis
2016-06-23 17:22:53 -04:00
committed by Miguel Portilla
parent 9cc80b7cb6
commit 654772a860
2 changed files with 73 additions and 34 deletions

View File

@@ -679,14 +679,11 @@ Json::Value checkFee (
feeTrack.scaleFeeLoad (feeDefault,
ledger->fees().base, ledger->fees().units, isUnlimited (role));
std::uint64_t fee = loadFee;
if (ledger->rules().enabled(featureFeeEscalation,
config.features))
{
auto const assumeTx = request.isMember("x-assume-tx") &&
request["x-assume-tx"].isConvertibleTo(Json::uintValue) ?
request["x-assume-tx"].asUInt() : 0;
auto const metrics = txQ.getMetrics(config, *ledger, assumeTx);
assert(metrics);
if(metrics)
{
auto const baseFee = ledger->fees().base;
@@ -709,7 +706,7 @@ Json::Value checkFee (
request["x-queue-okay"].isBool() &&
request["x-queue-okay"].asBool())
{
fee = loadFee;
fee = std::max(loadFee, limit);
}
if (fee > limit)
{
@@ -719,7 +716,7 @@ Json::Value checkFee (
return RPC::make_error (rpcHIGH_FEE, ss.str());
}
tx [jss::Fee] = static_cast<int>(fee);
tx [jss::Fee] = static_cast<unsigned int>(fee);
return Json::Value();
}

View File

@@ -1932,28 +1932,27 @@ public:
}
}
static
std::unique_ptr<Config>
makeConfig()
{
auto p = std::make_unique<Config>();
test::setupConfigForUnitTests(*p);
auto& section = p->section("transaction_queue");
section.set("minimum_txn_in_ledger_standalone", "3");
return p;
}
void testAutoFillEscalatedFees ()
{
test::jtx::Env env(*this, makeConfig(),
test::jtx::Env env(*this, []()
{
auto p = std::make_unique<Config>();
test::setupConfigForUnitTests(*p);
auto& section = p->section("transaction_queue");
section.set("minimum_txn_in_ledger_standalone", "3");
return p;
}(),
test::jtx::features(featureFeeEscalation));
LoadFeeTrack const& feeTrack = env.app().getFeeTrack();
{
// 1: high mult, no queue, no pad
Json::Value req;
Json::Reader ().parse (
"{ \"fee_mult_max\" : 1000, \"tx_json\" : { } } ", req);
Json::Reader ().parse (R"({
"fee_mult_max" : 1000,
"x-queue-okay" : false,
"tx_json" : { }
})", req);
Json::Value result =
checkFee (req, Role::ADMIN, true,
env.app().config(), feeTrack,
@@ -1967,8 +1966,11 @@ public:
{
// 2: high mult, can queue, no pad
Json::Value req;
Json::Reader().parse(
"{ \"fee_mult_max\" : 1000, \"x-queue-okay\" : true \"tx_json\" : { } } ", req);
Json::Reader().parse(R"({
"fee_mult_max" : 1000,
"x-queue-okay" : true,
"tx_json" : { }
})", req);
Json::Value result =
checkFee(req, Role::ADMIN, true,
env.app().config(), feeTrack,
@@ -1982,8 +1984,11 @@ public:
{
// 3: high mult, no queue, 4 pad
Json::Value req;
Json::Reader().parse(
"{ \"fee_mult_max\" : 1000, \"x-assume-tx\" : 4, \"tx_json\" : { } } ", req);
Json::Reader().parse(R"({
"fee_mult_max" : 1000,
"x-assume-tx" : 4,
"tx_json" : { }
})", req);
Json::Value result =
checkFee(req, Role::ADMIN, true,
env.app().config(), feeTrack,
@@ -1997,8 +2002,12 @@ public:
{
// 4: high mult, can queue, 4 pad
Json::Value req;
Json::Reader().parse(
"{ \"fee_mult_max\" : 1000, \"x-assume-tx\" : 4, \"x-queue-okay\" : true \"tx_json\" : { } } ", req);
Json::Reader().parse(R"({
"fee_mult_max" : 1000,
"x-assume-tx" : 4,
"x-queue-okay" : true,
"tx_json" : { }
})", req);
Json::Value result =
checkFee(req, Role::ADMIN, true,
env.app().config(), feeTrack,
@@ -2013,8 +2022,10 @@ public:
{
// 5: low mult, no queue, no pad
Json::Value req;
Json::Reader().parse(
"{ \"fee_mult_max\" : 5, \"tx_json\" : { } } ", req);
Json::Reader().parse(R"({
"fee_mult_max" : 5,
"tx_json" : { }
})", req);
Json::Value result =
checkFee(req, Role::ADMIN, true,
env.app().config(), feeTrack,
@@ -2028,8 +2039,11 @@ public:
{
// 6: low mult, can queue, no pad
Json::Value req;
Json::Reader().parse(
"{ \"fee_mult_max\" : 5, \"x-queue-okay\" : true \"tx_json\" : { } } ", req);
Json::Reader().parse(R"({
"fee_mult_max" : 5,
"x-queue-okay" : true,
"tx_json" : { }
})", req);
Json::Value result =
checkFee(req, Role::ADMIN, true,
env.app().config(), feeTrack,
@@ -2043,8 +2057,12 @@ public:
{
// 7: low mult, no queue, 4 pad
Json::Value req;
Json::Reader().parse(
"{ \"fee_mult_max\" : 5, \"x-assume-tx\" : 4, \"tx_json\" : { } } ", req);
Json::Reader().parse(R"({
"fee_mult_max" : 5,
"x-assume-tx" : 4,
"x-queue-okay" : false,
"tx_json" : { }
})", req);
Json::Value result =
checkFee(req, Role::ADMIN, true,
env.app().config(), feeTrack,
@@ -2057,8 +2075,12 @@ public:
{
// 8: : low mult, can queue, 4 pad
Json::Value req;
Json::Reader().parse(
"{ \"fee_mult_max\" : 5, \"x-assume-tx\" : 4, \"x-queue-okay\" : true \"tx_json\" : { } } ", req);
Json::Reader().parse(R"({
"fee_mult_max" : 5,
"x-assume-tx" : 4,
"x-queue-okay" : true,
"tx_json" : { }
})", req);
Json::Value result =
checkFee(req, Role::ADMIN, true,
env.app().config(), feeTrack,
@@ -2066,7 +2088,27 @@ public:
expect(!RPC::contains_error(result), "Legal checkFee");
expect(req[jss::tx_json].isMember(jss::Fee) &&
req[jss::tx_json][jss::Fee] == 10);
req[jss::tx_json][jss::Fee] == 50);
}
{
// 8a: : different low mult, can queue, 4 pad
Json::Value req;
Json::Reader().parse(R"({
"fee_mult_max" : 1000,
"fee_div_max" : 3,
"x-assume-tx" : 4,
"x-queue-okay" : true,
"tx_json" : { }
})", req);
Json::Value result =
checkFee(req, Role::ADMIN, true,
env.app().config(), feeTrack,
env.app().getTxQ(), env.current());
expect(!RPC::contains_error(result), "Legal checkFee");
expect(req[jss::tx_json].isMember(jss::Fee) &&
req[jss::tx_json][jss::Fee] == 3333);
}
}