Skip to content

Commit 8b8efad

Browse files
committed
Remove conditionals for fix1523 enabled 14Nov2017
1 parent 29be2a9 commit 8b8efad

File tree

4 files changed

+15
-176
lines changed

4 files changed

+15
-176
lines changed

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

+11-17
Original file line numberDiff line numberDiff line change
@@ -251,18 +251,13 @@ EscrowCreate::doApply()
251251
}
252252

253253
// If it's not a self-send, add escrow to recipient's owner directory.
254-
if (ctx_.view ().rules().enabled(fix1523))
254+
if (auto const dest = ctx_.tx[sfDestination]; dest != ctx_.tx[sfAccount])
255255
{
256-
auto const dest = ctx_.tx[sfDestination];
257-
258-
if (dest != ctx_.tx[sfAccount])
259-
{
260-
auto page = dirAdd(ctx_.view(), keylet::ownerDir(dest), slep->key(),
261-
false, describeOwnerDir(dest), ctx_.app.journal ("View"));
262-
if (!page)
263-
return tecDIR_FULL;
264-
(*slep)[sfDestinationNode] = *page;
265-
}
256+
auto page = dirAdd(ctx_.view(), keylet::ownerDir(dest), slep->key(),
257+
false, describeOwnerDir(dest), ctx_.app.journal ("View"));
258+
if (!page)
259+
return tecDIR_FULL;
260+
(*slep)[sfDestinationNode] = *page;
266261
}
267262

268263
// Deduct owner's balance, increment owner count
@@ -482,10 +477,10 @@ EscrowFinish::doApply()
482477
}
483478

484479
// Remove escrow from recipient's owner directory, if present.
485-
if (ctx_.view ().rules().enabled(fix1523) && (*slep)[~sfDestinationNode])
480+
if (auto const optPage = (*slep)[~sfDestinationNode]; optPage)
486481
{
487-
auto const page = (*slep)[sfDestinationNode];
488-
if (! ctx_.view().dirRemove(keylet::ownerDir(destID), page, k.key, true))
482+
if (! ctx_.view().dirRemove(
483+
keylet::ownerDir(destID), *optPage, k.key, true))
489484
{
490485
return tefBAD_LEDGER;
491486
}
@@ -564,11 +559,10 @@ EscrowCancel::doApply()
564559
}
565560

566561
// Remove escrow from recipient's owner directory, if present.
567-
if (ctx_.view ().rules().enabled(fix1523) && (*slep)[~sfDestinationNode])
562+
if (auto const optPage = (*slep)[~sfDestinationNode]; optPage)
568563
{
569-
auto const page = (*slep)[sfDestinationNode];
570564
if (! ctx_.view().dirRemove(
571-
keylet::ownerDir((*slep)[sfDestination]), page, k.key, true))
565+
keylet::ownerDir((*slep)[sfDestination]), *optPage, k.key, true))
572566
{
573567
return tefBAD_LEDGER;
574568
}

src/ripple/protocol/Feature.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ extern uint256 const retiredSortedDirectories;
380380
extern uint256 const fix1201;
381381
extern uint256 const fix1512;
382382
extern uint256 const fix1513;
383-
extern uint256 const fix1523;
383+
extern uint256 const retiredFix1523;
384384
extern uint256 const retiredFix1528;
385385
extern uint256 const featureDepositAuth;
386386
extern uint256 const featureChecks;

