Skip to content
Open
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
10 changes: 5 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added #TODO: change name is ambiguous in .gitmodules (it’s not clear what name should change or why). Consider either removing it or replacing it with a more specific note (eg. what should be renamed and when), ideally with an issue/PR reference.

Suggested change
#TODO: change name

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems legit

[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
Expand All @@ -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
105 changes: 99 additions & 6 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -46,3 +42,7 @@ 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 ENABLE_CAP_0071
AM_CPPFLAGS += -DCAP_0071
endif
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,9 @@ 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])

AM_CONDITIONAL(ENABLE_CAP_0071,
[test x$enable_next_protocol_version_unsafe_for_production = xyes])

AC_PATH_PROG(CARGO, cargo)
if test x"$CARGO" = x; then
AC_MSG_ERROR([cannot find cargo, needed for rust code])
Expand Down
36 changes: 20 additions & 16 deletions docs/versioning-soroban.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,26 @@ the upgrade from protocol 22 to 23:
## Dealing with "next"

Stellar-core and soroban-env-host both support the concept of a "next build",
which is a conditional-compilation mode (enabled by a configure flag
`--enable-next-protocol-version-unsafe-for-production`) that supports a protocol
number one-higher than "the one written on the label". I.e. stellar-core v22.0.0
and soroban-env-host v22.0.0 when built with "next" will support something they
call "protocol 23", and will build with XDR from a "next" repo, and so on.

Enabling the "next build" on a given checkout of the tree always shifts the
maximum core-supported protocol up by one. It might also conditionally-include a
work-in-progress "next soroban submodule", or it might simply pass the flag
`--features=next` to the current maximum-numbered soroban submodule (which will
in turn cause that soroban submodule to increment its own max-supported protocol
number).

Which of these two build variants the "next build" causes is controlled by a
variable `WIP_SOROBAN_PROTOCOL` in `src/Makefile.am` and is documented in more
detail there.
which is a conditional-compilation mode that supports a protocol number
one-higher than "the one written on the label".

Next-protocol XDR changes are gated behind `#ifdef` directives (e.g.,
`#ifdef CAP_0071`) in the `.x` files on the `main` branch of `stellar-xdr`.
These features are enabled with:

./configure --enable-next-protocol-version-unsafe-for-production

This flag defines `CAP_0071`, which:
- Bumps `CURRENT_LEDGER_PROTOCOL_VERSION` by one
- Is passed to both xdrc (for XDR `.h` generation) and C++ code
- Causes `--features next` to be passed to the main Rust crate, activating the
next soroban module (e.g., p27)
- Causes `--features cap_0071` to be passed to the next soroban module's cargo
build, which flows through to `rs-stellar-xdr` to enable the corresponding
XDR types

The `WIP_SOROBAN_PROTOCOL` variable in `src/Makefile.am` controls which soroban
submodule is included in next builds. See the comments there for details.

## Rust, Cargo, versions, submodules, rlibs, and dep-tree files

Expand Down
28 changes: 27 additions & 1 deletion hash-xdrs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 '{"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""}};'
Expand Down
25 changes: 17 additions & 8 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,14 @@ CARGO_FEATURE_TESTUTILS =
endif # !BUILD_TESTS


if ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
if ENABLE_CAP_0071
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) \
Expand All @@ -88,10 +87,15 @@ 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

SUFFIXES = .x .h .rs
.x.h:
mkdir -p $(@D)
$(XDRC) -hh -pedantic -o $@ $<
$(XDRC) -hh -pedantic $(XDR_FEATURE_FLAGS) -o $@ $<

BISON=bison
FLEX=flex
Expand Down Expand Up @@ -189,9 +193,14 @@ 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_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
if ENABLE_CAP_0071
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))
Expand Down Expand Up @@ -369,7 +378,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)" \
Expand Down
Loading
Loading