Skip to content

Commit 696561d

Browse files
committed
fixes
1 parent cca31af commit 696561d

File tree

3 files changed

+30
-48
lines changed

3 files changed

+30
-48
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

+14-8
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,16 @@ struct HostFunctionMetrics
201201

202202
~HostFunctionMetrics()
203203
{
204-
mMetrics.mHostFnOpReadEntry.Mark(mReadEntryCounters.mReadEntry);
204+
// mMetrics.mHostFnOpReadEntry.Mark(mReadEntryCounters.mReadEntry);
205205
mMetrics.mHostFnOpWriteEntry.Mark(mWriteEntry);
206206

207-
mMetrics.mHostFnOpReadKeyByte.Mark(mReadEntryCounters.mReadKeyByte);
207+
// mMetrics.mHostFnOpReadKeyByte.Mark(mReadEntryCounters.mReadKeyByte);
208208
mMetrics.mHostFnOpWriteKeyByte.Mark(mWriteKeyByte);
209209

210210
mMetrics.mHostFnOpReadLedgerByte.Mark(
211211
mReadEntryCounters.mLedgerReadByte);
212-
mMetrics.mHostFnOpReadDataByte.Mark(mReadEntryCounters.mReadDataByte);
213-
mMetrics.mHostFnOpReadCodeByte.Mark(mReadEntryCounters.mReadCodeByte);
212+
// mMetrics.mHostFnOpReadDataByte.Mark(mReadEntryCounters.mReadDataByte);
213+
// mMetrics.mHostFnOpReadCodeByte.Mark(mReadEntryCounters.mReadCodeByte);
214214

215215
mMetrics.mHostFnOpWriteLedgerByte.Mark(mLedgerWriteByte);
216216
mMetrics.mHostFnOpWriteDataByte.Mark(mWriteDataByte);
@@ -234,12 +234,12 @@ struct HostFunctionMetrics
234234
mMetrics.mHostFnOpDeclaredInsnsUsageRatio.Update(
235235
mCpuInsn * 1000000 / std::max(mDeclaredCpuInsn, uint64_t(1)));
236236

237-
mMetrics.mHostFnOpMaxRwKeyByte.Mark(
237+
/* mMetrics.mHostFnOpMaxRwKeyByte.Mark(
238238
mReadEntryCounters.mMaxReadWriteKeyByte);
239239
mMetrics.mHostFnOpMaxRwDataByte.Mark(
240240
mReadEntryCounters.mMaxReadWriteDataByte);
241241
mMetrics.mHostFnOpMaxRwCodeByte.Mark(
242-
mReadEntryCounters.mMaxReadWriteCodeByte);
242+
mReadEntryCounters.mMaxReadWriteCodeByte); */
243243
mMetrics.mHostFnOpMaxEmitEventByte.Mark(mMaxEmitEventByte);
244244

245245
mMetrics.accumulateModelledCpuInsns(mCpuInsn, mCpuInsnExclVm,
@@ -426,8 +426,8 @@ InvokeHostFunctionOpFrame::doApplyParallel(
426426
ledgerEntryCxxBufs.reserve(footprintLength);
427427
ttlEntryCxxBufs.reserve(footprintLength);
428428

429-
auto addReads = [&ledgerEntryCxxBufs, &ttlEntryCxxBufs, &entryMap,
430-
&resources, &sorobanConfig, &appConfig, &sorobanData, &res,
429+
auto addReads = [&metrics, &ledgerEntryCxxBufs, &ttlEntryCxxBufs, &entryMap,
430+
&sorobanConfig, &appConfig, &sorobanData, &res,
431431
&ledgerInfo, this](auto const& keys) -> bool {
432432
for (auto const& lk : keys)
433433
{
@@ -512,6 +512,12 @@ InvokeHostFunctionOpFrame::doApplyParallel(
512512
}
513513
}
514514

515+
// Only used for diagnostic events because loads are done in
516+
// doPreloadEntriesForParallelApply
517+
uint32_t keySize = static_cast<uint32_t>(xdr::xdr_size(lk));
518+
metrics.mReadEntryCounters.noteReadEntry(isCodeKey(lk), keySize,
519+
entrySize);
520+
515521
if (!validateContractLedgerEntry(lk, entrySize, sorobanConfig,
516522
appConfig, mParentTx, sorobanData))
517523
{

0 commit comments

Comments
 (0)