Skip to content

Commit

Permalink
Remove support for TransactionMeta v1
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjove committed Apr 3, 2020
1 parent f25cabe commit 6caec76
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 43 deletions.
6 changes: 0 additions & 6 deletions docs/stellar-core_example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,6 @@ DISABLE_XDR_FSYNC=false
# testing purposes.
MAX_SLOTS_TO_REMEMBER=12

# SUPPORTED_META_VERSION (1 or 2) defaults to 1.
# If set to 1, stellar-core will emit TransactionMeta as TransactionMetaV1. If
# set to 2, stellar-core will emit TransactionMeta as TransactionMetaV2. Do not
# set to 2 unless your downstream systems support TransactionMetaV2.
SUPPORTED_META_VERSION=1

# METADATA_OUTPUT_STREAM defaults to "", disabling it.
# A string specifying a stream to write fine-grained metadata to for each ledger
# close while running. This will be opened at startup and synchronously
Expand Down
2 changes: 1 addition & 1 deletion src/ledger/LedgerManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ LedgerManagerImpl::applyTransactions(
for (auto tx : txs)
{
auto txTime = mTransactionApply.TimeScope();
TransactionMeta tm(mApp.getConfig().SUPPORTED_META_VERSION);
TransactionMeta tm(2);
CLOG(DEBUG, "Tx") << " tx#" << index << " = "
<< hexAbbrev(tx->getFullHash())
<< " ops=" << tx->getNumOperations()
Expand Down
6 changes: 0 additions & 6 deletions src/main/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ Config::Config() : NODE_SEED(SecretKey::random())
BEST_OFFERS_CACHE_SIZE = 64;
PREFETCH_BATCH_SIZE = 1000;

SUPPORTED_META_VERSION = 1;

#ifdef BUILD_TESTS
TEST_CASES_ENABLED = false;
#endif
Expand Down Expand Up @@ -971,10 +969,6 @@ Config::processConfig(std::shared_ptr<cpptoml::table> t)
{
domainQualityMap = parseDomainsQuality(item.second);
}
else if (item.first == "SUPPORTED_META_VERSION")
{
SUPPORTED_META_VERSION = readInt<uint32_t>(item, 1, 2);
}
else if (item.first == "SURVEYOR_KEYS")
{
// processed later (may depend on previously defined public
Expand Down
5 changes: 0 additions & 5 deletions src/main/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,6 @@ class Config : public std::enable_shared_from_this<Config>
// the entry cache
size_t PREFETCH_BATCH_SIZE;

// The version of TransactionMeta that will be generated. Acceptable values
// are 1 (default) and 2. Set to 2 only if downstream systems have been
// updated to handle TransactionMetaV2.
int32_t SUPPORTED_META_VERSION;

#ifdef BUILD_TESTS
// If set to true, the application will be aware this run is for a test
// case. This is used right now in the signal handler to exit() instead of
Expand Down
3 changes: 1 addition & 2 deletions src/transactions/FeeBumpTransactionFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ FeeBumpTransactionFrame::apply(Application& app, AbstractLedgerTxn& ltx,
LedgerTxn ltxTx(ltx);
removeOneTimeSignerKeyFromFeeSource(ltxTx);

auto& txChanges =
meta.v() == 1 ? meta.v1().txChanges : meta.v2().txChangesBefore;
auto& txChanges = meta.v2().txChangesBefore;
txChanges = ltxTx.getChanges();
ltxTx.commit();
}
Expand Down
31 changes: 8 additions & 23 deletions src/transactions/TransactionFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,8 +668,7 @@ TransactionFrame::applyOperations(SignatureChecker& signatureChecker,
bool success = true;

TransactionMeta newMeta(2);
auto& operationsMeta = newMeta.v2().operations;
operationsMeta.reserve(getNumOperations());
newMeta.v2().operations.reserve(getNumOperations());

// shield outer scope of any side effects with LedgerTxn
LedgerTxn ltxTx(ltx);
Expand All @@ -691,7 +690,7 @@ TransactionFrame::applyOperations(SignatureChecker& signatureChecker,
op->getOperation(), op->getResult(), ltxOp.getDelta());
}

operationsMeta.emplace_back(ltxOp.getChanges());
newMeta.v2().operations.emplace_back(ltxOp.getChanges());
ltxOp.commit();
}

Expand All @@ -717,14 +716,9 @@ TransactionFrame::applyOperations(SignatureChecker& signatureChecker,

ltxTx.commit();
// commit -> propagate the meta to the outer scope
auto& omOperations = outerMeta.v() == 1 ? outerMeta.v1().operations
: outerMeta.v2().operations;
std::swap(omOperations, operationsMeta);
if (outerMeta.v() == 2)
{
std::swap(outerMeta.v2().txChangesAfter,
newMeta.v2().txChangesAfter);
}
std::swap(outerMeta.v2().operations, newMeta.v2().operations);
std::swap(outerMeta.v2().txChangesAfter,
newMeta.v2().txChangesAfter);
}
else
{
Expand Down Expand Up @@ -761,15 +755,8 @@ TransactionFrame::applyOperations(SignatureChecker& signatureChecker,
internalErrorCounter.inc();

// operations and txChangesAfter should already be empty at this point
if (outerMeta.v() == 1)
{
outerMeta.v1().operations.clear();
}
else
{
outerMeta.v2().operations.clear();
outerMeta.v2().txChangesAfter.clear();
}
outerMeta.v2().operations.clear();
outerMeta.v2().txChangesAfter.clear();
return false;
}

Expand All @@ -796,11 +783,9 @@ TransactionFrame::apply(Application& app, AbstractLedgerTxn& ltx,
auto signaturesValid = cv >= (ValidationType::kInvalidPostAuth) &&
processSignatures(signatureChecker, ltxTx);

auto& txChanges =
meta.v() == 1 ? meta.v1().txChanges : meta.v2().txChangesBefore;
auto changes = ltxTx.getChanges();
std::move(changes.begin(), changes.end(),
std::back_inserter(txChanges));
std::back_inserter(meta.v2().txChangesBefore));
ltxTx.commit();

bool valid = signaturesValid && cv == ValidationType::kFullyValid;
Expand Down

5 comments on commit 6caec76

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

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

saw approval from MonsieurNicolas
at jonjove@6caec76

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

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

merging jonjove/stellar-core/remove-meta-v1 = 6caec76 into auto

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

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

jonjove/stellar-core/remove-meta-v1 = 6caec76 merged ok, testing candidate = 6d510a8

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

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

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

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

fast-forwarding master to auto = 6d510a8

Please sign in to comment.