Skip to content

Commit 833df20

Browse files
RichardAHdangell7
andauthored
Fix240819 (#350)
fix240918 --------- Co-authored-by: Denis Angell <dangell@transia.co>
1 parent 5737c2b commit 833df20

File tree

8 files changed

+96
-30
lines changed

8 files changed

+96
-30
lines changed

src/ripple/app/misc/NetworkOPs.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,8 +1142,12 @@ NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)
11421142
// Enforce Network bar for emitted txn
11431143
if (view->rules().enabled(featureHooks) && hook::isEmittedTxn(*iTrans))
11441144
{
1145-
JLOG(m_journal.warn())
1146-
<< "Submitted transaction invalid: EmitDetails present.";
1145+
// RH NOTE: Warning removed here due to ConsesusSet using this function
1146+
// which continually triggers this bar. Doesn't seem dangerous, just
1147+
// annoying.
1148+
1149+
// JLOG(m_journal.warn())
1150+
// << "Submitted transaction invalid: EmitDetails present.";
11471151
return;
11481152
}
11491153

@@ -1155,7 +1159,11 @@ NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)
11551159

11561160
if ((flags & SF_BAD) != 0)
11571161
{
1158-
JLOG(m_journal.warn()) << "Submitted transaction cached bad";
1162+
// RH NOTE: Warning removed here due to ConsesusSet using this function
1163+
// which continually triggers this bar. Doesn't seem dangerous, just
1164+
// annoying.
1165+
1166+
// JLOG(m_journal.warn()) << "Submitted transaction cached bad";
11591167
return;
11601168
}
11611169

