Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marta-lokhova committed Dec 28, 2024
1 parent 26bd385 commit 464fa5b
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 32 deletions.
6 changes: 3 additions & 3 deletions src/bucket/BucketListSnapshotBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace stellar
{
template <class BucketT>
BucketListSnapshot<BucketT>::BucketListSnapshot(
BucketListBase<BucketT> const& bl, std::shared_ptr<LastClosedLedger const> lastClosed)
BucketListBase<BucketT> const& bl,
std::shared_ptr<LastClosedLedger const> lastClosed)
: mLastClosedLedger(lastClosed)
{
releaseAssert(threadIsMain());
Expand Down Expand Up @@ -142,8 +143,7 @@ BucketLevelSnapshot<BucketT>::BucketLevelSnapshot(
template <class BucketT>
SearchableBucketListSnapshotBase<BucketT>::SearchableBucketListSnapshotBase(
BucketSnapshotManager const& snapshotManager)
: mSnapshotManager(snapshotManager)
, mHistoricalSnapshots()
: mSnapshotManager(snapshotManager), mHistoricalSnapshots()
{
mSnapshotManager.maybeUpdateSnapshot(mSnapshot, mHistoricalSnapshots);
}
Expand Down
4 changes: 2 additions & 2 deletions src/bucket/BucketSnapshotManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ std::shared_ptr<SearchableLiveBucketListSnapshot const>
BucketSnapshotManager::copySearchableLiveBucketListSnapshot() const
{
// Can't use std::make_shared due to private constructor
return std::shared_ptr<SearchableLiveBucketListSnapshot>(
return std::shared_ptr<SearchableLiveBucketListSnapshot const>(
new SearchableLiveBucketListSnapshot(*this));
}

Expand All @@ -65,7 +65,7 @@ BucketSnapshotManager::copySearchableHotArchiveBucketListSnapshot() const
{
releaseAssert(mCurrHotArchiveSnapshot);
// Can't use std::make_shared due to private constructor
return std::shared_ptr<SearchableHotArchiveBucketListSnapshot>(
return std::shared_ptr<SearchableHotArchiveBucketListSnapshot const>(
new SearchableHotArchiveBucketListSnapshot(*this));
}

Expand Down
3 changes: 2 additions & 1 deletion src/bucket/test/BucketTestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ addLiveBatchAndUpdateSnapshot(Application& app, LedgerHeader header,
: nullptr;
addLiveBatchAndUpdateSnapshot(
app,
std::make_shared<LastClosedLedger>(lhe, app.getLedgerManager().getLastClosedLedgerHAS(),
std::make_shared<LastClosedLedger>(
lhe, app.getLedgerManager().getLastClosedLedgerHAS(),
sorobanConfig),
initEntries, liveEntries, deadEntries);
}
Expand Down
2 changes: 1 addition & 1 deletion src/catchup/CatchupWork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ CatchupWork::doReset()
mGetBucketStateWork.reset();
mVerifyTxResults.reset();
mVerifyLedgers.reset();
mLastApplied = mApp.getLedgerManager().getLastClosedLedgerHeader();
mLastApplied = lcl;
mCurrentWork.reset();
mHAS.reset();
mBucketHAS.reset();
Expand Down
2 changes: 1 addition & 1 deletion src/catchup/DownloadApplyTxsWork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace stellar

DownloadApplyTxsWork::DownloadApplyTxsWork(
Application& app, TmpDir const& downloadDir, LedgerRange const& range,
std::shared_ptr<LedgerHeaderHistoryEntry> lastApplied, bool waitForPublish,
std::shared_ptr<LedgerHeaderHistoryEntry>& lastApplied, bool waitForPublish,
std::shared_ptr<HistoryArchive> archive)
: BatchWork(app, "download-apply-ledgers")
, mRange(range)
Expand Down
4 changes: 2 additions & 2 deletions src/catchup/DownloadApplyTxsWork.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DownloadApplyTxsWork : public BatchWork
{
LedgerRange const mRange;
TmpDir const& mDownloadDir;
std::shared_ptr<LedgerHeaderHistoryEntry> mLastApplied;
std::shared_ptr<LedgerHeaderHistoryEntry>& mLastApplied;
uint32_t mCheckpointToQueue;
std::shared_ptr<BasicWork> mLastYieldedWork;
bool const mWaitForPublish;
Expand All @@ -34,7 +34,7 @@ class DownloadApplyTxsWork : public BatchWork
public:
DownloadApplyTxsWork(Application& app, TmpDir const& downloadDir,
LedgerRange const& range,
std::shared_ptr<LedgerHeaderHistoryEntry> lastApplied,
std::shared_ptr<LedgerHeaderHistoryEntry>& lastApplied,
bool waitForPublish,
std::shared_ptr<HistoryArchive> archive = nullptr);

Expand Down
2 changes: 2 additions & 0 deletions src/herder/TransactionQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ TransactionQueue::canAdd(
ban({tx});
if (canAddRes.second != 0)
{
CLOG_INFO(Tx, "Transaction rejected: {} insufficient fee",
hexAbbrev(tx->getFullHash()));
AddResult result(TransactionQueue::AddResultCode::ADD_STATUS_ERROR,
tx, txINSUFFICIENT_FEE);
result.txResult->getResult().feeCharged = canAddRes.second;
Expand Down
23 changes: 15 additions & 8 deletions src/herder/test/HerderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2641,6 +2641,13 @@ TEST_CASE("SCP State", "[herder]")
sim->addConnection(nodeIDs[0], nodeIDs[2]);
sim->addConnection(nodeIDs[1], nodeIDs[2]);
sim->addConnection(nodeIDs[0], nodeIDs[1]);

REQUIRE(sim->getNode(nodeIDs[0])
->getLedgerManager()
.getLastClosedLedgerNum() == expectedLedger);
REQUIRE(sim->getNode(nodeIDs[1])
->getLedgerManager()
.getLastClosedLedgerNum() == expectedLedger);
};

SECTION("Force SCP")
Expand Down Expand Up @@ -2693,10 +2700,10 @@ TEST_CASE("SCP State", "[herder]")

for (int i = 0; i <= 2; i++)
{
auto const& actual = sim->getNode(nodeIDs[i])
->getLedgerManager()
.getLastClosedLedgerHeader()
->header;
auto actual = sim->getNode(nodeIDs[i])
->getLedgerManager()
.getLastClosedLedgerHeader()
->header;
REQUIRE(actual == lcl.header);
}

Expand Down Expand Up @@ -3087,10 +3094,10 @@ TEST_CASE("soroban txs each parameter surge priced", "[soroban][herder]")
bool hadSorobanSurgePricing = false;
simulation->crankUntil(
[&]() {
auto& lclHeader = nodes[0]
->getLedgerManager()
.getLastClosedLedgerHeader()
->header;
auto lclHeader = nodes[0]
->getLedgerManager()
.getLastClosedLedgerHeader()
->header;
auto txSet = nodes[0]->getHerder().getTxSet(
lclHeader.scpValue.txSetHash);
GeneralizedTransactionSet xdrTxSet;
Expand Down
4 changes: 2 additions & 2 deletions src/herder/test/UpgradesTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,9 @@ testListUpgrades(VirtualClock::system_time_point preferredUpgradeDatetime,

VirtualClock clock;
auto app = createTestApplication(clock, cfg);
auto ls = LedgerSnapshot(*app);

auto header = LedgerHeader{};
auto& header = ls.getLedgerHeader().currentToModify();
header.ledgerVersion = cfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION;
header.baseFee = cfg.TESTING_UPGRADE_DESIRED_FEE;
header.baseReserve = cfg.TESTING_UPGRADE_RESERVE;
Expand All @@ -309,7 +310,6 @@ testListUpgrades(VirtualClock::system_time_point preferredUpgradeDatetime,
makeTxCountUpgrade(cfg.TESTING_UPGRADE_MAX_TX_SET_SIZE);
auto baseReserveUpgrade =
makeBaseReserveUpgrade(cfg.TESTING_UPGRADE_RESERVE);
auto ls = LedgerSnapshot(*app);

SECTION("protocol version upgrade needed")
{
Expand Down
6 changes: 4 additions & 2 deletions src/ledger/LedgerManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@ std::shared_ptr<LedgerHeaderHistoryEntry>
LedgerManagerImpl::getLastClosedLedgerHeader() const
{
releaseAssert(threadIsMain());
return std::make_shared<LedgerHeaderHistoryEntry>(getLastClosedLedger(mApp)->lhhe);
return std::make_shared<LedgerHeaderHistoryEntry>(
getLastClosedLedger(mApp)->lhhe);
}

HistoryArchiveState
Expand Down Expand Up @@ -1299,7 +1300,8 @@ LedgerManagerImpl::advanceReadOnlyLedgerState(LedgerHeader const& header,
lhhe.hash = ledgerHash;

auto& bm = mApp.getBucketManager();
auto lcl = std::make_shared<LastClosedLedger>(lhhe, getLastClosedLedgerHAS(), mSorobanNetworkConfig);
auto lcl = std::make_shared<LastClosedLedger>(
lhhe, getLastClosedLedgerHAS(), mSorobanNetworkConfig);
auto liveSnapshot = std::make_unique<BucketListSnapshot<LiveBucket>>(
bm.getLiveBucketList(), lcl);
auto hotArchiveSnapshot =
Expand Down
5 changes: 2 additions & 3 deletions src/ledger/LedgerStateSnapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,8 @@ BucketSnapshotState::BucketSnapshotState(
"BucketSnapshotState::BucketSnapshotState: snapshot is missing "
"last closed ledger");
}
mLedgerHeader = LedgerHeaderWrapper(
std::make_shared<LedgerHeader>(snapshot->getLastClosedLedger()
->getLedgerHeaderHistoryEntry().header));
mLedgerHeader = LedgerHeaderWrapper(std::make_shared<LedgerHeader>(
snapshot->getLastClosedLedger()->getLedgerHeaderHistoryEntry().header));
}

BucketSnapshotState::~BucketSnapshotState()
Expand Down
9 changes: 6 additions & 3 deletions src/ledger/LedgerStateSnapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class AbstractLedgerStateSnapshot
{
public:
virtual ~AbstractLedgerStateSnapshot() = default;
virtual std::shared_ptr<LastClosedLedger const> getLastClosedLedger() const = 0;
virtual std::shared_ptr<LastClosedLedger const>
getLastClosedLedger() const = 0;
virtual LedgerHeaderWrapper getLedgerHeader() const = 0;
virtual LedgerEntryWrapper getAccount(AccountID const& account) const = 0;
virtual LedgerEntryWrapper getAccount(LedgerHeaderWrapper const& header,
Expand All @@ -92,7 +93,8 @@ class LedgerTxnReadOnly : public AbstractLedgerStateSnapshot
public:
LedgerTxnReadOnly(AbstractLedgerTxn& ltx);
~LedgerTxnReadOnly() override;
std::shared_ptr<LastClosedLedger const> getLastClosedLedger() const override;
std::shared_ptr<LastClosedLedger const>
getLastClosedLedger() const override;
LedgerHeaderWrapper getLedgerHeader() const override;
LedgerEntryWrapper getAccount(AccountID const& account) const override;
LedgerEntryWrapper getAccount(LedgerHeaderWrapper const& header,
Expand All @@ -119,7 +121,8 @@ class BucketSnapshotState : public AbstractLedgerStateSnapshot
std::shared_ptr<SearchableLiveBucketListSnapshot const> snapshot);
~BucketSnapshotState() override;

std::shared_ptr<LastClosedLedger const> getLastClosedLedger() const override;
std::shared_ptr<LastClosedLedger const>
getLastClosedLedger() const override;
LedgerHeaderWrapper getLedgerHeader() const override;
LedgerEntryWrapper getAccount(AccountID const& account) const override;
LedgerEntryWrapper getAccount(LedgerHeaderWrapper const& header,
Expand Down
8 changes: 4 additions & 4 deletions src/test/TestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ upgradeSorobanNetworkConfig(std::function<void(SorobanNetworkConfig&)> modifyFn,
LoadGenMode::SOROBAN_CREATE_UPGRADE, 1, 1, 1);
createUpgradeLoadGenConfig.offset = offset;
// Get current network config.
auto cfg = nodes[0]->getLedgerManager().getSorobanNetworkConfig();
modifyFn(*cfg);
createUpgradeLoadGenConfig.copySorobanNetworkConfigToUpgradeConfig(*cfg);
auto cfg = *(nodes[0]->getLedgerManager().getSorobanNetworkConfig());
modifyFn(cfg);
createUpgradeLoadGenConfig.copySorobanNetworkConfigToUpgradeConfig(cfg);
auto upgradeSetKey = lg.getConfigUpgradeSetKey(
createUpgradeLoadGenConfig.getSorobanUpgradeConfig());
lg.generateLoad(createUpgradeLoadGenConfig);
Expand All @@ -259,7 +259,7 @@ upgradeSorobanNetworkConfig(std::function<void(SorobanNetworkConfig&)> modifyFn,
simulation->crankUntil(
[&]() {
auto netCfg = app.getLedgerManager().getSorobanNetworkConfig();
return netCfg == cfg;
return *netCfg == cfg;
},
2 * Herder::EXP_LEDGER_TIMESPAN_SECONDS, false);
}
Expand Down
1 change: 1 addition & 0 deletions src/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ saveTestTxMeta(stdfs::path const& dir)
}
out.exceptions(std::ios::failbit | std::ios::badbit);
out << fileRoot;
CLOG_INFO(Tx, "Wrote {} TxMetas to {}", filePair.second.size(), path);
}
}

Expand Down

0 comments on commit 464fa5b

Please sign in to comment.