Skip to content

Commit e967b18

Browse files
committed
Generalize number of supported soroban hosts, add host for p22.
1 parent da1895f commit e967b18

15 files changed

+802
-726
lines changed

Cargo.lock

+147-60
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common.mk

-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,3 @@ endif # USE_SPDLOG
4646
if ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
4747
AM_CPPFLAGS += -DENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
4848
endif # ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION
49-
50-
if ENABLE_PROTOCOL_UPGRADE_VIA_SOROBAN_ENV_HOST_PREV
51-
AM_CPPFLAGS += -DENABLE_PROTOCOL_UPGRADE_VIA_SOROBAN_ENV_HOST_PREV
52-
endif # ENABLE_PROTOCOL_UPGRADE_VIA_SOROBAN_ENV_HOST_PREV

configure.ac

-6
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,6 @@ AC_ARG_ENABLE(next-protocol-version-unsafe-for-production,
397397
AM_CONDITIONAL(ENABLE_NEXT_PROTOCOL_VERSION_UNSAFE_FOR_PRODUCTION,
398398
[test x$enable_next_protocol_version_unsafe_for_production = xyes])
399399

400-
AC_ARG_ENABLE(protocol-upgrade-via-soroban-env-host-prev,
401-
AS_HELP_STRING([--enable-protocol-upgrade-via-soroban-env-host-prev],
402-
[Pass "--feature=soroban-env-host-prev" to "cargo build" to enable protocol upgrades]))
403-
AM_CONDITIONAL(ENABLE_PROTOCOL_UPGRADE_VIA_SOROBAN_ENV_HOST_PREV,
404-
[test x$enable_protocol_upgrade_via_soroban_env_host_prev = xyes])
405-
406400
AC_ARG_ENABLE(libunwind,
407401
AS_HELP_STRING([--disable-libunwind],
408402
[Disable backtraces using libunwind]))

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel = "1.74.1"
2+
channel = "1.79.0"

src/Makefile.am

+3-7
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ else # !BUILD_TESTS
1414
stellar_core_SOURCES = main/StellarCoreVersion.cpp main/XDRFilesSha256.cpp $(SRC_CXX_FILES)
1515
endif # !BUILD_TESTS
1616

17-
if ENABLE_PROTOCOL_UPGRADE_VIA_SOROBAN_ENV_HOST_PREV
18-
CARGO_FEATURES = --features soroban-env-host-prev
19-
else
2017
CARGO_FEATURES =
21-
endif
2218
if USE_TRACY
2319
CARGO_FEATURES += --features tracy
2420
endif
@@ -80,7 +76,7 @@ RUST_BIN_DIR=$(RUST_BUILD_DIR)/bin
8076
RUST_TARGET_DIR=$(top_builddir)/target
8177
RUST_CXXBRIDGE=$(RUST_BIN_DIR)/cxxbridge
8278
RUST_PROFILE=release
83-
RUST_HOST_DEPFILES=rust/Cargo.toml $(top_srcdir)/Cargo.toml $(top_srcdir)/Cargo.lock rust/src/host-dep-tree-curr.txt rust/src/host-dep-tree-prev.txt
79+
RUST_HOST_DEPFILES=rust/Cargo.toml $(top_srcdir)/Cargo.toml $(top_srcdir)/Cargo.lock $(wildcard rust/src/dep-trees/*.txt)
8480
LIBRUST_STELLAR_CORE=$(RUST_TARGET_DIR)/$(RUST_PROFILE)/librust_stellar_core.a
8581
stellar_core_LDADD += $(LIBRUST_STELLAR_CORE) -ldl
8682

@@ -89,11 +85,11 @@ $(RUST_CXXBRIDGE):
8985
CARGO_HTTP_MULTIPLEXING=false $(CARGO) install --locked --root $(RUST_BUILD_DIR) cxxbridge-cmd --version 1.0.68
9086

9187
rust/RustBridge.h: rust/src/lib.rs $(SRC_RUST_FILES) Makefile $(RUST_CXXBRIDGE)
92-
$(RUST_CXXBRIDGE) $< --header --output $@.tmp
88+
$(RUST_CXXBRIDGE) $< --cfg test=false --header --output $@.tmp
9389
if cmp -s $@.tmp $@; then rm -v $@.tmp; else mv -v $@.tmp $@; fi
9490

9591
rust/RustBridge.cpp: rust/src/lib.rs $(SRC_RUST_FILES) Makefile $(RUST_CXXBRIDGE)
96-
$(RUST_CXXBRIDGE) $< --output $@.tmp
92+
$(RUST_CXXBRIDGE) $< --cfg test=false --output $@.tmp
9793
if cmp -s $@.tmp $@; then rm -v $@.tmp; else mv -v $@.tmp $@; fi
9894

9995
$(LIBRUST_STELLAR_CORE): $(RUST_HOST_DEPFILES) $(SRC_RUST_FILES) Makefile

src/main/CommandLine.cpp

+20-58
Original file line numberDiff line numberDiff line change
@@ -1650,81 +1650,43 @@ runSignTransaction(CommandLineArgs const& args)
16501650
int
16511651
runVersion(CommandLineArgs const&)
16521652
{
1653+
rust::Vec<SorobanVersionInfo> rustVersions =
1654+
rust_bridge::get_soroban_version_info(
1655+
Config::CURRENT_LEDGER_PROTOCOL_VERSION);
1656+
16531657
std::cout << STELLAR_CORE_VERSION << std::endl;
16541658
std::cout << "ledger protocol version: "
16551659
<< Config::CURRENT_LEDGER_PROTOCOL_VERSION << std::endl;
16561660
std::cout << "rust version: " << rust_bridge::get_rustc_version().c_str()
16571661
<< std::endl;
16581662

1659-
std::cout << "soroban-env-host: " << std::endl;
1660-
1661-
std::cout << " curr:" << std::endl;
1662-
std::cout << " package version: "
1663-
<< rust_bridge::get_soroban_env_pkg_versions().curr.c_str()
1664-
<< std::endl;
1665-
1666-
std::cout << " git version: "
1667-
<< rust_bridge::get_soroban_env_git_versions().curr.c_str()
1668-
<< std::endl;
1669-
1670-
std::cout << " ledger protocol version: "
1671-
<< rust_bridge::get_soroban_env_ledger_protocol_versions().curr
1672-
<< std::endl;
1673-
1674-
std::cout << " pre-release version: "
1675-
<< rust_bridge::get_soroban_env_pre_release_versions().curr
1676-
<< std::endl;
1677-
1678-
std::cout << " rs-stellar-xdr:" << std::endl;
1679-
1680-
std::cout
1681-
<< " package version: "
1682-
<< rust_bridge::get_soroban_xdr_bindings_pkg_versions().curr.c_str()
1683-
<< std::endl;
1684-
std::cout
1685-
<< " git version: "
1686-
<< rust_bridge::get_soroban_xdr_bindings_git_versions().curr.c_str()
1687-
<< std::endl;
1688-
std::cout << " base XDR git version: "
1689-
<< rust_bridge::get_soroban_xdr_bindings_base_xdr_git_versions()
1690-
.curr.c_str()
1691-
<< std::endl;
1663+
std::cout << "soroban-env-host versions: " << std::endl;
16921664

1693-
if (rust_bridge::compiled_with_soroban_prev())
1665+
size_t i = 0;
1666+
for (auto& host : rustVersions)
16941667
{
1695-
std::cout << " prev:" << std::endl;
1696-
std::cout << " package version: "
1697-
<< rust_bridge::get_soroban_env_pkg_versions().prev.c_str()
1668+
std::cout << " host[" << i << "]:" << std::endl;
1669+
std::cout << " package version: " << host.env_pkg_ver.c_str()
16981670
<< std::endl;
16991671

1700-
std::cout << " git version: "
1701-
<< rust_bridge::get_soroban_env_git_versions().prev.c_str()
1672+
std::cout << " git version: " << host.env_git_rev.c_str()
17021673
<< std::endl;
17031674

1704-
std::cout
1705-
<< " ledger protocol version: "
1706-
<< rust_bridge::get_soroban_env_ledger_protocol_versions().prev
1707-
<< std::endl;
1675+
std::cout << " ledger protocol version: " << host.env_max_proto
1676+
<< std::endl;
17081677

1709-
std::cout << " pre-release version: "
1710-
<< rust_bridge::get_soroban_env_pre_release_versions().prev
1678+
std::cout << " pre-release version: " << host.env_pre_release_ver
17111679
<< std::endl;
17121680

17131681
std::cout << " rs-stellar-xdr:" << std::endl;
17141682

1715-
std::cout
1716-
<< " package version: "
1717-
<< rust_bridge::get_soroban_xdr_bindings_pkg_versions().prev.c_str()
1718-
<< std::endl;
1719-
std::cout
1720-
<< " git version: "
1721-
<< rust_bridge::get_soroban_xdr_bindings_git_versions().prev.c_str()
1722-
<< std::endl;
1723-
std::cout
1724-
<< " base XDR git version: "
1725-
<< rust_bridge::get_soroban_xdr_bindings_base_xdr_git_versions()
1726-
.prev.c_str()
1727-
<< std::endl;
1683+
std::cout << " package version: " << host.xdr_pkg_ver.c_str()
1684+
<< std::endl;
1685+
std::cout << " git version: " << host.xdr_git_rev.c_str()
1686+
<< std::endl;
1687+
std::cout << " base XDR git version: "
1688+
<< host.xdr_base_git_rev.c_str() << std::endl;
1689+
++i;
17281690
}
17291691
return 0;
17301692
}

src/main/main.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,12 @@ void
170170
checkXDRFileIdentity()
171171
{
172172
using namespace stellar::rust_bridge;
173-
rust::Vec<XDRFileHash> rustHashes = get_xdr_hashes().curr;
173+
174+
rust::Vec<SorobanVersionInfo> rustVersions = get_soroban_version_info(
175+
stellar::Config::CURRENT_LEDGER_PROTOCOL_VERSION);
176+
rust::Vec<XDRFileHash> const& rustHashes =
177+
rustVersions.back().xdr_file_hashes;
178+
174179
for (auto const& cpp : stellar::XDR_FILES_SHA256)
175180
{
176181
if (cpp.first.empty())

src/rust/Cargo.toml

+53-42
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "stellar-core"
33
version = "0.1.0"
44
edition = "2021"
5-
rust-version = "1.74"
5+
rust-version = "1.79.0"
66
publish = false
77

88
[lib]
@@ -23,64 +23,75 @@ petgraph = "=0.6.4"
2323
toml = "=0.7.8"
2424
itertools = "=0.11.0"
2525

26-
# This copy of the soroban host is always enabled, and should always point to a
27-
# version that supports stellar-core's Config::CURRENT_LEDGER_PROTOCOL_VERSION.
28-
# When upgrading from protocol N to N+1, this copy will therefore have its
29-
# version advance first (to enable support for N+1) even before the network has
30-
# voted to upgrade to it. In order to avoid divergence during such an upgrade,
31-
# we will simultaneously enable the `prev` copy of soroban (below), continuing
32-
# to point to the previous already-released soroban that only supported protocol
33-
# N.
26+
# Stellar-core supports multiple versions of the Soroban host linked in
27+
# simultaneously. Each host is labeled with the _maximum_ protocol that it
28+
# supports. The minimum protocol supported by each host is implicitly one more
29+
# than the less-higher-numbered host's maximum protocol, though in some cases a
30+
# host may also be configured with an explicit minimum supported protocol, in
31+
# which case we have to keep extra hosts around to fill in any gaps in support.
32+
#
33+
# As an example: if we have hosts labeled -p21 and -p23, then the -p21 host will
34+
# be used to apply ledgers with protocol 20 and 21, and the -p23 host will be
35+
# used to apply ledgers with protocol 22 and 23.
36+
#
37+
# We add new hosts when performing a protocol upgrade. This allows us to hold
38+
# back any changes to the host's dependencies to the next protocol transition
39+
# and then simultaneously transition the entire network from one set of
40+
# dependencies to another at the (consensus) protocol upgrade boundary.
41+
#
42+
# We remove hosts -- when possible -- _after_ a protocol upgrade, once no more
43+
# ledgers with the previous protocol N-1 are being closed, and only when we have
44+
# convinced ourselves that the host everyone is now running, that supports the
45+
# new protocol N, can also faithfully replay all ledgers recorded under the
46+
# previous protocol N-1. If there is any divergence during replay, then either
47+
# the protocol N host has to be patched with some backward-compatibility code,
48+
# or else we have to keep the protocol N-1 host around indefinitely. If we can
49+
# get a clean replay with the new protocol N host, then we can remove the
50+
# protocol N-1 host from the codebase.
51+
#
52+
# Each additional copy of the soroban host adds a small amount of complexity to
53+
# the build and about 1.5MB of object code to the resulting binary. So we want
54+
# to keep the number of hosts down when and if it's easy to, but having the
55+
# number grow gradually is also not the end of the world.
3456

35-
[dependencies.soroban-env-host-curr]
36-
version = "=21.2.0"
57+
[dependencies.soroban-env-host-p22]
58+
version = "=22.0.0"
3759
git = "https://github.com/stellar/rs-soroban-env"
3860
package = "soroban-env-host"
39-
rev = "8809852dcf8489f99407a5ceac12625ee3d14693"
40-
41-
# This copy of the soroban host is _optional_ and only enabled during protocol
42-
# transitions. When transitioning from protocol N to N+1, the `curr` copy
43-
# (above) will bump its version to one that supports protocol N+1, and we will
44-
# simultaneously enable this `prev` copy by building with
45-
# `--feature=soroban-env-host-prev` and pointing its version and git rev to the
46-
# last soroban released to the network that speaks protocol N. When we deploy
47-
# this to a network running protocol N it will run on `prev` until the upgrade,
48-
# then switch from `prev` to `curr` at the upgrade, and then in the next release
49-
# we can turn `prev` off again.
50-
#
51-
# A note on `rev` hashes: When `prev` is disabled, the rust-analyzer IDE will
52-
# still want it to point to some version of soroban just for auto-completion
53-
# (because it builds with `--all-features`). To make this work, the `rev` spec
54-
# below has to be different from the `rev` spec in the `curr` copy of soroban
55-
# above. The easiest way to make this work is to just point to one git rev
56-
# before the rev specified for `curr`.
61+
rev = "81a4239f3e1ab5e4030140310faa64aba28dfdcb"
5762

58-
[dependencies.soroban-env-host-prev]
59-
optional = true
60-
version = "=20.3.0"
63+
[dependencies.soroban-env-host-p21]
64+
version = "=21.2.0"
6165
git = "https://github.com/stellar/rs-soroban-env"
6266
package = "soroban-env-host"
63-
rev = "93120b6b32cd910fcc224cbf6aec1333f771a8bc"
67+
rev = "8809852dcf8489f99407a5ceac12625ee3d14693"
68+
69+
# The test wasms and synth-wasm crate should usually be taken from the highest
70+
# supported host, since test material usually just grows over time.
6471

6572
[dependencies.soroban-test-wasms]
66-
version = "=21.2.0"
73+
version = "=22.0.0"
6774
git = "https://github.com/stellar/rs-soroban-env"
68-
rev = "8809852dcf8489f99407a5ceac12625ee3d14693"
75+
rev = "81a4239f3e1ab5e4030140310faa64aba28dfdcb"
6976

7077
[dependencies.soroban-synth-wasm]
71-
version = "=21.2.0"
78+
version = "=22.0.0"
7279
git = "https://github.com/stellar/rs-soroban-env"
73-
rev = "8809852dcf8489f99407a5ceac12625ee3d14693"
80+
rev = "81a4239f3e1ab5e4030140310faa64aba28dfdcb"
7481

7582
[dependencies.cargo-lock]
7683
version = "=9.0.0"
7784
git = "https://github.com/rustsec/rustsec"
7885
rev = "a5c69fc6e4b6068b43d7143f3a2f68c3f3de37d8"
7986
features = ["dependency-tree"]
8087

81-
# This feature definition is implied by the optional=true line in the dep, but
82-
# writing it out in full here cross-checks that nobody _removed_ that line.
8388
[features]
84-
soroban-env-host-prev = ["dep:soroban-env-host-prev"]
85-
tracy = ["dep:tracy-client", "soroban-env-host-curr/tracy"]
86-
core-vnext = ["soroban-env-host-curr/next"]
89+
90+
# The tracy feature should enable the tracy features of all supported hosts.
91+
tracy = ["dep:tracy-client", "soroban-env-host-p21/tracy", "soroban-env-host-p22/tracy"]
92+
93+
# The "vnext" feature enables not-yet-released features that (a) break protocol
94+
# but (b) are still under development, in between protocol releases. This
95+
# feature is not enabled by default, and is only intended for temporary use when
96+
# staging work across intra-protocol releases.
97+
core-vnext = ["soroban-env-host-p22/next"]

src/rust/src/contract.rs

+25-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
rust_bridge::{
88
CxxBuf, CxxFeeConfiguration, CxxLedgerEntryRentChange, CxxLedgerInfo,
99
CxxRentFeeConfiguration, CxxTransactionResources, CxxWriteFeeConfiguration, FeePair,
10-
InvokeHostFunctionOutput, RustBuf, XDRFileHash,
10+
InvokeHostFunctionOutput, RustBuf, SorobanVersionInfo, XDRFileHash,
1111
},
1212
};
1313
use log::{debug, trace};
@@ -26,13 +26,14 @@ use super::soroban_env_host::{
2626
compute_write_fee_per_1kb as host_compute_write_fee_per_1kb, FeeConfiguration,
2727
LedgerEntryRentChange, RentFeeConfiguration, TransactionResources, WriteFeeConfiguration,
2828
},
29+
meta,
2930
xdr::{
3031
self, ContractCostParams, ContractEvent, ContractEventBody, ContractEventType,
3132
ContractEventV0, DiagnosticEvent, ExtensionPoint, LedgerEntry, LedgerEntryData,
3233
LedgerEntryExt, Limits, ReadXdr, ScError, ScErrorCode, ScErrorType, ScSymbol, ScVal,
3334
TtlEntry, WriteXdr, XDR_FILES_SHA256,
3435
},
35-
HostError, LedgerInfo,
36+
HostError, LedgerInfo, VERSION,
3637
};
3738
use std::error::Error;
3839

@@ -184,6 +185,28 @@ pub fn get_xdr_hashes() -> Vec<XDRFileHash> {
184185
.collect()
185186
}
186187

188+
pub const fn get_max_proto() -> u32 {
189+
meta::get_ledger_protocol_version(VERSION.interface)
190+
}
191+
192+
pub fn get_soroban_version_info(core_max_proto: u32) -> SorobanVersionInfo {
193+
use meta::{get_ledger_protocol_version, get_pre_release_version};
194+
SorobanVersionInfo {
195+
env_max_proto: get_ledger_protocol_version(VERSION.interface),
196+
env_pkg_ver: VERSION.pkg.to_string(),
197+
env_git_rev: VERSION.rev.to_string(),
198+
env_pre_release_ver: get_pre_release_version(VERSION.interface),
199+
xdr_pkg_ver: VERSION.xdr.pkg.to_string(),
200+
xdr_git_rev: VERSION.xdr.rev.to_string(),
201+
xdr_base_git_rev: match VERSION.xdr.xdr {
202+
"next" => VERSION.xdr.xdr_next.to_string(),
203+
"curr" => VERSION.xdr.xdr_curr.to_string(),
204+
_ => "unknown configuration".to_string(),
205+
},
206+
xdr_file_hashes: get_xdr_hashes(),
207+
}
208+
}
209+
187210
fn log_diagnostic_events(events: &Vec<DiagnosticEvent>) {
188211
for e in events {
189212
debug!("Diagnostic event: {:?}", e);

src/rust/src/dep-trees/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
This directory contains explicit dependency trees for the different soroban
2+
hosts linked into stellar-core. To add a new one, install cargo-lock and run
3+
something like:
4+
5+
$ cargo lock tree --exact [email protected] > soroban_p22.txt
6+
$ git add soroban_p22.txt
7+
8+
With whatever version you want to support in place of "22".

0 commit comments

Comments
 (0)