Skip to content

Inherit txMaxInMemoryReadEntries from txMaxDiskReadEntries. #4730

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

Closed
wants to merge 2 commits into from
Closed
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
18 changes: 10 additions & 8 deletions Builds/VisualStudio/stellar-core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1630,23 +1630,25 @@ exit /b 0
<None Include="..\..\src\ledger\readme.md" />
<None Include="..\..\src\overlay\readme.md" />
<None Include="..\..\src\rust\Cargo.toml" />
<CustomBuild Include="..\..\src\rust\src\lib.rs">
<CustomBuild Include="..\..\src\rust\src\bridge.rs">
<FileType>Document</FileType>
<Command>$(MSBuildProjectDirectory)\generate_rust_bridge.bat $(OutDir)\..\bin\cxxbridge.exe</Command>
<AdditionalInputs>$(OutDir)\..\bin\cxxbridge.exe;src/$(Configuration)/generated/xdr/Stellar-ledger-entries.h;src/$(Configuration)/generated/xdr/Stellar-transaction.h;src/$(Configuration)/generated/xdr/Stellar-ledger.h;src/$(Configuration)/generated/xdr/Stellar-internal.h;src/$(Configuration)/generated/xdr/Stellar-contract-config-setting.h;src/$(Configuration)/generated/xdr/Stellar-types.h;src/$(Configuration)/generated/xdr/Stellar-contract.h;src/$(Configuration)/generated/xdr/Stellar-overlay.h;src/$(Configuration)/generated/xdr/Stellar-SCP.h</AdditionalInputs>
<Message>running cxxbridge to generate RustBridge.h and RustBridge.cpp</Message>
<Outputs>src\generated\rust\RustBridge.h;src\generated\rust\RustBridge.cpp</Outputs>
<OutputItemType>ClInclude</OutputItemType>
</CustomBuild>
<CustomBuild Include="..\..\src\rust\install-cxxbridge-cmd">
<FileType>Document</FileType>
<Command>cargo install --root $(OutDir)\.. cxxbridge-cmd --version 1.0.68</Command>
<Message>cargo install --root $(OutDir)\.. cxxbridge-cmd --version 1.0.68</Message>
<Outputs>$(OutDir)\..\bin\cxxbridge.exe</Outputs>
</CustomBuild>
<None Include="..\..\src\rust\src\b64.rs" />
<None Include="..\..\src\rust\src\contract.rs" />
<None Include="..\..\src\rust\src\common.rs" />
<None Include="..\..\src\rust\src\i128.rs" />
<None Include="..\..\src\rust\src\lib.rs" />
<None Include="..\..\src\rust\src\log.rs" />
<None Include="..\..\src\rust\src\soroban_invoke.rs" />
<None Include="..\..\src\rust\src\soroban_module_cache.rs" />
<None Include="..\..\src\rust\src\soroban_proto_all.rs" />
<None Include="..\..\src\rust\src\soroban_proto_any.rs" />
<None Include="..\..\src\rust\src\soroban_test_extra_protocol.rs" />
<None Include="..\..\src\rust\src\soroban_test_wasm.rs" />
<None Include="..\..\src\scp\readme.md" />
<None Include="..\..\src\test\check-nondet" />
<None Include="..\..\src\test\run-selftest-nopg" />
Expand Down
37 changes: 28 additions & 9 deletions Builds/VisualStudio/stellar-core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2603,9 +2603,6 @@
<None Include="..\..\src\rust\src\b64.rs">
<Filter>rust</Filter>
</None>
<None Include="..\..\src\rust\src\contract.rs">
<Filter>rust</Filter>
</None>
<None Include="..\..\src\rust\src\log.rs">
<Filter>rust</Filter>
</None>
Expand Down Expand Up @@ -2648,6 +2645,33 @@
<None Include="..\..\src\transactions\readme.md">
<Filter>transactions</Filter>
</None>
<None Include="..\..\src\rust\src\common.rs">
<Filter>rust</Filter>
</None>
<None Include="..\..\src\rust\src\i128.rs">
<Filter>rust</Filter>
</None>
<None Include="..\..\src\rust\src\lib.rs">
<Filter>rust</Filter>
</None>
<None Include="..\..\src\rust\src\soroban_invoke.rs">
<Filter>rust</Filter>
</None>
<None Include="..\..\src\rust\src\soroban_module_cache.rs">
<Filter>rust</Filter>
</None>
<None Include="..\..\src\rust\src\soroban_proto_all.rs">
<Filter>rust</Filter>
</None>
<None Include="..\..\src\rust\src\soroban_proto_any.rs">
<Filter>rust</Filter>
</None>
<None Include="..\..\src\rust\src\soroban_test_extra_protocol.rs">
<Filter>rust</Filter>
</None>
<None Include="..\..\src\rust\src\soroban_test_wasm.rs">
<Filter>rust</Filter>
</None>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\src\protocol-next\xdr\Stellar-contract.x">
Expand Down Expand Up @@ -2680,12 +2704,6 @@
<CustomBuild Include="..\..\src\main\StellarCoreVersion.cpp.in">
<Filter>main</Filter>
</CustomBuild>
<CustomBuild Include="..\..\src\rust\src\lib.rs">
<Filter>rust</Filter>
</CustomBuild>
<CustomBuild Include="..\..\src\rust\install-cxxbridge-cmd">
<Filter>rust</Filter>
</CustomBuild>
<CustomBuild Include="..\..\src\protocol-curr\xdr\Stellar-ledger.x">
<Filter>xdr\curr</Filter>
</CustomBuild>
Expand Down Expand Up @@ -2720,6 +2738,7 @@
<Filter>util\xdrquery</Filter>
</CustomBuild>
<CustomBuild Include="..\..\hash-xdrs.sh" />
<CustomBuild Include="..\..\src\rust\src\bridge.rs" />
</ItemGroup>
<ItemGroup>
<Text Include="..\..\INSTALL-Windows.md" />
Expand Down
2 changes: 1 addition & 1 deletion src/herder/test/HerderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ TEST_CASE("generalized tx set applied to ledger", "[herder][txset][soroban]")
auto resourceFee = sorobanResourceFee(
*app, resources, xdr::xdr_size(dummyUploadTx->getEnvelope()), 40);

