Skip to content
Draft
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
[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
94 changes: 94 additions & 0 deletions Cargo.lock

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

16 changes: 12 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,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
18 changes: 18 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])
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
31 changes: 23 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 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) \
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)" \
Expand Down
2 changes: 1 addition & 1 deletion src/main/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
;
Expand Down
Loading
Loading