Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1165f63
bump to protocol v10
MonsieurNicolas Nov 27, 2017
03174c9
added "exists" method to testAccount
MonsieurNicolas Jan 30, 2018
44bd9e7
removed obsolete calls to setCurrentLedgerVersion in txEnvelopeTests
MonsieurNicolas Jan 30, 2018
534caf7
move tests for bound checking into their own sections
MonsieurNicolas Jan 30, 2018
10179d6
Move to new meta format
MonsieurNicolas Jan 30, 2018
69dda2e
Process sequence number during apply
MonsieurNicolas Jan 30, 2018
f879d41
reworked herder test to be a bit more representative of what is going on
MonsieurNicolas Jan 30, 2018
2e67acb
reworked logic for testing transactions (applyCheck)
MonsieurNicolas Jan 30, 2018
e82be46
Add the BumpSequence Operation & Tests
JeremyRubin Sep 22, 2017
7e5e2a0
Fix to make BumpSequence target the source
JeremyRubin Sep 22, 2017
805c759
small refactors, load account instead of direct access
JeremyRubin Sep 23, 2017
7506448
Refactor to use native tx_NOACCOUNT error
JeremyRubin Sep 25, 2017
d2d7871
updated Visual Studio project with BumpSeq files
MonsieurNicolas Mar 20, 2018
cbd8d6f
clang-format & renamed BUMP_SEQ -> BUMP_SEQUENCE
MonsieurNicolas Feb 1, 2018
e5a7110
updated BumpSequence to be compliant with specification dated 13-Oct-…
MonsieurNicolas Feb 1, 2018
7a15050
introduce opNOT_SUPPORTED when operations are not supported (yet/anym…
MonsieurNicolas Feb 3, 2018
e9ed4c5
remove BUMP_SEQUENCE_NOT_SUPPORTED_YET, use operation level failure i…
MonsieurNicolas Feb 3, 2018
1f05651
added safeConvertToSigned utility function
MonsieurNicolas Feb 5, 2018
1082eb0
make it safe for sequence numbers to use the entire uint64 space
MonsieurNicolas Feb 5, 2018
4fe0945
update BumpSequence to allow bumping through the entire uint64 space
MonsieurNicolas Feb 5, 2018
6257cb2
make AccountMerge fail when the current sequence number is too far
MonsieurNicolas Feb 5, 2018
474ece9
added tests for sequence number overflow
MonsieurNicolas Feb 5, 2018
d7a12fd
added missing merge test (signers)
MonsieurNicolas Feb 6, 2018
f9f9187
make SequenceNumber a signed integer (BumpSeq proposal 08-Feb-2018)
MonsieurNicolas Feb 9, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update BumpSequence to allow bumping through the entire uint64 space
This makes it compliant with the proposal dated 02-Feb-2018
stellar/stellar-protocol#53
  • Loading branch information
MonsieurNicolas committed Mar 20, 2018
commit 4fe0945a8ce378e9149097bea3168d06a4fa775c
2 changes: 0 additions & 2 deletions src/test/TestExceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ throwIf(BumpSequenceResult const& result)
{
case BUMP_SEQUENCE_SUCCESS:
break;
case BUMP_SEQUENCE_TOO_FAR:
throw ex_BUMP_SEQUENCE_TOO_FAR{};
default:
throw ex_UNKNOWN{};
}
Expand Down
2 changes: 0 additions & 2 deletions src/test/TestExceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ TEST_EXCEPTION(ex_ALLOW_TRUST_TRUST_NOT_REQUIRED)
TEST_EXCEPTION(ex_ALLOW_TRUST_CANT_REVOKE)
TEST_EXCEPTION(ex_ALLOW_TRUST_SELF_NOT_ALLOWED)

TEST_EXCEPTION(ex_BUMP_SEQUENCE_TOO_FAR)

TEST_EXCEPTION(ex_CREATE_ACCOUNT_MALFORMED)
TEST_EXCEPTION(ex_CREATE_ACCOUNT_UNDERFUNDED)
TEST_EXCEPTION(ex_CREATE_ACCOUNT_LOW_RESERVE)
Expand Down
17 changes: 4 additions & 13 deletions src/transactions/BumpSequenceOpFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,13 @@ BumpSequenceOpFrame::doApply(Application& app, LedgerDelta& delta,
{
SequenceNumber current = mSourceAccount->getSeqNum();

SequenceNumber maxBump = ledgerManager.getCurrentLedgerHeader().ledgerSeq;
maxBump = (maxBump << 32) - 1;

if (mBumpSequenceOp.bumpTo > maxBump)
// Apply the bump (bump succeeds silently if bumpTo <= current)
if (mBumpSequenceOp.bumpTo > current)
{
app.getMetrics()
.NewMeter({"op-bump-sequence", "failure", "too-far"}, "operation")
.Mark();
innerResult().code(BUMP_SEQUENCE_TOO_FAR);
return false;
mSourceAccount->setSeqNum(mBumpSequenceOp.bumpTo);
mSourceAccount->storeChange(delta, ledgerManager.getDatabase());
}

// Apply the bump (bump succeeds silently if bumpTo < current)
mSourceAccount->setSeqNum(std::max(mBumpSequenceOp.bumpTo, current));
mSourceAccount->storeChange(delta, ledgerManager.getDatabase());

// Return successful results
innerResult().code(BUMP_SEQUENCE_SUCCESS);
app.getMetrics()
Expand Down
48 changes: 21 additions & 27 deletions src/transactions/BumpSequenceTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,34 @@ TEST_CASE("bump sequence", "[tx][bumpsequence]")
auto a = root.create("A", lm.getMinBalance(0) + 1000);
auto b = root.create("B", lm.getMinBalance(0) + 1000);

// close the ledger (this is required as bumpseq cannot work for
// an account just created)
closeLedgerOn(*app, 2, 1, 1, 2018);

SequenceNumber maxSeqNum =
(uint64(lm.getCurrentLedgerHeader().ledgerSeq) << 32) - 1;

for_versions_from(10, *app, [&]() {
SECTION("test success")
{
SECTION("min jump")
SECTION("test success")
{
for_versions_from(10, *app, [&]() {
SECTION("small bump")
{
auto newSeq = a.loadSequenceNumber() + 2;
a.bumpSequence(newSeq);
REQUIRE(a.loadSequenceNumber() == newSeq);
}
SECTION("max jump")
SECTION("large bump")
{
a.bumpSequence(maxSeqNum);
REQUIRE(a.loadSequenceNumber() == maxSeqNum);
auto newSeq = UINT64_MAX;
a.bumpSequence(newSeq);
REQUIRE(a.loadSequenceNumber() == newSeq);
}
}
SECTION("errors")
{
SECTION("too far")
SECTION("backward jump (no-op)")
{
auto prev = a.loadSequenceNumber();
REQUIRE_THROWS_AS(a.bumpSequence(maxSeqNum + 1),
ex_BUMP_SEQUENCE_TOO_FAR);
REQUIRE(a.loadSequenceNumber() == prev + 1);
auto oldSeq = a.loadSequenceNumber();
a.bumpSequence(1);
// tx consumes sequence, bumpSequence doesn't do anything
REQUIRE(a.loadSequenceNumber() == oldSeq + 1);
}
}
});
for_versions_to(9, *app, [&]() {
REQUIRE_THROWS_AS(a.bumpSequence(maxSeqNum), ex_opNOT_SUPPORTED);
});
});
}
SECTION("not supported")
{
for_versions_to(9, *app, [&]() {
REQUIRE_THROWS_AS(a.bumpSequence(1), ex_opNOT_SUPPORTED);
});
}
}
5 changes: 2 additions & 3 deletions src/xdr/Stellar-transaction.x
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,9 @@ default:
enum BumpSequenceResultCode
{
// codes considered as "success" for the operation
BUMP_SEQUENCE_SUCCESS = 0,
BUMP_SEQUENCE_SUCCESS = 0
// codes considered as "failure" for the operation
BUMP_SEQUENCE_TOO_FAR =
-1 // operation would bump past the maximum sequence number allowed
// (this operation never fails)
};

union BumpSequenceResult switch (BumpSequenceResultCode code)
Expand Down