Skip to content

Commit 5b2dc94

Browse files
committed
Post-rebase fixes
1 parent 39de3e6 commit 5b2dc94

10 files changed

+26
-65
lines changed

src/herder/TxSetFrame.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,10 +1817,12 @@ TxSetPhaseFrame::txsAreValid(Application& app,
18171817
LedgerSnapshot ls(app);
18181818
ls.getLedgerHeader().currentToModify().ledgerSeq =
18191819
app.getLedgerManager().getLastClosedLedgerNum() + 1;
1820+
1821+
// TODO: I *think* forApply should be false here? Is that right?
1822+
AppValidationWrapper avw(app.getAppConnector(), false, std::nullopt);
18201823
for (auto const& tx : *this)
18211824
{
1822-
auto txResult = tx->checkValid(app.getAppConnector(), ls, 0,
1823-
lowerBoundCloseTimeOffset,
1825+
auto txResult = tx->checkValid(avw, ls, 0, lowerBoundCloseTimeOffset,
18241826
upperBoundCloseTimeOffset);
18251827
if (!txResult->isSuccess())
18261828
{

src/herder/test/HerderTests.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3225,6 +3225,8 @@ TEST_CASE("overlay parallel processing")
32253225

32263226
// Background ledger close requires postgres
32273227
#ifdef USE_POSTGRES
3228+
// TODO: This is broken wtih background tx queue. Fix it. (note that this
3229+
// test doesn't run at all when --disable-postgres is set)
32283230
SECTION("background ledger close")
32293231
{
32303232
// Set threshold to 1 so all have to vote

src/herder/test/TxSetTests.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -991,9 +991,10 @@ TEST_CASE("applicable txset validation - transactions belong to correct phase",
991991
1)},
992992
2000);
993993
}
994+
AppValidationWrapper avw(app->getAppConnector(), false,
995+
std::nullopt);
994996
LedgerSnapshot ls(*app);
995-
REQUIRE(tx->checkValid(app->getAppConnector(), ls, 0, 0, 0)
996-
->isSuccess());
997+
REQUIRE(tx->checkValid(avw, ls, 0, 0, 0)->isSuccess());
997998
return tx;
998999
};
9991000

@@ -1117,9 +1118,10 @@ TEST_CASE("applicable txset validation - Soroban resources", "[txset][soroban]")
11171118
auto tx = sorobanTransactionFrameFromOps(
11181119
app->getNetworkID(), source, {op}, {}, resources, 2000,
11191120
100'000'000);
1121+
AppValidationWrapper avw(app->getAppConnector(), false,
1122+
std::nullopt);
11201123
LedgerSnapshot ls(*app);
1121-
REQUIRE(tx->checkValid(app->getAppConnector(), ls, 0, 0, 0)
1122-
->isSuccess());
1124+
REQUIRE(tx->checkValid(avw, ls, 0, 0, 0)->isSuccess());
11231125
return tx;
11241126
};
11251127

src/ledger/LedgerManagerImpl.cpp

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -145,21 +145,6 @@ LedgerManager::maxSorobanLedgerResources(SorobanNetworkConfig const& conf)
145145
return Resource(limits);
146146
}
147147

148-
Resource
149-
LedgerManager::maxSorobanTransactionResources(SorobanNetworkConfig const& conf)
150-
{
151-
ZoneScoped;
152-
int64_t const opCount = 1;
153-
std::vector<int64_t> limits = {opCount,
154-
conf.txMaxInstructions(),
155-
conf.txMaxSizeBytes(),
156-
conf.txMaxReadBytes(),
157-
conf.txMaxWriteBytes(),
158-
conf.txMaxReadLedgerEntries(),
159-
conf.txMaxWriteLedgerEntries()};
160-
return Resource(limits);
161-
}
162-
163148
uint32_t
164149
LedgerManager::getMaxTxSetSizeOps(LedgerHeader const& header)
165150
{
@@ -170,30 +155,11 @@ LedgerManager::getMaxTxSetSizeOps(LedgerHeader const& header)
170155
: (n * MAX_OPS_PER_TX);
171156
}
172157