src/ripple/app/rdb/impl/UnitaryShard.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ updateLedgerDBs(
173173

174174
auto const sParentHash{to_string(ledger->info().parentHash)};
175175
auto const sDrops{to_string(ledger->info().drops)};
176+
auto const closingTime{
177+
ledger->info().closeTime.time_since_epoch().count()};
178+
auto const prevClosingTime{
179+
ledger->info().parentCloseTime.time_since_epoch().count()};
180+
auto const closeTimeRes{ledger->info().closeTimeResolution.count()};
176181
auto const sAccountHash{to_string(ledger->info().accountHash)};
177182
auto const sTxHash{to_string(ledger->info().txHash)};
178183

@@ -188,11 +193,8 @@ updateLedgerDBs(
188193
":closingTime, :prevClosingTime, :closeTimeRes,"
189194
":closeFlags, :accountSetHash, :transSetHash);",
190195
soci::use(sHash), soci::use(ledgerSeq), soci::use(sParentHash),
191-
soci::use(sDrops),
192-
soci::use(ledger->info().closeTime.time_since_epoch().count()),
193-
soci::use(
194-
ledger->info().parentCloseTime.time_since_epoch().count()),
195-
soci::use(ledger->info().closeTimeResolution.count()),
196+
soci::use(sDrops), soci::use(closingTime),
197+
soci::use(prevClosingTime), soci::use(closeTimeRes),
196198
soci::use(ledger->info().closeFlags), soci::use(sAccountHash),
197199
soci::use(sTxHash);
198200

src/ripple/app/rdb/impl/Wallet.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,20 @@ insertPeerReservation(
205205
PublicKey const& nodeId,
206206
std::string const& description)
207207
{
208+
auto const sNodeId = toBase58(TokenType::NodePublic, nodeId);
208209
session << "INSERT INTO PeerReservations (PublicKey, Description) "
209210
"VALUES (:nodeId, :desc) "
210211
"ON CONFLICT (PublicKey) DO UPDATE SET "
211212
"Description=excluded.Description",
212-
soci::use(toBase58(TokenType::NodePublic, nodeId)),
213-
soci::use(description);
213+
soci::use(sNodeId), soci::use(description);
214214
}
215215

216216
void
217217
deletePeerReservation(soci::session& session, PublicKey const& nodeId)
218218
{
219+
auto const sNodeId = toBase58(TokenType::NodePublic, nodeId);
219220
session << "DELETE FROM PeerReservations WHERE PublicKey = :nodeId",
220-
soci::use(toBase58(TokenType::NodePublic, nodeId));
221+
soci::use(sNodeId);
221222
}
222223

223224
bool

src/ripple/app/tx/impl/Transactor.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,12 @@ Transactor::operator()()
19211921
STObject const meta = metaRaw.getAsObject();
19221922

19231923
uint32_t lgrCur = view().seq();
1924+
1925+
bool const has240819 = view().rules().enabled(fix240819);
1926+
1927+
auto const& sfRewardFields =
1928+
*(ripple::SField::knownCodeToField.at(917511 - has240819));
1929+
19241930
// iterate all affected balances
19251931
for (auto const& node : meta.getFieldArray(sfAffectedNodes))
19261932
{
@@ -1932,7 +1938,7 @@ Transactor::operator()()
19321938
if (nodeType != ltACCOUNT_ROOT || metaType == sfDeletedNode)
19331939
continue;
19341940

1935-
if (!node.isFieldPresent(sfFinalFields) ||
1941+
if (!node.isFieldPresent(sfRewardFields) ||
19361942
!node.isFieldPresent(sfLedgerIndex))
19371943
continue;
19381944

@@ -1948,7 +1954,7 @@ Transactor::operator()()
19481954
continue;
19491955

19501956
STObject& finalFields = (const_cast<STObject&>(node))
1951-
.getField(sfFinalFields)
1957+
.getField(sfRewardFields)
19521958
.downcast<STObject>();
19531959

19541960
if (!finalFields.isFieldPresent(sfBalance))

src/ripple/protocol/Feature.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace detail {
7474
// Feature.cpp. Because it's only used to reserve storage, and determine how
7575
// large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than
7676
// the actual number of amendments. A LogicError on startup will verify this.
77-
static constexpr std::size_t numFeatures = 70;
77+
static constexpr std::size_t numFeatures = 71;
7878

7979
/** Amendments that this server supports and the default voting behavior.
8080
Whether they are enabled depends on the Rules defined in the validated
@@ -358,6 +358,7 @@ extern uint256 const fixXahauV2;
358358
extern uint256 const featureRemit;
359359
extern uint256 const featureZeroB2M;
360360
extern uint256 const fixNSDelete;
361+
extern uint256 const fix240819;
361362

362363
} // namespace ripple
363364

src/ripple/protocol/impl/Feature.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ REGISTER_FIX (fixXahauV2, Supported::yes, VoteBehavior::De
464464
REGISTER_FEATURE(Remit, Supported::yes, VoteBehavior::DefaultNo);
465465
REGISTER_FEATURE(ZeroB2M, Supported::yes, VoteBehavior::DefaultNo);
466466
REGISTER_FIX (fixNSDelete, Supported::yes, VoteBehavior::DefaultNo);
467+
REGISTER_FIX (fix240819, Supported::yes, VoteBehavior::DefaultYes);
467468

468469
// The following amendments are obsolete, but must remain supported
469470
// because they could potentially get enabled.

src/ripple/server/impl/BaseWSPeer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ BaseWSPeer<Handler, Impl>::close(
256256
return post(strand_, [self = impl().shared_from_this(), reason] {
257257
self->close(reason);
258258
});
259+
if (do_close_)
260+
return;
259261
do_close_ = true;
260262
if (wq_.empty())
261263
{

src/test/app/XahauGenesis_test.cpp

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3968,8 +3968,8 @@ struct XahauGenesis_test : public beast::unit_test::suite
39683968
using namespace std::chrono_literals;
39693969
testcase("test claim reward valid without unl report");
39703970

3971-
Env env{
3972-
*this, envconfig(), supported_amendments() - featureXahauGenesis};
3971+
Env env{*this, envconfig(), features - featureXahauGenesis};
3972+
bool const has240819 = env.current()->rules().enabled(fix240819);
39733973

39743974
double const rateDrops = 0.00333333333 * 1'000'000;
39753975
STAmount const feesXRP = XRP(1);
@@ -4050,7 +4050,12 @@ struct XahauGenesis_test : public beast::unit_test::suite
40504050
// validate account fields
40514051
STAmount const postUser = preUser + netReward;
40524052
BEAST_EXPECT(expectAccountFields(
4053-
env, user, preLedger, preLedger + 1, postUser, preTime));
4053+
env,
4054+
user,
4055+
preLedger,
4056+
preLedger + 1,
4057+
has240819 ? (preUser - feesXRP) : postUser,
4058+
preTime));
40544059

40554060
env(claimReward(user, env.master), fee(feesXRP), ter(tecHOOK_REJECTED));
40564061
env.close();
@@ -4095,7 +4100,12 @@ struct XahauGenesis_test : public beast::unit_test::suite
40954100
// validate account fields
40964101
STAmount const postUser1 = preUser1 + netReward1;
40974102
BEAST_EXPECT(expectAccountFields(
4098-
env, user, preLedger1, preLedger1 + 1, postUser1, preTime1));
4103+
env,
4104+
user,
4105+
preLedger1,
4106+
preLedger1 + 1,
4107+
has240819 ? (preUser1 - feesXRP) : postUser1,
4108+
preTime1));
40994109
}
41004110

41014111
void
@@ -4219,8 +4229,14 @@ struct XahauGenesis_test : public beast::unit_test::suite
42194229

42204230
// validate account fields
42214231
STAmount const postUser = preUser + netReward;
4232+
bool const has240819 = env.current()->rules().enabled(fix240819);
42224233
BEAST_EXPECT(expectAccountFields(
4223-
env, user, preLedger, preLedger + 1, postUser, preTime));
4234+
env,
4235+
user,
4236+
preLedger,
4237+
preLedger + 1,
4238+
has240819 ? (preUser - feesXRP) : postUser,
4239+
preTime));
42244240
}
42254241

42264242
void
@@ -4352,10 +4368,15 @@ struct XahauGenesis_test : public beast::unit_test::suite
43524368
// validate account fields
43534369
STAmount const postAlice = preAlice + netReward + l1Reward;
43544370
bool const boolResult = withXahauV1 ? true : false;
4371+
bool const has240819 = env.current()->rules().enabled(fix240819);
43554372
BEAST_EXPECT(
43564373
expectAccountFields(
4357-
env, alice, preLedger, preLedger + 1, postAlice, preTime) ==
4358-
boolResult);
4374+
env,
4375+
alice,
4376+
preLedger,
4377+
preLedger + 1,
4378+
has240819 ? (preAlice - feesXRP) : postAlice,
4379+
preTime) == boolResult);
43594380
}
43604381
}
43614382

@@ -4367,6 +4388,7 @@ struct XahauGenesis_test : public beast::unit_test::suite
43674388
testcase("test claim reward optin optout");
43684389

43694390
Env env{*this, envconfig(), features - featureXahauGenesis};
4391+
bool const has240819 = env.current()->rules().enabled(fix240819);
43704392

43714393
double const rateDrops = 0.00333333333 * 1'000'000;
43724394
STAmount const feesXRP = XRP(1);
@@ -4436,7 +4458,12 @@ struct XahauGenesis_test : public beast::unit_test::suite
44364458
// validate account fields
44374459
STAmount const postUser = preUser + netReward;
44384460
BEAST_EXPECT(expectAccountFields(
4439-
env, user, preLedger, preLedger + 1, postUser, preTime));
4461+
env,
4462+
user,
4463+
preLedger,
4464+
preLedger + 1,
4465+
has240819 ? (preUser - feesXRP) : postUser,
4466+
preTime));
44404467

44414468
// opt out of claim rewards
44424469
env(claimReward(user, std::nullopt, 1), fee(feesXRP), ter(tesSUCCESS));
@@ -4461,7 +4488,7 @@ struct XahauGenesis_test : public beast::unit_test::suite
44614488
user,
44624489
preLedger1,
44634490
preLedger1 + 1,
4464-
env.balance(user),
4491+
has240819 ? (env.balance(user) + feesXRP) : env.balance(user),
44654492
preTime1));
44664493
}
44674494

@@ -4543,8 +4570,14 @@ struct XahauGenesis_test : public beast::unit_test::suite
45434570

45444571
// validate account fields
45454572
STAmount const postUser = preUser + netReward;
4573+
bool const has240819 = env.current()->rules().enabled(fix240819);
45464574
BEAST_EXPECT(expectAccountFields(
4547-
env, user, preLedger, preLedger + 1, postUser, preTime));
4575+
env,
4576+
user,
4577+
preLedger,
4578+
has240819 ? preLedger : preLedger + 1,
4579+
has240819 ? (preUser - feesXRP) : postUser,
4580+
preTime));
45484581
}
45494582

45504583
void
@@ -4618,8 +4651,14 @@ struct XahauGenesis_test : public beast::unit_test::suite
46184651

46194652
// validate account fields
46204653
STAmount const postUser = preUser + netReward;
4654+
bool const has240819 = env.current()->rules().enabled(fix240819);
46214655
BEAST_EXPECT(expectAccountFields(
4622-
env, user, preLedger, preLedger + 1, postUser, preTime));
4656+
env,
4657+
user,
4658+
preLedger,
4659+
preLedger + 1,
4660+
has240819 ? (preUser - feesXRP) : postUser,
4661+
preTime));
46234662
}
46244663

46254664
void
@@ -4824,13 +4863,13 @@ struct XahauGenesis_test : public beast::unit_test::suite
48244863
Env env{
48254864
*this,
48264865
makeGenesisConfig(
4827-
supported_amendments() - featureXahauGenesis,
4866+
features - featureXahauGenesis,
48284867
21337,
48294868
"10",
48304869
"1000000",
48314870
"200000",
48324871
0),
4833-
supported_amendments() - featureXahauGenesis};
4872+
features - featureXahauGenesis};
48344873

48354874
STAmount const feesXRP = XRP(1);
48364875

@@ -4890,8 +4929,7 @@ struct XahauGenesis_test : public beast::unit_test::suite
48904929
using namespace std::chrono_literals;
48914930
testcase("test compound interest over 12 claims");
48924931

4893-
Env env{
4894-
*this, envconfig(), supported_amendments() - featureXahauGenesis};
4932+
Env env{*this, envconfig(), features - featureXahauGenesis};
48954933

48964934
double const rateDrops = 0.00333333333 * 1'000'000;
48974935
STAmount const feesXRP = XRP(1);
@@ -4965,8 +5003,14 @@ struct XahauGenesis_test : public beast::unit_test::suite
49655003

49665004
// validate account fields
49675005
STAmount const postUser = preUser + netReward;
5006+
bool const has240819 = env.current()->rules().enabled(fix240819);
49685007
BEAST_EXPECT(expectAccountFields(
4969-
env, user, preLedger, preLedger + 1, postUser, preTime));
5008+
env,
5009+
user,
5010+
preLedger,
5011+
preLedger + 1,
5012+
has240819 ? (preUser - feesXRP) : postUser,
5013+
preTime));
49705014
}
49715015

49725016
STAmount const endBal = env.balance(user);
@@ -5012,6 +5056,7 @@ struct XahauGenesis_test : public beast::unit_test::suite
50125056
using namespace test::jtx;
50135057
auto const sa = supported_amendments();
50145058
testGovernHookWithFeats(sa);
5059+
testRewardHookWithFeats(sa - fix240819);
50155060
testRewardHookWithFeats(sa);
50165061
}
50175062
};

0 commit comments

Comments
 (0)