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

Consolidate v20 protocol version naming #3947

Merged
merged 1 commit into from
Sep 22, 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
2 changes: 1 addition & 1 deletion src/bucket/BucketList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ BucketList::scanForEviction(Application& app, AbstractLedgerTxn& ltx,
};

if (protocolVersionStartsFrom(ltx.getHeader().ledgerVersion,
ProtocolVersion::V_20))
SOROBAN_PROTOCOL_VERSION))
{
auto const& networkConfig =
app.getLedgerManager().getSorobanNetworkConfig(ltx);
Expand Down
2 changes: 1 addition & 1 deletion src/bucket/BucketManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ BucketManagerImpl::scanForEviction(AbstractLedgerTxn& ltx, uint32_t ledgerSeq)
{
ZoneScoped;
if (protocolVersionStartsFrom(ltx.getHeader().ledgerVersion,
ProtocolVersion::V_20))
SOROBAN_PROTOCOL_VERSION))
{
mBucketList->scanForEviction(mApp, ltx, ledgerSeq, mEntriesEvicted,
mBytesScannedForEviction,
Expand Down
4 changes: 2 additions & 2 deletions src/herder/HerderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ HerderImpl::triggerNextLedger(uint32_t ledgerSeqToTrigger,
invalidTxPhases);

if (protocolVersionStartsFrom(lcl.header.ledgerVersion,
ProtocolVersion::V_20))
SOROBAN_PROTOCOL_VERSION))
{
mSorobanTransactionQueue.ban(
invalidTxPhases[static_cast<size_t>(TxSetFrame::Phase::SOROBAN)]);
Expand Down Expand Up @@ -2000,7 +2000,7 @@ HerderImpl::maybeHandleUpgrade()
/* shouldUpdateLastModified */ true,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
if (protocolVersionIsBefore(ltx.loadHeader().current().ledgerVersion,
ProtocolVersion::V_20))
SOROBAN_PROTOCOL_VERSION))
{
// no-op on any earlier protocol
return;
Expand Down
4 changes: 2 additions & 2 deletions src/herder/HerderSCPDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ compareTxSets(TxSetFrameConstPtr l, TxSetFrameConstPtr r, Hash const& lh,
return lSize < rSize;
}
if (protocolVersionStartsFrom(header.ledgerVersion,
GENERALIZED_TX_SET_PROTOCOL_VERSION))
SOROBAN_PROTOCOL_VERSION))
{
auto lBids = l->getTotalInclusionFees();
auto rBids = r->getTotalInclusionFees();
Expand All @@ -598,7 +598,7 @@ compareTxSets(TxSetFrameConstPtr l, TxSetFrameConstPtr r, Hash const& lh,
}
}
if (protocolVersionStartsFrom(header.ledgerVersion,
GENERALIZED_TX_SET_PROTOCOL_VERSION))
SOROBAN_PROTOCOL_VERSION))
{
auto lEncodedSize = l->encodedSize();
auto rEncodedSize = r->encodedSize();
Expand Down
2 changes: 1 addition & 1 deletion src/herder/TxQueueLimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ TxQueueLimiter::reset(AbstractLedgerTxn& ltxOuter)
{
if (protocolVersionStartsFrom(
ltxOuter.loadHeader().current().ledgerVersion,
ProtocolVersion::V_20))
SOROBAN_PROTOCOL_VERSION))
{
mSurgePricingLaneConfig =
std::make_shared<SorobanGenericLaneConfig>(
Expand Down
16 changes: 8 additions & 8 deletions src/herder/TxSetFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ computeNonGenericTxSetContentsHash(TransactionSet const& xdrTxSet)
int64_t
computePerOpFee(TransactionFrameBase const& tx, uint32_t ledgerVersion)
{
auto rounding = protocolVersionStartsFrom(
ledgerVersion, GENERALIZED_TX_SET_PROTOCOL_VERSION)
? Rounding::ROUND_DOWN
: Rounding::ROUND_UP;
auto rounding =
protocolVersionStartsFrom(ledgerVersion, SOROBAN_PROTOCOL_VERSION)
? Rounding::ROUND_DOWN
: Rounding::ROUND_UP;
auto txOps = tx.getNumOperations();
return bigDivideOrThrow(tx.getInclusionFee(), 1,
static_cast<int64_t>(txOps), rounding);
Expand Down Expand Up @@ -250,7 +250,7 @@ TxSetFrame::makeFromTransactions(Transactions txs, Application& app,
phases.emplace_back(txs);
auto lclHeader = app.getLedgerManager().getLastClosedLedgerHeader();
if (protocolVersionStartsFrom(lclHeader.header.ledgerVersion,
GENERALIZED_TX_SET_PROTOCOL_VERSION))
SOROBAN_PROTOCOL_VERSION))
{
// Empty soroban phase
phases.emplace_back();
Expand All @@ -268,7 +268,7 @@ TxSetFrame::makeFromTransactions(Transactions txs, Application& app,
TxSetFrame::TxSetFrame(LedgerHeaderHistoryEntry const& lclHeader,
TxPhases const& txs)
: TxSetFrame(protocolVersionStartsFrom(lclHeader.header.ledgerVersion,
GENERALIZED_TX_SET_PROTOCOL_VERSION),
SOROBAN_PROTOCOL_VERSION),
lclHeader.hash, txs)
{
}
Expand Down Expand Up @@ -375,7 +375,7 @@ TxSetFrame::makeEmpty(LedgerHeaderHistoryEntry const& lclHeader)
// simple and exception-safe.
TxPhases phases;
phases.resize(protocolVersionStartsFrom(lclHeader.header.ledgerVersion,
GENERALIZED_TX_SET_PROTOCOL_VERSION)
SOROBAN_PROTOCOL_VERSION)
? static_cast<size_t>(Phase::PHASE_COUNT)
: 1);
std::shared_ptr<TxSetFrame> txSet(new TxSetFrame(lclHeader, phases));
Expand Down Expand Up @@ -578,7 +578,7 @@ TxSetFrame::checkValid(Application& app, uint64_t lowerBoundCloseTimeOffset,
}

bool needGeneralizedTxSet = protocolVersionStartsFrom(
lcl.header.ledgerVersion, GENERALIZED_TX_SET_PROTOCOL_VERSION);
lcl.header.ledgerVersion, SOROBAN_PROTOCOL_VERSION);
if (needGeneralizedTxSet != isGeneralizedTxSet())
{
CLOG_DEBUG(Herder,
Expand Down
108 changes: 45 additions & 63 deletions src/herder/test/HerderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ testTxSet(uint32 protocolVersion)
VirtualClock clock;
Application::pointer app = createTestApplication(clock, cfg);
bool uniqueAccounts =
protocolVersion >=
static_cast<uint32_t>(GENERALIZED_TX_SET_PROTOCOL_VERSION);
protocolVersion >= static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION);

// set up world
auto root = TestAccount::createRoot(*app);
Expand Down Expand Up @@ -652,7 +651,7 @@ TEST_CASE("txset", "[herder][txset]")
}
SECTION("generalized tx set protocol")
{
testTxSet(static_cast<uint32>(GENERALIZED_TX_SET_PROTOCOL_VERSION));
testTxSet(static_cast<uint32>(SOROBAN_PROTOCOL_VERSION));
}
SECTION("protocol current")
{
Expand Down Expand Up @@ -732,7 +731,7 @@ TEST_CASE_VERSIONS("txset with PreconditionsV2", "[herder][txset]")
{
LedgerTxn ltx(app->getLedgerTxnRoot());
if (ltx.loadHeader().current().ledgerVersion >=
static_cast<uint32_t>(GENERALIZED_TX_SET_PROTOCOL_VERSION))
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION))
{
return;
}
Expand Down Expand Up @@ -767,7 +766,7 @@ TEST_CASE_VERSIONS("txset with PreconditionsV2", "[herder][txset]")
{
LedgerTxn ltx(app->getLedgerTxnRoot());
if (ltx.loadHeader().current().ledgerVersion >=
static_cast<uint32_t>(GENERALIZED_TX_SET_PROTOCOL_VERSION))
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION))
{
return;
}
Expand Down Expand Up @@ -1220,33 +1219,28 @@ TEST_CASE("txset base fee", "[herder][txset]")
// high = 2*base (surge)
SECTION("maxed out surged")
{
testBaseFee(static_cast<uint32_t>(
GENERALIZED_TX_SET_PROTOCOL_VERSION) -
1,
baseCount, v11ExtraTx, maxTxSetSize, 1000,
2000);
testBaseFee(
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION) - 1,
baseCount, v11ExtraTx, maxTxSetSize, 1000, 2000);
}
SECTION("smallest surged")
{
testBaseFee(static_cast<uint32_t>(
GENERALIZED_TX_SET_PROTOCOL_VERSION) -
1,
baseCount + 1, v11ExtraTx - 50,
maxTxSetSize - 100 + 1, 1000, 2000);
testBaseFee(
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION) - 1,
baseCount + 1, v11ExtraTx - 50, maxTxSetSize - 100 + 1,
1000, 2000);
}
}
SECTION("generalized tx set protocol")
{
SECTION("fitting exactly into capacity does not cause surge")
{
testBaseFee(static_cast<uint32_t>(
GENERALIZED_TX_SET_PROTOCOL_VERSION),
testBaseFee(static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION),
baseCount, v11ExtraTx, maxTxSetSize, 100, 200);
}
SECTION("evicting one tx causes surge")
{
testBaseFee(static_cast<uint32_t>(
GENERALIZED_TX_SET_PROTOCOL_VERSION),
testBaseFee(static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION),
baseCount + 1, v11ExtraTx, maxTxSetSize, 1000,
2000, 1);
}
Expand All @@ -1255,41 +1249,37 @@ TEST_CASE("txset base fee", "[herder][txset]")
{
if (protocolVersionStartsFrom(
Config::CURRENT_LEDGER_PROTOCOL_VERSION,
GENERALIZED_TX_SET_PROTOCOL_VERSION))
SOROBAN_PROTOCOL_VERSION))
{
SECTION(
"fitting exactly into capacity does not cause surge")
{
testBaseFee(static_cast<uint32_t>(
GENERALIZED_TX_SET_PROTOCOL_VERSION),
baseCount, v11ExtraTx, maxTxSetSize, 100,
200);
testBaseFee(
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION),
baseCount, v11ExtraTx, maxTxSetSize, 100, 200);
}
SECTION("evicting one tx causes surge")
{
testBaseFee(static_cast<uint32_t>(
GENERALIZED_TX_SET_PROTOCOL_VERSION),
baseCount + 1, v11ExtraTx, maxTxSetSize,
1000, 2000, 1);
testBaseFee(
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION),
baseCount + 1, v11ExtraTx, maxTxSetSize, 1000, 2000,
1);
}
}
else
{
SECTION("maxed out surged")
{
testBaseFee(static_cast<uint32_t>(
GENERALIZED_TX_SET_PROTOCOL_VERSION) -
1,
baseCount, v11ExtraTx, maxTxSetSize, 1000,
2000);
testBaseFee(
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION) - 1,
baseCount, v11ExtraTx, maxTxSetSize, 1000, 2000);
}
SECTION("smallest surged")
{
testBaseFee(static_cast<uint32_t>(
GENERALIZED_TX_SET_PROTOCOL_VERSION) -
1,
baseCount + 1, v11ExtraTx - 50,
maxTxSetSize - 100 + 1, 1000, 2000);
testBaseFee(
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION) - 1,
baseCount + 1, v11ExtraTx - 50,
maxTxSetSize - 100 + 1, 1000, 2000);
}
}
}
Expand All @@ -1306,23 +1296,19 @@ TEST_CASE("txset base fee", "[herder][txset]")
{
// low = 20000+1 -> baseFee = 20001/2+ = 10001
// high = 10001*2
testBaseFee(
static_cast<uint32_t>(GENERALIZED_TX_SET_PROTOCOL_VERSION) -
1,
0, v11NewCount, maxTxSetSize, 20001, 20002);
testBaseFee(static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION) - 1,
0, v11NewCount, maxTxSetSize, 20001, 20002);
}
SECTION("generalized tx set protocol")
{
SECTION("fitting exactly into capacity does not cause surge")
{
testBaseFee(static_cast<uint32_t>(
GENERALIZED_TX_SET_PROTOCOL_VERSION),
testBaseFee(static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION),
0, v11NewCount, maxTxSetSize, 200, 200);
}
SECTION("evicting one tx causes surge")
{
testBaseFee(static_cast<uint32_t>(
GENERALIZED_TX_SET_PROTOCOL_VERSION),
testBaseFee(static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION),
0, v11NewCount + 1, maxTxSetSize, 20002, 20002,
1);
}
Expand All @@ -1331,7 +1317,7 @@ TEST_CASE("txset base fee", "[herder][txset]")
{
if (protocolVersionStartsFrom(
Config::CURRENT_LEDGER_PROTOCOL_VERSION,
GENERALIZED_TX_SET_PROTOCOL_VERSION))
SOROBAN_PROTOCOL_VERSION))
{
SECTION(
"fitting exactly into capacity does not cause surge")
Expand All @@ -1348,10 +1334,9 @@ TEST_CASE("txset base fee", "[herder][txset]")
}
else
{
testBaseFee(static_cast<uint32_t>(
GENERALIZED_TX_SET_PROTOCOL_VERSION) -
1,
0, v11NewCount, maxTxSetSize, 20001, 20002);
testBaseFee(
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION) - 1, 0,
v11NewCount, maxTxSetSize, 20001, 20002);
}
}
}
Expand Down Expand Up @@ -1403,8 +1388,7 @@ static void
surgeTest(uint32 protocolVersion, uint32_t nbTxs, uint32_t maxTxSetSize,
uint32_t expectedReduced)
{
if (protocolVersion >=
static_cast<uint32_t>(GENERALIZED_TX_SET_PROTOCOL_VERSION))
if (protocolVersion >= static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION))
{
throw std::runtime_error("Surge test does not apply post protocol 19");
}
Expand Down Expand Up @@ -1601,7 +1585,7 @@ TEST_CASE("surge pricing", "[herder][txset]")
{
Config cfg(getTestConfig());
cfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION =
static_cast<uint32_t>(GENERALIZED_TX_SET_PROTOCOL_VERSION);
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION);
// Max 1 classic op
cfg.TESTING_UPGRADE_MAX_TX_SET_SIZE = 1;

Expand Down Expand Up @@ -1849,7 +1833,7 @@ TEST_CASE("surge pricing", "[herder][txset]")
TEST_CASE("surge pricing with DEX separation", "[herder][txset]")
{
if (protocolVersionIsBefore(Config::CURRENT_LEDGER_PROTOCOL_VERSION,
GENERALIZED_TX_SET_PROTOCOL_VERSION))
SOROBAN_PROTOCOL_VERSION))
{
return;
}
Expand Down Expand Up @@ -2037,7 +2021,7 @@ TEST_CASE("surge pricing with DEX separation holds invariants",
"[herder][txset]")
{
if (protocolVersionIsBefore(Config::CURRENT_LEDGER_PROTOCOL_VERSION,
GENERALIZED_TX_SET_PROTOCOL_VERSION))
SOROBAN_PROTOCOL_VERSION))
{
return;
}
Expand Down Expand Up @@ -2170,9 +2154,9 @@ TEST_CASE("generalized tx set applied to ledger", "[herder][txset]")
{
Config cfg(getTestConfig());
cfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION =
static_cast<uint32_t>(GENERALIZED_TX_SET_PROTOCOL_VERSION);
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION);
cfg.LEDGER_PROTOCOL_VERSION =
static_cast<uint32_t>(GENERALIZED_TX_SET_PROTOCOL_VERSION);
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION);
VirtualClock clock;
Application::pointer app = createTestApplication(clock, cfg);
auto root = TestAccount::createRoot(*app);
Expand Down Expand Up @@ -2836,14 +2820,12 @@ TEST_CASE("SCP Driver", "[herder][acceptance]")
{
SECTION("before generalized tx set protocol")
{
testSCPDriver(static_cast<uint32>(GENERALIZED_TX_SET_PROTOCOL_VERSION) -
1,
1000, 15);
testSCPDriver(static_cast<uint32>(SOROBAN_PROTOCOL_VERSION) - 1, 1000,
15);
}
SECTION("generalized tx set protocol")
{
testSCPDriver(static_cast<uint32>(GENERALIZED_TX_SET_PROTOCOL_VERSION),
1000, 15);
testSCPDriver(static_cast<uint32>(SOROBAN_PROTOCOL_VERSION), 1000, 15);
}
SECTION("protocol current")
{
Expand Down
3 changes: 1 addition & 2 deletions src/herder/test/TestTxSetUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ makeNonValidatedTxSetBasedOnLedgerVersion(
uint32_t ledgerVersion, std::vector<TransactionFrameBasePtr> const& txs,
Application& app, Hash const& previousLedgerHash)
{
if (protocolVersionStartsFrom(ledgerVersion,
GENERALIZED_TX_SET_PROTOCOL_VERSION))
if (protocolVersionStartsFrom(ledgerVersion, SOROBAN_PROTOCOL_VERSION))
{
return makeNonValidatedGeneralizedTxSet(
{{std::make_pair(100LL, txs)}, {}}, app, previousLedgerHash);
Expand Down
Loading