Skip to content

Commit

Permalink
Better test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
SirTyson committed Oct 10, 2024
1 parent f09f6ea commit 54a8be1
Show file tree
Hide file tree
Showing 15 changed files with 514 additions and 343 deletions.
1 change: 0 additions & 1 deletion src/bucket/BucketManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,6 @@ BucketManagerImpl::getSearchableLiveBucketListSnapshot()
std::shared_ptr<SearchableHotArchiveBucketListSnapshot>
BucketManagerImpl::getSearchableHotArchiveBucketListSnapshot()
{
releaseAssert(mApp.getConfig().isUsingBucketListDB());
// Any other threads must maintain their own snapshot
releaseAssert(threadIsMain());
if (!mSearchableHotArchiveBucketListSnapshot)
Expand Down
69 changes: 33 additions & 36 deletions src/ledger/LedgerManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1685,50 +1685,47 @@ LedgerManagerImpl::transferLedgerEntriesToBucketList(
if (blEnabled &&
protocolVersionStartsFrom(initialLedgerVers, SOROBAN_PROTOCOL_VERSION))
{
auto ttlKeys = ltx.getAllTTLKeysWithoutSealing();
auto deletedPersistentDataKeys =
ltx.getAllDeletedPersistentContractDataKeysWithoutSealing();
auto createdPersistentDataKeys =
ltx.getAllCreatedPersistentContractDataKeysWithoutSealing();
LedgerTxn ltxEvictions(ltx);

auto evictedEntries =
mApp.getBucketManager().resolveBackgroundEvictionScan(
ltxEvictions, lh.ledgerSeq, ttlKeys, initialLedgerVers);

if (protocolVersionStartsFrom(
initialLedgerVers,
Bucket::FIRST_PROTOCOL_SUPPORTING_PERSISTENT_EVICTION))
{
auto deletedPersistentDataKeys =
ltx.getAllDeletedPersistentContractDataKeysWithoutSealing();
auto createdPersistentDataKeys =
ltx.getAllCreatedPersistentContractDataKeysWithoutSealing();
LedgerTxn ltxEvictions(ltx);
auto createdVec =
std::vector<LedgerKey>(createdPersistentDataKeys.begin(),
createdPersistentDataKeys.end());
auto deletedVec =
std::vector<LedgerKey>(deletedPersistentDataKeys.begin(),
deletedPersistentDataKeys.end());
mApp.getBucketManager().addHotArchiveBatch(
mApp, lh, evictedEntries.second, createdVec, deletedVec);

auto evictedEntries =
mApp.getBucketManager().resolveBackgroundEvictionScan(
ltxEvictions, lh.ledgerSeq, keys, initialLedgerVers);

if (protocolVersionStartsFrom(
initialLedgerVers,
Bucket::FIRST_PROTOCOL_SUPPORTING_PERSISTENT_EVICTION))
if (ledgerCloseMeta)
{
auto createdVec = std::vector<LedgerKey>(
createdPersistentDataKeys.begin(),
createdPersistentDataKeys.end());
auto deletedVec = std::vector<LedgerKey>(
deletedPersistentDataKeys.begin(),
deletedPersistentDataKeys.end());
mApp.getBucketManager().addHotArchiveBatch(
mApp, lh, evictedEntries.second, createdVec,
deletedVec);
}

if (ledgerCloseMeta)
{
ledgerCloseMeta->populateEvictedEntries(evictedEntries);
}
ledgerCloseMeta->populateEvictedEntries(evictedEntries);
}
else
{
}
else
{

if (ledgerCloseMeta)
{
ledgerCloseMeta->populateEvictedEntriesLegacy(
ltxEvictions.getChanges());
}
if (ledgerCloseMeta)
{
ledgerCloseMeta->populateEvictedEntriesLegacy(
ltxEvictions.getChanges());
}

ltxEvictions.commit();
}

ltxEvictions.commit();

getSorobanNetworkConfigInternal().maybeSnapshotBucketListSize(
lh.ledgerSeq, ltx, mApp);
}
Expand Down
20 changes: 20 additions & 0 deletions src/main/SettingsUpgradeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ getWasmRestoreTx(PublicKey const& publicKey, SequenceNumber seqNum)
TransactionEnvelope txEnv;
txEnv.type(ENVELOPE_TYPE_TX);

#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
txEnv.v1().tx.ext.sorobanData().ext.v(1);
#endif

auto& tx = txEnv.v1().tx;
tx.sourceAccount = toMuxedAccount(publicKey);
tx.fee = 100'000'000;
Expand Down Expand Up @@ -49,6 +53,10 @@ getWasmRestoreTx(PublicKey const& publicKey, SequenceNumber seqNum)
tx.ext.sorobanData().resources = restoreResources;
tx.ext.sorobanData().resourceFee = 55'000'000;

#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
tx.ext.sorobanData().ext.v(1);
#endif

return {txEnv, contractCodeLedgerKey};
}

Expand Down Expand Up @@ -96,6 +104,10 @@ getUploadTx(PublicKey const& publicKey, SequenceNumber seqNum)
tx.ext.sorobanData().resources = uploadResources;
tx.ext.sorobanData().resourceFee = 55'000'000;

#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
tx.ext.sorobanData().ext.v(1);
#endif

return {txEnv, contractCodeLedgerKey};
}

Expand Down Expand Up @@ -180,6 +192,10 @@ getCreateTx(PublicKey const& publicKey, LedgerKey const& contractCodeLedgerKey,
tx.ext.sorobanData().resources = uploadResources;
tx.ext.sorobanData().resourceFee = 15'000'000;

#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
tx.ext.sorobanData().ext.v(1);
#endif

return {txEnv, contractSourceRefLedgerKey, contractID};
}

Expand Down Expand Up @@ -274,6 +290,10 @@ getInvokeTx(PublicKey const& publicKey, LedgerKey const& contractCodeLedgerKey,
tx.ext.sorobanData().resources = invokeResources;
tx.ext.sorobanData().resourceFee = 65'000'000;

#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
tx.ext.sorobanData().ext.v(1);
#endif

ConfigUpgradeSetKey key;
key.contentHash = upgradeHash;
key.contractID = contractID;
Expand Down
Loading

0 comments on commit 54a8be1

Please sign in to comment.