mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-14 08:05:50 +00:00
Compare commits
1 Commits
bthomee/gi
...
ripple/was
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0db564d261 |
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -1,6 +1,10 @@
|
||||
# Set default behaviour, in case users don't have core.autocrlf set.
|
||||
#* text=auto
|
||||
|
||||
# These annoying files
|
||||
rippled.1 binary
|
||||
LICENSE binary
|
||||
|
||||
# Visual Studio
|
||||
*.sln text eol=crlf
|
||||
*.vcproj text eol=crlf
|
||||
|
||||
107
.gitignore
vendored
107
.gitignore
vendored
@@ -1,42 +1,69 @@
|
||||
# .gitignore
|
||||
|
||||
# Macintosh Desktop Services Store files.
|
||||
bin/boostbook_catalog.xml
|
||||
bin/config.log
|
||||
bin/project-cache.jam
|
||||
|
||||
# Ignore vim swap files.
|
||||
*.swp
|
||||
|
||||
# Ignore SCons support files.
|
||||
.sconsign.dblite
|
||||
|
||||
# Ignore python compiled files.
|
||||
*.pyc
|
||||
|
||||
# Ignore Macintosh Desktop Services Store files.
|
||||
.DS_Store
|
||||
|
||||
# Build, intermediate, and temporary artifacts.
|
||||
# Ignore backup/temps
|
||||
*~
|
||||
*.o
|
||||
*.pdb
|
||||
*.swp
|
||||
.clangd
|
||||
Debug/
|
||||
Release/
|
||||
/.build/
|
||||
/build/
|
||||
/db/
|
||||
/out.txt
|
||||
/tmp/
|
||||
CMakeSettings.json
|
||||
CMakeUserPresets.json
|
||||
|
||||
# Coverage files.
|
||||
# Ignore object files.
|
||||
*.o
|
||||
.nih_c
|
||||
tags
|
||||
TAGS
|
||||
GTAGS
|
||||
GRTAGS
|
||||
GPATH
|
||||
bin/rippled
|
||||
Debug/*.*
|
||||
Release/*.*
|
||||
|
||||
# Ignore coverage files.
|
||||
*.gcno
|
||||
*.gcda
|
||||
*.gcov
|
||||
|
||||
# Profiling data.
|
||||
gmon.out
|
||||
|
||||
# Levelization data.
|
||||
# Levelization checking
|
||||
.github/scripts/levelization/results/*
|
||||
!.github/scripts/levelization/results/loops.txt
|
||||
!.github/scripts/levelization/results/ordering.txt
|
||||
|
||||
# Customized configs.
|
||||
# Ignore tmp directory.
|
||||
tmp
|
||||
|
||||
# Ignore database directory.
|
||||
db/
|
||||
db/*.db
|
||||
db/*.db-*
|
||||
|
||||
# Ignore debug logs
|
||||
debug_log.txt
|
||||
|
||||
# Ignore customized configs
|
||||
rippled.cfg
|
||||
validators.txt
|
||||
|
||||
# XCode IDE.
|
||||
# Doxygen generated documentation output
|
||||
HtmlDocumentation
|
||||
docs/html_doc
|
||||
|
||||
# Xcode user-specific project settings
|
||||
# Xcode
|
||||
.DS_Store
|
||||
/build/
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
@@ -49,14 +76,38 @@ xcuserdata
|
||||
profile
|
||||
*.moved-aside
|
||||
DerivedData
|
||||
.idea/
|
||||
*.hmap
|
||||
|
||||
# JetBrains IDE.
|
||||
/.idea/
|
||||
# Intel Parallel Studio 2013 XE
|
||||
My Amplifier XE Results - RippleD
|
||||
|
||||
# Microsoft Visual Studio IDE.
|
||||
# Compiler intermediate output
|
||||
/out.txt
|
||||
|
||||
# Build Log
|
||||
rippled-build.log
|
||||
|
||||
# Profiling data
|
||||
gmon.out
|
||||
|
||||
Builds/VisualStudio2015/*.db
|
||||
Builds/VisualStudio2015/*.user
|
||||
Builds/VisualStudio2015/*.opendb
|
||||
Builds/VisualStudio2015/*.sdf
|
||||
|
||||
# MSVC
|
||||
*.pdb
|
||||
.vs/
|
||||
.vscode/
|
||||
CMakeSettings.json
|
||||
compile_commands.json
|
||||
.clangd
|
||||
packages
|
||||
pkg_out
|
||||
pkg
|
||||
CMakeUserPresets.json
|
||||
bld.rippled/
|
||||
.vscode
|
||||
|
||||
# AI tools.
|
||||
.augment
|
||||
# Suggested in-tree build directory
|
||||
/.build*/
|
||||
|
||||
1
BUILD.md
1
BUILD.md
@@ -144,6 +144,7 @@ git fetch origin master
|
||||
git checkout master
|
||||
conan export --version 1.1.10 recipes/snappy/all
|
||||
conan export --version 4.0.3 recipes/soci/all
|
||||
conan export --version 0.42.1 external/wasmi
|
||||
rm -rf .git
|
||||
```
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ endif()
|
||||
|
||||
find_package(nudb REQUIRED)
|
||||
find_package(date REQUIRED)
|
||||
find_package(wasmi REQUIRED)
|
||||
find_package(xxHash REQUIRED)
|
||||
|
||||
target_link_libraries(xrpl_libs INTERFACE
|
||||
|
||||
@@ -63,11 +63,17 @@ target_link_libraries(xrpl.imports.main
|
||||
Xrpl::opts
|
||||
Xrpl::syslibs
|
||||
secp256k1::secp256k1
|
||||
wasmi::wasmi
|
||||
xrpl.libpb
|
||||
xxHash::xxhash
|
||||
$<$<BOOL:${voidstar}>:antithesis-sdk-cpp>
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(xrpl.imports.main INTERFACE ntdll)
|
||||
endif()
|
||||
|
||||
|
||||
include(add_module)
|
||||
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
|
||||
import re
|
||||
|
||||
|
||||
class Xrpl(ConanFile):
|
||||
name = 'xrpl'
|
||||
|
||||
@@ -29,6 +30,7 @@ class Xrpl(ConanFile):
|
||||
'nudb/2.0.9',
|
||||
'openssl/3.5.4',
|
||||
'soci/4.0.3',
|
||||
'wasmi/0.42.1',
|
||||
'zlib/1.3.1',
|
||||
]
|
||||
|
||||
@@ -133,6 +135,7 @@ class Xrpl(ConanFile):
|
||||
self.folders.generators = 'build/generators'
|
||||
|
||||
generators = 'CMakeDeps'
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.variables['tests'] = self.options.tests
|
||||
@@ -190,6 +193,7 @@ class Xrpl(ConanFile):
|
||||
'protobuf::libprotobuf',
|
||||
'soci::soci',
|
||||
'sqlite3::sqlite',
|
||||
'wasmi::wasmi',
|
||||
'xxhash::xxhash',
|
||||
'zlib::zlib',
|
||||
]
|
||||
|
||||
3
docs/.gitignore
vendored
Normal file
3
docs/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
html
|
||||
temp
|
||||
out.txt
|
||||
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), |()| {})
|
||||
+}
|
||||
+
|
||||
@@ -62,6 +62,7 @@ XRPL_FIX (UniversalNumber, Supported::yes, VoteBehavior::DefaultNo
|
||||
XRPL_FEATURE(XRPFees, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(DisallowIncoming, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::yes, VoteBehavior::DefaultYes)
|
||||
XRPL_FIX (TrustLinesToSelf, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(ExpandedSignerList, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(CheckCashMakesTrustLine, Supported::yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(FlowSortStrands, Supported::yes, VoteBehavior::DefaultYes)
|
||||
@@ -118,7 +119,6 @@ XRPL_RETIRE(fixReducedOffersV1)
|
||||
XRPL_RETIRE(fixRmSmallIncreasedQOffers)
|
||||
XRPL_RETIRE(fixSTAmountCanonicalize)
|
||||
XRPL_RETIRE(fixTakerDryOfferRemoval)
|
||||
XRPL_RETIRE(fixTrustLinesToSelf)
|
||||
XRPL_RETIRE(CryptoConditions)
|
||||
XRPL_RETIRE(Escrow)
|
||||
XRPL_RETIRE(EnforceInvariants)
|
||||
|
||||
@@ -121,8 +121,7 @@ class Feature_test : public beast::unit_test::suite
|
||||
// Test a random sampling of the variables. If any of these get retired
|
||||
// or removed, swap out for any other feature.
|
||||
BEAST_EXPECT(
|
||||
featureToName(fixRemoveNFTokenAutoTrustLine) ==
|
||||
"fixRemoveNFTokenAutoTrustLine");
|
||||
featureToName(fixTrustLinesToSelf) == "fixTrustLinesToSelf");
|
||||
BEAST_EXPECT(featureToName(featureFlow) == "Flow");
|
||||
BEAST_EXPECT(featureToName(featureNegativeUNL) == "NegativeUNL");
|
||||
BEAST_EXPECT(
|
||||
|
||||
@@ -147,6 +147,88 @@ Change::preCompute()
|
||||
account_ == beast::zero, "ripple::Change::preCompute : zero account");
|
||||
}
|
||||
|
||||
void
|
||||
Change::activateTrustLinesToSelfFix()
|
||||
{
|
||||
JLOG(j_.warn()) << "fixTrustLinesToSelf amendment activation code starting";
|
||||
|
||||
auto removeTrustLineToSelf = [this](Sandbox& sb, uint256 id) {
|
||||
auto tl = sb.peek(keylet::child(id));
|
||||
|
||||
if (tl == nullptr)
|
||||
{
|
||||
JLOG(j_.warn()) << id << ": Unable to locate trustline";
|
||||
return true;
|
||||
}
|
||||
|
||||
if (tl->getType() != ltRIPPLE_STATE)
|
||||
{
|
||||
JLOG(j_.warn()) << id << ": Unexpected type "
|
||||
<< static_cast<std::uint16_t>(tl->getType());
|
||||
return true;
|
||||
}
|
||||
|
||||
auto const& lo = tl->getFieldAmount(sfLowLimit);
|
||||
auto const& hi = tl->getFieldAmount(sfHighLimit);
|
||||
|
||||
if (lo != hi)
|
||||
{
|
||||
JLOG(j_.warn()) << id << ": Trustline doesn't meet requirements";
|
||||
return true;
|
||||
}
|
||||
|
||||
if (auto const page = tl->getFieldU64(sfLowNode); !sb.dirRemove(
|
||||
keylet::ownerDir(lo.getIssuer()), page, tl->key(), false))
|
||||
{
|
||||
JLOG(j_.error()) << id << ": failed to remove low entry from "
|
||||
<< toBase58(lo.getIssuer()) << ":" << page
|
||||
<< " owner directory";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto const page = tl->getFieldU64(sfHighNode); !sb.dirRemove(
|
||||
keylet::ownerDir(hi.getIssuer()), page, tl->key(), false))
|
||||
{
|
||||
JLOG(j_.error()) << id << ": failed to remove high entry from "
|
||||
<< toBase58(hi.getIssuer()) << ":" << page
|
||||
<< " owner directory";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tl->getFlags() & lsfLowReserve)
|
||||
adjustOwnerCount(
|
||||
sb, sb.peek(keylet::account(lo.getIssuer())), -1, j_);
|
||||
|
||||
if (tl->getFlags() & lsfHighReserve)
|
||||
adjustOwnerCount(
|
||||
sb, sb.peek(keylet::account(hi.getIssuer())), -1, j_);
|
||||
|
||||
sb.erase(tl);
|
||||
|
||||
JLOG(j_.warn()) << "Successfully deleted trustline " << id;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
Sandbox sb(&view());
|
||||
|
||||
if (removeTrustLineToSelf(
|
||||
sb,
|
||||
uint256{
|
||||
"2F8F21EFCAFD7ACFB07D5BB04F0D2E18587820C7611305BB674A64EAB0FA71E1"sv}) &&
|
||||
removeTrustLineToSelf(
|
||||
sb,
|
||||
uint256{
|
||||
"326035D5C0560A9DA8636545DD5A1B0DFCFF63E68D491B5522B767BB00564B1A"sv}))
|
||||
{
|
||||
JLOG(j_.warn()) << "fixTrustLinesToSelf amendment activation code "
|
||||
"executed successfully";
|
||||
sb.apply(ctx_.rawView());
|
||||
}
|
||||
}
|
||||
|
||||
TER
|
||||
Change::applyAmendment()
|
||||
{
|
||||
@@ -223,6 +305,9 @@ Change::applyAmendment()
|
||||
amendments.push_back(amendment);
|
||||
amendmentObject->setFieldV256(sfAmendments, amendments);
|
||||
|
||||
if (amendment == fixTrustLinesToSelf)
|
||||
activateTrustLinesToSelfFix();
|
||||
|
||||
ctx_.app.getAmendmentTable().enable(amendment);
|
||||
|
||||
if (!ctx_.app.getAmendmentTable().isSupported(amendment))
|
||||
|
||||
@@ -29,6 +29,9 @@ public:
|
||||
preclaim(PreclaimContext const& ctx);
|
||||
|
||||
private:
|
||||
void
|
||||
activateTrustLinesToSelfFix();
|
||||
|
||||
TER
|
||||
applyAmendment();
|
||||
|
||||
|
||||
@@ -195,8 +195,29 @@ SetTrust::preclaim(PreclaimContext const& ctx)
|
||||
auto const currency = saLimitAmount.getCurrency();
|
||||
auto const uDstAccountID = saLimitAmount.getIssuer();
|
||||
|
||||
if (id == uDstAccountID)
|
||||
return temDST_IS_SRC;
|
||||
if (ctx.view.rules().enabled(fixTrustLinesToSelf))
|
||||
{
|
||||
if (id == uDstAccountID)
|
||||
return temDST_IS_SRC;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (id == uDstAccountID)
|
||||
{
|
||||
// Prevent trustline to self from being created,
|
||||
// unless one has somehow already been created
|
||||
// (in which case doApply will clean it up).
|
||||
auto const sleDelete =
|
||||
ctx.view.read(keylet::line(id, uDstAccountID, currency));
|
||||
|
||||
if (!sleDelete)
|
||||
{
|
||||
JLOG(ctx.j.trace())
|
||||
<< "Malformed transaction: Can not extend credit to self.";
|
||||
return temDST_IS_SRC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This might be nullptr
|
||||
auto const sleDst = ctx.view.read(keylet::account(uDstAccountID));
|
||||
@@ -382,6 +403,21 @@ SetTrust::doApply()
|
||||
|
||||
auto viewJ = ctx_.app.journal("View");
|
||||
|
||||
// Trust lines to self are impossible but because of the old bug there
|
||||
// are two on 19-02-2022. This code was here to allow those trust lines
|
||||
// to be deleted. The fixTrustLinesToSelf fix amendment will remove them
|
||||
// when it enables so this code will no longer be needed.
|
||||
if (!view().rules().enabled(fixTrustLinesToSelf) &&
|
||||
account_ == uDstAccountID)
|
||||
{
|
||||
return trustDelete(
|
||||
view(),
|
||||
view().peek(keylet::line(account_, uDstAccountID, currency)),
|
||||
account_,
|
||||
uDstAccountID,
|
||||
viewJ);
|
||||
}
|
||||
|
||||
SLE::pointer sleDst = view().peek(keylet::account(uDstAccountID));
|
||||
|
||||
if (!sleDst)
|
||||
|
||||
Reference in New Issue
Block a user