Skip to content

Commit c29192c

Browse files
authored
Add p28 host with CAP-85 support (#5358)
# Description The bulk of the change is the necessary plumbing to adapt Core to the breaking host e2e interface changes (for lazy storage entry decoding). For CAP-85 itself we don't need any Core changes, so this just has an e2e smoke test. # Checklist - [ ] Reviewed the [contributing](https://github.com/stellar/stellar-core/blob/master/CONTRIBUTING.md#submitting-changes) document - [ ] Rebased on top of master (no merge commits) - [ ] Ran `clang-format` v8.0.0 (via `make format` or the Visual Studio extension) - [ ] Compiles - [ ] Ran all tests - [ ] If change impacts performance, include supporting evidence per the [performance document](https://github.com/stellar/stellar-core/blob/master/performance-eval/performance-eval.md)
2 parents 0c8f7dc + a1179b6 commit c29192c

24 files changed

Lines changed: 1012 additions & 354 deletions

‎Cargo.lock‎

Lines changed: 46 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎common.mk‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,8 @@ endif # ENABLE_FASTDEV_UNSAFE_FOR_PRODUCTION
4949

5050
if CAP_0083
5151
AM_CPPFLAGS += -DCAP_0083
52-
endif
52+
endif
53+
54+
if CAP_0085_EXECUTABLE_REF
55+
AM_CPPFLAGS += -DCAP_0085_EXECUTABLE_REF
56+
endif

‎configure.ac‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,9 @@ AM_CONDITIONAL(ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION,
584584
AM_CONDITIONAL(CAP_0083,
585585
[test x$enable_next_protocol_version_unsafe_for_production = xyes])
586586

587+
AM_CONDITIONAL(CAP_0085_EXECUTABLE_REF,
588+
[test x$enable_next_protocol_version_unsafe_for_production = xyes])
589+
587590
AC_PATH_PROG(CARGO, cargo)
588591
if test x"$CARGO" = x; then
589592
AC_MSG_ERROR([cannot find cargo, needed for rust code])

‎src/Makefile.am‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ XDR_FEATURE_FLAGS =
106106
if CAP_0083
107107
XDR_FEATURE_FLAGS += -DCAP_0083
108108
endif
109+
if CAP_0085_EXECUTABLE_REF
110+
XDR_FEATURE_FLAGS += -DCAP_0085_EXECUTABLE_REF
111+
endif
109112

110113
SUFFIXES = .x .h .rs
111114
.x.h:
@@ -218,7 +221,7 @@ ALL_SOROBAN_PROTOCOLS=p27 p28
218221
else
219222
ALL_SOROBAN_PROTOCOLS=p21 p22 p23 p24 p25 p26 p27 p28
220223
endif
221-
WIP_SOROBAN_PROTOCOL=
224+
WIP_SOROBAN_PROTOCOL=p28
222225

223226
CARGO_XDR_FEATURE_FLAGS =
224227

‎src/herder/test/TransactionQueueTests.cpp‎

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,79 +1263,6 @@ TEST_CASE("Soroban tx filtering", "[soroban][transactionqueue]")
12631263
REQUIRE(app->getHerder().recvTransaction(feeBumpTx, false).code ==
12641264
TransactionQueue::AddResultCode::ADD_STATUS_ERROR);
12651265
}
1266-
1267-
auto runInvalidCreateContractTest =
1268-
[&](HostFunctionType hostFnType, ContractIDPreimageType preimageType,
1269-
ContractExecutableType executableType) {
1270-
Operation createOp;
1271-
createOp.body.type(INVOKE_HOST_FUNCTION);
1272-
auto& createHF = createOp.body.invokeHostFunctionOp().hostFunction;
1273-
createHF.type(hostFnType);
1274-
1275-
auto setPreimageAndExecutable = [&](ContractIDPreimage& preimage,
1276-
ContractExecutable& exec) {
1277-
preimage.type(preimageType);
1278-
if (preimageType == CONTRACT_ID_PREIMAGE_FROM_ASSET)
1279-
{
1280-
preimage.fromAsset() = makeNativeAsset();
1281-
}
1282-
else
1283-
{
1284-
preimage.fromAddress().address =
1285-
makeAccountAddress(a1.getPublicKey());
1286-
preimage.fromAddress().salt = sha256("salt");
1287-
}
1288-
exec.type(executableType);
1289-
if (executableType == CONTRACT_EXECUTABLE_WASM)
1290-
{
1291-
exec.wasm_hash() = sha256(wasm.data);
1292-
}
1293-
};
1294-
1295-
if (hostFnType == HOST_FUNCTION_TYPE_CREATE_CONTRACT)
1296-
{
1297-
setPreimageAndExecutable(
1298-
createHF.createContract().contractIDPreimage,
1299-
createHF.createContract().executable);
1300-
}
1301-
else
1302-
{
1303-
setPreimageAndExecutable(
1304-
createHF.createContractV2().contractIDPreimage,
1305-
createHF.createContractV2().executable);
1306-
}
1307-
1308-
auto tx = sorobanTransactionFrameFromOpsWithTotalFee(
1309-
app->getNetworkID(), a1, {createOp}, {}, resources,
1310-
uploadResourceFee + 100, uploadResourceFee);
1311-
auto feeBumpTx =
1312-
feeBump(*app, feeBumper, tx, uploadResourceFee + 200);
1313-
1314-
REQUIRE(app->getHerder().recvTransaction(tx, false).code ==
1315-
TransactionQueue::AddResultCode::ADD_STATUS_ERROR);
1316-
REQUIRE(app->getHerder().recvTransaction(feeBumpTx, false).code ==
1317-
TransactionQueue::AddResultCode::ADD_STATUS_ERROR);
1318-
};
1319-
1320-
SECTION("asset preimage with wasm executable")
1321-
{
1322-
runInvalidCreateContractTest(HOST_FUNCTION_TYPE_CREATE_CONTRACT,
1323-
CONTRACT_ID_PREIMAGE_FROM_ASSET,
1324-
CONTRACT_EXECUTABLE_WASM);
1325-
runInvalidCreateContractTest(HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2,
1326-
CONTRACT_ID_PREIMAGE_FROM_ASSET,
1327-
CONTRACT_EXECUTABLE_WASM);
1328-
}
1329-
1330-
SECTION("address preimage with SAC executable")
1331-
{
1332-
runInvalidCreateContractTest(HOST_FUNCTION_TYPE_CREATE_CONTRACT,
1333-
CONTRACT_ID_PREIMAGE_FROM_ADDRESS,
1334-
CONTRACT_EXECUTABLE_STELLAR_ASSET);
1335-
runInvalidCreateContractTest(HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2,
1336-
CONTRACT_ID_PREIMAGE_FROM_ADDRESS,
1337-
CONTRACT_EXECUTABLE_STELLAR_ASSET);
1338-
}
13391266
}
13401267

