Skip to content

Commit

Permalink
Harden handling of tx size upgrades in herder and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marta-lokhova committed Aug 1, 2024
1 parent 9e4b5d9 commit 3718d0d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/herder/HerderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,6 @@ HerderImpl::processExternalized(uint64 slotIndex, StellarValue const& value,
}

mLedgerManager.valueExternalized(ledgerData);

// Ensure potential upgrades are handled in overlay
maybeHandleUpgrade();
}

void
Expand Down Expand Up @@ -1099,6 +1096,9 @@ HerderImpl::lastClosedLedgerIncreased(bool latest)
maybeSetupSorobanQueue(
mLedgerManager.getLastClosedLedgerHeader().header.ledgerVersion);

// Ensure potential upgrades are handled in overlay
maybeHandleUpgrade();

if (latest)
{
releaseAssert(isTracking());
Expand Down
21 changes: 19 additions & 2 deletions src/herder/test/HerderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3797,8 +3797,10 @@ setupUpgradeAtNextLedger(Application& app)
ConfigUpgradeSetFrameConstPtr configUpgradeSet;
ConfigUpgradeSet configUpgradeSetXdr;
auto& configEntry = configUpgradeSetXdr.updatedEntry.emplace_back();
configEntry.configSettingID(CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0);
configEntry.contractHistoricalData().feeHistorical1KB = 1234;
configEntry.configSettingID(CONFIG_SETTING_CONTRACT_BANDWIDTH_V0);
configEntry.contractBandwidth().ledgerMaxTxsSizeBytes = 1'000'000;
configEntry.contractBandwidth().txMaxSizeBytes = 500'000;

configUpgradeSet = makeConfigUpgradeSet(ltx, configUpgradeSetXdr);

scheduledUpgrades.mConfigUpgradeSetKey = configUpgradeSet->getKey();
Expand Down Expand Up @@ -4016,6 +4018,14 @@ herderExternalizesValuesWithProtocol(uint32_t version)
// Ensure C processes future tx set and its fees correctly (even though
// its own ledger state isn't upgraded yet)
receiveLedger(fourth, herderC);
if (protocolVersionStartsFrom(version, SOROBAN_PROTOCOL_VERSION))
{
REQUIRE(herderA.getMaxTxSize() ==
500'000 + herderA.getFlowControlExtraBuffer());
REQUIRE(herderB.getMaxTxSize() ==
500'000 + herderB.getFlowControlExtraBuffer());
REQUIRE(herderC.getMaxTxSize() < herderA.getMaxTxSize());
}

// Wait until C goes out of sync, and processes future slots
simulation->crankUntil([&]() { return !lmC.isSynced(); },
Expand Down Expand Up @@ -4074,6 +4084,13 @@ herderExternalizesValuesWithProtocol(uint32_t version)
auto lcl = lmC.getLastClosedLedgerNum();
REQUIRE(lcl == herderC.trackingConsensusLedgerIndex());

// C properly upgraded max tx size despite externalizing out-of-order
if (protocolVersionStartsFrom(version, SOROBAN_PROTOCOL_VERSION))
{
REQUIRE(herderC.getMaxTxSize() ==
500'000 + herderC.getFlowControlExtraBuffer());
}

// Ensure that C sent out a nomination message for the next consensus
// round
simulation->crankUntil(
Expand Down

0 comments on commit 3718d0d

Please sign in to comment.