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

Implement rent fees. #3813

Merged
merged 2 commits into from
Jul 7, 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
4 changes: 4 additions & 0 deletions Builds/VisualStudio/stellar-core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ exit /b 0
<ClCompile Include="..\..\src\test\FuzzerImpl.cpp" />
<ClCompile Include="..\..\src\transactions\AllowTrustOpFrame.cpp" />
<ClCompile Include="..\..\src\transactions\BeginSponsoringFutureReservesOpFrame.cpp" />
<ClCompile Include="..\..\src\transactions\BumpFootprintExpirationOpFrame.cpp" />
<ClCompile Include="..\..\src\transactions\BumpSequenceOpFrame.cpp" />
<ClCompile Include="..\..\src\transactions\ChangeTrustOpFrame.cpp" />
<ClCompile Include="..\..\src\transactions\ClaimClaimableBalanceOpFrame.cpp" />
Expand All @@ -654,6 +655,7 @@ exit /b 0
<ClCompile Include="..\..\src\transactions\PathPaymentStrictReceiveOpFrame.cpp" />
<ClCompile Include="..\..\src\transactions\PathPaymentStrictSendOpFrame.cpp" />
<ClCompile Include="..\..\src\transactions\PaymentOpFrame.cpp" />
<ClCompile Include="..\..\src\transactions\RestoreFootprintOpFrame.cpp" />
<ClCompile Include="..\..\src\transactions\RevokeSponsorshipOpFrame.cpp" />
<ClCompile Include="..\..\src\transactions\SetOptionsOpFrame.cpp" />
<ClCompile Include="..\..\src\transactions\SetTrustLineFlagsOpFrame.cpp" />
Expand Down Expand Up @@ -1041,6 +1043,7 @@ exit /b 0
<ClInclude Include="..\..\src\test\FuzzerImpl.h" />
<ClInclude Include="..\..\src\transactions\AllowTrustOpFrame.h" />
<ClInclude Include="..\..\src\transactions\BeginSponsoringFutureReservesOpFrame.h" />
<ClInclude Include="..\..\src\transactions\BumpFootprintExpirationOpFrame.h" />
<ClInclude Include="..\..\src\transactions\BumpSequenceOpFrame.h" />
<ClInclude Include="..\..\src\transactions\ChangeTrustOpFrame.h" />
<ClInclude Include="..\..\src\transactions\ClaimClaimableBalanceOpFrame.h" />
Expand All @@ -1066,6 +1069,7 @@ exit /b 0
<ClInclude Include="..\..\src\transactions\PathPaymentStrictReceiveOpFrame.h" />
<ClInclude Include="..\..\src\transactions\PathPaymentStrictSendOpFrame.h" />
<ClInclude Include="..\..\src\transactions\PaymentOpFrame.h" />
<ClInclude Include="..\..\src\transactions\RestoreFootprintOpFrame.h" />
<ClInclude Include="..\..\src\transactions\RevokeSponsorshipOpFrame.h" />
<ClInclude Include="..\..\src\transactions\SetOptionsOpFrame.h" />
<ClInclude Include="..\..\src\transactions\SetTrustLineFlagsOpFrame.h" />
Expand Down
12 changes: 12 additions & 0 deletions Builds/VisualStudio/stellar-core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,12 @@
<ClCompile Include="..\..\src\util\TxResource.cpp">
<Filter>util</Filter>
</ClCompile>
<ClCompile Include="..\..\src\transactions\BumpFootprintExpirationOpFrame.cpp">
<Filter>transactions</Filter>
</ClCompile>
<ClCompile Include="..\..\src\transactions\RestoreFootprintOpFrame.cpp">
<Filter>transactions</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\lib\util\cpptoml.h">
Expand Down Expand Up @@ -2335,6 +2341,12 @@
<ClInclude Include="..\..\src\util\TxResource.h">
<Filter>util</Filter>
</ClInclude>
<ClInclude Include="..\..\src\transactions\BumpFootprintExpirationOpFrame.h">
<Filter>transactions</Filter>
</ClInclude>
<ClInclude Include="..\..\src\transactions\RestoreFootprintOpFrame.h">
<Filter>transactions</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\AUTHORS" />
Expand Down
77 changes: 28 additions & 49 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion src/ledger/LedgerTypeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ bool
autoBumpEnabled(LedgerEntry const& e)
{
#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
releaseAssert(isSorobanDataEntry(e.data));
releaseAssertOrThrow(isSorobanDataEntry(e.data));

// CONTRACT_CODE always has autobump enabled. For CONTRACT_DATA, check if
// the NO_AUTOBUMP flag set
Expand Down
22 changes: 22 additions & 0 deletions src/ledger/NetworkConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,17 @@ initialStateExpirationSettings()
entry.stateExpirationSettings().bucketListSizeWindowSampleSize =
InitialSorobanNetworkConfig::BUCKET_LIST_SIZE_WINDOW_SAMPLE_SIZE;

entry.stateExpirationSettings().bucketListSizeWindowSampleSize =
InitialSorobanNetworkConfig::BUCKET_LIST_SIZE_WINDOW_SAMPLE_SIZE;
entry.stateExpirationSettings().evictionScanSize =
InitialSorobanNetworkConfig::EVICTION_SCAN_SIZE;
entry.stateExpirationSettings().maxEntriesToExpire =
InitialSorobanNetworkConfig::MAX_ENTRIES_TO_EXPIRE;

entry.stateExpirationSettings().persistentRentRateDenominator =
InitialSorobanNetworkConfig::PERSISTENT_RENT_RATE_DENOMINATOR;
entry.stateExpirationSettings().tempRentRateDenominator =
InitialSorobanNetworkConfig::TEMP_RENT_RATE_DENOMINATOR;
return entry;
}

