Skip to content

Commit 2b0129a

Browse files
committed
modifySorobanNetorkConfig uses real upgrade flow
1 parent aaabd31 commit 2b0129a

20 files changed

+2154
-1950
lines changed

src/bucket/test/BucketListTests.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,8 @@ TEST_CASE_VERSIONS("network config snapshots BucketList size", "[bucketlist]")
917917
auto ledgersToGenerate =
918918
(windowSize + 1) *
919919
networkConfig.stateArchivalSettings().bucketListWindowSamplePeriod;
920-
for (uint32_t ledger = 1; ledger < ledgersToGenerate; ++ledger)
920+
auto lclSeq = lm.getLastClosedLedgerHeader().header.ledgerSeq;
921+
for (uint32_t ledger = lclSeq; ledger < ledgersToGenerate; ++ledger)
921922
{
922923
// Note: BucketList size in the sliding window is snapshotted before
923924
// adding new sliding window config entry with the resulting

src/herder/Upgrades.h

+4
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,15 @@ class ConfigUpgradeSetFrame
170170

171171
std::string toJson() const;
172172

173+
#ifndef BUILD_TESTS
173174
private:
175+
#endif
176+
174177
ConfigUpgradeSetFrame(ConfigUpgradeSet const& upgradeSetXDR,
175178
ConfigUpgradeSetKey const& key,
176179
uint32_t ledgerVersion);
177180

181+
private:
178182
bool isValidXDR(ConfigUpgradeSet const& upgradeSetXDR,
179183
ConfigUpgradeSetKey const& key) const;
180184

src/herder/test/HerderTests.cpp

+17-7
Original file line numberDiff line numberDiff line change
@@ -1077,16 +1077,17 @@ TEST_CASE("surge pricing", "[herder][txset][soroban]")
10771077
SECTION("max 0 ops per ledger")
10781078
{
10791079
Config cfg(getTestConfig(0, Config::TESTDB_IN_MEMORY));
1080-
cfg.TESTING_UPGRADE_MAX_TX_SET_SIZE = 0;
1081-
1082-
VirtualClock clock;
1083-
Application::pointer app = createTestApplication(clock, cfg);
1084-
auto root = app->getRoot();
1085-
1086-
auto destAccount = root->create("destAccount", 500000000);
10871080

10881081
SECTION("classic")
10891082
{
1083+
cfg.TESTING_UPGRADE_MAX_TX_SET_SIZE = 0;
1084+
1085+
VirtualClock clock;
1086+
Application::pointer app = createTestApplication(clock, cfg);
1087+
auto root = app->getRoot();
1088+
1089+
auto destAccount = root->create("destAccount", 500000000);
1090+
10901091
auto tx = makeMultiPayment(destAccount, *root, 1, 100, 0, 1);
10911092

10921093
TxFrameList invalidTxs;
@@ -1099,6 +1100,15 @@ TEST_CASE("surge pricing", "[herder][txset][soroban]")
10991100
}
11001101
SECTION("soroban")
11011102
{
1103+
// Dont set TESTING_UPGRADE_MAX_TX_SET_SIZE for soroban test case
1104+
// because we need to submit a TX for the actual kill switch
1105+
// upgrade.
1106+
VirtualClock clock;
1107+
Application::pointer app = createTestApplication(clock, cfg);
1108+
auto root = app->getRoot();
1109+
1110+
auto destAccount = root->create("destAccount", 500000000);
1111+
11021112
uint32_t const baseFee = 10'000'000;
11031113
modifySorobanNetworkConfig(*app, [](SorobanNetworkConfig& cfg) {
11041114
cfg.mLedgerMaxTxCount = 0;

src/herder/test/TxSetTests.cpp

+43-9
Original file line numberDiff line numberDiff line change
@@ -1069,10 +1069,23 @@ TEST_CASE("applicable txset validation - Soroban resources", "[txset][soroban]")
10691069
op.body.type(INVOKE_HOST_FUNCTION);
10701070
op.body.invokeHostFunctionOp().hostFunction.type(
10711071
HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM);
1072+
1073+
// Make sure that our transactions are large enough so our upgrade
1074+
// maintains at least the minimum required max tx size
1075+
auto randomWasm = rust_bridge::get_random_wasm(
1076+
MinimumSorobanNetworkConfig::TX_MAX_SIZE_BYTES, 0);
1077+
op.body.invokeHostFunctionOp().hostFunction.wasm().insert(
1078+
op.body.invokeHostFunctionOp().hostFunction.wasm().begin(),
1079+
randomWasm.data.data(),
1080+
randomWasm.data.data() + randomWasm.data.size());
1081+
10721082
SorobanResources resources;
1073-
resources.instructions = 1'000'000;
1083+
resources.instructions =
1084+
MinimumSorobanNetworkConfig::TX_MAX_INSTRUCTIONS;
10741085
resources.readBytes = 5'000;
1075-
resources.writeBytes = 2'000;
1086+
resources.writeBytes =
1087+
MinimumSorobanNetworkConfig::TX_MAX_WRITE_BYTES;
1088+
10761089
for (int i = 0; i < 8; ++i)
10771090
{
10781091
resources.footprint.readOnly.push_back(
@@ -1110,13 +1123,34 @@ TEST_CASE("applicable txset validation - Soroban resources", "[txset][soroban]")
11101123
// accommodate 20 txs created by `createTx()`.
11111124
modifySorobanNetworkConfig(
11121125
*app, [&](SorobanNetworkConfig& sorobanCfg) {
1113-
sorobanCfg.mLedgerMaxInstructions = 20 * 1'000'000;
1114-
sorobanCfg.mLedgerMaxReadBytes = 20 * 5000;
1115-
sorobanCfg.mLedgerMaxWriteBytes = 20 * 2000;
1116-
sorobanCfg.mLedgerMaxReadLedgerEntries = 20 * 10;
1117-
sorobanCfg.mLedgerMaxWriteLedgerEntries = 20 * 2;
1118-
sorobanCfg.mLedgerMaxTxCount = 20;
1119-
sorobanCfg.mLedgerMaxTransactionsSizeBytes = 20 * txSize;
1126+
auto const txCount = 20;
1127+
sorobanCfg.mLedgerMaxTxCount = txCount;
1128+
1129+
sorobanCfg.mTxMaxInstructions =
1130+
MinimumSorobanNetworkConfig::TX_MAX_INSTRUCTIONS;
1131+
sorobanCfg.mLedgerMaxInstructions =
1132+
txCount * sorobanCfg.mTxMaxInstructions;
1133+
1134+
sorobanCfg.mTxMaxReadBytes = 5000;
1135+
sorobanCfg.mLedgerMaxReadBytes =
1136+
txCount * sorobanCfg.mTxMaxReadBytes;
1137+
1138+
sorobanCfg.mTxMaxWriteBytes =
1139+
MinimumSorobanNetworkConfig::TX_MAX_WRITE_BYTES;
1140+
sorobanCfg.mLedgerMaxWriteBytes =
1141+
txCount * sorobanCfg.mTxMaxWriteBytes;
1142+
1143+
sorobanCfg.mTxMaxReadLedgerEntries = 10;
1144+
sorobanCfg.mLedgerMaxReadLedgerEntries =
1145+
txCount * sorobanCfg.mTxMaxReadLedgerEntries;
1146+
1147+
sorobanCfg.mTxMaxWriteLedgerEntries = 2;
1148+
sorobanCfg.mLedgerMaxWriteLedgerEntries =
1149+
txCount * sorobanCfg.mTxMaxWriteLedgerEntries;
1150+
1151+
sorobanCfg.mTxMaxSizeBytes = txSize;
1152+
sorobanCfg.mLedgerMaxTransactionsSizeBytes =
1153+
txCount * sorobanCfg.mTxMaxSizeBytes;
11201154

11211155
if (protocolVersionStartsFrom(
11221156
protocolVersion,

src/ledger/test/LedgerCloseMetaStreamTests.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ TEST_CASE_VERSIONS("meta stream contains reasonable meta", "[ledgerclosemeta]")
399399
createResources, 1000);
400400

401401
closeLedger(test.getApp(), {tx1, tx2, tx3, tx4, tx5});
402-
targetSeq = 28;
402+
targetSeq = 31;
403403
}
404404
else
405405
{
@@ -421,8 +421,8 @@ TEST_CASE_VERSIONS("meta stream contains reasonable meta", "[ledgerclosemeta]")
421421
.bucketListWindowSamplePeriod = 1;
422422
});
423423

424-
// Modify Soroban network config closes a ledger
425-
++targetSeq;
424+
// Modify Soroban network config closes 4 ledgers
425+
targetSeq += 4;
426426
}
427427

428428
auto root = app->getRoot();

src/overlay/test/OverlayTests.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ TEST_CASE("flow control byte capacity", "[overlay][flowcontrol]")
160160
auto setupApp = [txSize, tx1](Application& app) {
161161
app.getHerder().setMaxClassicTxSize(txSize);
162162

163+
app.start();
163164
if (appProtocolVersionStartsFrom(app, SOROBAN_PROTOCOL_VERSION))
164165
{
165166
overrideSorobanNetworkConfigForTest(app);
@@ -168,8 +169,6 @@ TEST_CASE("flow control byte capacity", "[overlay][flowcontrol]")
168169
static_cast<uint32_t>(xdr::xdr_size(tx1.transaction()));
169170
});
170171
}
171-
172-
app.start();
173172
};
174173

175174
auto test = [&](bool shouldRequestMore) {
@@ -629,6 +628,9 @@ TEST_CASE("drop peers that dont respect capacity", "[overlay][flowcontrol]")
629628
{
630629
modifySorobanNetworkConfig(*app1, [txSize](SorobanNetworkConfig& cfg) {
631630
cfg.mTxMaxSizeBytes = txSize;
631+
// Set the ledger max transactions size to the tx max size
632+
// to have a valid upgrade.
633+
cfg.mLedgerMaxTransactionsSizeBytes = cfg.mTxMaxSizeBytes;
632634
});
633635
}
634636

src/simulation/LoadGenerator.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -1515,24 +1515,32 @@ GeneratedLoadConfig::copySorobanNetworkConfigToUpgradeConfig(
15151515

15161516
upgradeCfg.ledgerMaxInstructions = cfg.ledgerMaxInstructions();
15171517
upgradeCfg.txMaxInstructions = cfg.txMaxInstructions();
1518+
upgradeCfg.feeRatePerInstructionsIncrement =
1519+
cfg.feeRatePerInstructionsIncrement();
15181520
upgradeCfg.txMemoryLimit = cfg.txMemoryLimit();
15191521

15201522
upgradeCfg.ledgerMaxReadLedgerEntries = cfg.ledgerMaxReadLedgerEntries();
15211523
upgradeCfg.ledgerMaxReadBytes = cfg.ledgerMaxReadBytes();
15221524
upgradeCfg.ledgerMaxWriteLedgerEntries = cfg.ledgerMaxWriteLedgerEntries();
15231525
upgradeCfg.ledgerMaxWriteBytes = cfg.ledgerMaxWriteBytes();
15241526
upgradeCfg.ledgerMaxTxCount = cfg.ledgerMaxTxCount();
1527+
upgradeCfg.feeReadLedgerEntry = cfg.feeReadLedgerEntry();
1528+
upgradeCfg.feeWriteLedgerEntry = cfg.feeWriteLedgerEntry();
1529+
upgradeCfg.feeRead1KB = cfg.feeRead1KB();
15251530
upgradeCfg.txMaxReadLedgerEntries = cfg.txMaxReadLedgerEntries();
15261531
upgradeCfg.txMaxReadBytes = cfg.txMaxReadBytes();
15271532
upgradeCfg.txMaxWriteLedgerEntries = cfg.txMaxWriteLedgerEntries();
15281533
upgradeCfg.txMaxWriteBytes = cfg.txMaxWriteBytes();
15291534

1535+
upgradeCfg.feeHistorical1KB = cfg.feeHistorical1KB();
1536+
15301537
upgradeCfg.txMaxContractEventsSizeBytes =
15311538
cfg.txMaxContractEventsSizeBytes();
15321539

15331540
upgradeCfg.ledgerMaxTransactionsSizeBytes =
15341541
cfg.ledgerMaxTransactionSizesBytes();
15351542
upgradeCfg.txMaxSizeBytes = cfg.txMaxSizeBytes();
1543+
upgradeCfg.feeTransactionSize1KB = cfg.feeTransactionSize1KB();
15361544

15371545
upgradeCfg.maxEntryTTL = cfg.stateArchivalSettings().maxEntryTTL;
15381546
upgradeCfg.minTemporaryTTL = cfg.stateArchivalSettings().minTemporaryTTL;
@@ -1550,6 +1558,9 @@ GeneratedLoadConfig::copySorobanNetworkConfigToUpgradeConfig(
15501558
upgradeCfg.evictionScanSize = cfg.stateArchivalSettings().evictionScanSize;
15511559
upgradeCfg.startingEvictionScanLevel =
15521560
cfg.stateArchivalSettings().startingEvictionScanLevel;
1561+
1562+
upgradeCfg.writeFee1KBBucketListLow = cfg.writeFee1KBBucketListLow();
1563+
upgradeCfg.writeFee1KBBucketListHigh = cfg.writeFee1KBBucketListHigh();
15531564
}
15541565

15551566
GeneratedLoadConfig

0 commit comments

Comments
 (0)