-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Unconditionalize 2017 amendments #3292
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Left a couple of comments, most of which are at your discretion. Please remove the dead code I pointed out; once that's done, this is a 👍 from me.
@@ -119,8 +119,7 @@ RCLConsensus::Adaptor::acquireLedger(LedgerHash const& hash) | |||
// Notify inbound transactions of the new ledger sequence number | |||
inboundTransactions_.newRound(built->info().seq); | |||
|
|||
// Use the ledger timing rules of the acquired ledger | |||
parms_.useRoundedCloseTime = built->rules().enabled(fix1528); | |||
parms_.useRoundedCloseTime = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that with this change, useRoundedCloseTime
will only ever be true
, in which case this member (and the conditionals it control) can be removed. Please double-check if that's the case.
@@ -90,51 +90,48 @@ ApplyContext::checkInvariantsHelper( | |||
XRPAmount const fee, | |||
std::index_sequence<Is...>) | |||
{ | |||
if (view_->rules().enabled(featureEnforceInvariants)) | |||
auto checkers = getInvariantChecks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this can be moved inside the try
. I don't know that it matters much, but just pointing it out.
src/ripple/app/tx/impl/Escrow.cpp
Outdated
@@ -488,10 +477,10 @@ EscrowFinish::doApply() | |||
} | |||
|
|||
// Remove escrow from recipient's owner directory, if present. | |||
if (ctx_.view ().rules().enabled(fix1523) && (*slep)[~sfDestinationNode]) | |||
if (auto const optPage = (*slep)[~sfDestinationNode]; optPage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, what do others think about code clarity? Are the two forms identical or am I missing something?
if (auto const optPage = (*slep)[~sfDestinationNode]; optPage))
vs.
if (auto const optPage = (*slep)[~sfDestinationNode])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two forms have identical results. I'm happy to change. The second form is more in keeping with the rest of the code base.
src/ripple/ledger/impl/View.cpp
Outdated
if (strictOrder) | ||
return view.dirAppend(dir, uLedgerIndex, fDescriber); | ||
else | ||
return view.dirInsert(dir, uLedgerIndex, fDescriber); | ||
|
||
JLOG (j.trace()) << "dirAdd:" << |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we unconditionalized this amendment, the code from here on down and until the end of the function—about 100 lines worth—is unreachable and can simply be eliminated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I was not paying close enough attention. Thanks.
src/ripple/protocol/Feature.h
Outdated
@@ -366,24 +365,23 @@ foreachFeature(FeatureBitset bs, F&& f) | |||
|
|||
extern uint256 const featureTickets; | |||
extern uint256 const featureOwnerPaysFee; | |||
extern uint256 const featureCompareFlowV1V2; | |||
extern uint256 const featurePayChan; | |||
extern uint256 const retiredPayChan; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to group the unconditionalized amendments together at the bottom, with a comment explaining that they are amendments that have been activated and are live and the "pre-amendment" code has been removed.
6bc0e72
to
d7fc6f0
Compare
@nbougalis, thanks for the review comments. I believe all your comments have been addressed. If I missed anything please let me know. BTW, despite how Github displays them, the [FOLD] commits are actually placed immediately adjacent to their target in the commit stack. I dunno why Github shows them in time order not in commit order, but here we are... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just have a question, actually in previously merged code. Sorry I did not review that PR, nor the spec. About the warning in ApplicationImp::loadOldLedger(), when an really old ledger is replayed, the code logs a warning message and continues. What are the possible outcomes? I mean, will unrecognized data be ignored? Or will data be handled differently which could result in some different states, but no long term effect because later ledgers will be correctly replayed, or something else? Will the expected behavior be tested?
Hi @pwang200, thanks for the review.
First, it's important to know that the warning is associated with replaying ledgers more than two years old. Replaying a ledger is a debugging technique that must be actively requested by someone using rippled. And ledger replay happens on a stand-alone rippled instance; it never happens on the live network. With that background, let me get back to your original question. There are three possible outcomes. From most likely to least likely they are:
Even in the crashing case nothing bad happens to the network, since the replay is done on a stand-alone instance If someone wants to understand why an old transaction originally played the way it did, and they run across case 2 or 3, then they would need to build an old version of the server from source and use it for the replay. That's also the advice that the warning provides. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation of my question. It is very clear.
src/ripple/protocol/Feature.h
Outdated
@@ -369,7 +369,7 @@ extern uint256 const featurePayChan; | |||
extern uint256 const featureFlow; | |||
extern uint256 const featureCompareTakerFlowCross; | |||
extern uint256 const featureFlowCross; | |||
extern uint256 const featureCryptoConditions; | |||
extern uint256 const retiredCryptoConditions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed no rule enabled calls were removed. I assume the amendment was never proposed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure about the history. Apparently the amendment was already unconditionalized before I got here. It looks like it had to do with SusPay
, which was never enabled (https://xrpl.org/known-amendments.html#cryptoconditions). But the CryptoConditions amendment is live and on the ledger.
src/ripple/protocol/impl/Feature.cpp
Outdated
@@ -161,7 +161,7 @@ uint256 const featureFlow = *getRegisteredFeature("Flow"); | |||
uint256 const featureCompareTakerFlowCross = *getRegisteredFeature("CompareTakerFlowCross"); | |||
uint256 const featureFlowCross = *getRegisteredFeature("FlowCross"); | |||
uint256 const retiredCryptoConditions = *getRegisteredFeature("CryptoConditions"); | |||
uint256 const featureTickSize = *getRegisteredFeature("TickSize"); | |||
uint256 const retiredTickSize = *getRegisteredFeature("TickSize"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing a retired tick size is full
:)
// some circumstances, it is possible for the deferred credits table | ||
// to compute usable balance just slightly above what the ledger | ||
// calculates (but always less than the actual balance). | ||
auto adjustedAmt = std::min({amount, lastBal - delta, minBal}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent comment!
|
||
std::pair<TER, Strand> | ||
toStrandV2 ( | ||
toStrand ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great reduction in unnecessary code!
src/ripple/ledger/impl/View.cpp
Outdated
if (strictOrder) | ||
return view.dirAppend(dir, uLedgerIndex, fDescriber); | ||
else | ||
return view.dirInsert(dir, uLedgerIndex, fDescriber); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider eliminating the else
statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah never mind, I see you did that in a later commit.
src/ripple/app/tx/impl/Escrow.cpp
Outdated
if (! ctx_.view().dirRemove( | ||
keylet::ownerDir((*slep)[sfDestination]), page, k.key, true)) | ||
keylet::ownerDir((*slep)[sfDestination]), *optPage, k.key, true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: beyond 80 cols, consider removing one tab indentation.
@@ -33,6 +33,8 @@ class AccountSet_test : public beast::unit_test::suite | |||
|
|||
void testNullAccountSet() | |||
{ | |||
testcase ("No AccountSet"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job giving these names.
src/test/rpc/AccountSet_test.cpp
Outdated
using namespace test::jtx; | ||
auto runTest = [](Env&& env, double tr) | ||
|
||
auto runTest = [this](double tr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think transferRate
or rate
might be an improvement over tr
.
src/test/rpc/AccountSet_test.cpp
Outdated
// Test gateway with a variety of allowed transfer rates | ||
for (double tr = 1.0; tr <= 2.0; tr += 0.03125) | ||
{ | ||
runTest (tr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering the runTest
lambda is now only called from here, why not just move the code inside the loop?
// operation of these legacy TransferRates. | ||
// | ||
// Two out-of-bound values are currently in the ledger (March 2020) | ||
// They are 4.0 and 4.294967295. So those are the values we test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent comments!
src/test/rpc/AccountSet_test.cpp
Outdated
// | ||
// Two out-of-bound values are currently in the ledger (March 2020) | ||
// They are 4.0 and 4.294967295. So those are the values we test. | ||
for (double tr : {4.0, 4.294967295}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider renaming tr
to transferRate
or rate
.
env.enableFeature(fix1201); | ||
env.trust(USD(10), alice, bob); | ||
env.close(); | ||
env(rate(gw, 2.0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the rate be set here to tr
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We wish to use use transferRate
, but transferRate
is currently invalid. So we hack the invalid value into the ledger a few lines down. I'm adding the following comment to justify the 2.0
:
// We'd like to use transferRate here, but the transactor
// blocks transfer rates that large. So we use an acceptable
// transfer rate here and later hack the ledger to replace
// the acceptable value with an out-of-bounds value.
d7fc6f0
to
a90f5ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@miguelportilla, thanks for the great review. I think I've addressed all your comments. At your convenience let me know if I missed anything. Thanks.
env.enableFeature(fix1201); | ||
env.trust(USD(10), alice, bob); | ||
env.close(); | ||
env(rate(gw, 2.0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We wish to use use transferRate
, but transferRate
is currently invalid. So we hack the invalid value into the ledger a few lines down. I'm adding the following comment to justify the 2.0
:
// We'd like to use transferRate here, but the transactor
// blocks transfer rates that large. So we use an acceptable
// transfer rate here and later hack the ledger to replace
// the acceptable value with an out-of-bounds value.
Codecov Report
@@ Coverage Diff @@
## develop #3292 +/- ##
===========================================
- Coverage 70.61% 70.54% -0.08%
===========================================
Files 676 676
Lines 54339 54112 -227
===========================================
- Hits 38374 38173 -201
+ Misses 15965 15939 -26
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
a90f5ee
to
0d83223
Compare
Squashed all fixes into their appropriate commits and rebased to 1.6.0-b1. |
Amendments that were enabled in 2017 have now been on the books and active for over two years. Once an amendment is enabled it cannot be revoked. So the only situations where these amendments are disabled is when replaying ledgers (and their contained transactions) from before 2018.
It is uncommon, but not unheard of, to want to replay ledgers that are more than two years old. If these changes are accepted into the code base then a user wanting to replay a ledger from before 2018 will need to build an old version of the rippled code. This requirement is reinforced by a message that the rippled software generates if it is asked to replay a ledger from before 2018.
This pull request consists of a collection of small commits. Each commit unconditionalizes one specific amendment. Each commit is, to all intents and purposes, standalone. Reviewing the commits one at a time may make the review process easier. My intention is that these separate commits will not be squashed before merging. That way, in case one of the commits has an error, identifying the problem using a binary search will be easier.