mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
Compare commits
1 Commits
ximinez/va
...
ripple/was
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0db564d261 |
1
BUILD.md
1
BUILD.md
@@ -144,6 +144,7 @@ git fetch origin master
|
|||||||
git checkout master
|
git checkout master
|
||||||
conan export --version 1.1.10 recipes/snappy/all
|
conan export --version 1.1.10 recipes/snappy/all
|
||||||
conan export --version 4.0.3 recipes/soci/all
|
conan export --version 4.0.3 recipes/soci/all
|
||||||
|
conan export --version 0.42.1 external/wasmi
|
||||||
rm -rf .git
|
rm -rf .git
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ endif()
|
|||||||
|
|
||||||
find_package(nudb REQUIRED)
|
find_package(nudb REQUIRED)
|
||||||
find_package(date REQUIRED)
|
find_package(date REQUIRED)
|
||||||
|
find_package(wasmi REQUIRED)
|
||||||
find_package(xxHash REQUIRED)
|
find_package(xxHash REQUIRED)
|
||||||
|
|
||||||
target_link_libraries(xrpl_libs INTERFACE
|
target_link_libraries(xrpl_libs INTERFACE
|
||||||
|
|||||||
@@ -63,11 +63,17 @@ target_link_libraries(xrpl.imports.main
|
|||||||
Xrpl::opts
|
Xrpl::opts
|
||||||
Xrpl::syslibs
|
Xrpl::syslibs
|
||||||
secp256k1::secp256k1
|
secp256k1::secp256k1
|
||||||
|
wasmi::wasmi
|
||||||
xrpl.libpb
|
xrpl.libpb
|
||||||
xxHash::xxhash
|
xxHash::xxhash
|
||||||
$<$<BOOL:${voidstar}>:antithesis-sdk-cpp>
|
$<$<BOOL:${voidstar}>:antithesis-sdk-cpp>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
target_link_libraries(xrpl.imports.main INTERFACE ntdll)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
include(add_module)
|
include(add_module)
|
||||||
include(target_link_modules)
|
include(target_link_modules)
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from conan import ConanFile, __version__ as conan_version
|
|||||||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
|
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
class Xrpl(ConanFile):
|
class Xrpl(ConanFile):
|
||||||
name = 'xrpl'
|
name = 'xrpl'
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ class Xrpl(ConanFile):
|
|||||||
'nudb/2.0.9',
|
'nudb/2.0.9',
|
||||||
'openssl/3.5.4',
|
'openssl/3.5.4',
|
||||||
'soci/4.0.3',
|
'soci/4.0.3',
|
||||||
|
'wasmi/0.42.1',
|
||||||
'zlib/1.3.1',
|
'zlib/1.3.1',
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -133,6 +135,7 @@ class Xrpl(ConanFile):
|
|||||||
self.folders.generators = 'build/generators'
|
self.folders.generators = 'build/generators'
|
||||||
|
|
||||||
generators = 'CMakeDeps'
|
generators = 'CMakeDeps'
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
tc = CMakeToolchain(self)
|
tc = CMakeToolchain(self)
|
||||||
tc.variables['tests'] = self.options.tests
|
tc.variables['tests'] = self.options.tests
|
||||||
@@ -190,6 +193,7 @@ class Xrpl(ConanFile):
|
|||||||
'protobuf::libprotobuf',
|
'protobuf::libprotobuf',
|
||||||
'soci::soci',
|
'soci::soci',
|
||||||
'sqlite3::sqlite',
|
'sqlite3::sqlite',
|
||||||
|
'wasmi::wasmi',
|
||||||
'xxhash::xxhash',
|
'xxhash::xxhash',
|
||||||
'zlib::zlib',
|
'zlib::zlib',
|
||||||
]
|
]
|
||||||
|
|||||||
5
external/wasmi/conandata.yml
vendored
Normal file
5
external/wasmi/conandata.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
patches:
|
||||||
|
0.42.1:
|
||||||
|
- patch_description: install only static lib (to prevent conflict with shared)
|
||||||
|
patch_file: patches/wasmi.patch
|
||||||
|
patch_type: conan
|
||||||
90
external/wasmi/conanfile.py
vendored
Normal file
90
external/wasmi/conanfile.py
vendored
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
import os
|
||||||
|
# import json
|
||||||
|
|
||||||
|
required_conan_version = ">=1.55.0"
|
||||||
|
|
||||||
|
class WasmiConan(ConanFile):
|
||||||
|
name = "wasmi"
|
||||||
|
license = "Apache License v2.0"
|
||||||
|
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]}
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
def generate(self):
|
||||||
|
tc = CMakeToolchain(self)
|
||||||
|
|
||||||
|
tc.variables["CMAKE_CXX_STANDARD"] = 20
|
||||||
|
tc.variables["BUILD_SHARED_LIBS"] = 0
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
15
external/wasmi/patches/static_only.patch
vendored
Normal file
15
external/wasmi/patches/static_only.patch
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
diff --git a/crates/c_api/CMakeLists.txt b/crates/c_api/CMakeLists.txt
|
||||||
|
index b15c787..97dd294 100644
|
||||||
|
--- a/crates/c_api/CMakeLists.txt
|
||||||
|
+++ b/crates/c_api/CMakeLists.txt
|
||||||
|
@@ -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 )
|
||||||
|
+endif()
|
||||||
|
+
|
||||||
|
# Instructions on how to build and install the Wasmi Rust crate.
|
||||||
|
find_program(WASMI_CARGO_BINARY cargo REQUIRED)
|
||||||
|
include(ExternalProject)
|
||||||
109
external/wasmi/patches/wasmi.patch
vendored
Normal file
109
external/wasmi/patches/wasmi.patch
vendored
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
diff --git a/crates/c_api/CMakeLists.txt b/crates/c_api/CMakeLists.txt
|
||||||
|
index b15c787a..0d0a04b7 100644
|
||||||
|
--- a/crates/c_api/CMakeLists.txt
|
||||||
|
+++ b/crates/c_api/CMakeLists.txt
|
||||||
|
@@ -43,6 +43,11 @@ 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 )
|
||||||
|
+endif()
|
||||||
|
+
|
||||||
|
+
|
||||||
|
# Instructions on how to build and install the Wasmi Rust crate.
|
||||||
|
find_program(WASMI_CARGO_BINARY cargo REQUIRED)
|
||||||
|
include(ExternalProject)
|
||||||
|
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
|
||||||
|
+++ b/crates/c_api/include/wasm.h
|
||||||
|
@@ -146,6 +146,13 @@ WASM_DECLARE_OWN(store)
|
||||||
|
|
||||||
|
WASM_API_EXTERN own wasm_store_t* wasm_store_new(wasm_engine_t*);
|
||||||
|
|
||||||
|
+// Store fuel functions (forward declarations)
|
||||||
|
+struct wasmi_error;
|
||||||
|
+
|
||||||
|
+WASM_API_EXTERN struct wasmi_error* wasm_store_get_fuel(const wasm_store_t*, uint64_t* fuel);
|
||||||
|
+WASM_API_EXTERN struct wasmi_error* wasm_store_set_fuel(wasm_store_t*, uint64_t fuel);
|
||||||
|
+//WASM_API_EXTERN void *wasm_store_get_data(const wasm_store_t*);
|
||||||
|
+//WASM_API_EXTERN void wasm_store_set_data(wasm_store_t*, void *data);
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Type Representations
|
||||||
|
diff --git a/crates/c_api/include/wasmi.h b/crates/c_api/include/wasmi.h
|
||||||
|
index 2caffa37..0c0584ec 100644
|
||||||
|
--- a/crates/c_api/include/wasmi.h
|
||||||
|
+++ b/crates/c_api/include/wasmi.h
|
||||||
|
@@ -10,7 +10,7 @@
|
||||||
|
/**
|
||||||
|
* \brief Wasmi version string.
|
||||||
|
*/
|
||||||
|
-#define WASMI_VERSION "0.35.0"
|
||||||
|
+#define WASMI_VERSION "0.42.1"
|
||||||
|
/**
|
||||||
|
* \brief Wasmi major version number.
|
||||||
|
*/
|
||||||
|
@@ -18,10 +18,10 @@
|
||||||
|
/**
|
||||||
|
* \brief Wasmi minor version number.
|
||||||
|
*/
|
||||||
|
-#define WASMI_VERSION_MINOR 35
|
||||||
|
+#define WASMI_VERSION_MINOR 42
|
||||||
|
/**
|
||||||
|
* \brief Wasmi patch version number.
|
||||||
|
*/
|
||||||
|
-#define WASMI_VERSION_PATCH 0
|
||||||
|
+#define WASMI_VERSION_PATCH 1
|
||||||
|
|
||||||
|
#endif // WASMI_H
|
||||||
|
diff --git a/crates/c_api/src/store.rs b/crates/c_api/src/store.rs
|
||||||
|
index 56d4898f..543dbff8 100644
|
||||||
|
--- a/crates/c_api/src/store.rs
|
||||||
|
+++ b/crates/c_api/src/store.rs
|
||||||
|
@@ -175,3 +175,44 @@ pub extern "C" fn wasmi_context_set_fuel(
|
||||||
|
) -> Option<Box<wasmi_error_t>> {
|
||||||
|
crate::handle_result(store.set_fuel(fuel), |()| {})
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
+////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
+////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
+////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
+
|
||||||
|
+/// Returns the current fuel of the wasm store context in `fuel`.
|
||||||
|
+///
|
||||||
|
+/// Wraps [`Store::get_fuel`].
|
||||||
|
+///
|
||||||
|
+/// # Errors
|
||||||
|
+///
|
||||||
|
+/// If [`Store::get_fuel`] errors.
|
||||||
|
+#[no_mangle]
|
||||||
|
+pub extern "C" fn wasm_store_get_fuel(
|
||||||
|
+ store: &wasm_store_t,
|
||||||
|
+ fuel: &mut u64,
|
||||||
|
+) -> Option<Box<wasmi_error_t>> {
|
||||||
|
+ let context = unsafe { store.inner.context() };
|
||||||
|
+ crate::handle_result(context.get_fuel(), |amt| {
|
||||||
|
+ *fuel = amt;
|
||||||
|
+ })
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/// Sets the current fuel of the wasm store context to `fuel`.
|
||||||
|
+///
|
||||||
|
+/// Wraps [`Store::set_fuel`].
|
||||||
|
+///
|
||||||
|
+/// # Errors
|
||||||
|
+///
|
||||||
|
+/// If [`Store::set_fuel`] errors.
|
||||||
|
+#[no_mangle]
|
||||||
|
+pub extern "C" fn wasm_store_set_fuel(
|
||||||
|
+ store: &mut wasm_store_t,
|
||||||
|
+ fuel: u64,
|
||||||
|
+) -> Option<Box<wasmi_error_t>> {
|
||||||
|
+
|
||||||
|
+ let mut context = unsafe { store.inner.context_mut() };
|
||||||
|
+ crate::handle_result(context.set_fuel(fuel), |()| {})
|
||||||
|
+}
|
||||||
|
+
|
||||||
Reference in New Issue
Block a user