Expand Down Expand Up @@ -1140,5 +1151,16 @@ SorobanNetworkConfig::rustBridgeFeeConfiguration() const

return res;
}

CxxRentFeeConfiguration
SorobanNetworkConfig::rustBridgeRentFeeConfiguration() const
{
CxxRentFeeConfiguration res{};
auto const& cfg = stateExpirationSettings();
res.fee_per_write_1kb = feeWrite1KB();
res.persistent_rent_rate_denominator = cfg.persistentRentRateDenominator;
res.temporary_rent_rate_denominator = cfg.tempRentRateDenominator;
return res;
}
#endif
} // namespace stellar
9 changes: 9 additions & 0 deletions src/ledger/NetworkConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ struct InitialSorobanNetworkConfig

static constexpr uint32_t AUTO_BUMP_NUM_LEDGERS = 0;

static constexpr uint64_t EVICTION_SCAN_SIZE = 1;
static constexpr uint32_t MAX_ENTRIES_TO_EXPIRE = 1;

// Rent payment of ~1 XLM/year for a max entry.
static constexpr int64_t PERSISTENT_RENT_RATE_DENOMINATOR = 252'480;
// Rent payment of ~0.1 XLM/year for a max entry.
static constexpr int64_t TEMP_RENT_RATE_DENOMINATOR = 2'524'800;

// General execution settings
static constexpr uint32_t LEDGER_MAX_TX_COUNT = 10;
};
Expand Down Expand Up @@ -215,6 +223,7 @@ class SorobanNetworkConfig
static bool isValidCostParams(ContractCostParams const& params);

CxxFeeConfiguration rustBridgeFeeConfiguration() const;
CxxRentFeeConfiguration rustBridgeRentFeeConfiguration() const;

// State expiration settings
StateExpirationSettings const& stateExpirationSettings() const;
Expand Down
8 changes: 4 additions & 4 deletions src/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rustc-simple-version = "0.1.0"
version = "0.0.17"
git = "https://github.com/stellar/rs-soroban-env"
package = "soroban-env-host"
rev = "400d806387140553e4e685d232deb3a807ec0e36"
rev = "2dcd6a6c2bf835f6ebfede445a73304ad9c713c9"

# This copy of the soroban host is _optional_ and only enabled during protocol
# transitions. When transitioning from protocol N to N+1, the `curr` copy
Expand All @@ -48,14 +48,14 @@ rev = "400d806387140553e4e685d232deb3a807ec0e36"

[dependencies.soroban-env-host-prev]
optional = true
version = "0.0.16"
version = "0.0.17"
git = "https://github.com/stellar/rs-soroban-env"
package = "soroban-env-host"
rev = "7ed0c2903049092b70e6e4f366e70e677ce134ea"
rev = "dace9621c53f3386739bb4c300721f9d47996a23"

[dependencies.soroban-test-wasms]
git = "https://github.com/stellar/rs-soroban-env"
rev = "400d806387140553e4e685d232deb3a807ec0e36"
rev = "2dcd6a6c2bf835f6ebfede445a73304ad9c713c9"

[dependencies.cargo-lock]
git = "https://github.com/rustsec/rustsec"
Expand Down
Loading