Skip to content

Commit f93eaaa

Browse files
committed
fixes
1 parent cca31af commit f93eaaa

File tree

3 files changed

+24
-55
lines changed

3 files changed

+24
-55
lines changed

src/ledger/LedgerManagerImpl.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -1606,9 +1606,12 @@ LedgerManagerImpl::collectEntries(AppConnector& app, AbstractLedgerTxn& ltx,
16061606
ThreadEntryMap entryMap;
16071607
for (auto const& txBundle : txs)
16081608
{
1609-
txBundle.getTx()->preloadEntriesForParallelApply(
1610-
app.getConfig(), app.getLedgerManager().getSorobanMetrics(), ltx,
1611-
entryMap, txBundle.getResPayload());
1609+
if (txBundle.getResPayload()->isSuccess())
1610+
{
1611+
txBundle.getTx()->preloadEntriesForParallelApply(
1612+
app.getConfig(), app.getLedgerManager().getSorobanMetrics(),
1613+
ltx, entryMap, txBundle.getResPayload());
1614+
}
16121615
}
16131616

16141617
return entryMap;
@@ -1741,9 +1744,7 @@ LedgerManagerImpl::applyThread(ThreadEntryMap& entryMap, Thread const& thread,
17411744
}
17421745
else
17431746
{
1744-
releaseAssertOrThrow(
1745-
txBundle.getResPayload()->getResultCode() == txFAILED ||
1746-
txBundle.getResPayload()->getResultCode() == txINTERNAL_ERROR);
1747+
releaseAssertOrThrow(!txBundle.getResPayload()->isSuccess());
17471748
}
17481749
}
17491750

