Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute Soroban write fee based on the bucket list size. #3827

Merged
merged 3 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 22 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/bucket/test/BucketListTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,9 @@ TEST_CASE_VERSIONS("network config snapshots BucketList size", "[bucketlist]")
check();

// Take snapshots more frequently for faster testing
networkConfig.setBucketListSnapshotPeriodForTesting(64);
app->getLedgerManager()
.getMutableSorobanNetworkConfig(ltx)
.setBucketListSnapshotPeriodForTesting(64);

// Generate enough ledgers to fill sliding window
auto ledgersToGenerate =
Expand Down
2 changes: 1 addition & 1 deletion src/bucket/test/BucketTestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ LedgerManagerForBucketTests::transferLedgerEntriesToBucketList(
std::vector<LedgerKey> dead;
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
mApp.getLedgerManager()
.getSorobanNetworkConfig(ltx)
.getMutableSorobanNetworkConfig(ltx)
.maybeSnapshotBucketListSize(ledgerSeq, ltx, mApp);
#endif
ltx.getAllEntries(init, live, dead);
Expand Down
11 changes: 0 additions & 11 deletions src/herder/Upgrades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,17 +1387,6 @@ ConfigUpgradeSetFrame::applyTo(AbstractLedgerTxn& ltx, Application& app) const
auto const id = updatedEntry.configSettingID();
key.configSetting().configSettingID = id;
ltx.load(key).current().data.configSetting() = updatedEntry;

// State Expiration Setting may have changed BucketListWindowSize, so
// BucketManager may have to update window
if (id == ConfigSettingID::CONFIG_SETTING_STATE_EXPIRATION)
{
auto newWindowSize = updatedEntry.stateExpirationSettings()
.bucketListSizeWindowSampleSize;
app.getLedgerManager()
.getSorobanNetworkConfig(ltx)
.maybeUpdateBucketListWindowSize(ltx, newWindowSize);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/ledger/LedgerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class LedgerManager
#ifdef BUILD_TESTS
virtual void
setSorobanNetworkConfig(SorobanNetworkConfig const& config) = 0;

virtual SorobanNetworkConfig&
getMutableSorobanNetworkConfig(AbstractLedgerTxn& ltx) = 0;
#endif

// Return the (changing) number of seconds since the LCL closed.
Expand Down
25 changes: 19 additions & 6 deletions src/ledger/LedgerManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,8 @@ LedgerManagerImpl::getLastClosedLedgerNum() const
return mLastClosedLedger.header.ledgerSeq;
}

SorobanNetworkConfig const&
LedgerManagerImpl::getSorobanNetworkConfig(AbstractLedgerTxn& ltx)
SorobanNetworkConfig&
LedgerManagerImpl::getSorobanNetworkConfigInternal(AbstractLedgerTxn& ltx)
{
if (!mSorobanNetworkConfig)
{
Expand All @@ -509,12 +509,24 @@ LedgerManagerImpl::getSorobanNetworkConfig(AbstractLedgerTxn& ltx)
return *mSorobanNetworkConfig;
}

SorobanNetworkConfig const&
LedgerManagerImpl::getSorobanNetworkConfig(AbstractLedgerTxn& ltx)
{
return getSorobanNetworkConfigInternal(ltx);
}

#ifdef BUILD_TESTS
void
LedgerManagerImpl::setSorobanNetworkConfig(SorobanNetworkConfig const& config)
{
mSorobanNetworkConfig = config;
}

SorobanNetworkConfig&
LedgerManagerImpl::getMutableSorobanNetworkConfig(AbstractLedgerTxn& ltx)
{
return getSorobanNetworkConfigInternal(ltx);
}
#endif

// called by txherder
Expand Down Expand Up @@ -1156,7 +1168,9 @@ LedgerManagerImpl::maybeUpdateNetworkConfig(bool upgradeHappened,

if (protocolVersionStartsFrom(ledgerVersion, SOROBAN_PROTOCOL_VERSION))
{
mSorobanNetworkConfig->loadFromLedger(rootLtx);
mSorobanNetworkConfig->loadFromLedger(
rootLtx, mApp.getConfig().CURRENT_LEDGER_PROTOCOL_VERSION,
ledgerVersion);
}
#endif
}
Expand Down Expand Up @@ -1456,9 +1470,8 @@ LedgerManagerImpl::transferLedgerEntriesToBucketList(AbstractLedgerTxn& ltx,
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
if (blEnabled)
{
mApp.getLedgerManager()
.getSorobanNetworkConfig(ltx)
.maybeSnapshotBucketListSize(ledgerSeq, ltx, mApp);
getSorobanNetworkConfigInternal(ltx).maybeSnapshotBucketListSize(
ledgerSeq, ltx, mApp);
}
#endif

Expand Down
5 changes: 5 additions & 0 deletions src/ledger/LedgerManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class LedgerManagerImpl : public LedgerManager

void emitNextMeta();

SorobanNetworkConfig&
getSorobanNetworkConfigInternal(AbstractLedgerTxn& ltx);

protected:
virtual void transferLedgerEntriesToBucketList(AbstractLedgerTxn& ltx,
uint32_t ledgerSeq,
Expand Down Expand Up @@ -128,6 +131,8 @@ class LedgerManagerImpl : public LedgerManager

#ifdef BUILD_TESTS
void setSorobanNetworkConfig(SorobanNetworkConfig const& config) override;
SorobanNetworkConfig&
getMutableSorobanNetworkConfig(AbstractLedgerTxn& ltx) override;
#endif

uint64_t secondsSinceLastLedgerClose() const override;
Expand Down
Loading