src/ripple/protocol/impl/Feature.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ uint256 const retiredSortedDirectories = *getRegisteredFeature("SortedDirectorie
171171
uint256 const fix1201 = *getRegisteredFeature("fix1201");
172172
uint256 const fix1512 = *getRegisteredFeature("fix1512");
173173
uint256 const fix1513 = *getRegisteredFeature("fix1513");
174-
uint256 const fix1523 = *getRegisteredFeature("fix1523");
174+
uint256 const retiredFix1523 = *getRegisteredFeature("fix1523");
175175
uint256 const retiredFix1528 = *getRegisteredFeature("fix1528");
176176
uint256 const featureDepositAuth = *getRegisteredFeature("DepositAuth");
177177
uint256 const featureChecks = *getRegisteredFeature("Checks");

src/test/app/Escrow_test.cpp

+2-157
Original file line numberDiff line numberDiff line change
@@ -1056,28 +1056,7 @@ struct Escrow_test : public beast::unit_test::suite
10561056
auto const carol = Account("carol");
10571057

10581058
{
1059-
testcase ("Metadata & Ownership (without fix1523)");
1060-
Env env(*this, supported_amendments() - fix1523);
1061-
env.fund(XRP(5000), alice, bruce, carol);
1062-
1063-
auto const seq = env.seq(alice);
1064-
env(escrow(alice, carol, XRP(1000)), finish_time(env.now() + 1s));
1065-
1066-
BEAST_EXPECT((*env.meta())[sfTransactionResult] ==
1067-
static_cast<std::uint8_t>(tesSUCCESS));
1068-
1069-
auto const escrow = env.le(keylet::escrow(alice.id(), seq));
1070-
BEAST_EXPECT(escrow);
1071-
1072-
ripple::Dir aod (*env.current(), keylet::ownerDir(alice.id()));
1073-
BEAST_EXPECT(std::distance(aod.begin(), aod.end()) == 1);
1074-
BEAST_EXPECT(std::find(aod.begin(), aod.end(), escrow) != aod.end());
1075-
1076-
ripple::Dir cod (*env.current(), keylet::ownerDir(carol.id()));
1077-
BEAST_EXPECT(cod.begin() == cod.end());
1078-
}
1079-
{
1080-
testcase ("Metadata (with fix1523, to self)");
1059+
testcase ("Metadata to self");
10811060

10821061
Env env(*this);
10831062
env.fund(XRP(5000), alice, bruce, carol);
@@ -1141,7 +1120,7 @@ struct Escrow_test : public beast::unit_test::suite
11411120
}
11421121
}
11431122
{
1144-
testcase ("Metadata (with fix1523, to other)");
1123+
testcase ("Metadata to other");
11451124

11461125
Env env(*this);
11471126
env.fund(XRP(5000), alice, bruce, carol);
@@ -1266,139 +1245,6 @@ struct Escrow_test : public beast::unit_test::suite
12661245
}
12671246
}
12681247