@@ -1782,6 +1783,8 @@ LedgerManagerImpl::applySorobanStage(AppConnector& app, AbstractLedgerTxn& ltx,
17821783
{
17831784
for (auto const& txBundle : thread)
17841785
{
1786+
// This can mark a tx as failed due to validation.
1787+
// Make sure results are checked.
17851788
txBundle.getTx()->preParallelApply(app, ltx,
17861789
txBundle.getEffects().getMeta(),
17871790
txBundle.getResPayload());

src/testdata/ledger-close-meta-v1-protocol-23-soroban.json

+7-34
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@
12271227
{
12281228
"type": "LEDGER_ENTRY_CREATED",
12291229
"created": {
1230-
"lastModifiedLedgerSeq": 28,
1230+
"lastModifiedLedgerSeq": 0,
12311231
"data": {
12321232
"type": "CONTRACT_DATA",
12331233
"contractData": {
@@ -1254,7 +1254,7 @@
12541254
{
12551255
"type": "LEDGER_ENTRY_CREATED",
12561256
"created": {
1257-
"lastModifiedLedgerSeq": 28,
1257+
"lastModifiedLedgerSeq": 0,
12581258
"data": {
12591259
"type": "TTL",
12601260
"ttl": {
@@ -1569,7 +1569,7 @@
15691569
{
15701570
"type": "LEDGER_ENTRY_UPDATED",
15711571
"updated": {
1572-
"lastModifiedLedgerSeq": 28,
1572+
"lastModifiedLedgerSeq": 6,
15731573
"data": {
15741574
"type": "TTL",
15751575
"ttl": {
@@ -1601,7 +1601,7 @@
16011601
{
16021602
"type": "LEDGER_ENTRY_UPDATED",
16031603
"updated": {
1604-
"lastModifiedLedgerSeq": 28,
1604+
"lastModifiedLedgerSeq": 6,
16051605
"data": {
16061606
"type": "TTL",
16071607
"ttl": {
@@ -1898,33 +1898,6 @@
18981898
"operations": [
18991899
{
19001900
"changes": [
1901-
{
1902-
"type": "LEDGER_ENTRY_RESTORED",
1903-
"restored": {
1904-
"lastModifiedLedgerSeq": 7,
1905-
"data": {
1906-
"type": "CONTRACT_DATA",
1907-
"contractData": {
1908-
"ext": {
1909-
"v": 0
1910-
},
1911-
"contract": "CAA3QKIP2SNVXUJTB4HKOGF55JTSSMQGED3FZYNHMNSXYV3DRRMAWA3Y",
1912-
"key": {
1913-
"type": "SCV_SYMBOL",
1914-
"sym": "archived"
1915-
},
1916-
"durability": "PERSISTENT",
1917-
"val": {
1918-
"type": "SCV_U64",
1919-
"u64": 42
1920-
}
1921-
}
1922-
},
1923-
"ext": {
1924-
"v": 0
1925-
}
1926-
}
1927-
},
19281901
{
19291902
"type": "LEDGER_ENTRY_STATE",
19301903
"state": {
@@ -1942,9 +1915,9 @@
19421915
}
19431916
},
19441917
{
1945-
"type": "LEDGER_ENTRY_RESTORED",
1946-
"restored": {
1947-
"lastModifiedLedgerSeq": 28,
1918+
"type": "LEDGER_ENTRY_UPDATED",
1919+
"updated": {
1920+
"lastModifiedLedgerSeq": 7,
19481921
"data": {
19491922
"type": "TTL",
19501923
"ttl": {

src/transactions/InvokeHostFunctionOpFrame.cpp

+8-15
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,10 @@ struct HostFunctionMetrics
201201

202202
~HostFunctionMetrics()
203203
{
204-
mMetrics.mHostFnOpReadEntry.Mark(mReadEntryCounters.mReadEntry);
205204
mMetrics.mHostFnOpWriteEntry.Mark(mWriteEntry);
206205

207-
mMetrics.mHostFnOpReadKeyByte.Mark(mReadEntryCounters.mReadKeyByte);
208206
mMetrics.mHostFnOpWriteKeyByte.Mark(mWriteKeyByte);
209207

210-
mMetrics.mHostFnOpReadLedgerByte.Mark(
211-
mReadEntryCounters.mLedgerReadByte);
212-
mMetrics.mHostFnOpReadDataByte.Mark(mReadEntryCounters.mReadDataByte);
213-
mMetrics.mHostFnOpReadCodeByte.Mark(mReadEntryCounters.mReadCodeByte);
214-
215208
mMetrics.mHostFnOpWriteLedgerByte.Mark(mLedgerWriteByte);
216209
mMetrics.mHostFnOpWriteDataByte.Mark(mWriteDataByte);
217210
mMetrics.mHostFnOpWriteCodeByte.Mark(mWriteCodeByte);
@@ -234,12 +227,6 @@ struct HostFunctionMetrics
234227
mMetrics.mHostFnOpDeclaredInsnsUsageRatio.Update(
235228
mCpuInsn * 1000000 / std::max(mDeclaredCpuInsn, uint64_t(1)));
236229

237-
mMetrics.mHostFnOpMaxRwKeyByte.Mark(
238-
mReadEntryCounters.mMaxReadWriteKeyByte);
239-
mMetrics.mHostFnOpMaxRwDataByte.Mark(
240-
mReadEntryCounters.mMaxReadWriteDataByte);
241-
mMetrics.mHostFnOpMaxRwCodeByte.Mark(
242-
mReadEntryCounters.mMaxReadWriteCodeByte);
243230
mMetrics.mHostFnOpMaxEmitEventByte.Mark(mMaxEmitEventByte);
244231

245232
mMetrics.accumulateModelledCpuInsns(mCpuInsn, mCpuInsnExclVm,
@@ -426,8 +413,8 @@ InvokeHostFunctionOpFrame::doApplyParallel(
426413
ledgerEntryCxxBufs.reserve(footprintLength);
427414
ttlEntryCxxBufs.reserve(footprintLength);
428415

429-
auto addReads = [&ledgerEntryCxxBufs, &ttlEntryCxxBufs, &entryMap,
430-
&resources, &sorobanConfig, &appConfig, &sorobanData, &res,
416+
auto addReads = [&metrics, &ledgerEntryCxxBufs, &ttlEntryCxxBufs, &entryMap,
417+
&sorobanConfig, &appConfig, &sorobanData, &res,
431418
&ledgerInfo, this](auto const& keys) -> bool {
432419
for (auto const& lk : keys)
433420
{
@@ -512,6 +499,12 @@ InvokeHostFunctionOpFrame::doApplyParallel(
512499
}
513500
}
514501

502+
// Only used for diagnostic events because loads are done in
503+
// doPreloadEntriesForParallelApply
504+
uint32_t keySize = static_cast<uint32_t>(xdr::xdr_size(lk));
505+
metrics.mReadEntryCounters.noteReadEntry(isCodeKey(lk), keySize,
506+
entrySize);
507+
515508
if (!validateContractLedgerEntry(lk, entrySize, sorobanConfig,
516509
appConfig, mParentTx, sorobanData))
517510
{

0 commit comments

Comments
 (0)