Skip to content

Commit

Permalink
added restore tx meta
Browse files Browse the repository at this point in the history
  • Loading branch information
SirTyson committed Oct 10, 2024
1 parent 1dfeaf1 commit f09f6ea
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/transactions/FeeBumpTransactionFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ FeeBumpTransactionFrame::sorobanResources() const
return mInnerTx->sorobanResources();
}

#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
xdr::xvector<ArchivalProof> const&
FeeBumpTransactionFrame::sorobanProofs() const
{
return mInnerTx->sorobanProofs();
}
#endif

FeeBumpTransactionFrame::FeeBumpTransactionFrame(
Hash const& networkID, TransactionEnvelope const& envelope)
Expand Down
34 changes: 34 additions & 0 deletions src/transactions/TransactionFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,32 @@ namespace
// Limit to the maximum resource fee allowed for transaction,
// roughly 112 million lumens.
int64_t const MAX_RESOURCE_FEE = 1LL << 50;

// Starting in protocol 23, some operation meta needs to be modified
// to be consumed by downstream systems. In particular, restoration is
// logically a new entry creation from the perspective of ltx and stellar-core
// as a whole, but this change type is reclassified to LEDGER_ENTRY_RESTORED
// for easier consumption downstream.
void
processOpLedgerEntryChanges(std::shared_ptr<OperationFrame const> op,
LedgerEntryChanges& changes)
{
if (op->getOperation().body.type() != RESTORE_FOOTPRINT)
{
return;
}

for (auto& change : changes)
{
if (change.type() == LEDGER_ENTRY_CREATED)
{
auto le = change.created();
change.type(LEDGER_ENTRY_RESTORED);
change.restored() = le;
}
}
}

} // namespace

using namespace std;
Expand Down Expand Up @@ -1638,6 +1664,14 @@ TransactionFrame::applyOperations(SignatureChecker& signatureChecker,
// The operation meta will be empty if the transaction
// doesn't succeed so we may as well not do any work in that
// case
auto changes = ltxOp.getChanges();

if (protocolVersionStartsFrom(
ledgerVersion,
Bucket::FIRST_PROTOCOL_SUPPORTING_PERSISTENT_EVICTION))
{
processOpLedgerEntryChanges(op, changes);
}
operationMetas.emplace_back(ltxOp.getChanges());
}

Expand Down
3 changes: 1 addition & 2 deletions src/transactions/test/InvokeHostFunctionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2914,8 +2914,7 @@ TEST_CASE("state archival operation errors", "[tx][soroban][archival]")
}

#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
TEST_CASE("evicted persistent entries"
"[tx][soroban][archival]")
TEST_CASE("evicted persistent entries", "[tx][soroban][archival]")
{
auto test = [](bool requireProofs) {
auto cfg = getTestConfig();
Expand Down

0 comments on commit f09f6ea

Please sign in to comment.