173-
Resource
174-
LedgerManager::maxClassicLedgerResources(LedgerHeader const& header)
175-
{
176-
return Resource(LedgerManager::getMaxTxSetSizeOps(header));
177-
}
178-
179-
Resource
180-
LedgerManager::maxSorobanLedgerResources(SorobanNetworkConfig const& conf)
181-
{
182-
ZoneScoped std::vector<int64_t> limits = {
183-
conf.ledgerMaxTxCount(),
184-
conf.ledgerMaxInstructions(),
185-
conf.ledgerMaxTransactionSizesBytes(),
186-
conf.ledgerMaxReadBytes(),
187-
conf.ledgerMaxWriteBytes(),
188-
conf.ledgerMaxReadLedgerEntries(),
189-
conf.ledgerMaxWriteLedgerEntries()};
190-
return Resource(limits);
191-
}
192-
193158
Resource
194159
LedgerManager::maxSorobanTransactionResources(SorobanNetworkConfig const& conf)
195160
{
196-
ZoneScoped int64_t const opCount = 1;
161+
ZoneScoped;
162+
int64_t const opCount = 1;
197163
std::vector<int64_t> limits = {opCount,
198164
conf.txMaxInstructions(),
199165
conf.txMaxSizeBytes(),
@@ -204,16 +170,6 @@ LedgerManager::maxSorobanTransactionResources(SorobanNetworkConfig const& conf)
204170
return Resource(limits);
205171
}
206172

207-
uint32_t
208-
LedgerManager::getMaxTxSetSizeOps(LedgerHeader const& header)
209-
{
210-
auto n = header.maxTxSetSize;
211-
return protocolVersionStartsFrom(header.ledgerVersion,
212-
ProtocolVersion::V_11)
213-
? n
214-
: (n * MAX_OPS_PER_TX);
215-
}
216-
217173
LedgerManagerImpl::LedgerApplyMetrics::LedgerApplyMetrics(
218174
medida::MetricsRegistry& registry)
219175
: mTransactionApply(registry.NewTimer({"ledger", "transaction", "apply"}))
@@ -506,7 +462,7 @@ uint32_t
506462
LedgerManagerImpl::getLastMaxTxSetSizeOps() const
507463
{
508464
releaseAssert(threadIsMain());
509-
return LedgerManager::getMaxTxSetSizeOps(mLastClosedLedger.header);
465+
return LedgerManager::getMaxTxSetSizeOps(getLCLState().ledgerHeader.header);
510466
}
511467

512468
Resource
@@ -518,12 +474,12 @@ LedgerManagerImpl::maxLedgerResources(bool isSoroban)
518474
if (isSoroban)
519475
{
520476
return LedgerManager::maxSorobanLedgerResources(
521-
getSorobanNetworkConfigReadOnly());
477+
getLastClosedSorobanNetworkConfig());
522478
}
523479
else
524480
{
525481
return LedgerManager::maxClassicLedgerResources(
526-
mLastClosedLedger.header);
482+
getLCLState().ledgerHeader.header);
527483
}
528484
}
529485

@@ -533,7 +489,7 @@ LedgerManagerImpl::maxSorobanTransactionResources()
533489
ZoneScoped;
534490

535491
return LedgerManager::maxSorobanTransactionResources(
536-
mApp.getLedgerManager().getSorobanNetworkConfigReadOnly());
492+
getLastClosedSorobanNetworkConfig());
537493
}
538494

539495
int64_t

src/main/AppConnector.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,18 @@ AppConnector::getLastClosedSorobanNetworkConfig() const
5656
SorobanNetworkConfig const&
5757
AppConnector::getSorobanNetworkConfigForApply() const
5858
{
59+
releaseAssert(threadIsMain() ||
60+
mApp.threadIsType(Application::ThreadType::APPLY));
5961
return mApp.getLedgerManager().getSorobanNetworkConfigForApply();
6062
}
6163

6264
std::optional<SorobanNetworkConfig>
6365
AppConnector::maybeGetSorobanNetworkConfigReadOnly() const
6466
{
6567
releaseAssert(threadIsMain());
66-
if (mApp.getLedgerManager().hasSorobanNetworkConfig())
68+
if (mApp.getLedgerManager().hasLastClosedSorobanNetworkConfig())
6769
{
68-
return mApp.getLedgerManager().getSorobanNetworkConfigReadOnly();
70+
return mApp.getLedgerManager().getLastClosedSorobanNetworkConfig();
6971
}
7072
return std::nullopt;
7173
}

src/main/AppConnector.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ class AppConnector
7272
// `getSorobanNetworkConfig` will throw an assertion error in that case.
7373
std::optional<SorobanNetworkConfig>
7474
maybeGetSorobanNetworkConfigReadOnly() const;
75-
bool threadIsType(Application::ThreadType type) const;
7675

7776
bool threadIsType(Application::ThreadType type) const;
7877

src/main/Application.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class Application
171171
WORKER,
172172
EVICTION,
173173
OVERLAY,
174-
LEDGER_CLOSE,
174+
APPLY,
175175
TX_QUEUE
176176
};
177177

src/main/ApplicationImpl.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ ApplicationImpl::ApplicationImpl(VirtualClock& clock, Config const& cfg)
199199
if (mConfig.BACKGROUND_TX_QUEUE)
200200
{
201201
// TODO: Keep priority unchanged as tx queue processes time-sensitive
202-
// tasks? Or should tx queue priority be downgraded? The priority
203-
// locking mechanism in TransactionQueue is designed to prevent tx queue
204-
// from starving other work, so it may be fine to keep priority
205-
// unchanged.
202+
// tasks? Or should tx queue priority be downgraded?
206203
mTxQueueThread = std::thread{[this]() { mTxQueueIOContext->run(); }};
207204
mThreadTypes[mTxQueueThread->get_id()] = ThreadType::TX_QUEUE;
208205
}

src/transactions/TransactionFrameBase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ SorobanNetworkConfig const&
3131
AppValidationWrapper::getSorobanNetworkConfig() const
3232
{
3333
return mForApply ? mApp.getSorobanNetworkConfigForApply()
34-
: mApp.getSorobanNetworkConfigReadOnly();
34+
: mApp.getLastClosedSorobanNetworkConfig();
3535
}
3636

3737
uint32_t

src/transactions/TransactionUtils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace stellar
1717
{
1818

1919
class Application;
20+
class AppConnector;
2021
class Config;
2122
class ConstLedgerTxnEntry;
2223
class ConstTrustLineWrapper;

0 commit comments

Comments
 (0)