Skip to content
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

Fee-Bump Transactions #2258

Closed
wants to merge 15 commits into from
Closed

Fee-Bump Transactions #2258

wants to merge 15 commits into from

Conversation

jonjove
Copy link
Contributor

@jonjove jonjove commented Aug 29, 2019

Implements fee-bump transactions, although not exactly as proposed in https://github.com/stellar/stellar-protocol/blob/master/core/cap-0015.md. Some key changes:

  • Make TransactionEnvelope into an XDR union
  • Create an abstract base class for TransactionFrame
  • Require TransactionEnvelope signatures are sorted
  • Support multiple transactions with the same inner transaction for fixed (sourceAccount, seqNum) in TransactionQueue
  • Redesign TxSetFrame trimming, validity checking, and surge pricing

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v5.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

switch (txenv.type())
{
case ENVELOPE_TYPE_TX_V0:
signtxn(txenv.v0(), sk, sha256(netId));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing break

struct FeeBumpTransaction
{
AccountID feeSource;
uint64 fee;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CAP update: int64 (uint64 is usually problematic)

* a TransactionSignaturePayload */
DecoratedSignature signatures<20>;
union TransactionEnvelope switch (EnvelopeType type) {
case ENVELOPE_TYPE_TX_V0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open question:
should we do what CAP19 describes, introducing ENVELOPE_TYPE_TX.
As we have the notion of normalization (for hashing), we could mutate the payload any way we want when un-marshaling, in particular, we could just always convert to ENVELOPE_TYPE_TX and never deal with tx0.

Less code change related to the removal of the "AccountID" member (not just in this commit but in SDKs as well).

@@ -792,6 +835,7 @@ default:

enum TransactionResultCode
{
txFEE_BUMPED = 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need a comment here that explains that InnerTransactionResult needs to be kept in sync

case txSUCCESS:
case txFAILED:
OperationResult results<>;
case txTOO_EARLY:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment txFEE_BUMPED not included

// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0

#include "herder/TransactionQueue.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not call this file FeeBumpTests.cpp : it's the same filename used in the transactions test suite

// seqNum is unconstrained user input.
int64_t seqNum = tx->getSeqNum();
int64_t start = transactions.front().front()->getSeqNum();
if (seqNum >= start && (seqNum - start) < transactions.size())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signed/unsigned comparison

}
else
{
transactions.emplace_back(1, tx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe consider using
transactions.emplace_back(std::vector<TransactionFrameBasePtr>{tx});
(easier to read than transactions.emplace_back(1, tx);)

if ((*txIt)->getFullHash() != tx->getFullHash())
addFee(tx);

auto& transactions = mPendingTransactions[tx->getSourceID()].mTransactions;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we should have transactions be a *parameter (avoids the extra findTx call), and when null, would add the entry for that user

@@ -542,6 +542,12 @@ CommandHandler::tx(std::string const& params, std::string& retStr)
decoder::decode_b64(blob, binBlob);

xdr::xdr_from_opaque(binBlob, envelope);
if (envelope.type() == ENVELOPE_TYPE_TX_V0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general, it seems we're missing tests for txNOT_NORMALIZED.
Envelope test in particular: I am surprised this didn't trip in the multi sig case; maybe we should randomize them better?

We may want to land #2129 before.

@MonsieurNicolas
Copy link
Contributor

closing as this is obsolete now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants