Skip to content

Commit f09f6ea

Browse files
committed
added restore tx meta
1 parent 1dfeaf1 commit f09f6ea

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

src/transactions/FeeBumpTransactionFrame.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ FeeBumpTransactionFrame::sorobanResources() const
5454
return mInnerTx->sorobanResources();
5555
}
5656

57+
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
5758
xdr::xvector<ArchivalProof> const&
5859
FeeBumpTransactionFrame::sorobanProofs() const
5960
{
6061
return mInnerTx->sorobanProofs();
6162
}
63+
#endif
6264

6365
FeeBumpTransactionFrame::FeeBumpTransactionFrame(
6466
Hash const& networkID, TransactionEnvelope const& envelope)

src/transactions/TransactionFrame.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,32 @@ namespace
5656
// Limit to the maximum resource fee allowed for transaction,
5757
// roughly 112 million lumens.
5858
int64_t const MAX_RESOURCE_FEE = 1LL << 50;
59+
60+
// Starting in protocol 23, some operation meta needs to be modified
61+
// to be consumed by downstream systems. In particular, restoration is
62+
// logically a new entry creation from the perspective of ltx and stellar-core
63+
// as a whole, but this change type is reclassified to LEDGER_ENTRY_RESTORED
64+
// for easier consumption downstream.
65+
void
66+
processOpLedgerEntryChanges(std::shared_ptr<OperationFrame const> op,
67+
LedgerEntryChanges& changes)
68+
{
69+
if (op->getOperation().body.type() != RESTORE_FOOTPRINT)
70+
{
71+
return;
72+
}
73+
74+
for (auto& change : changes)
75+
{
76+
if (change.type() == LEDGER_ENTRY_CREATED)
77+
{
78+
auto le = change.created();
79+
change.type(LEDGER_ENTRY_RESTORED);
80+
change.restored() = le;
81+
}
82+
}
83+
}
84+
5985
} // namespace
6086

6187
using namespace std;
@@ -1638,6 +1664,14 @@ TransactionFrame::applyOperations(SignatureChecker& signatureChecker,
16381664
// The operation meta will be empty if the transaction
16391665
// doesn't succeed so we may as well not do any work in that
16401666
// case
1667+
auto changes = ltxOp.getChanges();
1668+
1669+
if (protocolVersionStartsFrom(
1670+
ledgerVersion,
1671+
Bucket::FIRST_PROTOCOL_SUPPORTING_PERSISTENT_EVICTION))
1672+
{
1673+
processOpLedgerEntryChanges(op, changes);
1674+
}
16411675
operationMetas.emplace_back(ltxOp.getChanges());
16421676
}
16431677

src/transactions/test/InvokeHostFunctionTests.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -2914,8 +2914,7 @@ TEST_CASE("state archival operation errors", "[tx][soroban][archival]")
29142914
}
29152915

29162916
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
2917-
TEST_CASE("evicted persistent entries"
2918-
"[tx][soroban][archival]")
2917+
TEST_CASE("evicted persistent entries", "[tx][soroban][archival]")
29192918
{
29202919
auto test = [](bool requireProofs) {
29212920
auto cfg = getTestConfig();

0 commit comments

Comments
 (0)