diff --git a/.gitmodules b/.gitmodules index 20affef707..4b7d855be3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -23,14 +23,11 @@ path = lib/spdlog url = https://github.com/gabime/spdlog ignore = dirty -[submodule "src/protocol-next/xdr"] - path = src/protocol-next/xdr - url = https://github.com/stellar/stellar-xdr - branch = next +#TODO: change name [submodule "src/protocol-curr/xdr"] path = src/protocol-curr/xdr url = https://github.com/stellar/stellar-xdr - branch = curr + branch = main [submodule "src/rust/soroban/p21"] path = src/rust/soroban/p21 url = https://github.com/stellar/rs-soroban-env @@ -50,6 +47,9 @@ [submodule "src/rust/soroban/p26"] path = src/rust/soroban/p26 url = https://github.com/stellar/rs-soroban-env.git +[submodule "src/rust/soroban/p27"] + path = src/rust/soroban/p27 + url = https://github.com/stellar/rs-soroban-env.git [submodule "lib/gperftools"] path = lib/gperftools url = https://github.com/gperftools/gperftools.git diff --git a/Cargo.lock b/Cargo.lock index 373a429099..40e79dfa71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1426,6 +1426,17 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "soroban-builtin-sdk-macros" +version = "26.1.2" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c0e58f94ff2983a09440cef6a54253349fd3c4db#c0e58f94ff2983a09440cef6a54253349fd3c4db" +dependencies = [ + "itertools 0.13.0", + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "soroban-env-common" version = "21.2.2" @@ -1522,6 +1533,22 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "soroban-env-common" +version = "26.1.2" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c0e58f94ff2983a09440cef6a54253349fd3c4db#c0e58f94ff2983a09440cef6a54253349fd3c4db" +dependencies = [ + "crate-git-revision", + "ethnum", + "num-derive", + "num-traits", + "soroban-env-macros 26.1.2", + "soroban-wasmi", + "static_assertions", + "stellar-xdr 26.0.0", + "wasmparser", +] + [[package]] name = "soroban-env-host" version = "21.2.2" @@ -1730,6 +1757,42 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "soroban-env-host" +version = "26.1.2" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c0e58f94ff2983a09440cef6a54253349fd3c4db#c0e58f94ff2983a09440cef6a54253349fd3c4db" +dependencies = [ + "ark-bls12-381 0.5.0", + "ark-bn254 0.5.0", + "ark-ec 0.5.0", + "ark-ff 0.5.0", + "ark-serialize 0.5.0", + "curve25519-dalek", + "ecdsa", + "ed25519-dalek", + "elliptic-curve", + "generic-array", + "getrandom", + "hex-literal", + "hmac", + "k256", + "num-derive", + "num-integer", + "num-traits", + "p256", + "rand", + "rand_chacha", + "sec1", + "sha2", + "sha3", + "soroban-builtin-sdk-macros 26.1.2", + "soroban-env-common 26.1.2", + "soroban-wasmi", + "static_assertions", + "stellar-strkey 0.0.13", + "wasmparser", +] + [[package]] name = "soroban-env-macros" version = "21.2.2" @@ -1814,6 +1877,20 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "soroban-env-macros" +version = "26.1.2" +source = "git+https://github.com/stellar/rs-soroban-env?rev=c0e58f94ff2983a09440cef6a54253349fd3c4db#c0e58f94ff2983a09440cef6a54253349fd3c4db" +dependencies = [ + "itertools 0.13.0", + "proc-macro2", + "quote", + "serde", + "serde_json", + "stellar-xdr 26.0.0", + "syn 2.0.39", +] + [[package]] name = "soroban-synth-wasm" version = "23.0.0" @@ -1884,6 +1961,7 @@ dependencies = [ "soroban-env-host 24.0.0", "soroban-env-host 25.0.0", "soroban-env-host 25.0.1", + "soroban-env-host 26.1.2", "soroban-synth-wasm", "soroban-test-wasms", "stellar-quorum-analyzer", @@ -2038,6 +2116,22 @@ dependencies = [ "stellar-strkey 0.0.13", ] +[[package]] +name = "stellar-xdr" +version = "26.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea3195594b044ea3a5b05906f81d945480825f00db4e3ae7d77526bf546ff3a" +dependencies = [ + "base64 0.22.1", + "cfg_eval", + "crate-git-revision", + "escape-bytes", + "ethnum", + "hex", + "sha2", + "stellar-strkey 0.0.13", +] + [[package]] name = "subtle" version = "2.6.1" diff --git a/common.mk b/common.mk index efefce5b78..917ca6e382 100644 --- a/common.mk +++ b/common.mk @@ -17,11 +17,7 @@ if USE_POSTGRES AM_CPPFLAGS += -DUSE_POSTGRES=1 $(libpq_CFLAGS) endif # USE_POSTGRES -if ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION -AM_CPPFLAGS += -I"$(top_builddir)/src/protocol-next" -else AM_CPPFLAGS += -I"$(top_builddir)/src/protocol-curr" -endif # Unconditionally add CEREAL_THREAD_SAFE, we always want it. AM_CPPFLAGS += -DCEREAL_THREAD_SAFE @@ -46,3 +42,15 @@ endif # USE_SPDLOG if ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION AM_CPPFLAGS += -DENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION endif # ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION + +if BUILDING_NEXT_PROTOCOL +AM_CPPFLAGS += -DBUILDING_NEXT_PROTOCOL +endif + +if ENABLE_CAP_0071 +AM_CPPFLAGS += -DCAP_0071 +endif + +if ENABLE_TEST_FEATURE +AM_CPPFLAGS += -DTEST_FEATURE +endif diff --git a/configure.ac b/configure.ac index 8955369018..c37902e75f 100644 --- a/configure.ac +++ b/configure.ac @@ -549,6 +549,24 @@ AC_ARG_ENABLE(next-protocol-version-unsafe-for-production, AM_CONDITIONAL(ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION, [test x$enable_next_protocol_version_unsafe_for_production = xyes]) +AC_ARG_ENABLE(cap-0071, + AS_HELP_STRING([--enable-cap-0071], + [Enable CAP-0071 XDR types and implementation])) +AM_CONDITIONAL(ENABLE_CAP_0071, + [test x$enable_cap_0071 = xyes -o x$enable_next_protocol_version_unsafe_for_production = xyes]) + +AC_ARG_ENABLE(test-feature, + AS_HELP_STRING([--enable-test-feature], + [Enable TEST_FEATURE XDR types (testing only)])) +AM_CONDITIONAL(ENABLE_TEST_FEATURE, + [test x$enable_test_feature = xyes -o x$enable_next_protocol_version_unsafe_for_production = xyes]) + +# Derived conditional: true if any next-protocol feature is enabled. +# Add new next-protocol feature flags to this condition. +# Note: TEST_FEATURE is excluded as it is a test fixture, not a protocol feature. +AM_CONDITIONAL(BUILDING_NEXT_PROTOCOL, + [test x$enable_next_protocol_version_unsafe_for_production = xyes -o x$enable_cap_0071 = xyes]) + AC_PATH_PROG(CARGO, cargo) if test x"$CARGO" = x; then AC_MSG_ERROR([cannot find cargo, needed for rust code]) diff --git a/hash-xdrs.sh b/hash-xdrs.sh index 42c4d7cfa7..5e98c3a8e0 100755 --- a/hash-xdrs.sh +++ b/hash-xdrs.sh @@ -7,6 +7,9 @@ # # The goal is to detect the (unfortunately easy) condition of C++ and Rust code # communicating with each other using different XDR definitions. +# +# Hashes are computed after stripping #ifdef/#endif blocks and removing all +# whitespace, so they are stable regardless of feature ifdefs or formatting. set -o errexit set -o pipefail @@ -28,7 +31,30 @@ EOF # Hashes to ignore IGNORE="Stellar-internal\|Stellar-overlay\|Stellar-contract-spec\|Stellar-contract-meta\|Stellar-contract-env-meta" -sha256sum -b $1/xdr/*.x | grep -v "${IGNORE}" | perl -pe 's/([a-f0-9]+)[ \*]+(.*)/{"$2", "$1"},/' +# Strip #ifdef/#endif blocks (inclusive) and remove all whitespace before +# hashing. This produces a canonical hash of the base XDR content. +# Content between #ifdef and #else (the feature-on branch) is stripped, +# while content between #else and #endif (the feature-off branch) is kept, +# since it represents the base types when no features are enabled. +# Note: this does not hash the feature-gated XDR content. The feature flag +# validation in checkXDRFileIdentity() separately verifies that C++ and Rust +# have the same XDR features enabled. +xdr_hash() { + awk 'BEGIN{skip=0} /#ifdef/{skip=1; next} /#else/{skip=0; next} /#endif/{skip=0; next} skip==0{print}' "$1" \ + | tr -d '[:space:]' \ + | sha256sum -b \ + | cut -d' ' -f1 +} + +for f in $1/xdr/*.x; do + fname=$(basename "$f") + # Skip ignored files + if echo "$fname" | grep -q "${IGNORE}"; then + continue + fi + hash=$(xdr_hash "$f") + echo "{\"$f\", \"$hash\"}," +done # Add empty entries for the 5 skipped files echo '{"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""}};' diff --git a/src/Makefile.am b/src/Makefile.am index a79ff23d70..55a7ea896f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -62,15 +62,14 @@ CARGO_FEATURE_TESTUTILS = endif # !BUILD_TESTS -if ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION +if BUILDING_NEXT_PROTOCOL CARGO_FEATURE_NEXT = --features next -main/XDRFilesSha256.cpp: $(SRC_X_FILES) Makefile $(top_srcdir)/hash-xdrs.sh - $(top_srcdir)/hash-xdrs.sh $(top_srcdir)/src/protocol-next >$@ else CARGO_FEATURE_NEXT = +endif + main/XDRFilesSha256.cpp: $(SRC_X_FILES) Makefile $(top_srcdir)/hash-xdrs.sh $(top_srcdir)/hash-xdrs.sh $(top_srcdir)/src/protocol-curr >$@ -endif # tcmalloc must be linked early to properly override malloc/free stellar_core_LDADD = $(libtcmalloc_LIBS) $(soci_LIBS) $(libmedida_LIBS) \ @@ -88,10 +87,18 @@ TEST_FILES = $(TESTDATA_DIR)/stellar-core_example.cfg $(TESTDATA_DIR)/stellar-co BUILT_SOURCES = $(SRC_X_FILES:.x=.h) main/StellarCoreVersion.cpp main/XDRFilesSha256.cpp $(TEST_FILES) $(SRC_X_FILES:.x=.h): $(XDRC) +XDR_FEATURE_FLAGS = +if ENABLE_CAP_0071 +XDR_FEATURE_FLAGS += -DCAP_0071 +endif +if ENABLE_TEST_FEATURE +XDR_FEATURE_FLAGS += -DTEST_FEATURE +endif + SUFFIXES = .x .h .rs .x.h: mkdir -p $(@D) - $(XDRC) -hh -pedantic -o $@ $< + $(XDRC) -hh -pedantic $(XDR_FEATURE_FLAGS) -o $@ $< BISON=bison FLEX=flex @@ -189,9 +196,17 @@ SOROBAN_BUILD_DIR=$(abspath $(RUST_BUILD_DIR))/soroban # ALL_SOROBAN_PROTOCOLS as you see fit). ALL_SOROBAN_PROTOCOLS=p21 p22 p23 p24 p25 p26 -WIP_SOROBAN_PROTOCOL= +WIP_SOROBAN_PROTOCOL=p27 + +CARGO_XDR_FEATURE_FLAGS = +if ENABLE_CAP_0071 +CARGO_XDR_FEATURE_FLAGS += --features cap_0071 +endif +if ENABLE_TEST_FEATURE +CARGO_XDR_FEATURE_FLAGS += --features test_feature +endif -if ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION +if BUILDING_NEXT_PROTOCOL ALL_SOROBAN_PROTOCOLS+=$(WIP_SOROBAN_PROTOCOL) # This means "only pass --features=next if there's no WIP submodule" SOROBAN_FEATURE_NEXT=$(if $(WIP_SOROBAN_PROTOCOL),,$(CARGO_FEATURE_NEXT)) @@ -369,7 +384,7 @@ $(SOROBAN_LIBS_STAMP): $(wildcard rust/soroban/p*/Cargo.lock) $(ALL_SOROBAN_GIT_ FEATURE_FLAGS="" \ ;; \ $(SOROBAN_MAX_PROTOCOL)) \ - FEATURE_FLAGS="$(CARGO_FEATURE_TRACY) $(SOROBAN_FEATURE_NEXT)" \ + FEATURE_FLAGS="$(CARGO_FEATURE_TRACY) $(SOROBAN_FEATURE_NEXT) $(CARGO_XDR_FEATURE_FLAGS)" \ ;; \ *) \ FEATURE_FLAGS="$(CARGO_FEATURE_TRACY)" \ diff --git a/src/main/Config.cpp b/src/main/Config.cpp index f60ec2688e..2746967d38 100644 --- a/src/main/Config.cpp +++ b/src/main/Config.cpp @@ -32,7 +32,7 @@ namespace stellar { uint32 const Config::CURRENT_LEDGER_PROTOCOL_VERSION = 26 -#ifdef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION +#ifdef BUILDING_NEXT_PROTOCOL + 1 #endif ; diff --git a/src/main/main.cpp b/src/main/main.cpp index ee8f73dd0c..593576b705 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -227,6 +227,44 @@ checkXDRFileIdentity() "Rust. C++ size = {} and Rust size = {}.", stellar::XDR_FILES_SHA256.size(), rustHashes.size())); } + + // Verify that C++ and Rust have the same XDR feature flags enabled. + std::vector cppFeatures; +#ifdef CAP_0071 + cppFeatures.emplace_back("cap_0071"); +#endif +#ifdef TEST_FEATURE + cppFeatures.emplace_back("test_feature"); +#endif + + rust::Vec const& rustFeatures = + rustVersions.back().xdr_features; + + if (cppFeatures.size() != rustFeatures.size()) + { + throw std::runtime_error(fmt::format( + "XDR feature count mismatch: C++ has {} features, Rust has {}", + cppFeatures.size(), rustFeatures.size())); + } + for (auto const& cppFeat : cppFeatures) + { + bool found = false; + for (auto const& rustFeat : rustFeatures) + { + if (cppFeat == std::string(rustFeat.begin(), rustFeat.end())) + { + found = true; + break; + } + } + if (!found) + { + throw std::runtime_error(fmt::format( + "XDR feature mismatch: C++ has feature '{}' but Rust " + "does not", + cppFeat)); + } + } } void @@ -369,10 +407,16 @@ main(int argc, char* const* argv) rust_bridge::check_sensible_soroban_config_for_protocol( Config::CURRENT_LEDGER_PROTOCOL_VERSION); - // Disable XDR hash checking in vnext builds -#ifndef ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION - checkXDRFileIdentity(); -#endif + // The p26 rs-stellar-xdr crate uses raw file + // hashes, which can't match the ifdef-stripped hashes used here. + // The easiest thing to do was to just skip the check for p26. Which + // should be fine as the xdr on the rust side shouldn't change, and the + // xdr on the core should always be backwards compatible. This is + // temporary until we bump to p27. + if (Config::CURRENT_LEDGER_PROTOCOL_VERSION != 26) + { + checkXDRFileIdentity(); + } } catch (...) { diff --git a/src/protocol-curr/xdr b/src/protocol-curr/xdr index cff714a5eb..db28a8fa81 160000 --- a/src/protocol-curr/xdr +++ b/src/protocol-curr/xdr @@ -1 +1 @@ -Subproject commit cff714a5ebaaaf2dac343b3546c2df73f0b7a36e +Subproject commit db28a8fa81979396fd724e7b89478ae3af55a1f1 diff --git a/src/protocol-next/xdr b/src/protocol-next/xdr deleted file mode 160000 index 5b64bdbd3a..0000000000 --- a/src/protocol-next/xdr +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5b64bdbd3a15267a093765106fb03935852bdc1d diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml index de57c3e2e1..a351d1ae23 100644 --- a/src/rust/Cargo.toml +++ b/src/rust/Cargo.toml @@ -109,6 +109,13 @@ tracy-client = { version = "=0.17.0", features = [ # Cargo.lock! The unified build will re-resolve transitive dependencies and # unify them, perturbing the contents of the lockfile. +[dependencies.soroban-env-host-p27] +version = "=26.1.2" +git = "https://github.com/stellar/rs-soroban-env" +package = "soroban-env-host" +rev = "c0e58f94ff2983a09440cef6a54253349fd3c4db" +optional = true + [dependencies.soroban-env-host-p26] version = "=25.0.1" git = "https://github.com/stellar/rs-soroban-env" @@ -178,7 +185,8 @@ unified = ["dep:soroban-env-host-p21", "dep:soroban-env-host-p23", "dep:soroban-env-host-p24", "dep:soroban-env-host-p25", - "dep:soroban-env-host-p26"] + "dep:soroban-env-host-p26", + "dep:soroban-env-host-p27"] tracy = ["dep:tracy-client"] diff --git a/src/rust/soroban/p27 b/src/rust/soroban/p27 new file mode 160000 index 0000000000..6f5f001228 --- /dev/null +++ b/src/rust/soroban/p27 @@ -0,0 +1 @@ +Subproject commit 6f5f00122891e7dd4abaaefdb3a0d59b1aaa93a6 diff --git a/src/rust/src/bridge.rs b/src/rust/src/bridge.rs index 2d2eeb8f21..3897a5e354 100644 --- a/src/rust/src/bridge.rs +++ b/src/rust/src/bridge.rs @@ -96,6 +96,7 @@ pub(crate) mod rust_bridge { pub xdr_git_rev: String, pub xdr_base_git_rev: String, pub xdr_file_hashes: Vec, + pub xdr_features: Vec, } struct CxxTransactionResources { diff --git a/src/rust/src/common.rs b/src/rust/src/common.rs index cec25ddc8c..20c78db65b 100644 --- a/src/rust/src/common.rs +++ b/src/rust/src/common.rs @@ -111,6 +111,8 @@ fn compare_xdr_files_sha256( } pub(crate) fn check_xdr_version_identities() -> Result<(), Box> { + // TODO: Remove the "next" feature guard and update the quorum analyze to use the new xdr + #[cfg(not(feature = "next"))] compare_xdr_files_sha256( "stellar_quorum_analyzer", &stellar_quorum_analyzer::xdr::curr::XDR_FILES_SHA256, diff --git a/src/rust/src/dep-trees/p27-expect.txt b/src/rust/src/dep-trees/p27-expect.txt new file mode 100644 index 0000000000..3f497d3ef3 --- /dev/null +++ b/src/rust/src/dep-trees/p27-expect.txt @@ -0,0 +1,308 @@ +soroban-env-host v26.1.2 (src/rust/soroban/p27/soroban-env-host) +├── ark-bls12-381 v0.5.0 +│ ├── ark-ec v0.5.0 +│ │ ├── ahash v0.8.11 +│ │ │ ├── cfg-if v1.0.0 +│ │ │ ├── once_cell v1.19.0 +│ │ │ └── zerocopy v0.7.35 +│ │ │ └── zerocopy-derive v0.7.35 (proc-macro) +│ │ │ ├── proc-macro2 v1.0.69 +│ │ │ │ └── unicode-ident v1.0.9 +│ │ │ ├── quote v1.0.33 +│ │ │ │ └── proc-macro2 v1.0.69 (*) +│ │ │ └── syn v2.0.39 +│ │ │ ├── proc-macro2 v1.0.69 (*) +│ │ │ ├── quote v1.0.33 (*) +│ │ │ └── unicode-ident v1.0.9 +│ │ │ [build-dependencies] +│ │ │ └── version_check v0.9.4 +│ │ ├── ark-ff v0.5.0 +│ │ │ ├── ark-ff-asm v0.5.0 (proc-macro) +│ │ │ │ ├── quote v1.0.33 (*) +│ │ │ │ └── syn v2.0.39 (*) +│ │ │ ├── ark-ff-macros v0.5.0 (proc-macro) +│ │ │ │ ├── num-bigint v0.4.4 +│ │ │ │ │ ├── num-integer v0.1.45 +│ │ │ │ │ │ └── num-traits v0.2.17 +│ │ │ │ │ │ [build-dependencies] +│ │ │ │ │ │ └── autocfg v1.1.0 +│ │ │ │ │ │ [build-dependencies] +│ │ │ │ │ │ └── autocfg v1.1.0 +│ │ │ │ │ └── num-traits v0.2.17 (*) +│ │ │ │ │ [build-dependencies] +│ │ │ │ │ └── autocfg v1.1.0 +│ │ │ │ ├── num-traits v0.2.17 (*) +│ │ │ │ ├── proc-macro2 v1.0.69 (*) +│ │ │ │ ├── quote v1.0.33 (*) +│ │ │ │ └── syn v2.0.39 (*) +│ │ │ ├── ark-serialize v0.5.0 +│ │ │ │ ├── ark-serialize-derive v0.5.0 (proc-macro) +│ │ │ │ │ ├── proc-macro2 v1.0.69 (*) +│ │ │ │ │ ├── quote v1.0.33 (*) +│ │ │ │ │ └── syn v2.0.39 (*) +│ │ │ │ ├── ark-std v0.5.0 +│ │ │ │ │ ├── num-traits v0.2.17 +│ │ │ │ │ │ [build-dependencies] +│ │ │ │ │ │ └── autocfg v1.1.0 +│ │ │ │ │ └── rand v0.8.5 +│ │ │ │ │ ├── libc v0.2.176 +│ │ │ │ │ ├── rand_chacha v0.3.1 +│ │ │ │ │ │ ├── ppv-lite86 v0.2.17 +│ │ │ │ │ │ └── rand_core v0.6.4 +│ │ │ │ │ │ └── getrandom v0.2.11 +│ │ │ │ │ │ ├── cfg-if v1.0.0 +│ │ │ │ │ │ ├── js-sys v0.3.64 +│ │ │ │ │ │ │ └── wasm-bindgen v0.2.100 +│ │ │ │ │ │ │ ├── cfg-if v1.0.0 +│ │ │ │ │ │ │ ├── once_cell v1.19.0 +│ │ │ │ │ │ │ ├── rustversion v1.0.14 (proc-macro) +│ │ │ │ │ │ │ └── wasm-bindgen-macro v0.2.100 (proc-macro) +│ │ │ │ │ │ │ ├── quote v1.0.33 (*) +│ │ │ │ │ │ │ └── wasm-bindgen-macro-support v0.2.100 +│ │ │ │ │ │ │ ├── proc-macro2 v1.0.69 (*) +│ │ │ │ │ │ │ ├── quote v1.0.33 (*) +│ │ │ │ │ │ │ ├── syn v2.0.39 (*) +│ │ │ │ │ │ │ ├── wasm-bindgen-backend v0.2.100 +│ │ │ │ │ │ │ │ ├── bumpalo v3.13.0 +│ │ │ │ │ │ │ │ ├── log v0.4.19 +│ │ │ │ │ │ │ │ ├── proc-macro2 v1.0.69 (*) +│ │ │ │ │ │ │ │ ├── quote v1.0.33 (*) +│ │ │ │ │ │ │ │ ├── syn v2.0.39 (*) +│ │ │ │ │ │ │ │ └── wasm-bindgen-shared v0.2.100 +│ │ │ │ │ │ │ │ └── unicode-ident v1.0.9 +│ │ │ │ │ │ │ └── wasm-bindgen-shared v0.2.100 (*) +│ │ │ │ │ │ ├── libc v0.2.176 +│ │ │ │ │ │ ├── wasi v0.11.0+wasi-snapshot-preview1 +│ │ │ │ │ │ └── wasm-bindgen v0.2.100 (*) +│ │ │ │ │ └── rand_core v0.6.4 (*) +│ │ │ │ ├── arrayvec v0.7.6 +│ │ │ │ ├── digest v0.10.7 +│ │ │ │ │ ├── block-buffer v0.10.4 +│ │ │ │ │ │ └── generic-array v0.14.7 +│ │ │ │ │ │ ├── typenum v1.16.0 +│ │ │ │ │ │ └── zeroize v1.8.1 +│ │ │ │ │ │ └── zeroize_derive v1.4.2 (proc-macro) +│ │ │ │ │ │ ├── proc-macro2 v1.0.69 (*) +│ │ │ │ │ │ ├── quote v1.0.33 (*) +│ │ │ │ │ │ └── syn v2.0.39 (*) +│ │ │ │ │ │ [build-dependencies] +│ │ │ │ │ │ └── version_check v0.9.4 +│ │ │ │ │ ├── const-oid v0.9.2 +│ │ │ │ │ ├── crypto-common v0.1.6 +│ │ │ │ │ │ ├── generic-array v0.14.7 (*) +│ │ │ │ │ │ └── typenum v1.16.0 +│ │ │ │ │ └── subtle v2.5.0 +│ │ │ │ └── num-bigint v0.4.4 (*) +│ │ │ ├── ark-std v0.5.0 (*) +│ │ │ ├── arrayvec v0.7.6 +│ │ │ ├── digest v0.10.7 (*) +│ │ │ ├── educe v0.6.0 (proc-macro) +│ │ │ │ ├── enum-ordinalize v4.3.2 +│ │ │ │ │ └── enum-ordinalize-derive v4.3.2 (proc-macro) +│ │ │ │ │ ├── proc-macro2 v1.0.69 (*) +│ │ │ │ │ ├── quote v1.0.33 (*) +│ │ │ │ │ └── syn v2.0.39 (*) +│ │ │ │ ├── proc-macro2 v1.0.69 (*) +│ │ │ │ ├── quote v1.0.33 (*) +│ │ │ │ └── syn v2.0.39 (*) +│ │ │ ├── itertools v0.13.0 +│ │ │ │ └── either v1.8.1 +│ │ │ ├── num-bigint v0.4.4 (*) +│ │ │ ├── num-traits v0.2.17 (*) +│ │ │ ├── paste v1.0.12 (proc-macro) +│ │ │ └── zeroize v1.8.1 (*) +│ │ ├── ark-poly v0.5.0 +│ │ │ ├── ahash v0.8.11 (*) +│ │ │ ├── ark-ff v0.5.0 (*) +│ │ │ ├── ark-serialize v0.5.0 (*) +│ │ │ ├── ark-std v0.5.0 (*) +│ │ │ ├── educe v0.6.0 (proc-macro) (*) +│ │ │ ├── fnv v1.0.7 +│ │ │ └── hashbrown v0.15.5 +│ │ │ └── allocator-api2 v0.2.21 +│ │ ├── ark-serialize v0.5.0 (*) +│ │ ├── ark-std v0.5.0 (*) +│ │ ├── educe v0.6.0 (proc-macro) (*) +│ │ ├── fnv v1.0.7 +│ │ ├── hashbrown v0.15.5 (*) +│ │ ├── itertools v0.13.0 (*) +│ │ ├── num-bigint v0.4.4 (*) +│ │ ├── num-integer v0.1.45 +│ │ │ └── num-traits v0.2.17 (*) +│ │ │ [build-dependencies] +│ │ │ └── autocfg v1.1.0 +│ │ ├── num-traits v0.2.17 (*) +│ │ └── zeroize v1.8.1 (*) +│ ├── ark-ff v0.5.0 (*) +│ ├── ark-serialize v0.5.0 (*) +│ └── ark-std v0.5.0 (*) +├── ark-bn254 v0.5.0 +│ ├── ark-ec v0.5.0 (*) +│ ├── ark-ff v0.5.0 (*) +│ └── ark-std v0.5.0 (*) +├── ark-ec v0.5.0 (*) +├── ark-ff v0.5.0 (*) +├── ark-serialize v0.5.0 (*) +├── curve25519-dalek v4.1.3 +│ ├── cfg-if v1.0.0 +│ ├── cpufeatures v0.2.8 +│ │ └── libc v0.2.176 +│ ├── curve25519-dalek-derive v0.1.0 (proc-macro) +│ │ ├── proc-macro2 v1.0.69 (*) +│ │ ├── quote v1.0.33 (*) +│ │ └── syn v2.0.39 (*) +│ ├── digest v0.10.7 (*) +│ ├── fiat-crypto v0.2.5 +│ ├── subtle v2.5.0 +│ └── zeroize v1.8.1 (*) +│ [build-dependencies] +│ └── rustc_version v0.4.0 +│ └── semver v1.0.17 +├── ecdsa v0.16.9 +│ ├── der v0.7.6 +│ │ ├── const-oid v0.9.2 +│ │ └── zeroize v1.8.1 (*) +│ ├── digest v0.10.7 (*) +│ ├── elliptic-curve v0.13.8 +│ │ ├── base16ct v0.2.0 +│ │ ├── crypto-bigint v0.5.2 +│ │ │ ├── generic-array v0.14.7 (*) +│ │ │ ├── rand_core v0.6.4 (*) +│ │ │ ├── subtle v2.5.0 +│ │ │ └── zeroize v1.8.1 (*) +│ │ ├── digest v0.10.7 (*) +│ │ ├── ff v0.13.0 +│ │ │ ├── rand_core v0.6.4 (*) +│ │ │ └── subtle v2.5.0 +│ │ ├── generic-array v0.14.7 (*) +│ │ ├── group v0.13.0 +│ │ │ ├── ff v0.13.0 (*) +│ │ │ ├── rand_core v0.6.4 (*) +│ │ │ └── subtle v2.5.0 +│ │ ├── rand_core v0.6.4 (*) +│ │ ├── sec1 v0.7.2 +│ │ │ ├── base16ct v0.2.0 +│ │ │ ├── der v0.7.6 (*) +│ │ │ ├── generic-array v0.14.7 (*) +│ │ │ ├── subtle v2.5.0 +│ │ │ └── zeroize v1.8.1 (*) +│ │ ├── subtle v2.5.0 +│ │ └── zeroize v1.8.1 (*) +│ ├── rfc6979 v0.4.0 +│ │ ├── hmac v0.12.1 +│ │ │ └── digest v0.10.7 (*) +│ │ └── subtle v2.5.0 +│ └── signature v2.1.0 +│ ├── digest v0.10.7 (*) +│ └── rand_core v0.6.4 (*) +├── ed25519-dalek v2.1.1 +│ ├── curve25519-dalek v4.1.3 (*) +│ ├── ed25519 v2.2.2 +│ │ └── signature v2.1.0 (*) +│ ├── rand_core v0.6.4 (*) +│ ├── sha2 v0.10.9 +│ │ ├── cfg-if v1.0.0 +│ │ ├── cpufeatures v0.2.8 (*) +│ │ └── digest v0.10.7 (*) +│ ├── subtle v2.5.0 +│ └── zeroize v1.8.1 (*) +├── elliptic-curve v0.13.8 (*) +├── generic-array v0.14.7 (*) +├── getrandom v0.2.11 (*) +├── hex-literal v0.4.1 +├── hmac v0.12.1 (*) +├── k256 v0.13.4 +│ ├── cfg-if v1.0.0 +│ ├── ecdsa v0.16.9 (*) +│ ├── elliptic-curve v0.13.8 (*) +│ └── sha2 v0.10.9 (*) +├── num-derive v0.4.1 (proc-macro) +│ ├── proc-macro2 v1.0.69 (*) +│ ├── quote v1.0.33 (*) +│ └── syn v2.0.39 (*) +├── num-integer v0.1.45 (*) +├── num-traits v0.2.17 (*) +├── p256 v0.13.2 +│ ├── ecdsa v0.16.9 (*) +│ ├── elliptic-curve v0.13.8 (*) +│ ├── primeorder v0.13.3 +│ │ └── elliptic-curve v0.13.8 (*) +│ └── sha2 v0.10.9 (*) +├── rand v0.8.5 (*) +├── rand_chacha v0.3.1 (*) +├── sec1 v0.7.2 (*) +├── sha2 v0.10.9 (*) +├── sha3 v0.10.8 +│ ├── digest v0.10.7 (*) +│ └── keccak v0.1.4 +│ └── cpufeatures v0.2.8 (*) +├── soroban-builtin-sdk-macros v26.1.2 (proc-macro) (src/rust/soroban/p27/soroban-builtin-sdk-macros) +│ ├── itertools v0.13.0 +│ │ └── either v1.8.1 +│ ├── proc-macro2 v1.0.69 (*) +│ ├── quote v1.0.33 (*) +│ └── syn v2.0.39 (*) +├── soroban-env-common v26.1.2 (src/rust/soroban/p27/soroban-env-common) +│ ├── ethnum v1.5.0 +│ ├── num-derive v0.4.1 (proc-macro) (*) +│ ├── num-traits v0.2.17 (*) +│ ├── soroban-env-macros v26.1.2 (proc-macro) (src/rust/soroban/p27/soroban-env-macros) +│ │ ├── itertools v0.13.0 (*) +│ │ ├── proc-macro2 v1.0.69 (*) +│ │ ├── quote v1.0.33 (*) +│ │ ├── serde v1.0.192 +│ │ │ └── serde_derive v1.0.192 (proc-macro) +│ │ │ ├── proc-macro2 v1.0.69 (*) +│ │ │ ├── quote v1.0.33 (*) +│ │ │ └── syn v2.0.39 (*) +│ │ ├── serde_json v1.0.108 +│ │ │ ├── itoa v1.0.6 +│ │ │ ├── ryu v1.0.13 +│ │ │ └── serde v1.0.192 (*) +│ │ ├── stellar-xdr v26.0.0 (https://github.com/stellar/rs-stellar-xdr?rev=f0ed902950d517ec3cc31d5af7c268e2f025d093#f0ed9029) +│ │ │ ├── escape-bytes v0.1.1 +│ │ │ ├── ethnum v1.5.0 +│ │ │ ├── hex v0.4.3 +│ │ │ ├── sha2 v0.10.9 (*) +│ │ │ └── stellar-strkey v0.0.13 +│ │ │ └── data-encoding v2.6.0 +│ │ │ [build-dependencies] +│ │ │ └── crate-git-revision v0.0.6 +│ │ │ ├── serde v1.0.192 (*) +│ │ │ ├── serde_derive v1.0.192 (proc-macro) (*) +│ │ │ └── serde_json v1.0.108 (*) +│ │ │ [build-dependencies] +│ │ │ └── crate-git-revision v0.0.6 (*) +│ │ └── syn v2.0.39 (*) +│ ├── soroban-wasmi v0.31.1-soroban.20.0.1 (https://github.com/stellar/wasmi?rev=0ed3f3dee30dc41ebe21972399e0a73a41944aa0#0ed3f3de) +│ │ ├── smallvec v1.13.2 +│ │ ├── spin v0.9.8 +│ │ ├── wasmi_arena v0.4.0 (https://github.com/stellar/wasmi?rev=0ed3f3dee30dc41ebe21972399e0a73a41944aa0#0ed3f3de) +│ │ ├── wasmi_core v0.13.0 (https://github.com/stellar/wasmi?rev=0ed3f3dee30dc41ebe21972399e0a73a41944aa0#0ed3f3de) +│ │ │ ├── downcast-rs v1.2.0 +│ │ │ ├── libm v0.2.8 +│ │ │ ├── num-traits v0.2.17 (*) +│ │ │ └── paste v1.0.12 (proc-macro) +│ │ └── wasmparser-nostd v0.100.2 +│ │ └── indexmap-nostd v0.4.0 +│ ├── static_assertions v1.1.0 +│ ├── stellar-xdr v26.0.0 (https://github.com/stellar/rs-stellar-xdr?rev=f0ed902950d517ec3cc31d5af7c268e2f025d093#f0ed9029) +│ │ ├── base64 v0.22.1 +│ │ ├── escape-bytes v0.1.1 +│ │ ├── ethnum v1.5.0 +│ │ ├── hex v0.4.3 +│ │ ├── sha2 v0.10.9 (*) +│ │ └── stellar-strkey v0.0.13 (*) +│ │ [build-dependencies] +│ │ └── crate-git-revision v0.0.6 (*) +│ └── wasmparser v0.116.1 +│ ├── indexmap v2.0.2 +│ │ ├── equivalent v1.0.1 +│ │ └── hashbrown v0.14.1 +│ └── semver v1.0.17 +│ [build-dependencies] +│ └── crate-git-revision v0.0.6 (*) +├── soroban-wasmi v0.31.1-soroban.20.0.1 (https://github.com/stellar/wasmi?rev=0ed3f3dee30dc41ebe21972399e0a73a41944aa0#0ed3f3de) (*) +├── static_assertions v1.1.0 +├── stellar-strkey v0.0.13 (*) +└── wasmparser v0.116.1 (*) diff --git a/src/rust/src/soroban_module_cache.rs b/src/rust/src/soroban_module_cache.rs index c6dd8e5dcf..958bd7347a 100644 --- a/src/rust/src/soroban_module_cache.rs +++ b/src/rust/src/soroban_module_cache.rs @@ -19,11 +19,16 @@ use crate::{ soroban_proto_all::{get_host_module_for_protocol, p23, p24, p25, p26, protocol_agnostic}, }; +#[cfg(feature = "next")] +use crate::soroban_proto_all::p27; + pub(crate) struct SorobanModuleCache { pub(crate) p23_cache: p23::soroban_proto_any::ProtocolSpecificModuleCache, pub(crate) p24_cache: p24::soroban_proto_any::ProtocolSpecificModuleCache, pub(crate) p25_cache: p25::soroban_proto_any::ProtocolSpecificModuleCache, pub(crate) p26_cache: p26::soroban_proto_any::ProtocolSpecificModuleCache, + #[cfg(feature = "next")] + pub(crate) p27_cache: p27::soroban_proto_any::ProtocolSpecificModuleCache, } impl SorobanModuleCache { @@ -33,6 +38,8 @@ impl SorobanModuleCache { p24_cache: p24::soroban_proto_any::ProtocolSpecificModuleCache::new()?, p25_cache: p25::soroban_proto_any::ProtocolSpecificModuleCache::new()?, p26_cache: p26::soroban_proto_any::ProtocolSpecificModuleCache::new()?, + #[cfg(feature = "next")] + p27_cache: p27::soroban_proto_any::ProtocolSpecificModuleCache::new()?, }) } pub fn compile( @@ -46,7 +53,7 @@ impl SorobanModuleCache { 25 => self.p25_cache.compile(_wasm), 26 => self.p26_cache.compile(_wasm), #[cfg(feature = "next")] - 27 => self.p26_cache.compile(_wasm), + 27 => self.p27_cache.compile(_wasm), // Add other protocols here as needed. _ => Err(protocol_agnostic::make_error("unsupported protocol")), } @@ -57,6 +64,8 @@ impl SorobanModuleCache { p24_cache: self.p24_cache.shallow_clone()?, p25_cache: self.p25_cache.shallow_clone()?, p26_cache: self.p26_cache.shallow_clone()?, + #[cfg(feature = "next")] + p27_cache: self.p27_cache.shallow_clone()?, })) } @@ -69,6 +78,8 @@ impl SorobanModuleCache { self.p24_cache.evict(&_hash)?; self.p25_cache.evict(&_hash)?; self.p26_cache.evict(&_hash)?; + #[cfg(feature = "next")] + self.p27_cache.evict(&_hash)?; Ok(()) } pub fn clear(&self) -> Result<(), Box> { @@ -76,6 +87,8 @@ impl SorobanModuleCache { self.p24_cache.clear()?; self.p25_cache.clear()?; self.p26_cache.clear()?; + #[cfg(feature = "next")] + self.p27_cache.clear()?; Ok(()) } @@ -94,7 +107,7 @@ impl SorobanModuleCache { 25 => self.p25_cache.contains_module(&_hash), 26 => self.p26_cache.contains_module(&_hash), #[cfg(feature = "next")] - 27 => self.p26_cache.contains_module(&_hash), + 27 => self.p27_cache.contains_module(&_hash), _ => Err(protocol_agnostic::make_error("unsupported protocol")), } } @@ -110,7 +123,7 @@ impl SorobanModuleCache { 25 => bytes = bytes.max(self.p25_cache.get_mem_bytes_consumed()?), 26 => bytes = bytes.max(self.p26_cache.get_mem_bytes_consumed()?), #[cfg(feature = "next")] - 27 => bytes = bytes.max(self.p26_cache.get_mem_bytes_consumed()?), + 27 => bytes = bytes.max(self.p27_cache.get_mem_bytes_consumed()?), _ => return Err(protocol_agnostic::make_error("unsupported protocol")), } Ok(bytes) diff --git a/src/rust/src/soroban_proto_all.rs b/src/rust/src/soroban_proto_all.rs index efa552d856..5b4014d2aa 100644 --- a/src/rust/src/soroban_proto_all.rs +++ b/src/rust/src/soroban_proto_all.rs @@ -32,10 +32,10 @@ use crate::RustBuf; // We also alias the latest soroban as soroban_curr to help reduce churn in code // that's just "always supposed to use the latest". -//#[cfg(not(feature = "next"))] +#[cfg(not(feature = "next"))] pub(crate) use p26 as soroban_curr; -//#[cfg(feature = "next")] -//pub(crate) use p27 as soroban_curr; +#[cfg(feature = "next")] +pub(crate) use p27 as soroban_curr; // We also pin some protocol _agnostic_ definitions that are technically // implemented by a specific version of soroban, but which is protocol-stable @@ -52,6 +52,175 @@ pub(crate) mod protocol_agnostic { pub(crate) use super::p24::soroban_env_host::xdr::int128_helpers; } +#[cfg(feature = "next")] +#[path = "."] +pub(crate) mod p27 { + pub(crate) extern crate soroban_env_host_p27; + use crate::{ + bridge::rust_bridge::CxxLedgerEntryRentChange, + rust_bridge::{ + CxxFeeConfiguration, CxxRentFeeConfiguration, CxxRentWriteFeeConfiguration, + CxxTransactionResources, + }, + SorobanModuleCache, + }; + use soroban_env_host::{ + budget::Budget, + e2e_invoke::{self, InvokeHostFunctionResult}, + fees::{ + compute_rent_write_fee_per_1kb, FeeConfiguration, LedgerEntryRentChange, + RentFeeConfiguration, RentWriteFeeConfiguration, TransactionResources, + }, + vm::wasm_module_memory_cost, + xdr::{ContractCodeEntry, DiagnosticEvent}, + HostError, LedgerInfo, TraceHook, + }; + pub(crate) use soroban_env_host_p27 as soroban_env_host; + + pub(crate) mod soroban_proto_any; + + pub(crate) use soroban_env_host::{CompilationContext, ErrorHandler, ModuleCache}; + + pub(crate) const fn get_version_pre_release(v: &soroban_env_host::Version) -> u32 { + v.interface.pre_release + } + + pub(crate) const fn get_version_protocol(v: &soroban_env_host::Version) -> u32 { + v.interface.protocol + } + + pub(crate) fn get_xdr_base_git_rev() -> String { + soroban_env_host::xdr::VERSION.xdr.to_string() + } + pub(crate) fn get_xdr_pkg_ver() -> String { + soroban_env_host::xdr::VERSION.pkg.to_string() + } + pub(crate) fn get_xdr_git_rev() -> String { + soroban_env_host::xdr::VERSION.rev.to_string() + } + pub(crate) fn get_xdr_features() -> Vec { + soroban_env_host::xdr::VERSION + .features + .iter() + .map(|s| s.to_string()) + .collect() + } + + pub fn invoke_host_function_with_trace_hook_and_module_cache< + T: AsRef<[u8]>, + I: ExactSizeIterator, + >( + budget: &Budget, + enable_diagnostics: bool, + encoded_host_fn: T, + encoded_resources: T, + restored_rw_entry_indices: &[u32], + encoded_source_account: T, + encoded_auth_entries: I, + ledger_info: LedgerInfo, + encoded_ledger_entries: I, + encoded_ttl_entries: I, + base_prng_seed: T, + diagnostic_events: &mut Vec, + trace_hook: Option, + module_cache: &SorobanModuleCache, + ) -> Result { + e2e_invoke::invoke_host_function( + budget, + enable_diagnostics, + encoded_host_fn, + encoded_resources, + restored_rw_entry_indices, + encoded_source_account, + encoded_auth_entries, + ledger_info, + encoded_ledger_entries, + encoded_ttl_entries, + base_prng_seed, + diagnostic_events, + trace_hook, + Some(module_cache.p27_cache.module_cache.clone()), + ) + } + + pub(crate) fn wasm_module_memory_cost_wrapper( + budget: &Budget, + contract_code_entry: &ContractCodeEntry, + ) -> Result { + wasm_module_memory_cost(budget, contract_code_entry) + } + + pub(crate) fn compute_rent_write_fee_per_1kb_wrapper( + bucket_list_size: i64, + fee_config: CxxRentWriteFeeConfiguration, + ) -> i64 { + compute_rent_write_fee_per_1kb(bucket_list_size, &fee_config.into()) + } + + pub(crate) fn convert_transaction_resources( + value: &CxxTransactionResources, + ) -> TransactionResources { + TransactionResources { + instructions: value.instructions, + disk_read_entries: value.disk_read_entries, + write_entries: value.write_entries, + disk_read_bytes: value.disk_read_bytes, + write_bytes: value.write_bytes, + contract_events_size_bytes: value.contract_events_size_bytes, + transaction_size_bytes: value.transaction_size_bytes, + } + } + + impl From for RentWriteFeeConfiguration { + fn from(value: CxxRentWriteFeeConfiguration) -> Self { + Self { + state_target_size_bytes: value.state_target_size_bytes, + rent_fee_1kb_state_size_low: value.rent_fee_1kb_state_size_low, + rent_fee_1kb_state_size_high: value.rent_fee_1kb_state_size_high, + state_size_rent_fee_growth_factor: value.state_size_rent_fee_growth_factor, + } + } + } + + pub(crate) fn convert_rent_fee_configuration( + value: &CxxRentFeeConfiguration, + ) -> RentFeeConfiguration { + RentFeeConfiguration { + fee_per_rent_1kb: value.fee_per_rent_1kb, + fee_per_write_1kb: value.fee_per_write_1kb, + fee_per_write_entry: value.fee_per_write_entry, + persistent_rent_rate_denominator: value.persistent_rent_rate_denominator, + temporary_rent_rate_denominator: value.temporary_rent_rate_denominator, + } + } + + pub(crate) fn convert_fee_configuration(value: CxxFeeConfiguration) -> FeeConfiguration { + FeeConfiguration { + fee_per_instruction_increment: value.fee_per_instruction_increment, + fee_per_disk_read_entry: value.fee_per_disk_read_entry, + fee_per_write_entry: value.fee_per_write_entry, + fee_per_disk_read_1kb: value.fee_per_disk_read_1kb, + fee_per_write_1kb: value.fee_per_write_1kb, + fee_per_historical_1kb: value.fee_per_historical_1kb, + fee_per_contract_event_1kb: value.fee_per_contract_event_1kb, + fee_per_transaction_size_1kb: value.fee_per_transaction_size_1kb, + } + } + + pub(crate) fn convert_ledger_entry_rent_change( + value: &CxxLedgerEntryRentChange, + ) -> LedgerEntryRentChange { + LedgerEntryRentChange { + is_persistent: value.is_persistent, + is_code_entry: value.is_code_entry, + old_size_bytes: value.old_size_bytes, + new_size_bytes: value.new_size_bytes, + old_live_until_ledger: value.old_live_until_ledger, + new_live_until_ledger: value.new_live_until_ledger, + } + } +} + #[path = "."] pub(crate) mod p26 { pub(crate) extern crate soroban_env_host_p26; @@ -92,6 +261,23 @@ pub(crate) mod p26 { v.interface.protocol } + pub(crate) fn get_xdr_base_git_rev() -> String { + use soroban_env_host::VERSION; + match VERSION.xdr.xdr { + "curr" => VERSION.xdr.xdr_curr.to_string(), + _ => VERSION.xdr.xdr_next.to_string(), + } + } + pub(crate) fn get_xdr_pkg_ver() -> String { + soroban_env_host::VERSION.xdr.pkg.to_string() + } + pub(crate) fn get_xdr_git_rev() -> String { + soroban_env_host::VERSION.xdr.rev.to_string() + } + pub(crate) fn get_xdr_features() -> Vec { + vec![] + } + pub fn invoke_host_function_with_trace_hook_and_module_cache< T: AsRef<[u8]>, I: ExactSizeIterator, @@ -284,6 +470,24 @@ pub(crate) mod p25 { ) } + pub(crate) fn get_xdr_features() -> Vec { + vec![] + } + + pub(crate) fn get_xdr_base_git_rev() -> String { + use soroban_env_host::VERSION; + match VERSION.xdr.xdr { + "curr" => VERSION.xdr.xdr_curr.to_string(), + _ => VERSION.xdr.xdr_next.to_string(), + } + } + pub(crate) fn get_xdr_pkg_ver() -> String { + soroban_env_host::VERSION.xdr.pkg.to_string() + } + pub(crate) fn get_xdr_git_rev() -> String { + soroban_env_host::VERSION.xdr.rev.to_string() + } + pub(crate) fn wasm_module_memory_cost_wrapper( budget: &Budget, contract_code_entry: &ContractCodeEntry, @@ -439,6 +643,24 @@ pub(crate) mod p24 { ) } + pub(crate) fn get_xdr_features() -> Vec { + vec![] + } + + pub(crate) fn get_xdr_base_git_rev() -> String { + use soroban_env_host::VERSION; + match VERSION.xdr.xdr { + "curr" => VERSION.xdr.xdr_curr.to_string(), + _ => VERSION.xdr.xdr_next.to_string(), + } + } + pub(crate) fn get_xdr_pkg_ver() -> String { + soroban_env_host::VERSION.xdr.pkg.to_string() + } + pub(crate) fn get_xdr_git_rev() -> String { + soroban_env_host::VERSION.xdr.rev.to_string() + } + pub(crate) fn wasm_module_memory_cost_wrapper( budget: &Budget, contract_code_entry: &ContractCodeEntry, @@ -594,6 +816,24 @@ pub(crate) mod p23 { ) } + pub(crate) fn get_xdr_features() -> Vec { + vec![] + } + + pub(crate) fn get_xdr_base_git_rev() -> String { + use soroban_env_host::VERSION; + match VERSION.xdr.xdr { + "curr" => VERSION.xdr.xdr_curr.to_string(), + _ => VERSION.xdr.xdr_next.to_string(), + } + } + pub(crate) fn get_xdr_pkg_ver() -> String { + soroban_env_host::VERSION.xdr.pkg.to_string() + } + pub(crate) fn get_xdr_git_rev() -> String { + soroban_env_host::VERSION.xdr.rev.to_string() + } + pub(crate) fn wasm_module_memory_cost_wrapper( budget: &Budget, contract_code_entry: &ContractCodeEntry, @@ -676,6 +916,24 @@ pub(crate) mod p23 { pub(crate) mod p22 { pub(crate) extern crate soroban_env_host_p22; pub(crate) use soroban_env_host_p22 as soroban_env_host; + + pub(crate) fn get_xdr_base_git_rev() -> String { + use soroban_env_host::VERSION; + match VERSION.xdr.xdr { + "curr" => VERSION.xdr.xdr_curr.to_string(), + _ => VERSION.xdr.xdr_next.to_string(), + } + } + pub(crate) fn get_xdr_pkg_ver() -> String { + soroban_env_host::VERSION.xdr.pkg.to_string() + } + pub(crate) fn get_xdr_git_rev() -> String { + soroban_env_host::VERSION.xdr.rev.to_string() + } + pub(crate) fn get_xdr_features() -> Vec { + vec![] + } + pub(crate) mod soroban_proto_any; use crate::{ bridge::rust_bridge::CxxLedgerEntryRentChange, @@ -865,6 +1123,24 @@ pub(crate) mod p22 { pub(crate) mod p21 { pub(crate) extern crate soroban_env_host_p21; pub(crate) use soroban_env_host_p21 as soroban_env_host; + + pub(crate) fn get_xdr_base_git_rev() -> String { + use soroban_env_host::VERSION; + match VERSION.xdr.xdr { + "curr" => VERSION.xdr.xdr_curr.to_string(), + _ => VERSION.xdr.xdr_next.to_string(), + } + } + pub(crate) fn get_xdr_pkg_ver() -> String { + soroban_env_host::VERSION.xdr.pkg.to_string() + } + pub(crate) fn get_xdr_git_rev() -> String { + soroban_env_host::VERSION.xdr.rev.to_string() + } + pub(crate) fn get_xdr_features() -> Vec { + vec![] + } + pub(crate) mod soroban_proto_any; use crate::{ bridge::rust_bridge::CxxLedgerEntryRentChange, @@ -1193,6 +1469,8 @@ const HOST_MODULES: &'static [HostModule] = &[ proto_versioned_functions_for_module!(p24), proto_versioned_functions_for_module!(p25), proto_versioned_functions_for_module!(p26), + #[cfg(feature = "next")] + proto_versioned_functions_for_module!(p27), ]; pub(crate) fn get_host_module_for_protocol( diff --git a/src/rust/src/soroban_proto_any.rs b/src/rust/src/soroban_proto_any.rs index 2dda58618a..37bbd79aba 100644 --- a/src/rust/src/soroban_proto_any.rs +++ b/src/rust/src/soroban_proto_any.rs @@ -201,41 +201,17 @@ pub const fn get_max_proto() -> u32 { pub fn get_soroban_version_info(core_max_proto: u32) -> SorobanVersionInfo { let env_max_proto = get_max_proto(); - let xdr_base_git_rev = match VERSION.xdr.xdr { - "curr" => VERSION.xdr.xdr_curr.to_string(), - "next" | "curr,next" => { - if !cfg!(feature = "next") { - warn!( - "soroban version {} XDR module built with 'next' feature, - but core built without 'vnext' feature", - VERSION.pkg - ); - } - if core_max_proto != env_max_proto { - warn!( - "soroban version {} XDR module for env version {} built with 'next' feature, \ - even though this is not the newest core protocol ({})", - VERSION.pkg, env_max_proto, core_max_proto - ); - warn!( - "this can happen if multiple soroban crates depend on the \ - same XDR crate which then gets feature-unified" - ) - } - VERSION.xdr.xdr_next.to_string() - } - other => format!("unknown XDR module configuration: '{other}'"), - }; SorobanVersionInfo { env_max_proto, env_pkg_ver: VERSION.pkg.to_string(), env_git_rev: VERSION.rev.to_string(), env_pre_release_ver: super::get_version_pre_release(&VERSION), - xdr_pkg_ver: VERSION.xdr.pkg.to_string(), - xdr_git_rev: VERSION.xdr.rev.to_string(), - xdr_base_git_rev, + xdr_pkg_ver: super::get_xdr_pkg_ver(), + xdr_git_rev: super::get_xdr_git_rev(), + xdr_base_git_rev: super::get_xdr_base_git_rev(), xdr_file_hashes: get_xdr_hashes(), + xdr_features: super::get_xdr_features(), } }