uint32_t const rentFee = 20'050;
uint32_t const rentFee = 20'168;
resourceFee += rentFee;
resources.footprint.readWrite.pop_back();
auto addSorobanTx = [&](uint32_t inclusionFee) {
Expand Down
21 changes: 17 additions & 4 deletions src/ledger/NetworkConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,11 +924,15 @@ initialParallelComputeEntry()
}

ConfigSettingEntry
initialLedgerCostExtEntry()
initialLedgerCostExtEntry(uint32_t txMaxDiskReadEntries)
{
ConfigSettingEntry entry(CONFIG_SETTING_CONTRACT_LEDGER_COST_EXT_V0);
// Initialize `txMaxInMemoryReadEntries` with the value of the older
// `txMaxDiskReadEntries` setting that used to apply to the whole
// transaction footprint, so that we ensure that no transactions
// will become invalid due to this limit.
entry.contractLedgerCostExt().txMaxInMemoryReadEntries =
InitialSorobanNetworkConfig::TX_MAX_IN_MEMORY_READ_ENTRIES;
txMaxDiskReadEntries;
entry.contractLedgerCostExt().feeWrite1KB =
InitialSorobanNetworkConfig::FEE_LEDGER_WRITE_1KB;
return entry;
Expand Down Expand Up @@ -1192,8 +1196,17 @@ SorobanNetworkConfig::createLedgerEntriesForV23(AbstractLedgerTxn& ltx,
ZoneScoped;
createConfigSettingEntry(initialParallelComputeEntry(), ltx,
static_cast<uint32_t>(ProtocolVersion::V_23));
createConfigSettingEntry(initialLedgerCostExtEntry(), ltx,
static_cast<uint32_t>(ProtocolVersion::V_23));
// We expect CONFIG_SETTING_CONTRACT_LEDGER_COST_V0 to exist when upgrading
// to protocol 23 as it must be created during the protocol 20 upgrade.
LedgerKey key(CONFIG_SETTING);
key.configSetting().configSettingID =
ConfigSettingID::CONFIG_SETTING_CONTRACT_LEDGER_COST_V0;
auto le = ltx.loadWithoutRecord(key).current();
auto const& ledgerCostSetting =
le.data.configSetting().contractLedgerCost();
createConfigSettingEntry(
initialLedgerCostExtEntry(ledgerCostSetting.txMaxDiskReadBytes), ltx,
static_cast<uint32_t>(ProtocolVersion::V_23));
}

void
Expand Down
3 changes: 1 addition & 2 deletions src/ledger/NetworkConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ struct InitialSorobanNetworkConfig
static constexpr uint32_t LEDGER_MAX_DEPENDENT_TX_CLUSTERS = 1;

// Ledger cost extension settings
static constexpr uint32_t TX_MAX_IN_MEMORY_READ_ENTRIES = 100;
static constexpr int64_t FEE_LEDGER_WRITE_1KB = 1'000;
static constexpr int64_t FEE_LEDGER_WRITE_1KB = 3'500;
};

