From 46594c89f01b7dbb5fe02efd46836a46953edc31 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 26 Sep 2024 16:14:03 -0700 Subject: [PATCH 1/4] Pass --features testutils to librust_stellar_core build --- src/Makefile.am | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 17b66a1bb3..c2537269a7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,12 +8,6 @@ include $(srcdir)/src.mk noinst_HEADERS = $(SRC_H_FILES) -if BUILD_TESTS -stellar_core_SOURCES = main/StellarCoreVersion.cpp main/XDRFilesSha256.cpp $(SRC_CXX_FILES) $(SRC_TEST_CXX_FILES) -else # !BUILD_TESTS -stellar_core_SOURCES = main/StellarCoreVersion.cpp main/XDRFilesSha256.cpp $(SRC_CXX_FILES) -endif # !BUILD_TESTS - if USE_TRACY CARGO_FEATURE_TRACY = --features tracy else @@ -226,7 +220,7 @@ $(LIBRUST_STELLAR_CORE): $(RUST_HOST_DEPFILES) $(SRC_RUST_FILES) Makefile $(SORO --$(RUST_PROFILE) \ --locked \ --target-dir $(abspath $(RUST_TARGET_DIR)) \ - $(CARGO_FEATURE_TRACY) $(CARGO_FEATURE_NEXT) \ + $(CARGO_FEATURE_TRACY) $(CARGO_FEATURE_NEXT) $(CARGO_FEATURE_TESTUTILS) \ -- \ $(ALL_SOROBAN_EXTERN_ARGS) \ $(ALL_SOROBAN_DEPEND_ARGS) From 59ab7875d6158b25ff62afce53c2672a74cb1699 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 26 Sep 2024 16:22:40 -0700 Subject: [PATCH 2/4] fix a couple testutils-gated bugs in lib.rs --- src/rust/src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs index 0441ed8204..4a4685e711 100644 --- a/src/rust/src/lib.rs +++ b/src/rust/src/lib.rs @@ -513,9 +513,9 @@ use log::partition::TX; // We have multiple copies of soroban linked into stellar-core here. This is // accomplished using an adaptor module -- contract.rs -- mounted multiple times -// into the same outer crate, inside different modules soroban_p21, soroban_p22, -// etc. each with its own local binding for the external crate soroban_env_host. -// The contract.rs module imports soroban_env_host from `super` which means each +// into the same outer crate, inside different modules p21, p22, etc. each with +// its own local binding for the external crate soroban_env_host. The +// contract.rs module imports soroban_env_host from `super` which means each // instance of it sees a different soroban. This is a bit of a hack and only // works when the soroban versions all have a compatible _enough_ interface to // all be called from "the same" contract.rs. @@ -774,6 +774,7 @@ mod test_extra_protocol { use super::*; use std::hash::Hasher; + use std::str::FromStr; pub(super) fn maybe_invoke_host_function_again_and_compare_outputs( res1: &Result>, @@ -845,7 +846,7 @@ mod test_extra_protocol { ) -> Result<(), Box> { match new_protocol { 22 => { - use soroban_p22::contract::{ + use p22::contract::{ inplace_modify_cxxbuf_encoded_type, xdr::SorobanResources, }; if let Ok(extra) = std::env::var("SOROBAN_TEST_CPU_BUDGET_FACTOR") { @@ -884,7 +885,7 @@ mod test_extra_protocol { match new_protocol { 22 => { - use soroban_p22::contract::{ + use p22::contract::{ inplace_modify_cxxbuf_encoded_type, xdr::ContractCostParams, xdr::ContractCostType as CT, }; From 053a5d386773f66b84ffb006d32c1fc6b523573e Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 26 Sep 2024 17:19:35 -0700 Subject: [PATCH 3/4] Do _not_ pass --features testutils to soroban (appears to perturb metering!) --- src/Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index c2537269a7..e6220bfe8b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -181,13 +181,13 @@ $(SOROBAN_LIBS_STAMP): $(wildcard rust/soroban/p*/Cargo.lock) Makefile $(RUST_DE FEATURE_FLAGS="" ; \ case "$$proto" in \ p21) \ - FEATURE_FLAGS="$(CARGO_FEATURE_TESTUTILS)" \ + FEATURE_FLAGS="" \ ;; \ $(SOROBAN_MAX_PROTOCOL)) \ - FEATURE_FLAGS="$(CARGO_FEATURE_TRACY) $(CARGO_FEATURE_NEXT) $(CARGO_FEATURE_TESTUTILS)" \ + FEATURE_FLAGS="$(CARGO_FEATURE_TRACY) $(CARGO_FEATURE_NEXT)" \ ;; \ *) \ - FEATURE_FLAGS="$(CARGO_FEATURE_TRACY) $(CARGO_FEATURE_TESTUTILS)" \ + FEATURE_FLAGS="$(CARGO_FEATURE_TRACY)" \ ;; \ esac ; \ cd $(abspath $(RUST_BUILD_DIR))/soroban/$$proto && \ From 998cf6909af7e43b863fb65cc28efdb2e36faf27 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 26 Sep 2024 17:45:19 -0700 Subject: [PATCH 4/4] format --- src/rust/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs index 4a4685e711..082c16c624 100644 --- a/src/rust/src/lib.rs +++ b/src/rust/src/lib.rs @@ -846,9 +846,7 @@ mod test_extra_protocol { ) -> Result<(), Box> { match new_protocol { 22 => { - use p22::contract::{ - inplace_modify_cxxbuf_encoded_type, xdr::SorobanResources, - }; + use p22::contract::{inplace_modify_cxxbuf_encoded_type, xdr::SorobanResources}; if let Ok(extra) = std::env::var("SOROBAN_TEST_CPU_BUDGET_FACTOR") { if let Ok(factor) = u32::from_str(&extra) { inplace_modify_cxxbuf_encoded_type::(