1269-
void testDeletedDestination()
1270-
{
1271-
// Make sure an Escrow behaves as expected if its destination is
1272-
// deleted from the ledger. This can only happen if fix1523 is
1273-
// not enabled. fix1523 is what adds the Escrow to the Escrow's
1274-
// destination directory.
1275-
testcase ("Deleted destination");
1276-
1277-
using namespace jtx;
1278-
using namespace std::chrono;
1279-
1280-
Account const alice {"alice"};
1281-
Account const bruce {"bruce"};
1282-
Account const carol {"carol"};
1283-
Account const daria {"daria"};
1284-
Account const evita {"evita"};
1285-
Account const fiona {"fiona"};
1286-
Account const grace {"grace"};
1287-
1288-
Env env(*this, supported_amendments() - fix1523);
1289-
1290-
env.fund(XRP(5000), alice, bruce, carol, daria, evita, fiona, grace);
1291-
env.close();
1292-
1293-
// Because fix1523 is not in play, bruce does not have a back link
1294-
// from his directory to the escrow. So we should be able to delete
1295-
// bruce's account even though he is the destination of an escrow.
1296-
std::uint32_t const aliceEscrowSeq {env.seq(alice)};
1297-
env(escrow(alice, bruce, XRP(1000)), finish_time(env.now() + 1s));
1298-
1299-
// Similar to bruce, we should be able to delete daria's account.
1300-
std::uint32_t const carolEscrowSeq {env.seq(carol)};
1301-
env(escrow(carol, daria, XRP(1000)),
1302-
finish_time(env.now() + 1s), cancel_time(env.now() + 2s));
1303-
env.close();
1304-
1305-
// Now engage fix1523 so any additional escrows we make will have
1306-
// back links from both the source and the destination.
1307-
env.enableFeature (fix1523);
1308-
env.close();
1309-
1310-
// Neither evita not fiona should be able to delete their accounts
1311-
// once this escrow is created.
1312-
std::uint32_t const evitaEscrowSeq {env.seq(evita)};
1313-
env(escrow(evita, fiona, XRP(1000)), finish_time(env.now() + 1s));
1314-
env.close();
1315-
1316-
// Close enough ledgers to be able to delete any of the accounts.
1317-
{
1318-
std::uint32_t const openLedgerSeq {env.current()->seq()};
1319-
int const delta = [&]()->int {
1320-
if (env.seq(alice) + 255 > openLedgerSeq)
1321-
return env.seq(alice) - openLedgerSeq + 255;
1322-
return 0;
1323-
}();
1324-
for (int i = 0; i < delta; ++i)
1325-
env.close();
1326-
}
1327-
1328-
// The presence of escrows should prevent all of the accounts from
1329-
// being deleted except for bruce and daria.
1330-
auto const acctDelFee {drops (env.current()->fees().increment)};
1331-
env (acctdelete (alice, grace), fee (acctDelFee), ter (tecHAS_OBLIGATIONS));
1332-
env (acctdelete (bruce, grace), fee (acctDelFee));
1333-
env (acctdelete (carol, grace), fee (acctDelFee), ter (tecHAS_OBLIGATIONS));
1334-
env (acctdelete (daria, grace), fee (acctDelFee));
1335-
env (acctdelete (evita, grace), fee (acctDelFee), ter (tecHAS_OBLIGATIONS));
1336-
env (acctdelete (fiona, grace), fee (acctDelFee), ter (tecHAS_OBLIGATIONS));
1337-
env.close();
1338-
1339-
// At this point the destination of alice's escrow is missing. Make
1340-
// sure the escrow still behaves well. In particular, an EscrowFinish
1341-
// should fail but leave the Escrow object in the ledger.
1342-
env(finish(alice, alice, aliceEscrowSeq), ter(tecNO_DST));
1343-
env.close();
1344-
1345-
// Verify that alice's escrow remains in the ledger.
1346-
Keylet const aliceEscrowKey {
1347-
keylet::escrow (alice.id(), aliceEscrowSeq)};
1348-
BEAST_EXPECT (env.current()->exists (aliceEscrowKey));
1349-
1350-
// Since alice still has the escrow she should not be able to delete
1351-
// her account.
1352-
env (acctdelete (alice, grace), fee (acctDelFee), ter (tecHAS_OBLIGATIONS));
1353-
1354-
// The fact that the destination of carol's escrow has evaporated
1355-
// should have no impact on whether carol's escrow can be canceled.
1356-
env(cancel(carol, carol, carolEscrowSeq));
1357-
env.close();
1358-
1359-
// Now that carol's escrow is gone carol should be able to delete
1360-
// her account.
1361-
env (acctdelete (carol, grace), fee (acctDelFee));
1362-
env.close();
1363-
1364-
// We'll now resurrect bruce's account. alice should then be able to
1365-
// finish her escrow.
1366-
env(pay (grace, bruce, XRP (5000)));
1367-
env.close();
1368-
1369-
// bruce's account should have returned to the ledger.
1370-
BEAST_EXPECT (env.current()->exists (keylet::account (bruce.id())));
1371-
BEAST_EXPECT (env.balance (bruce) == XRP (5000));
1372-
1373-
// Verify that alice's escrow is still in the ledger.
1374-
BEAST_EXPECT (env.current()->exists (aliceEscrowKey));
1375-
1376-
// alice finishes her escrow to bruce's resurrected account.
1377-
env(finish(alice, alice, aliceEscrowSeq));
1378-
env.close();
1379-
1380-
// Verify that alice's escrow is gone from the ledger.
1381-
BEAST_EXPECT (! env.current()->exists (aliceEscrowKey));
1382-
1383-
// Now alice can delete her account.
1384-
env (acctdelete (alice, grace), fee (acctDelFee));
1385-
env.close();
1386-
1387-
// eveta and fiona are still prevented from deletion by evita's escrow.
1388-
env (acctdelete (evita, grace), fee (acctDelFee), ter (tecHAS_OBLIGATIONS));
1389-
env (acctdelete (fiona, grace), fee (acctDelFee), ter (tecHAS_OBLIGATIONS));
1390-
env.close();
1391-
1392-
// Finish evita's escrow. Then both evita's and fiona's accounts can
1393-
// be deleted.
1394-
env(finish(fiona, evita, evitaEscrowSeq));
1395-
env.close();
1396-
1397-
env (acctdelete (evita, grace), fee (acctDelFee));
1398-
env (acctdelete (fiona, grace), fee (acctDelFee));
1399-
env.close();
1400-
}
1401-
14021248
void run() override
14031249
{
14041250
testEnablement();
@@ -1411,7 +1257,6 @@ struct Escrow_test : public beast::unit_test::suite
14111257
testEscrowConditions();
14121258
testMetaAndOwnership();
14131259
testConsequences();
1414-
testDeletedDestination();
14151260
}
14161261
};
14171262

0 commit comments

Comments
 (0)