// Defines the subset of the `InitialSorobanNetworkConfig` to be overridden for
Expand Down
45 changes: 24 additions & 21 deletions src/transactions/test/InvokeHostFunctionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ TEST_CASE_VERSIONS("refund test with closeLedger", "[tx][soroban][feebump]")
int64_t expectedRefund =
protocolVersionStartsFrom(test.getLedgerVersion(),
ProtocolVersion::V_23)
? 981'525
? 981'407
: 981'527;
int64_t initialFee = tx->getEnvelope().v1().tx.fee;
REQUIRE(a1.getBalance() ==
Expand Down Expand Up @@ -1685,7 +1685,7 @@ TEST_CASE_VERSIONS("refund is sent to fee-bump source",
int64_t expectedRefund =
protocolVersionStartsFrom(test.getLedgerVersion(),
ProtocolVersion::V_23)
? 981'525
? 981'407
: 981'527;

// Use the inner transactions fee, which already includes the minimum
Expand Down Expand Up @@ -2556,7 +2556,7 @@ TEST_CASE_VERSIONS("state archival", "[tx][soroban][archival]")
// reason for that is that due to the way the test is set up, the
// rent bump fee has been dominated by the TTL write fee (because
// the write fee itself is high). After protocol 23 the write fee
// is just 1000, and the rent fee itself is small in both cases due
// is just 3500, and the rent fee itself is small in both cases due
// to large denominator.
// We should eventually update this test to use the small
// denominators instead of large write fees in order to get more
Expand All @@ -2565,17 +2565,17 @@ TEST_CASE_VERSIONS("state archival", "[tx][soroban][archival]")
int const rentBumpForWasm =
protocolVersionStartsFrom(test.getLedgerVersion(),
ProtocolVersion::V_23)
? 167
? 285
: 943;
int const rentBumpForInstance =
protocolVersionStartsFrom(test.getLedgerVersion(),
ProtocolVersion::V_23)
? 48
? 166
: 939;
int const rentBumpForInstanceAndWasm =
protocolVersionStartsFrom(test.getLedgerVersion(),
ProtocolVersion::V_23)
? 215
? 450
: 1881;

SECTION("restore contract instance and wasm")
Expand Down Expand Up @@ -2826,7 +2826,7 @@ TEST_CASE_VERSIONS("state archival", "[tx][soroban][archival]")
{lk, lk2}, /*charge for one entry*/
protocolVersionStartsFrom(test.getLedgerVersion(),
ProtocolVersion::V_23)
? 20'048
? 20'166
: 20'939);

// Live entry TTL should be unchanged
Expand Down Expand Up @@ -2912,7 +2912,7 @@ TEST_CASE_VERSIONS("state archival", "[tx][soroban][archival]")
int64_t const expectedRefund =
protocolVersionStartsFrom(test.getLedgerVersion(),
ProtocolVersion::V_23)
? 40'096
? 40'331
: 41'877;
test.invokeExtendOp(keysToExtend, 10'100, expectedRefund);
REQUIRE(
Expand Down Expand Up @@ -3057,7 +3057,7 @@ TEST_CASE("charge rent fees for storage resize", "[tx][soroban]")

SECTION("resize and extend")
{
uint32_t const expectedRefundableFee = 55'989;
uint32_t const expectedRefundableFee = 56107;
REQUIRE(client.resizeStorageAndExtend(
"key", 5, 2'000'000, 2'000'000,
spec.setRefundableResourceFee(expectedRefundableFee - 1)) ==
Expand Down Expand Up @@ -3289,7 +3289,7 @@ TEST_CASE_VERSIONS("archival meta", "[tx][soroban][archival]")
{
SECTION("manual restore")
{
test.invokeRestoreOp({persistentKey}, 20'048);
test.invokeRestoreOp({persistentKey}, 20'166);
testRestore();
}

Expand Down Expand Up @@ -3409,7 +3409,7 @@ TEST_CASE_VERSIONS("archival meta", "[tx][soroban][archival]")

SECTION("manual restore")
{
test.invokeRestoreOp({persistentKey}, 20'048);
test.invokeRestoreOp({persistentKey}, 20'166);
testRestore();
}

Expand Down Expand Up @@ -3521,12 +3521,15 @@ TEST_CASE_VERSIONS("state archival operation errors", "[tx][soroban][archival]")
restoreResources.diskReadBytes = 9'000;
restoreResources.writeBytes = 9'000;

auto const resourceFee = 300'000 + 40'000 * dataKeys.size();
auto const nonRefundableResourceFee =
sorobanResourceFee(test.getApp(), restoreResources, 400, 0);
auto const rentFee = 100'000;
auto const resourceFee = nonRefundableResourceFee + rentFee;

SECTION("insufficient refundable fee")
{
auto tx = test.createRestoreTx(restoreResources, 1'000,
40'000 * dataKeys.size());
nonRefundableResourceFee);
auto result = test.invokeTx(tx);
REQUIRE(!isSuccessResult(result));
REQUIRE(result.result.results()[0]
Expand Down Expand Up @@ -3740,7 +3743,7 @@ TEST_CASE("persistent entry archival", "[tx][soroban][archival]")
.at(0);

// Restore should skip nonexistent key and charge same fees
test.invokeRestoreOp({lk, randomKey}, 20'048);
test.invokeRestoreOp({lk, randomKey}, 20'166);
}

SECTION("key accessible after restore")
Expand All @@ -3767,7 +3770,7 @@ TEST_CASE("persistent entry archival", "[tx][soroban][archival]")

SECTION("restore op")
{
test.invokeRestoreOp({lk}, 20'048);
test.invokeRestoreOp({lk}, 20'166);
check();
}

Expand Down Expand Up @@ -3885,7 +3888,7 @@ TEST_CASE("autorestore contract instance", "[tx][soroban][archival]")
makeSymbolSCVal("key"), ContractDataDurability::PERSISTENT);

// We need to restore instance, wasm, and data entry
auto const refundableRestoreCost = 60'146;
auto const refundableRestoreCost = 60'498;
auto keysToRestore = client.getContract().getKeys();
keysToRestore.push_back(lk);
REQUIRE(client.get("key", ContractDataDurability::PERSISTENT,
Expand Down Expand Up @@ -3992,7 +3995,7 @@ TEST_CASE("autorestore contract instance", "[tx][soroban][archival]")
auto const expectedSize = 80;

// Restore wasm and instance so we just restore data later
test.invokeRestoreOp(contractKeys, 40'098);
test.invokeRestoreOp(contractKeys, 40'333);

SECTION("insufficient read bytes")
{
Expand Down Expand Up @@ -4102,9 +4105,9 @@ TEST_CASE("autorestore with storage resize", "[tx][soroban][archival]")

REQUIRE(!test.isEntryLive(lk, test.getLCLSeq()));

auto const costToRestore1KB = 20'048;
auto const costToBump = 105'141;
auto const costToBumpAfterResize = 263'570;
auto const costToRestore1KB = 20'166;
auto const costToBump = 105'259;
auto const costToBumpAfterResize = 263'688;

auto getExpectedRestoredLedger = [&]() {
return test.getLCLSeq() +
Expand Down Expand Up @@ -6133,7 +6136,7 @@ TEST_CASE("Module cache cost with restore gaps", "[tx][soroban][modulecache]")
SECTION("scenario A: restore in one ledger, invoke in next")
{
// Restore contract in ledger N+1
test.invokeRestoreOp(contractKeys, 40098);
test.invokeRestoreOp(contractKeys, 40333);

// Invoke in ledger N+2
// Because we have a gap between restore and invoke, the module cache
Expand Down
15 changes: 9 additions & 6 deletions src/transactions/test/SorobanTxTestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1267,26 +1267,29 @@ SorobanTest::getLCLSeq() const

TransactionFrameBaseConstPtr
SorobanTest::createExtendOpTx(SorobanResources const& resources,
uint32_t extendTo, uint32_t fee,
int64_t refundableFee, TestAccount* source)
uint32_t extendTo, uint32_t inclusionFee,
int64_t resourceFee, TestAccount* source)
{
Operation op;
op.body.type(EXTEND_FOOTPRINT_TTL);
op.body.extendFootprintTTLOp().extendTo = extendTo;
auto& acc = source ? *source : getRoot();
return sorobanTransactionFrameFromOps(getApp().getNetworkID(), acc, {op},
{}, resources, fee, refundableFee);
{}, resources, inclusionFee,
resourceFee);
}

TransactionFrameBaseConstPtr
SorobanTest::createRestoreTx(SorobanResources const& resources, uint32_t fee,
int64_t refundableFee, TestAccount* source)
SorobanTest::createRestoreTx(SorobanResources const& resources,
uint32_t inclusionFee, int64_t resourceFee,
TestAccount* source)
{
Operation op;
op.body.type(RESTORE_FOOTPRINT);
auto& acc = source ? *source : getRoot();
return sorobanTransactionFrameFromOps(getApp().getNetworkID(), acc, {op},
{}, resources, fee, refundableFee);
{}, resources, inclusionFee,
resourceFee);
}

bool
Expand Down
6 changes: 3 additions & 3 deletions src/transactions/test/SorobanTxTestUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,11 @@ class SorobanTest

TransactionFrameBaseConstPtr
createExtendOpTx(SorobanResources const& resources, uint32_t extendTo,
uint32_t fee, int64_t refundableFee,
uint32_t inclusionFee, int64_t resourceFee,
TestAccount* source = nullptr);
TransactionFrameBaseConstPtr
createRestoreTx(SorobanResources const& resources, uint32_t fee,
int64_t refundableFee, TestAccount* source = nullptr);
createRestoreTx(SorobanResources const& resources, uint32_t inclusionFee,
int64_t resourceFee, TestAccount* source = nullptr);

bool isTxValid(TransactionFrameBaseConstPtr tx);

Expand Down
Loading