13411268
TEST_CASE("TransactionQueue Key Filtering", "[soroban][transactionqueue]")

‎src/ledger/LedgerTypeUtils.cpp‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,26 @@ ledgerEntrySizeForRent(LedgerEntry const& entry, uint32_t entryXdrSize,
5959
if (protocolVersionStartsFrom(ledgerVersion, ProtocolVersion::V_23) &&
6060
isCodeEntry)
6161
{
62-
uint32_t memorySize = rust_bridge::contract_code_memory_size_for_rent(
63-
Config::CURRENT_LEDGER_PROTOCOL_VERSION, ledgerVersion,
64-
toCxxBuf(entry.data.contractCode()),
65-
toCxxBuf(sorobanConfig.cpuCostParams()),
66-
toCxxBuf(sorobanConfig.memCostParams()));
62+
auto const& codeEntry = entry.data.contractCode();
63+
uint32_t memorySize;
64+
// Starting from p28 we use a more optimal version of rent size
65+
// computation function.
66+
if (protocolVersionStartsFrom(ledgerVersion, ProtocolVersion::V_28))
67+
{
68+
memorySize = rust_bridge::contract_code_memory_size_for_rent_v2(
69+
Config::CURRENT_LEDGER_PROTOCOL_VERSION, ledgerVersion,
70+
toCxxBuf(codeEntry.ext),
71+
static_cast<uint32_t>(codeEntry.code.size()),
72+
toCxxBuf(sorobanConfig.cpuCostParams()),
73+
toCxxBuf(sorobanConfig.memCostParams()));
74+
}
75+
else
76+
{
77+
memorySize = rust_bridge::contract_code_memory_size_for_rent(
78+
Config::CURRENT_LEDGER_PROTOCOL_VERSION, ledgerVersion,
79+
toCxxBuf(codeEntry), toCxxBuf(sorobanConfig.cpuCostParams()),
80+
toCxxBuf(sorobanConfig.memCostParams()));
81+
}
6782
uint64_t totalSize = static_cast<uint64_t>(entrySizeForRent) +
6883
static_cast<uint64_t>(memorySize);
6984
entrySizeForRent = static_cast<uint32_t>(std::min(

‎src/main/main.cpp‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,12 @@ main(int argc, char* const* argv)
428428
Config::CURRENT_LEDGER_PROTOCOL_VERSION);
429429

430430
#ifndef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
431-
checkXDRFileIdentity();
431+
// Disable the XDR check temporarily until p28 bump. Due to imperfect
432+
// check mechanism, vCurr XDR has 'diverged' from p27 host XDR because
433+
// we've moved some definitions around (even though there were no
434+
// semantic changes).
435+
// When we bump Core to p28, we should re-enable this check.
436+
// checkXDRFileIdentity();
432437
#endif
433438
}
434439
catch (...)

‎src/protocol-curr/xdr‎

‎src/rust/Cargo.toml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,11 @@ tracy-client = { version = "=0.17.0", features = [
115115
# unify them, perturbing the contents of the lockfile.
116116

117117
[dependencies.soroban-env-host-p28]
118-
version = "=27.0.0"
118+
version = "=28.0.0"
119119
git = "https://github.com/stellar/rs-soroban-env"
120120
package = "soroban-env-host"
121-
rev = "883fd56374fc619afaa4c4c7489563555b7173f2"
121+
rev = "88cadc320cd2030bae2110036b361ff474776db1"
122122
optional = true
123-
features = ["next"]
124123

125124
[dependencies.soroban-env-host-p27]
126125
version = "=27.0.0"

‎src/rust/soroban/p28‎

Submodule p28 updated 635 files

0 commit comments

Comments
 (0)