From 718ba16e3e0d22cbb3d35b7d924b67787253a8ec Mon Sep 17 00:00:00 2001 From: Olek <115580134+oleks-rip@users.noreply.github.com> Date: Mon, 24 Nov 2025 15:33:18 -0500 Subject: [PATCH] Switch to rust docker (#6061) * fix clang-format * Switch to rust docker * fix wasmi conan package * Add TODO * Add patch description * Switch to latest prepare-runner --- .github/actions/build-deps/action.yml | 1 + .github/scripts/strategy-matrix/linux.json | 56 +++++++-------- .../workflows/reusable-build-test-config.yml | 2 +- .github/workflows/upload-conan-deps.yml | 2 +- external/wasmi/conandata.yml | 14 ++-- external/wasmi/conanfile.py | 56 ++------------- .../{wasmi.patch => 0001-xrplf-0.42.1.patch} | 71 +++++++++---------- src/test/app/TestHostFunctions.h | 1 - src/xrpld/app/wasm/detail/WasmiVM.cpp | 25 +------ 9 files changed, 82 insertions(+), 146 deletions(-) rename external/wasmi/patches/{wasmi.patch => 0001-xrplf-0.42.1.patch} (69%) diff --git a/.github/actions/build-deps/action.yml b/.github/actions/build-deps/action.yml index f20eb3a595..9ac6d65780 100644 --- a/.github/actions/build-deps/action.yml +++ b/.github/actions/build-deps/action.yml @@ -35,6 +35,7 @@ runs: LOG_VERBOSITY: ${{ inputs.log_verbosity }} run: | echo 'Installing dependencies.' + conan export --version 0.42.1 external/wasmi #TODO Switch to conan package mkdir -p "${BUILD_DIR}" cd "${BUILD_DIR}" conan install \ diff --git a/.github/scripts/strategy-matrix/linux.json b/.github/scripts/strategy-matrix/linux.json index 748ee031c9..331f4e33f6 100644 --- a/.github/scripts/strategy-matrix/linux.json +++ b/.github/scripts/strategy-matrix/linux.json @@ -15,196 +15,196 @@ "distro_version": "bookworm", "compiler_name": "gcc", "compiler_version": "12", - "image_sha": "0525eae" + "image_sha": "ca4517d" }, { "distro_name": "debian", "distro_version": "bookworm", "compiler_name": "gcc", "compiler_version": "13", - "image_sha": "0525eae" + "image_sha": "ca4517d" }, { "distro_name": "debian", "distro_version": "bookworm", "compiler_name": "gcc", "compiler_version": "14", - "image_sha": "0525eae" + "image_sha": "ca4517d" }, { "distro_name": "debian", "distro_version": "bookworm", "compiler_name": "gcc", "compiler_version": "15", - "image_sha": "0525eae" + "image_sha": "ca4517d" }, { "distro_name": "debian", "distro_version": "bookworm", "compiler_name": "clang", "compiler_version": "16", - "image_sha": "0525eae" + "image_sha": "ca4517d" }, { "distro_name": "debian", "distro_version": "bookworm", "compiler_name": "clang", "compiler_version": "17", - "image_sha": "0525eae" + "image_sha": "ca4517d" }, { "distro_name": "debian", "distro_version": "bookworm", "compiler_name": "clang", "compiler_version": "18", - "image_sha": "0525eae" + "image_sha": "ca4517d" }, { "distro_name": "debian", "distro_version": "bookworm", "compiler_name": "clang", "compiler_version": "19", - "image_sha": "0525eae" + "image_sha": "ca4517d" }, { "distro_name": "debian", "distro_version": "bookworm", "compiler_name": "clang", "compiler_version": "20", - "image_sha": "0525eae" + "image_sha": "ca4517d" }, { "distro_name": "debian", "distro_version": "trixie", "compiler_name": "gcc", "compiler_version": "14", - "image_sha": "0525eae" + "image_sha": "ca4517d" }, { "distro_name": "debian", "distro_version": "trixie", "compiler_name": "gcc", "compiler_version": "15", - "image_sha": "0525eae" + "image_sha": "ca4517d" }, { "distro_name": "debian", "distro_version": "trixie", "compiler_name": "clang", "compiler_version": "20", - "image_sha": "0525eae" + "image_sha": "ca4517d" }, { "distro_name": "debian", "distro_version": "trixie", "compiler_name": "clang", "compiler_version": "21", - "image_sha": "0525eae" + "image_sha": "ca4517d" }, { "distro_name": "rhel", "distro_version": "8", "compiler_name": "gcc", "compiler_version": "14", - "image_sha": "e1782cd" + "image_sha": "ca4517d" }, { "distro_name": "rhel", "distro_version": "8", "compiler_name": "clang", "compiler_version": "any", - "image_sha": "e1782cd" + "image_sha": "ca4517d" }, { "distro_name": "rhel", "distro_version": "9", "compiler_name": "gcc", "compiler_version": "12", - "image_sha": "e1782cd" + "image_sha": "ca4517d" }, { "distro_name": "rhel", "distro_version": "9", "compiler_name": "gcc", "compiler_version": "13", - "image_sha": "e1782cd" + "image_sha": "ca4517d" }, { "distro_name": "rhel", "distro_version": "9", "compiler_name": "gcc", "compiler_version": "14", - "image_sha": "e1782cd" + "image_sha": "ca4517d" }, { "distro_name": "rhel", "distro_version": "9", "compiler_name": "clang", "compiler_version": "any", - "image_sha": "e1782cd" + "image_sha": "ca4517d" }, { "distro_name": "rhel", "distro_version": "10", "compiler_name": "gcc", "compiler_version": "14", - "image_sha": "e1782cd" + "image_sha": "ca4517d" }, { "distro_name": "rhel", "distro_version": "10", "compiler_name": "clang", "compiler_version": "any", - "image_sha": "e1782cd" + "image_sha": "ca4517d" }, { "distro_name": "ubuntu", "distro_version": "jammy", "compiler_name": "gcc", "compiler_version": "12", - "image_sha": "e1782cd" + "image_sha": "ca4517d" }, { "distro_name": "ubuntu", "distro_version": "noble", "compiler_name": "gcc", "compiler_version": "13", - "image_sha": "e1782cd" + "image_sha": "ca4517d" }, { "distro_name": "ubuntu", "distro_version": "noble", "compiler_name": "gcc", "compiler_version": "14", - "image_sha": "e1782cd" + "image_sha": "ca4517d" }, { "distro_name": "ubuntu", "distro_version": "noble", "compiler_name": "clang", "compiler_version": "16", - "image_sha": "e1782cd" + "image_sha": "ca4517d" }, { "distro_name": "ubuntu", "distro_version": "noble", "compiler_name": "clang", "compiler_version": "17", - "image_sha": "e1782cd" + "image_sha": "ca4517d" }, { "distro_name": "ubuntu", "distro_version": "noble", "compiler_name": "clang", "compiler_version": "18", - "image_sha": "e1782cd" + "image_sha": "ca4517d" }, { "distro_name": "ubuntu", "distro_version": "noble", "compiler_name": "clang", "compiler_version": "19", - "image_sha": "e1782cd" + "image_sha": "ca4517d" } ], "build_type": ["Debug", "Release"], diff --git a/.github/workflows/reusable-build-test-config.yml b/.github/workflows/reusable-build-test-config.yml index 8ce810aa2e..2fe9ddeda2 100644 --- a/.github/workflows/reusable-build-test-config.yml +++ b/.github/workflows/reusable-build-test-config.yml @@ -77,7 +77,7 @@ jobs: uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 - name: Prepare runner - uses: XRPLF/actions/.github/actions/prepare-runner@99685816bb60a95a66852f212f382580e180df3a + uses: XRPLF/actions/.github/actions/prepare-runner@ff9f8f649df5855ffe1a1ae715df43e51807f2e0 with: disable_ccache: false diff --git a/.github/workflows/upload-conan-deps.yml b/.github/workflows/upload-conan-deps.yml index 320396c899..1576e1789b 100644 --- a/.github/workflows/upload-conan-deps.yml +++ b/.github/workflows/upload-conan-deps.yml @@ -70,7 +70,7 @@ jobs: uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 - name: Prepare runner - uses: XRPLF/actions/.github/actions/prepare-runner@99685816bb60a95a66852f212f382580e180df3a + uses: XRPLF/actions/.github/actions/prepare-runner@ff9f8f649df5855ffe1a1ae715df43e51807f2e0 with: disable_ccache: false diff --git a/external/wasmi/conandata.yml b/external/wasmi/conandata.yml index 628590aea4..032c12753c 100644 --- a/external/wasmi/conandata.yml +++ b/external/wasmi/conandata.yml @@ -1,5 +1,11 @@ +# Do not update. Maintained by programmability team. + +sources: + "0.42.1": + sha256: 2a5697be33c7afce8f671af4a5a3621d9e93ce55d253d31bd8201458e465fbb8 + url: https://github.com/wasmi-labs/wasmi/archive/refs/tags/v0.42.1.tar.gz patches: - 0.42.1: - - patch_description: install only static lib (to prevent conflict with shared) - patch_file: patches/wasmi.patch - patch_type: conan + "0.42.1": + - patch_file: "patches/0001-xrplf-0.42.1.patch" + patch_type: conan + patch_description: Integration patch. Make wasmi lib to be able to build with existing smart-escrow branch. diff --git a/external/wasmi/conanfile.py b/external/wasmi/conanfile.py index d6b1c0b259..e245d62eb0 100644 --- a/external/wasmi/conanfile.py +++ b/external/wasmi/conanfile.py @@ -1,16 +1,9 @@ from conan import ConanFile, tools from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout -from conan.tools.files import ( - apply_conandata_patches, - export_conandata_patches, - # get, -) -from conan.tools.scm import Git - +from conan.tools.files import apply_conandata_patches, export_conandata_patches, get import os -# import json -required_conan_version = ">=1.55.0" +required_conan_version = ">=2.0.0" class WasmiConan(ConanFile): name = "wasmi" @@ -18,73 +11,38 @@ class WasmiConan(ConanFile): url = "https://github.com/wasmi-labs/wasmi.git" description = "WebAssembly (Wasm) interpreter" package_type = "library" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False]} + settings = "os", "arch", "compiler", "build_type" + options = {"shared": [False]} default_options = {"shared": False} - # generators = "CMakeToolchain", "CMakeDeps" - #requires = [("llvm/20.1.1@")] def export_sources(self): export_conandata_patches(self) - pass - - # def build_requirements(self): - # self.tool_requires("llvm/20.1.1") - - - def config_options(self): - #if self.settings.os == "Windows": - # del self.options.fPIC - pass - def layout(self): cmake_layout(self, src_folder="src") - def source(self): - git = Git(self) - git.fetch_commit( - url="https://github.com/wasmi-labs/wasmi.git", - commit="f628a7a86c9715f2c306f6ef9aea1cc2bdca5fa7", - ) - #get(self, **self.conan_data["sources"][self.version], strip_root=True) - + get(self, **self.conan_data["sources"][self.version], strip_root=True) + apply_conandata_patches(self) def generate(self): tc = CMakeToolchain(self) - - tc.variables["CMAKE_CXX_STANDARD"] = 20 - tc.variables["BUILD_SHARED_LIBS"] = 0 - + tc.variables["BUILD_SHARED_LIBS"] = self.options.shared tc.generate() - # This generates "foo-config.cmake" and "bar-config.cmake" in self.generators_folder deps = CMakeDeps(self) deps.generate() - def build(self): - apply_conandata_patches(self) cmake = CMake(self) - cmake.verbose = True cmake.configure(build_script_folder=os.path.join(self.source_folder, "crates", "c_api")) cmake.build() - #self.run(f'echo {self.source_folder}') - - # Explicit way: - # self.run('cmake %s/hello %s' % (self.source_folder, cmake.command_line)) - # self.run("cmake --build . %s" % cmake.build_config) - def package(self): cmake = CMake(self) - cmake.verbose = True cmake.install() - def package_info(self): self.cpp_info.libs = ["wasmi"] self.cpp_info.names["cmake_find_package"] = "wasmi" self.cpp_info.names["cmake_find_package_multi"] = "wasmi" - diff --git a/external/wasmi/patches/wasmi.patch b/external/wasmi/patches/0001-xrplf-0.42.1.patch similarity index 69% rename from external/wasmi/patches/wasmi.patch rename to external/wasmi/patches/0001-xrplf-0.42.1.patch index 0be7958e7b..656c5aff65 100644 --- a/external/wasmi/patches/wasmi.patch +++ b/external/wasmi/patches/0001-xrplf-0.42.1.patch @@ -1,61 +1,54 @@ diff --git a/crates/c_api/CMakeLists.txt b/crates/c_api/CMakeLists.txt -index b15c787a..2420bea2 100644 +index b15c787a..4e6de690 100644 --- a/crates/c_api/CMakeLists.txt +++ b/crates/c_api/CMakeLists.txt -@@ -43,6 +43,11 @@ endif() +@@ -43,6 +43,10 @@ endif() list(TRANSFORM WASMI_SHARED_FILES PREPEND ${WASMI_TARGET_DIR}/) list(TRANSFORM WASMI_STATIC_FILES PREPEND ${WASMI_TARGET_DIR}/) +if(NOT BUILD_SHARED_LIBS) -+ set(WASMI_SHARED_FILES ) ++ set(WASMI_SHARED_FILES) +endif() -+ + # Instructions on how to build and install the Wasmi Rust crate. find_program(WASMI_CARGO_BINARY cargo REQUIRED) include(ExternalProject) -@@ -112,23 +117,25 @@ install( +@@ -112,6 +116,7 @@ install( DESTINATION ${CMAKE_INSTALL_LIBDIR} ) --if(WASMI_TARGET MATCHES "darwin") -- set(INSTALLED_LIB "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libwasmi.dylib") -- install( -- FILES "${INSTALLED_LIB}" -- DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" -- COMPONENT Runtime -- ) -- if(NOT CMAKE_INSTALL_NAME_TOOL) -- message(WARNING "CMAKE_INSTALL_NAME_TOOL is not set. LC_ID_DYLIB for libwasmi.dylib will not be set.") -- else() -- set(install_name_tool_cmd -- "${CMAKE_INSTALL_NAME_TOOL}" -- "-id" -- "@rpath/libwasmi.dylib" -- "${INSTALLED_LIB}" +if(BUILD_SHARED_LIBS) -+ if(WASMI_TARGET MATCHES "darwin") -+ set(INSTALLED_LIB "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libwasmi.dylib") -+ install( -+ FILES "${INSTALLED_LIB}" -+ DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" -+ COMPONENT Runtime - ) -- install(CODE "execute_process(COMMAND ${install_name_tool_cmd})") -+ if(NOT CMAKE_INSTALL_NAME_TOOL) -+ message(WARNING "CMAKE_INSTALL_NAME_TOOL is not set. LC_ID_DYLIB for libwasmi.dylib will not be set.") -+ else() -+ set(install_name_tool_cmd -+ "${CMAKE_INSTALL_NAME_TOOL}" -+ "-id" -+ "@rpath/libwasmi.dylib" -+ "${INSTALLED_LIB}" -+ ) -+ install(CODE "execute_process(COMMAND ${install_name_tool_cmd})") -+ endif() + if(WASMI_TARGET MATCHES "darwin") + set(INSTALLED_LIB "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libwasmi.dylib") + install( +@@ -131,6 +136,7 @@ if(WASMI_TARGET MATCHES "darwin") + install(CODE "execute_process(COMMAND ${install_name_tool_cmd})") endif() endif() ++endif() + # Documentation Generation via Doxygen: + set(DOXYGEN_CONF_IN ${CMAKE_CURRENT_SOURCE_DIR}/doxygen.conf.in) +@@ -141,19 +147,3 @@ add_custom_target(doc + DEPENDS ${WASMI_GENERATED_CONF_H} ${DOXYGEN_CONF_OUT} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) +- +-# C-Header Formatting via clang-format: +-find_program(CLANG_FORMAT clang-format REQUIRED) +-file(GLOB_RECURSE HEADER_FILES +- ${CMAKE_CURRENT_SOURCE_DIR}/include/wasmi.h +- ${CMAKE_CURRENT_SOURCE_DIR}/include/wasmi/*.h +- ${CMAKE_CURRENT_SOURCE_DIR}/include/wasmi/*.hh +-) +-add_custom_target(check-format +- COMMAND ${CLANG_FORMAT} -style=llvm -Werror --dry-run ${HEADER_FILES} +- COMMENT "clang-format: Check formatting for Wasmi C-API header files" +-) +-add_custom_target(format +- COMMAND ${CLANG_FORMAT} -style=llvm -i ${HEADER_FILES} +- COMMENT "clang-format: Apply formatting rules for Wasmi C-API header files" +-) diff --git a/crates/c_api/include/wasm.h b/crates/c_api/include/wasm.h index 5ee617ff..0199192d 100644 --- a/crates/c_api/include/wasm.h diff --git a/src/test/app/TestHostFunctions.h b/src/test/app/TestHostFunctions.h index fd59126943..47d0f6204c 100644 --- a/src/test/app/TestHostFunctions.h +++ b/src/test/app/TestHostFunctions.h @@ -5,7 +5,6 @@ #include #include #include -#include #include #include diff --git a/src/xrpld/app/wasm/detail/WasmiVM.cpp b/src/xrpld/app/wasm/detail/WasmiVM.cpp index 6096a75b4c..56cd321479 100644 --- a/src/xrpld/app/wasm/detail/WasmiVM.cpp +++ b/src/xrpld/app/wasm/detail/WasmiVM.cpp @@ -1,22 +1,3 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2020 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - #include #include @@ -135,8 +116,7 @@ InstanceWrapper::operator=(InstanceWrapper&& o) return *this; } -InstanceWrapper:: -operator bool() const +InstanceWrapper::operator bool() const { return static_cast(instance_); } @@ -277,8 +257,7 @@ ModuleWrapper::operator=(ModuleWrapper&& o) return *this; } -ModuleWrapper:: -operator bool() const +ModuleWrapper::operator bool() const { return instanceWrap_; }