mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-11 12:46:44 +00:00
Compare commits
44 Commits
develop
...
tapanito/l
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64c7ff9972 | ||
|
|
189f2d60bd | ||
|
|
b921570a0f | ||
|
|
3c41d29904 | ||
|
|
beb8a1872d | ||
|
|
24db40e56c | ||
|
|
da4513d096 | ||
|
|
2e2fddefe9 | ||
|
|
db997ecad9 | ||
|
|
5c414eb396 | ||
|
|
929d15b380 | ||
|
|
20d6e93b57 | ||
|
|
73fe6e113a | ||
|
|
df1a55d11a | ||
|
|
3314c21542 | ||
|
|
23eee6192f | ||
|
|
68e4fbdf2b | ||
|
|
bb0a09ae21 | ||
|
|
d94232007f | ||
|
|
df8bfbe5af | ||
|
|
347d1a19ef | ||
|
|
d65fab27a1 | ||
|
|
b5d25c5ab1 | ||
|
|
7222150095 | ||
|
|
a67da5c2ed | ||
|
|
d2f23b2f5b | ||
|
|
4067e5025f | ||
|
|
ed4330a7d6 | ||
|
|
feba605998 | ||
|
|
b322097529 | ||
|
|
e159d27373 | ||
|
|
ba53026006 | ||
|
|
34773080df | ||
|
|
3c3bd75991 | ||
|
|
7459fe454d | ||
|
|
106bf48725 | ||
|
|
74c968d4e3 | ||
|
|
167147281c | ||
|
|
ba60306610 | ||
|
|
6674500896 | ||
|
|
c5d7ebe93d | ||
|
|
d0b5ca9dab | ||
|
|
5e51893e9b | ||
|
|
3422c11d02 |
@@ -153,7 +153,7 @@ Checks: "-*,
|
||||
readability-use-std-min-max
|
||||
"
|
||||
# ---
|
||||
# readability-inconsistent-declaration-parameter-name, # In this codebase this check will break a lot of arg names
|
||||
# readability-inconsistent-declaration-parameter-name, # in this codebase this check will break a lot of arg names
|
||||
# readability-static-accessed-through-instance, # this check is probably unnecessary. It makes the code less readable
|
||||
# ---
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
libxrpl.basics > xrpl.basics
|
||||
libxrpl.conditions > xrpl.basics
|
||||
libxrpl.conditions > xrpl.conditions
|
||||
libxrpl.config > xrpl.basics
|
||||
libxrpl.config > xrpl.config
|
||||
libxrpl.core > xrpl.basics
|
||||
libxrpl.core > xrpl.core
|
||||
libxrpl.core > xrpl.json
|
||||
@@ -19,7 +17,6 @@ libxrpl.ledger > xrpl.shamap
|
||||
libxrpl.net > xrpl.basics
|
||||
libxrpl.net > xrpl.net
|
||||
libxrpl.nodestore > xrpl.basics
|
||||
libxrpl.nodestore > xrpl.config
|
||||
libxrpl.nodestore > xrpl.json
|
||||
libxrpl.nodestore > xrpl.nodestore
|
||||
libxrpl.nodestore > xrpl.protocol
|
||||
@@ -27,7 +24,6 @@ libxrpl.protocol > xrpl.basics
|
||||
libxrpl.protocol > xrpl.json
|
||||
libxrpl.protocol > xrpl.protocol
|
||||
libxrpl.rdb > xrpl.basics
|
||||
libxrpl.rdb > xrpl.config
|
||||
libxrpl.rdb > xrpl.core
|
||||
libxrpl.rdb > xrpl.rdb
|
||||
libxrpl.resource > xrpl.basics
|
||||
@@ -35,7 +31,6 @@ libxrpl.resource > xrpl.json
|
||||
libxrpl.resource > xrpl.protocol
|
||||
libxrpl.resource > xrpl.resource
|
||||
libxrpl.server > xrpl.basics
|
||||
libxrpl.server > xrpl.config
|
||||
libxrpl.server > xrpl.core
|
||||
libxrpl.server > xrpl.json
|
||||
libxrpl.server > xrpl.protocol
|
||||
@@ -57,7 +52,6 @@ libxrpl.tx > xrpl.tx
|
||||
test.app > test.jtx
|
||||
test.app > test.unit_test
|
||||
test.app > xrpl.basics
|
||||
test.app > xrpl.config
|
||||
test.app > xrpl.core
|
||||
test.app > xrpld.app
|
||||
test.app > xrpld.consensus
|
||||
@@ -96,7 +90,6 @@ test.consensus > xrpl.tx
|
||||
test.core > test.jtx
|
||||
test.core > test.unit_test
|
||||
test.core > xrpl.basics
|
||||
test.core > xrpl.config
|
||||
test.core > xrpl.core
|
||||
test.core > xrpld.core
|
||||
test.core > xrpl.json
|
||||
@@ -111,7 +104,6 @@ test.csf > xrpl.protocol
|
||||
test.json > test.jtx
|
||||
test.json > xrpl.json
|
||||
test.jtx > xrpl.basics
|
||||
test.jtx > xrpl.config
|
||||
test.jtx > xrpl.core
|
||||
test.jtx > xrpld.app
|
||||
test.jtx > xrpld.core
|
||||
@@ -134,7 +126,6 @@ test.ledger > xrpl.protocol
|
||||
test.nodestore > test.jtx
|
||||
test.nodestore > test.unit_test
|
||||
test.nodestore > xrpl.basics
|
||||
test.nodestore > xrpl.config
|
||||
test.nodestore > xrpld.core
|
||||
test.nodestore > xrpl.nodestore
|
||||
test.nodestore > xrpl.protocol
|
||||
@@ -142,7 +133,6 @@ test.nodestore > xrpl.rdb
|
||||
test.overlay > test.jtx
|
||||
test.overlay > test.unit_test
|
||||
test.overlay > xrpl.basics
|
||||
test.overlay > xrpl.config
|
||||
test.overlay > xrpld.app
|
||||
test.overlay > xrpld.core
|
||||
test.overlay > xrpld.overlay
|
||||
@@ -169,7 +159,6 @@ test.resource > xrpl.basics
|
||||
test.resource > xrpl.resource
|
||||
test.rpc > test.jtx
|
||||
test.rpc > xrpl.basics
|
||||
test.rpc > xrpl.config
|
||||
test.rpc > xrpl.core
|
||||
test.rpc > xrpld.app
|
||||
test.rpc > xrpld.core
|
||||
@@ -184,7 +173,6 @@ test.rpc > xrpl.tx
|
||||
test.server > test.jtx
|
||||
test.server > test.unit_test
|
||||
test.server > xrpl.basics
|
||||
test.server > xrpl.config
|
||||
test.server > xrpld.app
|
||||
test.server > xrpld.core
|
||||
test.server > xrpl.json
|
||||
@@ -192,7 +180,6 @@ test.server > xrpl.protocol
|
||||
test.server > xrpl.server
|
||||
test.shamap > test.unit_test
|
||||
test.shamap > xrpl.basics
|
||||
test.shamap > xrpl.config
|
||||
test.shamap > xrpl.nodestore
|
||||
test.shamap > xrpl.protocol
|
||||
test.shamap > xrpl.shamap
|
||||
@@ -201,7 +188,6 @@ test.toplevel > xrpl.json
|
||||
test.unit_test > xrpl.basics
|
||||
test.unit_test > xrpl.protocol
|
||||
tests.libxrpl > xrpl.basics
|
||||
tests.libxrpl > xrpl.config
|
||||
tests.libxrpl > xrpl.core
|
||||
tests.libxrpl > xrpl.json
|
||||
tests.libxrpl > xrpl.ledger
|
||||
@@ -214,7 +200,6 @@ tests.libxrpl > xrpl.shamap
|
||||
tests.libxrpl > xrpl.tx
|
||||
xrpl.conditions > xrpl.basics
|
||||
xrpl.conditions > xrpl.protocol
|
||||
xrpl.config > xrpl.basics
|
||||
xrpl.core > xrpl.basics
|
||||
xrpl.core > xrpl.json
|
||||
xrpl.core > xrpl.protocol
|
||||
@@ -225,7 +210,6 @@ xrpl.ledger > xrpl.server
|
||||
xrpl.ledger > xrpl.shamap
|
||||
xrpl.net > xrpl.basics
|
||||
xrpl.nodestore > xrpl.basics
|
||||
xrpl.nodestore > xrpl.config
|
||||
xrpl.nodestore > xrpl.protocol
|
||||
xrpl.protocol > xrpl.basics
|
||||
xrpl.protocol > xrpl.json
|
||||
@@ -253,7 +237,6 @@ xrpl.tx > xrpl.ledger
|
||||
xrpl.tx > xrpl.protocol
|
||||
xrpld.app > test.unit_test
|
||||
xrpld.app > xrpl.basics
|
||||
xrpld.app > xrpl.config
|
||||
xrpld.app > xrpl.core
|
||||
xrpld.app > xrpld.consensus
|
||||
xrpld.app > xrpld.core
|
||||
@@ -272,13 +255,11 @@ xrpld.consensus > xrpl.json
|
||||
xrpld.consensus > xrpl.ledger
|
||||
xrpld.consensus > xrpl.protocol
|
||||
xrpld.core > xrpl.basics
|
||||
xrpld.core > xrpl.config
|
||||
xrpld.core > xrpl.core
|
||||
xrpld.core > xrpl.net
|
||||
xrpld.core > xrpl.protocol
|
||||
xrpld.core > xrpl.rdb
|
||||
xrpld.overlay > xrpl.basics
|
||||
xrpld.overlay > xrpl.config
|
||||
xrpld.overlay > xrpl.core
|
||||
xrpld.overlay > xrpld.consensus
|
||||
xrpld.overlay > xrpld.core
|
||||
@@ -291,18 +272,15 @@ xrpld.overlay > xrpl.server
|
||||
xrpld.overlay > xrpl.shamap
|
||||
xrpld.overlay > xrpl.tx
|
||||
xrpld.peerfinder > xrpl.basics
|
||||
xrpld.peerfinder > xrpl.config
|
||||
xrpld.peerfinder > xrpld.core
|
||||
xrpld.peerfinder > xrpl.protocol
|
||||
xrpld.peerfinder > xrpl.rdb
|
||||
xrpld.perflog > xrpl.basics
|
||||
xrpld.perflog > xrpl.config
|
||||
xrpld.perflog > xrpl.core
|
||||
xrpld.perflog > xrpld.rpc
|
||||
xrpld.perflog > xrpl.json
|
||||
xrpld.perflog > xrpl.protocol
|
||||
xrpld.rpc > xrpl.basics
|
||||
xrpld.rpc > xrpl.config
|
||||
xrpld.rpc > xrpl.core
|
||||
xrpld.rpc > xrpld.core
|
||||
xrpld.rpc > xrpl.json
|
||||
|
||||
57
.github/scripts/strategy-matrix/generate.py
vendored
57
.github/scripts/strategy-matrix/generate.py
vendored
@@ -27,19 +27,6 @@ def get_cmake_args(build_type: str, extra_args: str) -> str:
|
||||
return " ".join(args)
|
||||
|
||||
|
||||
def runs_on_event(exclude_event_types: list[str], event: str | None) -> bool:
|
||||
"""Whether a config should run for the current event.
|
||||
|
||||
'exclude_event_types' is a list of GitHub event names (e.g.
|
||||
["pull_request"]) on which the config should NOT run; an empty list means
|
||||
the config runs on every event. When no event is given (event is None), no
|
||||
filtering is applied.
|
||||
"""
|
||||
if event is None:
|
||||
return True
|
||||
return event not in exclude_event_types
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Input types — shapes of the JSON config files
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -56,9 +43,6 @@ class LinuxConfig:
|
||||
suffix: str = ""
|
||||
extra_cmake_args: str = ""
|
||||
image: str = "" # only used by package_configs entries
|
||||
# List of GitHub event names (e.g. "pull_request") on which this config
|
||||
# should NOT run. Empty means it runs on every event.
|
||||
exclude_event_types: list[str] = dataclasses.field(default_factory=list)
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
@@ -93,9 +77,6 @@ class PlatformConfig:
|
||||
build_type: list[str]
|
||||
build_only: bool = False # if true, skip tests (e.g. macos/Windows Debug)
|
||||
extra_cmake_args: str = ""
|
||||
# List of GitHub event names (e.g. "pull_request") on which this config
|
||||
# should NOT run. Empty means it runs on every event.
|
||||
exclude_event_types: list[str] = dataclasses.field(default_factory=list)
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
if isinstance(self.build_type, str):
|
||||
@@ -170,21 +151,16 @@ _ARCHS: dict[str, Architecture] = {
|
||||
}
|
||||
|
||||
|
||||
def expand_linux_matrix(
|
||||
linux: LinuxFile, event: str | None = None
|
||||
) -> list[MatrixEntry]:
|
||||
def expand_linux_matrix(linux: LinuxFile) -> list[MatrixEntry]:
|
||||
"""Expand a LinuxFile into a flat list of matrix entries.
|
||||
|
||||
Each config entry is expanded over the cross-product of its
|
||||
compiler, build_type, sanitizers, and architecture lists. Configs that
|
||||
exclude the current event are skipped.
|
||||
compiler, build_type, sanitizers, and architecture lists.
|
||||
"""
|
||||
entries: list[MatrixEntry] = []
|
||||
|
||||
for distro, configs in linux.configs.items():
|
||||
for cfg in configs:
|
||||
if not runs_on_event(cfg.exclude_event_types, event):
|
||||
continue
|
||||
# An empty sanitizers list means "one entry with no sanitizer".
|
||||
effective_sanitizers = cfg.sanitizers or [""]
|
||||
effective_archs = {arch: _ARCHS[arch] for arch in cfg.arch}
|
||||
@@ -242,20 +218,13 @@ def expand_linux_packaging(linux: LinuxFile) -> list[PackagingEntry]:
|
||||
return entries
|
||||
|
||||
|
||||
def expand_platform_matrix(
|
||||
pf: PlatformFile, event: str | None = None
|
||||
) -> list[MatrixEntry]:
|
||||
"""Expand a PlatformFile (macOS or Windows) into matrix entries.
|
||||
|
||||
Configs that exclude the current event are skipped.
|
||||
"""
|
||||
def expand_platform_matrix(pf: PlatformFile) -> list[MatrixEntry]:
|
||||
"""Expand a PlatformFile (macOS or Windows) into matrix entries."""
|
||||
platform_name, arch = pf.platform.split("/")
|
||||
is_windows = platform_name == "windows"
|
||||
|
||||
entries: list[MatrixEntry] = []
|
||||
for cfg in pf.configs:
|
||||
if not runs_on_event(cfg.exclude_event_types, event):
|
||||
continue
|
||||
for build_type in cfg.build_type:
|
||||
entries.append(
|
||||
MatrixEntry(
|
||||
@@ -293,14 +262,6 @@ if __name__ == "__main__":
|
||||
help="Emit the Linux packaging matrix instead of the build/test matrix.",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-e",
|
||||
"--event",
|
||||
help="The GitHub event name that triggered the workflow (e.g. 'push', "
|
||||
"'pull_request'). Configs are filtered by their 'event_type'. If "
|
||||
"omitted, no filtering is applied.",
|
||||
default=None,
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
matrix: list[MatrixEntry] | list[PackagingEntry] = []
|
||||
@@ -309,16 +270,12 @@ if __name__ == "__main__":
|
||||
matrix = expand_linux_packaging(LinuxFile.load(THIS_DIR / "linux.json"))
|
||||
else:
|
||||
if args.config in ("linux", None):
|
||||
matrix += expand_linux_matrix(
|
||||
LinuxFile.load(THIS_DIR / "linux.json"), args.event
|
||||
)
|
||||
matrix += expand_linux_matrix(LinuxFile.load(THIS_DIR / "linux.json"))
|
||||
if args.config in ("macos", None):
|
||||
matrix += expand_platform_matrix(
|
||||
PlatformFile.load(THIS_DIR / "macos.json"), args.event
|
||||
)
|
||||
matrix += expand_platform_matrix(PlatformFile.load(THIS_DIR / "macos.json"))
|
||||
if args.config in ("windows", None):
|
||||
matrix += expand_platform_matrix(
|
||||
PlatformFile.load(THIS_DIR / "windows.json"), args.event
|
||||
PlatformFile.load(THIS_DIR / "windows.json")
|
||||
)
|
||||
|
||||
print(f"matrix={json.dumps({'include': [dataclasses.asdict(e) for e in matrix]})}")
|
||||
|
||||
9
.github/scripts/strategy-matrix/linux.json
vendored
9
.github/scripts/strategy-matrix/linux.json
vendored
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"image_tag": "sha-63ffdc3",
|
||||
"image_tag": "sha-8abe82e",
|
||||
"configs": {
|
||||
"ubuntu": [
|
||||
{
|
||||
@@ -41,8 +41,7 @@
|
||||
"build_type": ["Debug"],
|
||||
"arch": ["amd64"],
|
||||
"suffix": "unity",
|
||||
"extra_cmake_args": "-Dunity=ON",
|
||||
"exclude_event_types": ["pull_request"]
|
||||
"extra_cmake_args": "-Dunity=ON"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -68,7 +67,7 @@
|
||||
"compiler": ["gcc"],
|
||||
"build_type": ["Release"],
|
||||
"arch": ["amd64"],
|
||||
"image": "ghcr.io/xrplf/xrpld/packaging-debian:sha-63ffdc3"
|
||||
"image": "debian:bookworm"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -77,7 +76,7 @@
|
||||
"compiler": ["gcc"],
|
||||
"build_type": ["Release"],
|
||||
"arch": ["amd64"],
|
||||
"image": "ghcr.io/xrplf/xrpld/packaging-rhel:sha-63ffdc3"
|
||||
"image": "registry.access.redhat.com/ubi9/ubi:latest"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
3
.github/scripts/strategy-matrix/macos.json
vendored
3
.github/scripts/strategy-matrix/macos.json
vendored
@@ -9,8 +9,7 @@
|
||||
{
|
||||
"build_type": "Debug",
|
||||
"extra_cmake_args": "-DCMAKE_POLICY_VERSION_MINIMUM=3.5",
|
||||
"build_only": true,
|
||||
"exclude_event_types": ["pull_request"]
|
||||
"build_only": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
6
.github/scripts/strategy-matrix/windows.json
vendored
6
.github/scripts/strategy-matrix/windows.json
vendored
@@ -3,10 +3,6 @@
|
||||
"runner": ["self-hosted", "Windows", "devbox"],
|
||||
"configs": [
|
||||
{ "build_type": "Release" },
|
||||
{
|
||||
"build_type": "Debug",
|
||||
"build_only": true,
|
||||
"exclude_event_types": ["pull_request"]
|
||||
}
|
||||
{ "build_type": "Debug", "build_only": true }
|
||||
]
|
||||
}
|
||||
|
||||
10
.github/workflows/build-nix-images.yml
vendored
10
.github/workflows/build-nix-images.yml
vendored
@@ -6,20 +6,23 @@ on:
|
||||
- develop
|
||||
paths:
|
||||
- ".github/workflows/build-nix-images.yml"
|
||||
- ".github/workflows/reusable-build-docker-image.yml"
|
||||
- ".github/workflows/reusable-build-merge-docker-images.yml"
|
||||
- "flake.nix"
|
||||
- "flake.lock"
|
||||
- "nix/**"
|
||||
pull_request:
|
||||
paths:
|
||||
- ".github/workflows/build-nix-images.yml"
|
||||
- ".github/workflows/reusable-build-docker-image.yml"
|
||||
- ".github/workflows/reusable-build-merge-docker-images.yml"
|
||||
- "flake.nix"
|
||||
- "flake.lock"
|
||||
- "nix/**"
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
# Read `on-trigger.yml` for the rationale behind this concurrency group name.
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' && github.sha || github.ref }}
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
defaults:
|
||||
@@ -46,9 +49,8 @@ jobs:
|
||||
base_image: debian:bookworm
|
||||
- name: rhel
|
||||
base_image: registry.access.redhat.com/ubi9/ubi:latest
|
||||
uses: XRPLF/actions/.github/workflows/build-multiarch-image.yml@c1b480188519e0cad040e6aa70db1cbc5a797e07
|
||||
uses: ./.github/workflows/reusable-build-merge-docker-images.yml
|
||||
with:
|
||||
image_name: ghcr.io/xrplf/xrpld/nix-${{ matrix.distro.name }}
|
||||
dockerfile: nix/docker/Dockerfile
|
||||
base_image: ${{ matrix.distro.base_image }}
|
||||
push: ${{ github.repository == 'XRPLF/rippled' && github.event_name == 'push' }}
|
||||
|
||||
10
.github/workflows/build-packaging-images.yml
vendored
10
.github/workflows/build-packaging-images.yml
vendored
@@ -6,18 +6,21 @@ on:
|
||||
- develop
|
||||
paths:
|
||||
- ".github/workflows/build-packaging-images.yml"
|
||||
- ".github/workflows/reusable-build-docker-image.yml"
|
||||
- ".github/workflows/reusable-build-merge-docker-images.yml"
|
||||
- "package/Dockerfile"
|
||||
- "package/install-packaging-tools.sh"
|
||||
pull_request:
|
||||
paths:
|
||||
- ".github/workflows/build-packaging-images.yml"
|
||||
- ".github/workflows/reusable-build-docker-image.yml"
|
||||
- ".github/workflows/reusable-build-merge-docker-images.yml"
|
||||
- "package/Dockerfile"
|
||||
- "package/install-packaging-tools.sh"
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
# Read `on-trigger.yml` for the rationale behind this concurrency group name.
|
||||
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' && github.sha || github.ref }}
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
defaults:
|
||||
@@ -38,9 +41,8 @@ jobs:
|
||||
base_image: debian:bookworm
|
||||
- name: rhel
|
||||
base_image: registry.access.redhat.com/ubi9/ubi:latest
|
||||
uses: XRPLF/actions/.github/workflows/build-multiarch-image.yml@c1b480188519e0cad040e6aa70db1cbc5a797e07
|
||||
uses: ./.github/workflows/reusable-build-merge-docker-images.yml
|
||||
with:
|
||||
image_name: ghcr.io/xrplf/xrpld/packaging-${{ matrix.distro.name }}
|
||||
dockerfile: package/Dockerfile
|
||||
base_image: ${{ matrix.distro.base_image }}
|
||||
push: ${{ github.repository == 'XRPLF/rippled' && github.event_name == 'push' }}
|
||||
|
||||
2
.github/workflows/pre-commit.yml
vendored
2
.github/workflows/pre-commit.yml
vendored
@@ -14,7 +14,7 @@ on:
|
||||
jobs:
|
||||
# Call the workflow in the XRPLF/actions repo that runs the pre-commit hooks.
|
||||
run-hooks:
|
||||
uses: XRPLF/actions/.github/workflows/pre-commit.yml@312aaab296060ff89d7f798dcab59f019bea6e02
|
||||
uses: XRPLF/actions/.github/workflows/pre-commit.yml@cba1f0891650baf1a9c88624dc2d72573be2eb81
|
||||
with:
|
||||
runs_on: ubuntu-latest
|
||||
container: '{ "image": "ghcr.io/xrplf/ci/tools-rippled-pre-commit:sha-41ec7c1" }'
|
||||
|
||||
4
.github/workflows/publish-docs.yml
vendored
4
.github/workflows/publish-docs.yml
vendored
@@ -41,13 +41,13 @@ env:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/xrplf/xrpld/nix-ubuntu:sha-63ffdc3
|
||||
container: ghcr.io/xrplf/xrpld/nix-ubuntu:sha-8abe82e
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
|
||||
- name: Prepare runner
|
||||
uses: XRPLF/actions/prepare-runner@c47daebb2f9db64ffbac71b47d68a661498d5ce8
|
||||
uses: XRPLF/actions/prepare-runner@90f11ee655d1687824fb8793db770477d52afbab
|
||||
with:
|
||||
enable_ccache: false
|
||||
|
||||
|
||||
89
.github/workflows/reusable-build-docker-image.yml
vendored
Normal file
89
.github/workflows/reusable-build-docker-image.yml
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
# Build a single-platform Docker image. On push, the image is pushed to
|
||||
# GHCR with arch-suffixed tags (e.g. `:latest-amd64`, `:sha-abc-amd64`)
|
||||
# so the calling workflow can stitch per-arch builds into a multi-arch
|
||||
# manifest without needing to pass digests around.
|
||||
name: Reusable build Docker image (single platform)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
image_name:
|
||||
description: "Full image name without tag (e.g. 'ghcr.io/xrplf/xrpld/nix-ubuntu')"
|
||||
required: true
|
||||
type: string
|
||||
dockerfile:
|
||||
description: "Path to the Dockerfile, relative to the repository root"
|
||||
required: true
|
||||
type: string
|
||||
base_image:
|
||||
description: "Value passed to the Dockerfile as the BASE_IMAGE build arg"
|
||||
required: true
|
||||
type: string
|
||||
platform:
|
||||
description: "Docker platform string, e.g. linux/amd64"
|
||||
required: true
|
||||
type: string
|
||||
runner:
|
||||
description: "GitHub Actions runner label to build on"
|
||||
required: true
|
||||
type: string
|
||||
push:
|
||||
description: "Whether to push the image to GHCR"
|
||||
required: true
|
||||
type: boolean
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build ${{ inputs.platform }}
|
||||
runs-on: ${{ inputs.runner }}
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
|
||||
- name: Determine arch
|
||||
id: vars
|
||||
env:
|
||||
PLATFORM: ${{ inputs.platform }}
|
||||
run: |
|
||||
echo "arch=${PLATFORM##*/}" >>$GITHUB_OUTPUT
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
if: inputs.push
|
||||
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
|
||||
with:
|
||||
images: ${{ inputs.image_name }}
|
||||
tags: |
|
||||
type=sha,prefix=sha-,format=short
|
||||
type=raw,value=latest
|
||||
flavor: |
|
||||
suffix=-${{ steps.vars.outputs.arch }},onlatest=true
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
|
||||
with:
|
||||
context: .
|
||||
file: ${{ inputs.dockerfile }}
|
||||
platforms: ${{ inputs.platform }}
|
||||
push: ${{ inputs.push }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: BASE_IMAGE=${{ inputs.base_image }}
|
||||
89
.github/workflows/reusable-build-merge-docker-images.yml
vendored
Normal file
89
.github/workflows/reusable-build-merge-docker-images.yml
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
name: Reusable build and merge Docker image (multi-arch)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
image_name:
|
||||
description: "Full image name without tag (e.g. 'ghcr.io/xrplf/xrpld/nix-ubuntu')"
|
||||
required: true
|
||||
type: string
|
||||
dockerfile:
|
||||
description: "Path to the Dockerfile, relative to the repository root"
|
||||
required: true
|
||||
type: string
|
||||
base_image:
|
||||
description: "Value passed to the Dockerfile as the BASE_IMAGE build arg"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build ${{ inputs.image_name }}
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
- platform: linux/amd64
|
||||
runner: ubuntu-latest
|
||||
- platform: linux/arm64
|
||||
runner: ubuntu-24.04-arm
|
||||
|
||||
uses: ./.github/workflows/reusable-build-docker-image.yml
|
||||
with:
|
||||
image_name: ${{ inputs.image_name }}
|
||||
dockerfile: ${{ inputs.dockerfile }}
|
||||
base_image: ${{ inputs.base_image }}
|
||||
platform: ${{ matrix.target.platform }}
|
||||
runner: ${{ matrix.target.runner }}
|
||||
push: ${{ github.repository == 'XRPLF/rippled' && github.event_name == 'push' }}
|
||||
|
||||
merge:
|
||||
name: Merge ${{ inputs.image_name }}
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
|
||||
|
||||
- name: Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
|
||||
with:
|
||||
images: ${{ inputs.image_name }}
|
||||
tags: |
|
||||
type=sha,prefix=sha-,format=short
|
||||
type=raw,value=latest
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Create multi-arch manifests
|
||||
if: ${{ github.repository == 'XRPLF/rippled' && github.event_name == 'push' }}
|
||||
run: |
|
||||
for tag in $(jq -cr '.tags[]' <<<"$DOCKER_METADATA_OUTPUT_JSON"); do
|
||||
docker buildx imagetools create -t "$tag" "${tag}-amd64" "${tag}-arm64"
|
||||
done
|
||||
|
||||
- name: Inspect image
|
||||
if: ${{ github.repository == 'XRPLF/rippled' && github.event_name == 'push' }}
|
||||
env:
|
||||
IMAGE_NAME: ${{ inputs.image_name }}
|
||||
IMAGE_VERSION: ${{ steps.meta.outputs.version }}
|
||||
run: |
|
||||
docker buildx imagetools inspect "${IMAGE_NAME}:${IMAGE_VERSION}"
|
||||
@@ -82,7 +82,7 @@ jobs:
|
||||
name: ${{ inputs.config_name }}
|
||||
runs-on: ${{ fromJSON(inputs.runs_on) }}
|
||||
container: ${{ inputs.image != '' && inputs.image || null }}
|
||||
timeout-minutes: ${{ inputs.sanitizers != '' && 360 || 90 }}
|
||||
timeout-minutes: ${{ inputs.sanitizers != '' && 360 || 60 }}
|
||||
env:
|
||||
# Use a namespace to keep the objects separate for each configuration.
|
||||
CCACHE_NAMESPACE: ${{ inputs.config_name }}
|
||||
@@ -113,7 +113,7 @@ jobs:
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
|
||||
- name: Prepare runner
|
||||
uses: XRPLF/actions/prepare-runner@c47daebb2f9db64ffbac71b47d68a661498d5ce8
|
||||
uses: XRPLF/actions/prepare-runner@90f11ee655d1687824fb8793db770477d52afbab
|
||||
with:
|
||||
enable_ccache: ${{ inputs.ccache_enabled }}
|
||||
|
||||
|
||||
6
.github/workflows/reusable-clang-tidy.yml
vendored
6
.github/workflows/reusable-clang-tidy.yml
vendored
@@ -29,14 +29,14 @@ jobs:
|
||||
if: ${{ inputs.check_only_changed }}
|
||||
permissions:
|
||||
contents: read
|
||||
uses: XRPLF/actions/.github/workflows/determine-tidy-files.yml@312aaab296060ff89d7f798dcab59f019bea6e02
|
||||
uses: XRPLF/actions/.github/workflows/determine-tidy-files.yml@224f3c48d3014d082a1129237b8291ff0b0a331f
|
||||
|
||||
run-clang-tidy:
|
||||
name: Run clang tidy
|
||||
needs: [determine-files]
|
||||
if: ${{ always() && !cancelled() && (!inputs.check_only_changed || needs.determine-files.outputs.cpp_changed_files != '' || needs.determine-files.outputs.clang_tidy_config_changed == 'true') }}
|
||||
runs-on: ["self-hosted", "Linux", "X64", "heavy"]
|
||||
container: "ghcr.io/xrplf/xrpld/nix-debian:sha-63ffdc3"
|
||||
container: "ghcr.io/xrplf/xrpld/nix-debian:sha-8abe82e"
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
|
||||
- name: Prepare runner
|
||||
uses: XRPLF/actions/prepare-runner@c47daebb2f9db64ffbac71b47d68a661498d5ce8
|
||||
uses: XRPLF/actions/prepare-runner@90f11ee655d1687824fb8793db770477d52afbab
|
||||
with:
|
||||
enable_ccache: false
|
||||
|
||||
|
||||
25
.github/workflows/reusable-package.yml
vendored
25
.github/workflows/reusable-package.yml
vendored
@@ -68,6 +68,31 @@ jobs:
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
# Packaging runs in a vanilla distro image, so the tooling has to come
|
||||
# from the distro's archive: debhelper for deb, rpm-build (and the
|
||||
# systemd / find-debuginfo macros it depends on) for rpm. Run this
|
||||
# before actions/checkout so the latter can use git (real history) for
|
||||
# build_pkg.sh's SOURCE_DATE_EPOCH; otherwise it falls back to a tarball
|
||||
# download and the timestamp comes from wall-clock time.
|
||||
- name: Install packaging tooling (deb)
|
||||
if: ${{ matrix.distro == 'debian' }}
|
||||
run: |
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
debhelper \
|
||||
git
|
||||
|
||||
- name: Install packaging tooling (rpm)
|
||||
if: ${{ matrix.distro == 'rhel' }}
|
||||
run: |
|
||||
dnf install -y --setopt=install_weak_deps=False \
|
||||
git \
|
||||
rpm-build \
|
||||
redhat-rpm-config \
|
||||
systemd-rpm-macros
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
|
||||
|
||||
@@ -35,5 +35,4 @@ jobs:
|
||||
id: generate
|
||||
env:
|
||||
GENERATE_CONFIG: ${{ inputs.os != '' && format('--config={0}', inputs.os) || '' }}
|
||||
GENERATE_EVENT: ${{ github.event_name }}
|
||||
run: ./generate.py ${GENERATE_CONFIG} --event="${GENERATE_EVENT}" >>"${GITHUB_OUTPUT}"
|
||||
run: ./generate.py ${GENERATE_CONFIG} >>"${GITHUB_OUTPUT}"
|
||||
|
||||
2
.github/workflows/reusable-upload-recipe.yml
vendored
2
.github/workflows/reusable-upload-recipe.yml
vendored
@@ -40,7 +40,7 @@ defaults:
|
||||
jobs:
|
||||
upload:
|
||||
runs-on: ubuntu-latest
|
||||
container: ghcr.io/xrplf/xrpld/nix-ubuntu:sha-63ffdc3
|
||||
container: ghcr.io/xrplf/xrpld/nix-ubuntu:sha-8abe82e
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
|
||||
3
.github/workflows/upload-conan-deps.yml
vendored
3
.github/workflows/upload-conan-deps.yml
vendored
@@ -30,7 +30,6 @@ on:
|
||||
- ".github/scripts/strategy-matrix/**"
|
||||
- conanfile.py
|
||||
- conan.lock
|
||||
- conan/profiles/**
|
||||
|
||||
env:
|
||||
CONAN_REMOTE_NAME: xrplf
|
||||
@@ -68,7 +67,7 @@ jobs:
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
|
||||
- name: Prepare runner
|
||||
uses: XRPLF/actions/prepare-runner@c47daebb2f9db64ffbac71b47d68a661498d5ce8
|
||||
uses: XRPLF/actions/prepare-runner@90f11ee655d1687824fb8793db770477d52afbab
|
||||
with:
|
||||
enable_ccache: false
|
||||
|
||||
|
||||
14
BUILD.md
14
BUILD.md
@@ -45,14 +45,14 @@ found here](./docs/build/environment.md).
|
||||
It is possible to build with Conan 1.60+, but the instructions are
|
||||
significantly different, which is why we are not recommending it.
|
||||
|
||||
`xrpld` is written in the C++23 dialect and includes the `<concepts>` header.
|
||||
The [tested compiler versions][2] are:
|
||||
`xrpld` is written in the C++20 dialect and includes the `<concepts>` header.
|
||||
The [minimum compiler versions][2] required are:
|
||||
|
||||
| Compiler | Version |
|
||||
| ----------- | --------- |
|
||||
| GCC | 15 |
|
||||
| Clang | 22 |
|
||||
| Apple Clang | 17 |
|
||||
| GCC | 12 |
|
||||
| Clang | 16 |
|
||||
| Apple Clang | 16 |
|
||||
| MSVC | 19.44[^3] |
|
||||
|
||||
### Linux
|
||||
@@ -232,11 +232,11 @@ name and then creating a new `default` profile for a different compiler.
|
||||
#### Select language
|
||||
|
||||
The default profile created by Conan will typically select different C++ dialect
|
||||
than C++23 used by this project. You should set `23` in the profile line
|
||||
than C++20 used by this project. You should set `20` in the profile line
|
||||
starting with `compiler.cppstd=`. For example:
|
||||
|
||||
```bash
|
||||
sed -i.bak -e 's|^compiler\.cppstd=.*$|compiler.cppstd=23|' $(conan config home)/profiles/default
|
||||
sed -i.bak -e 's|^compiler\.cppstd=.*$|compiler.cppstd=20|' $(conan config home)/profiles/default
|
||||
```
|
||||
|
||||
#### Select standard library in Linux
|
||||
|
||||
@@ -15,7 +15,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
project(xrpl)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
|
||||
@@ -94,9 +94,6 @@ add_module(xrpl basics)
|
||||
target_link_libraries(xrpl.libxrpl.basics PUBLIC xrpl.libxrpl.beast)
|
||||
|
||||
# Level 03
|
||||
add_module(xrpl config)
|
||||
target_link_libraries(xrpl.libxrpl.config PUBLIC xrpl.libxrpl.basics)
|
||||
|
||||
add_module(xrpl json)
|
||||
target_link_libraries(xrpl.libxrpl.json PUBLIC xrpl.libxrpl.basics)
|
||||
|
||||
@@ -123,7 +120,6 @@ target_link_libraries(
|
||||
xrpl.libxrpl.core
|
||||
PUBLIC
|
||||
xrpl.libxrpl.basics
|
||||
xrpl.libxrpl.config
|
||||
xrpl.libxrpl.json
|
||||
xrpl.libxrpl.protocol
|
||||
xrpl.libxrpl.protocol_autogen
|
||||
@@ -147,11 +143,7 @@ target_link_libraries(
|
||||
add_module(xrpl nodestore)
|
||||
target_link_libraries(
|
||||
xrpl.libxrpl.nodestore
|
||||
PUBLIC
|
||||
xrpl.libxrpl.basics
|
||||
xrpl.libxrpl.config
|
||||
xrpl.libxrpl.json
|
||||
xrpl.libxrpl.protocol
|
||||
PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json xrpl.libxrpl.protocol
|
||||
)
|
||||
|
||||
add_module(xrpl shamap)
|
||||
@@ -167,14 +159,13 @@ target_link_libraries(
|
||||
add_module(xrpl rdb)
|
||||
target_link_libraries(
|
||||
xrpl.libxrpl.rdb
|
||||
PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.config xrpl.libxrpl.core
|
||||
PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.core
|
||||
)
|
||||
|
||||
add_module(xrpl server)
|
||||
target_link_libraries(
|
||||
xrpl.libxrpl.server
|
||||
PUBLIC
|
||||
xrpl.libxrpl.config
|
||||
xrpl.libxrpl.protocol
|
||||
xrpl.libxrpl.core
|
||||
xrpl.libxrpl.rdb
|
||||
@@ -219,7 +210,6 @@ target_link_modules(
|
||||
basics
|
||||
beast
|
||||
conditions
|
||||
config
|
||||
core
|
||||
crypto
|
||||
git
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
arch=x86_64
|
||||
build_type=Release
|
||||
compiler=gcc
|
||||
compiler.cppstd=23
|
||||
compiler.cppstd=20
|
||||
compiler.libcxx=libstdc++11
|
||||
compiler.version=13
|
||||
os=Linux
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
arch=armv8
|
||||
build_type=Release
|
||||
compiler=apple-clang
|
||||
compiler.cppstd=23
|
||||
compiler.cppstd=20
|
||||
compiler.libcxx=libc++
|
||||
compiler.version=17.0
|
||||
os=Macos
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
arch=x86_64
|
||||
build_type=Release
|
||||
compiler=msvc
|
||||
compiler.cppstd=23
|
||||
compiler.cppstd=20
|
||||
compiler.runtime=dynamic
|
||||
compiler.runtime_type=Release
|
||||
compiler.version=194
|
||||
|
||||
@@ -12,7 +12,7 @@ arch={{ arch }}
|
||||
build_type=Debug
|
||||
compiler={{compiler}}
|
||||
compiler.version={{ compiler_version }}
|
||||
compiler.cppstd=23
|
||||
compiler.cppstd=20
|
||||
{% if os == "Windows" %}
|
||||
compiler.runtime=static
|
||||
{% else %}
|
||||
|
||||
@@ -52,50 +52,52 @@ include(default)
|
||||
{% endif %}
|
||||
|
||||
{# Frame pointer required for meaningful stack traces; -O1 for reasonable performance #}
|
||||
{% set sanitizer_compiler_flags = ["-fno-omit-frame-pointer", "-O1"] %}
|
||||
{% set compile_flags = ["-fno-omit-frame-pointer", "-O1"] %}
|
||||
|
||||
{% if compiler == "gcc" %}
|
||||
{# Suppress false positive warnings with GCC #}
|
||||
{% set _ = sanitizer_compiler_flags.append("-Wno-stringop-overflow") %}
|
||||
{% set _ = compile_flags.append("-Wno-stringop-overflow") %}
|
||||
|
||||
{% set relocation_flags = [] %}
|
||||
|
||||
{% if arch == "x86_64" and enable_asan %}
|
||||
{# Large code model prevents relocation errors in instrumented ASAN binaries #}
|
||||
{% set _ = sanitizer_compiler_flags.append("-mcmodel=large") %}
|
||||
{% set _ = compile_flags.append("-mcmodel=large") %}
|
||||
{% set _ = relocation_flags.append("-mcmodel=large") %}
|
||||
{% elif enable_tsan %}
|
||||
{# GCC doesn't support atomic_thread_fence with TSAN; suppress warnings #}
|
||||
{% set _ = sanitizer_compiler_flags.append("-Wno-tsan") %}
|
||||
{% set _ = compile_flags.append("-Wno-tsan") %}
|
||||
{% if arch == "x86_64" %}
|
||||
{# Medium code model for TSAN; large is incompatible #}
|
||||
{% set _ = sanitizer_compiler_flags.append("-mcmodel=medium") %}
|
||||
{% set _ = compile_flags.append("-mcmodel=medium") %}
|
||||
{% set _ = relocation_flags.append("-mcmodel=medium") %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% set fsanitize = "-fsanitize=" ~ ",".join(sanitizer_types) %}
|
||||
{% set _ = sanitizer_compiler_flags.append(fsanitize) %}
|
||||
{% set _ = compile_flags.append(fsanitize) %}
|
||||
{% set _ = relocation_flags.append(fsanitize) %}
|
||||
|
||||
{% set sanitizer_linker_flags = relocation_flags %}
|
||||
{% set sanitizer_compiler_flags = " ".join(compile_flags) %}
|
||||
{% set sanitizer_linker_flags = " ".join(relocation_flags) %}
|
||||
{% elif compiler == "clang" or compiler == "apple-clang" %}
|
||||
{% set fsanitize = "-fsanitize=" ~ ",".join(sanitizer_types) %}
|
||||
{% set _ = sanitizer_compiler_flags.append(fsanitize) %}
|
||||
{% set _ = compile_flags.append(fsanitize) %}
|
||||
|
||||
{% set sanitizer_linker_flags = [fsanitize] %}
|
||||
{% set sanitizer_compiler_flags = " ".join(compile_flags) %}
|
||||
{% set sanitizer_linker_flags = fsanitize %}
|
||||
{% endif %}
|
||||
|
||||
[conf]
|
||||
tools.build:defines+={{defines}}
|
||||
tools.build:cxxflags+={{sanitizer_compiler_flags}}
|
||||
tools.build:sharedlinkflags+={{sanitizer_linker_flags}}
|
||||
tools.build:exelinkflags+={{sanitizer_linker_flags}}
|
||||
tools.build:cxxflags+=['{{sanitizer_compiler_flags}}']
|
||||
tools.build:sharedlinkflags+=['{{sanitizer_linker_flags}}']
|
||||
tools.build:exelinkflags+=['{{sanitizer_linker_flags}}']
|
||||
|
||||
tools.info.package_id:confs+=["tools.build:cxxflags", "tools.build:exelinkflags", "tools.build:sharedlinkflags", "tools.build:defines"]
|
||||
|
||||
# &: means "apply only to the consumer/root package"
|
||||
&:tools.cmake.cmaketoolchain:extra_variables={"SANITIZERS": "{{sanitizers}}", "SANITIZERS_COMPILER_FLAGS": "{{sanitizer_compiler_flags | join(' ')}}", "SANITIZERS_LINKER_FLAGS": "{{sanitizer_linker_flags | join(' ')}}"}
|
||||
&:tools.cmake.cmaketoolchain:extra_variables={"SANITIZERS": "{{sanitizers}}", "SANITIZERS_COMPILER_FLAGS": "{{sanitizer_compiler_flags}}", "SANITIZERS_LINKER_FLAGS": "{{sanitizer_linker_flags}}"}
|
||||
|
||||
[options]
|
||||
{% if enable_asan %}
|
||||
|
||||
@@ -84,7 +84,6 @@ words:
|
||||
- coro
|
||||
- coros
|
||||
- cowid
|
||||
- cpack
|
||||
- cryptocondition
|
||||
- cryptoconditional
|
||||
- cryptoconditions
|
||||
|
||||
6
flake.lock
generated
6
flake.lock
generated
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1780749050,
|
||||
"narHash": "sha256-3av0pIjlOWQ6rDbNOmpUSvbNnJkGORQKKjb4LtCZsIY=",
|
||||
"lastModified": 1780243769,
|
||||
"narHash": "sha256-x5UQuRsH3MqI0U9afaXSNqzTPSeZlRLvFAav2Ux1pNw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a799d3e3886da994fa307f817a6bc705ae538eeb",
|
||||
"rev": "331800de5053fcebacf6813adb5db9c9dca22a0c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
248
include/xrpl/basics/Expected.h
Normal file
248
include/xrpl/basics/Expected.h
Normal file
@@ -0,0 +1,248 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/contract.h>
|
||||
|
||||
#include <boost/outcome.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
/** Expected is an approximation of std::expected (hoped for in C++23)
|
||||
|
||||
See: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0323r10.html
|
||||
|
||||
The implementation is entirely based on boost::outcome_v2::result.
|
||||
*/
|
||||
|
||||
// Exception thrown by an invalid access to Expected.
|
||||
struct BadExpectedAccess : public std::runtime_error
|
||||
{
|
||||
BadExpectedAccess() : runtime_error("bad expected access")
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
// Custom policy for Expected. Always throw on an invalid access.
|
||||
struct ThrowPolicy : public boost::outcome_v2::policy::base
|
||||
{
|
||||
template <class Impl>
|
||||
static constexpr void
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
wide_value_check(Impl&& self)
|
||||
{
|
||||
if (!base::_has_value(std::forward<Impl>(self)))
|
||||
Throw<BadExpectedAccess>();
|
||||
}
|
||||
|
||||
template <class Impl>
|
||||
static constexpr void
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
wide_error_check(Impl&& self)
|
||||
{
|
||||
if (!base::_has_error(std::forward<Impl>(self)))
|
||||
Throw<BadExpectedAccess>();
|
||||
}
|
||||
|
||||
template <class Impl>
|
||||
static constexpr void
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
wide_exception_check(Impl&& self)
|
||||
{
|
||||
if (!base::_has_exception(std::forward<Impl>(self)))
|
||||
Throw<BadExpectedAccess>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// Definition of Unexpected, which is used to construct the unexpected
|
||||
// return type of an Expected.
|
||||
template <class E>
|
||||
class Unexpected
|
||||
{
|
||||
public:
|
||||
static_assert(!std::is_same_v<E, void>, "E must not be void");
|
||||
|
||||
Unexpected() = delete;
|
||||
|
||||
constexpr explicit Unexpected(E const& e) : val_(e)
|
||||
{
|
||||
}
|
||||
|
||||
constexpr explicit Unexpected(E&& e) : val_(std::move(e))
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr E const&
|
||||
value() const&
|
||||
{
|
||||
return val_;
|
||||
}
|
||||
|
||||
constexpr E&
|
||||
value() &
|
||||
{
|
||||
return val_;
|
||||
}
|
||||
|
||||
constexpr E&&
|
||||
value() &&
|
||||
{
|
||||
return std::move(val_);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr E const&&
|
||||
value() const&&
|
||||
{
|
||||
return std::move(val_);
|
||||
}
|
||||
|
||||
private:
|
||||
E val_;
|
||||
};
|
||||
|
||||
// Unexpected deduction guide that converts array to const*.
|
||||
template <typename E, std::size_t N>
|
||||
Unexpected(E (&)[N]) -> Unexpected<E const*>;
|
||||
|
||||
// Definition of Expected. All of the machinery comes from boost::result.
|
||||
template <class T, class E>
|
||||
class [[nodiscard]] Expected : private boost::outcome_v2::result<T, E, detail::ThrowPolicy>
|
||||
{
|
||||
using Base = boost::outcome_v2::result<T, E, detail::ThrowPolicy>;
|
||||
|
||||
public:
|
||||
template <typename U>
|
||||
requires std::convertible_to<U, T>
|
||||
constexpr Expected(U&& r) : Base(boost::outcome_v2::in_place_type_t<T>{}, std::forward<U>(r))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
requires std::convertible_to<U, E> && (!std::is_reference_v<U>)
|
||||
constexpr Expected(Unexpected<U> e)
|
||||
: Base(boost::outcome_v2::in_place_type_t<E>{}, std::move(e.value()))
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
has_value() const
|
||||
{
|
||||
return Base::has_value();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr T const&
|
||||
value() const
|
||||
{
|
||||
return Base::value();
|
||||
}
|
||||
|
||||
constexpr T&
|
||||
value()
|
||||
{
|
||||
return Base::value();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr E const&
|
||||
error() const&
|
||||
{
|
||||
return Base::error();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr E&
|
||||
error() &
|
||||
{
|
||||
return Base::error();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr E&&
|
||||
error() &&
|
||||
{
|
||||
return std::move(Base::error());
|
||||
}
|
||||
|
||||
constexpr explicit
|
||||
operator bool() const
|
||||
{
|
||||
return has_value();
|
||||
}
|
||||
|
||||
// Add operator* and operator-> so the Expected API looks a bit more like
|
||||
// what std::expected is likely to look like. See:
|
||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0323r10.html
|
||||
[[nodiscard]] constexpr T&
|
||||
operator*()
|
||||
{
|
||||
return this->value();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr T const&
|
||||
operator*() const
|
||||
{
|
||||
return this->value();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr T*
|
||||
operator->()
|
||||
{
|
||||
return &this->value();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr T const*
|
||||
operator->() const
|
||||
{
|
||||
return &this->value();
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization of Expected<void, E>. Allows returning either success
|
||||
// (without a value) or the reason for the failure.
|
||||
template <class E>
|
||||
class [[nodiscard]]
|
||||
Expected<void, E> : private boost::outcome_v2::result<void, E, detail::ThrowPolicy>
|
||||
{
|
||||
using Base = boost::outcome_v2::result<void, E, detail::ThrowPolicy>;
|
||||
|
||||
public:
|
||||
// The default constructor makes a successful Expected<void, E>.
|
||||
// This aligns with std::expected behavior proposed in P0323R10.
|
||||
constexpr Expected() : Base(boost::outcome_v2::success())
|
||||
{
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
requires std::convertible_to<U, E> && (!std::is_reference_v<U>)
|
||||
constexpr Expected(Unexpected<U> e) : Base(E(std::move(e.value())))
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr E const&
|
||||
error() const&
|
||||
{
|
||||
return Base::error();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr E&
|
||||
error() &
|
||||
{
|
||||
return Base::error();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr E&&
|
||||
error() &&
|
||||
{
|
||||
return std::move(Base::error());
|
||||
}
|
||||
|
||||
constexpr explicit
|
||||
operator bool() const
|
||||
{
|
||||
return Base::has_value();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -408,40 +408,33 @@ public:
|
||||
}
|
||||
|
||||
friend constexpr bool
|
||||
operator<(Number const& l, Number const& r) noexcept
|
||||
operator<(Number const& x, Number const& y) noexcept
|
||||
{
|
||||
bool const lneg = l.negative_;
|
||||
bool const rneg = r.negative_;
|
||||
|
||||
// If the two amounts have different signs (zero is treated as positive)
|
||||
// then the comparison is true iff the left is negative.
|
||||
bool const lneg = x.negative_;
|
||||
bool const rneg = y.negative_;
|
||||
|
||||
if (lneg != rneg)
|
||||
return lneg;
|
||||
|
||||
// Both have same sign and the left is zero: both must be non-negative.
|
||||
// If the right is greater than 0, then it is larger, so the comparison is true.
|
||||
if (l.mantissa_ == 0)
|
||||
return r.mantissa_ > 0;
|
||||
// Both have same sign and the left is zero: the right must be
|
||||
// greater than 0.
|
||||
if (x.mantissa_ == 0)
|
||||
return y.mantissa_ > 0;
|
||||
|
||||
// Both have same sign, the right is zero and the left is non-zero, so the left must be
|
||||
// positive, and thus is larger, so the comparison is false.
|
||||
if (r.mantissa_ == 0)
|
||||
// Both have same sign, the right is zero and the left is non-zero.
|
||||
if (y.mantissa_ == 0)
|
||||
return false;
|
||||
|
||||
// Both have the same sign, compare by exponents:
|
||||
if (l.exponent_ > r.exponent_)
|
||||
if (x.exponent_ > y.exponent_)
|
||||
return lneg;
|
||||
if (l.exponent_ < r.exponent_)
|
||||
if (x.exponent_ < y.exponent_)
|
||||
return !lneg;
|
||||
|
||||
// If equal signs and exponents, compare mantissas.
|
||||
if (lneg)
|
||||
{
|
||||
// If negative, the operator is reversed.
|
||||
return l.mantissa_ > r.mantissa_;
|
||||
}
|
||||
|
||||
return l.mantissa_ < r.mantissa_;
|
||||
// If equal exponents, compare mantissas
|
||||
return x.mantissa_ < y.mantissa_;
|
||||
}
|
||||
|
||||
/** Return the sign of the amount */
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -96,7 +95,13 @@ strUnHex(std::size_t strSize, Iterator begin, Iterator end)
|
||||
}
|
||||
|
||||
inline std::optional<Blob>
|
||||
strUnHex(std::string_view strSrc)
|
||||
strUnHex(std::string const& strSrc)
|
||||
{
|
||||
return strUnHex(strSrc.size(), strSrc.cbegin(), strSrc.cend());
|
||||
}
|
||||
|
||||
inline std::optional<Blob>
|
||||
strViewUnHex(std::string_view strSrc)
|
||||
{
|
||||
return strUnHex(strSrc.size(), strSrc.cbegin(), strSrc.cend());
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
@@ -44,7 +43,7 @@ std::string
|
||||
base64Encode(std::uint8_t const* data, std::size_t len);
|
||||
|
||||
inline std::string
|
||||
base64Encode(std::string_view s)
|
||||
base64Encode(std::string const& s)
|
||||
{
|
||||
return base64Encode(reinterpret_cast<std::uint8_t const*>(s.data()), s.size());
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/basics/Slice.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/basics/hardened_hash.h>
|
||||
@@ -19,7 +20,6 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
#include <expected>
|
||||
#include <type_traits>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -177,7 +177,7 @@ private:
|
||||
BadChar,
|
||||
};
|
||||
|
||||
constexpr std::expected<decltype(data_), ParseResult>
|
||||
constexpr Expected<decltype(data_), ParseResult>
|
||||
parseFromStringView(std::string_view sv) noexcept
|
||||
{
|
||||
// Local lambda that converts a single hex char to four bits and
|
||||
@@ -216,7 +216,7 @@ private:
|
||||
}
|
||||
|
||||
if (sv.size() != size() * 2)
|
||||
return std::unexpected(ParseResult::BadLength);
|
||||
return Unexpected(ParseResult::BadLength);
|
||||
|
||||
std::size_t i = 0u;
|
||||
auto in = sv.begin();
|
||||
@@ -227,7 +227,7 @@ private:
|
||||
{
|
||||
if (auto const result = hexCharToUInt(*in++, shift, accum);
|
||||
result != ParseResult::Okay)
|
||||
return std::unexpected(result);
|
||||
return Unexpected(result);
|
||||
}
|
||||
ret[i++] = accum;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
template <class Stream, class Iter>
|
||||
Stream&
|
||||
join(Stream& s, Iter iter, Iter end, std::string_view delimiter)
|
||||
join(Stream& s, Iter iter, Iter end, std::string const& delimiter)
|
||||
{
|
||||
if (iter == end)
|
||||
return s;
|
||||
|
||||
@@ -7,11 +7,8 @@
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <new>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <type_traits>
|
||||
|
||||
namespace beast {
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <xrpl/beast/insight/CounterImpl.h>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace beast::insight {
|
||||
|
||||
@@ -30,7 +29,7 @@ public:
|
||||
factory function in the Collector interface.
|
||||
@see Collector.
|
||||
*/
|
||||
explicit Counter(std::shared_ptr<CounterImpl> impl) : impl_(std::move(impl))
|
||||
explicit Counter(std::shared_ptr<CounterImpl> const& impl) : impl_(impl)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace beast::insight {
|
||||
|
||||
@@ -32,7 +31,7 @@ public:
|
||||
factory function in the Collector interface.
|
||||
@see Collector.
|
||||
*/
|
||||
explicit Event(std::shared_ptr<EventImpl> impl) : impl_(std::move(impl))
|
||||
explicit Event(std::shared_ptr<EventImpl> const& impl) : impl_(impl)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <xrpl/beast/insight/GaugeImpl.h>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace beast::insight {
|
||||
|
||||
@@ -32,7 +31,7 @@ public:
|
||||
factory function in the Collector interface.
|
||||
@see Collector.
|
||||
*/
|
||||
explicit Gauge(std::shared_ptr<GaugeImpl> impl) : impl_(std::move(impl))
|
||||
explicit Gauge(std::shared_ptr<GaugeImpl> const& impl) : impl_(impl)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <xrpl/beast/insight/HookImpl.h>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace beast::insight {
|
||||
|
||||
@@ -21,7 +20,7 @@ public:
|
||||
factory function in the Collector interface.
|
||||
@see Collector.
|
||||
*/
|
||||
explicit Hook(std::shared_ptr<HookImpl> impl) : impl_(std::move(impl))
|
||||
explicit Hook(std::shared_ptr<HookImpl> const& impl) : impl_(impl)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <xrpl/beast/insight/MeterImpl.h>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace beast::insight {
|
||||
|
||||
@@ -29,7 +28,7 @@ public:
|
||||
factory function in the Collector interface.
|
||||
@see Collector.
|
||||
*/
|
||||
explicit Meter(std::shared_ptr<MeterImpl> impl) : impl_(std::move(impl))
|
||||
explicit Meter(std::shared_ptr<MeterImpl> const& impl) : impl_(impl)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
|
||||
public:
|
||||
template <class = void>
|
||||
explicit Selector(ModeT mode, std::string pattern = "");
|
||||
explicit Selector(ModeT mode, std::string const& pattern = "");
|
||||
|
||||
template <class = void>
|
||||
bool
|
||||
@@ -51,9 +51,9 @@ public:
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <class>
|
||||
Selector::Selector(ModeT mode, std::string pattern) : mode_(mode), pat_(std::move(pattern))
|
||||
Selector::Selector(ModeT mode, std::string const& pattern) : mode_(mode), pat_(pattern)
|
||||
{
|
||||
if (mode_ == ModeT::Automatch && pat_.empty())
|
||||
if (mode_ == ModeT::Automatch && pattern.empty())
|
||||
mode_ = ModeT::All;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
// Macros below are copied from antithesis_sdk.h and slightly simplified
|
||||
// The duplication is because Visual Studio 2019 cannot compile that header
|
||||
// even with the option -Zc:__cplusplus added.
|
||||
// NOTE: cond must not contain bare commas outside () or []. Commas inside {}
|
||||
// are not protected by the preprocessor and would be parsed as extra arguments.
|
||||
#define ALWAYS(cond, message, ...) assert((message) && (cond))
|
||||
#define ALWAYS_OR_UNREACHABLE(cond, message) assert((message) && (cond))
|
||||
#define SOMETIMES(cond, message, ...)
|
||||
@@ -24,8 +22,6 @@
|
||||
#define XRPL_ASSERT_PARTS(cond, function, description, ...) \
|
||||
XRPL_ASSERT(cond, function " : " description)
|
||||
|
||||
#define XRPL_ASSERT_IF(guard, cond, message) XRPL_ASSERT(!(guard) || (cond), message)
|
||||
|
||||
// How to use the instrumentation macros:
|
||||
//
|
||||
// * XRPL_ASSERT if cond must be true but the line might not be reached during
|
||||
@@ -33,14 +29,6 @@
|
||||
// * XRPL_ASSERT_PARTS is for convenience, and works like XRPL_ASSERT, but
|
||||
// splits the message param into "function" and "description", then joins
|
||||
// them with " : " before passing to XRPL_ASSERT.
|
||||
// * XRPL_ASSERT_IF(guard, cond, message) asserts the implication
|
||||
// `guard => cond`: it can only fail when guard is true (e.g. an amendment
|
||||
// is enabled) and cond is false. Unlike `if (guard) XRPL_ASSERT(...)`, the
|
||||
// assertion site is always evaluated, so the fuzzer registers it
|
||||
// unconditionally; cond itself is short-circuited and only evaluated when
|
||||
// guard is true. NOTE: do not rely on side effects in guard — in release
|
||||
// builds the assertion body is stripped, and the compiler may optimize away
|
||||
// a side-effect-free guard entirely.
|
||||
// * ALWAYS if cond must be true _and_ the line must be reached during fuzzing.
|
||||
// Same like `assert` in normal use.
|
||||
// * REACHABLE if the line must be reached during fuzzing
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
struct Sections
|
||||
{
|
||||
static constexpr auto kAmendments = "amendments";
|
||||
static constexpr auto kAmendmentMajorityTime = "amendment_majority_time";
|
||||
static constexpr auto kBetaRpcApi = "beta_rpc_api";
|
||||
static constexpr auto kClusterNodes = "cluster_nodes";
|
||||
static constexpr auto kCompression = "compression";
|
||||
static constexpr auto kCrawl = "crawl";
|
||||
static constexpr auto kDatabasePath = "database_path";
|
||||
static constexpr auto kDebugLogfile = "debug_logfile";
|
||||
static constexpr auto kElbSupport = "elb_support";
|
||||
static constexpr auto kFeatures = "features";
|
||||
static constexpr auto kFeeDefault = "fee_default";
|
||||
static constexpr auto kFetchDepth = "fetch_depth";
|
||||
static constexpr auto kHashrouter = "hashrouter";
|
||||
static constexpr auto kImportNodeDatabase = "import_db";
|
||||
static constexpr auto kInsight = "insight";
|
||||
static constexpr auto kIoWorkers = "io_workers";
|
||||
static constexpr auto kIps = "ips";
|
||||
static constexpr auto kIpsFixed = "ips_fixed";
|
||||
static constexpr auto kLedgerHistory = "ledger_history";
|
||||
static constexpr auto kLedgerReplay = "ledger_replay";
|
||||
static constexpr auto kLedgerTxTables = "ledger_tx_tables";
|
||||
static constexpr auto kMaxTransactions = "max_transactions";
|
||||
static constexpr auto kNetworkId = "network_id";
|
||||
static constexpr auto kNetworkQuorum = "network_quorum";
|
||||
static constexpr auto kNodeDatabase = "node_db";
|
||||
static constexpr auto kNodeSeed = "node_seed";
|
||||
static constexpr auto kNodeSize = "node_size";
|
||||
static constexpr auto kOverlay = "overlay";
|
||||
static constexpr auto kPathSearch = "path_search";
|
||||
static constexpr auto kPathSearchFast = "path_search_fast";
|
||||
static constexpr auto kPathSearchMax = "path_search_max";
|
||||
static constexpr auto kPathSearchOld = "path_search_old";
|
||||
static constexpr auto kPeerPrivate = "peer_private";
|
||||
static constexpr auto kPeersInMax = "peers_in_max";
|
||||
static constexpr auto kPeersMax = "peers_max";
|
||||
static constexpr auto kPeersOutMax = "peers_out_max";
|
||||
static constexpr auto kPerf = "perf";
|
||||
static constexpr auto kPortGrpc = "port_grpc";
|
||||
static constexpr auto kPortPeer = "port_peer";
|
||||
static constexpr auto kPortRpc = "port_rpc";
|
||||
static constexpr auto kPortWs = "port_ws";
|
||||
static constexpr auto kPortWssAdmin = "port_wss_admin";
|
||||
static constexpr auto kPrefetchWorkers = "prefetch_workers";
|
||||
static constexpr auto kReduceRelay = "reduce_relay";
|
||||
static constexpr auto kRelationalDb = "relational_db";
|
||||
static constexpr auto kRelayProposals = "relay_proposals";
|
||||
static constexpr auto kRelayValidations = "relay_validations";
|
||||
static constexpr auto kRpcStartup = "rpc_startup";
|
||||
static constexpr auto kServer = "server";
|
||||
static constexpr auto kServerDomain = "server_domain";
|
||||
static constexpr auto kSigningSupport = "signing_support";
|
||||
static constexpr auto kSntp = "sntp_servers";
|
||||
static constexpr auto kSqdb = "sqdb";
|
||||
static constexpr auto kSqlite = "sqlite";
|
||||
static constexpr auto kSslVerify = "ssl_verify";
|
||||
static constexpr auto kSslVerifyDir = "ssl_verify_dir";
|
||||
static constexpr auto kSslVerifyFile = "ssl_verify_file";
|
||||
static constexpr auto kSweepInterval = "sweep_interval";
|
||||
static constexpr auto kTransactionQueue = "transaction_queue";
|
||||
static constexpr auto kValidationSeed = "validation_seed";
|
||||
static constexpr auto kValidatorKeys = "validator_keys";
|
||||
static constexpr auto kValidatorKeyRevocation = "validator_key_revocation";
|
||||
static constexpr auto kValidatorListKeys = "validator_list_keys";
|
||||
static constexpr auto kValidatorListSites = "validator_list_sites";
|
||||
static constexpr auto kValidatorListThreshold = "validator_list_threshold";
|
||||
static constexpr auto kValidatorToken = "validator_token";
|
||||
static constexpr auto kValidators = "validators";
|
||||
static constexpr auto kValidatorsFile = "validators_file";
|
||||
static constexpr auto kVetoAmendments = "veto_amendments";
|
||||
static constexpr auto kVl = "vl";
|
||||
static constexpr auto kVoting = "voting";
|
||||
static constexpr auto kWorkers = "workers";
|
||||
};
|
||||
|
||||
struct Keys
|
||||
{
|
||||
static constexpr auto kAccountReserve = "account_reserve";
|
||||
static constexpr auto kAddress = "address";
|
||||
static constexpr auto kAdmin = "admin";
|
||||
static constexpr auto kAdminPassword = "admin_password";
|
||||
static constexpr auto kAdminUser = "admin_user";
|
||||
static constexpr auto kAdvisoryDelete = "advisory_delete";
|
||||
static constexpr auto kAgeThresholdSeconds = "age_threshold_seconds";
|
||||
static constexpr auto kBackOff = "backOff";
|
||||
static constexpr auto kBackOffMilliseconds = "back_off_milliseconds";
|
||||
static constexpr auto kBackend = "backend";
|
||||
static constexpr auto kBbtOptions = "bbt_options";
|
||||
static constexpr auto kBgThreads = "bg_threads";
|
||||
static constexpr auto kBlockSize = "block_size";
|
||||
static constexpr auto kCacheAge = "cache_age";
|
||||
static constexpr auto kCacheMb = "cache_mb";
|
||||
static constexpr auto kCacheSize = "cache_size";
|
||||
static constexpr auto kClientMaxWindowBits = "client_max_window_bits";
|
||||
static constexpr auto kClientNoContextTakeover = "client_no_context_takeover";
|
||||
static constexpr auto kCompressLevel = "compress_level";
|
||||
static constexpr auto kCounts = "counts";
|
||||
static constexpr auto kDeleteBatch = "delete_batch";
|
||||
static constexpr auto kEarliestSeq = "earliest_seq";
|
||||
static constexpr auto kFastLoad = "fast_load";
|
||||
static constexpr auto kFileSizeMb = "file_size_mb";
|
||||
static constexpr auto kFileSizeMult = "file_size_mult";
|
||||
static constexpr auto kFilterBits = "filter_bits";
|
||||
static constexpr auto kFilterFull = "filter_full";
|
||||
static constexpr auto kHardSet = "hard_set";
|
||||
static constexpr auto kHighThreads = "high_threads";
|
||||
static constexpr auto kHoldTime = "hold_time";
|
||||
static constexpr auto kIp = "ip";
|
||||
static constexpr auto kJournalMode = "journal_mode";
|
||||
static constexpr auto kJournalSizeLimit = "journal_size_limit";
|
||||
static constexpr auto kLedgersInQueue = "ledgers_in_queue";
|
||||
static constexpr auto kLimit = "limit";
|
||||
static constexpr auto kLogInterval = "log_interval";
|
||||
static constexpr auto kMaxDivergedTime = "max_diverged_time";
|
||||
static constexpr auto kMaxLedgerCountsToStore = "max_ledger_counts_to_store";
|
||||
static constexpr auto kMaxUnknownTime = "max_unknown_time";
|
||||
static constexpr auto kMaximumTxnInLedger = "maximum_txn_in_ledger";
|
||||
static constexpr auto kMaximumTxnPerAccount = "maximum_txn_per_account";
|
||||
static constexpr auto kMemoryLevel = "memory_level";
|
||||
static constexpr auto kMinLedgersToComputeSizeLimit = "min_ledgers_to_compute_size_limit";
|
||||
static constexpr auto kMinimumEscalationMultiplier = "minimum_escalation_multiplier";
|
||||
static constexpr auto kMinimumLastLedgerBuffer = "minimum_last_ledger_buffer";
|
||||
static constexpr auto kMinimumQueueSize = "minimum_queue_size";
|
||||
static constexpr auto kMinimumTxnInLedger = "minimum_txn_in_ledger";
|
||||
static constexpr auto kMinimumTxnInLedgerStandalone = "minimum_txn_in_ledger_standalone";
|
||||
static constexpr auto kNormalConsensusIncreasePercent = "normal_consensus_increase_percent";
|
||||
static constexpr auto kNudbBlockSize = "nudb_block_size";
|
||||
static constexpr auto kOnlineDelete = "online_delete";
|
||||
static constexpr auto kOpenFiles = "open_files";
|
||||
static constexpr auto kOptions = "options";
|
||||
static constexpr auto kOverlay = "overlay";
|
||||
static constexpr auto kOwnerReserve = "owner_reserve";
|
||||
static constexpr auto kPageSize = "page_size";
|
||||
static constexpr auto kPassword = "password";
|
||||
static constexpr auto kPath = "path";
|
||||
static constexpr auto kPermessageDeflate = "permessage_deflate";
|
||||
static constexpr auto kPort = "port";
|
||||
static constexpr auto kPrefix = "prefix";
|
||||
static constexpr auto kProtocol = "protocol";
|
||||
static constexpr auto kRecoveryWaitSeconds = "recovery_wait_seconds";
|
||||
static constexpr auto kReferenceFee = "reference_fee";
|
||||
static constexpr auto kRelayTime = "relay_time";
|
||||
static constexpr auto kRetrySequencePercent = "retry_sequence_percent";
|
||||
static constexpr auto kRqBundle = "rq_bundle";
|
||||
static constexpr auto kSafetyLevel = "safety_level";
|
||||
static constexpr auto kSecureGateway = "secure_gateway";
|
||||
static constexpr auto kSendQueueLimit = "send_queue_limit";
|
||||
static constexpr auto kServer = "server";
|
||||
static constexpr auto kServerMaxWindowBits = "server_max_window_bits";
|
||||
static constexpr auto kServerNoContextTakeover = "server_no_context_takeover";
|
||||
static constexpr auto kSlowConsensusDecreasePercent = "slow_consensus_decrease_percent";
|
||||
static constexpr auto kSslCert = "ssl_cert";
|
||||
static constexpr auto kSslCertChain = "ssl_cert_chain";
|
||||
static constexpr auto kSslChain = "ssl_chain";
|
||||
static constexpr auto kSslCiphers = "ssl_ciphers";
|
||||
static constexpr auto kSslClientCa = "ssl_client_ca";
|
||||
static constexpr auto kSslKey = "ssl_key";
|
||||
static constexpr auto kSynchronous = "synchronous";
|
||||
static constexpr auto kTargetTxnInLedger = "target_txn_in_ledger";
|
||||
static constexpr auto kTempStore = "temp_store";
|
||||
static constexpr auto kTxEnable = "tx_enable";
|
||||
static constexpr auto kTxMetrics = "tx_metrics";
|
||||
static constexpr auto kTxMinPeers = "tx_min_peers";
|
||||
static constexpr auto kTxRelayPercentage = "tx_relay_percentage";
|
||||
static constexpr auto kType = "type";
|
||||
static constexpr auto kUniversalCompaction = "universal_compaction";
|
||||
static constexpr auto kUnl = "unl";
|
||||
static constexpr auto kUseTxTables = "use_tx_tables";
|
||||
static constexpr auto kUser = "user";
|
||||
static constexpr auto kVpBaseSquelchEnable = "vp_base_squelch_enable";
|
||||
static constexpr auto kVpBaseSquelchMaxSelectedPeers = "vp_base_squelch_max_selected_peers";
|
||||
static constexpr auto kVpEnable = "vp_enable";
|
||||
};
|
||||
|
||||
} // namespace xrpl
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/core/JobTypes.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
|
||||
@@ -17,7 +18,6 @@ class Journal;
|
||||
|
||||
namespace xrpl {
|
||||
class Application;
|
||||
class Section;
|
||||
namespace perf {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -35,7 +34,7 @@ private:
|
||||
static void
|
||||
standard(std::string& strWord);
|
||||
static int
|
||||
wsrch(std::string_view strWord, int iMin, int iMax);
|
||||
wsrch(std::string const& strWord, int iMin, int iMax);
|
||||
static int
|
||||
etob(std::string& strData, std::vector<std::string> vsHuman);
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
insert(std::shared_ptr<STTx const> txn);
|
||||
insert(std::shared_ptr<STTx const> const& txn);
|
||||
|
||||
// Pops the next transaction on account that follows seqProx in the
|
||||
// sort order. Normally called when a transaction is successfully
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/Number.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
@@ -17,8 +18,6 @@
|
||||
#include <xrpl/protocol/STAmount.h>
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
|
||||
#include <expected>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
namespace detail {
|
||||
@@ -742,7 +741,7 @@ ammPoolHolds(
|
||||
* provided then they are used as the AMM token pair issues.
|
||||
* Otherwise the missing issues are fetched from ammSle.
|
||||
*/
|
||||
std::expected<std::tuple<STAmount, STAmount, STAmount>, TER>
|
||||
Expected<std::tuple<STAmount, STAmount, STAmount>, TER>
|
||||
ammHolds(
|
||||
ReadView const& view,
|
||||
SLE const& ammSle,
|
||||
@@ -802,14 +801,14 @@ initializeFeeAuctionVote(
|
||||
* otherwise. Return tecINTERNAL if encountered an unexpected condition,
|
||||
* for instance Liquidity Provider has more than one LPToken trustline.
|
||||
*/
|
||||
std::expected<bool, TER>
|
||||
Expected<bool, TER>
|
||||
isOnlyLiquidityProvider(ReadView const& view, Issue const& ammIssue, AccountID const& lpAccount);
|
||||
|
||||
/** Due to rounding, the LPTokenBalance of the last LP might
|
||||
* not match the LP's trustline balance. If it's within the tolerance,
|
||||
* update LPTokenBalance to match the LP's trustline balance.
|
||||
*/
|
||||
std::expected<bool, TER>
|
||||
Expected<bool, TER>
|
||||
verifyAndAdjustLPTokenBalance(
|
||||
Sandbox& sb,
|
||||
STAmount const& lpTokens,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/ledger/ApplyView.h>
|
||||
#include <xrpl/ledger/ReadView.h>
|
||||
@@ -8,7 +9,6 @@
|
||||
#include <xrpl/protocol/STLedgerEntry.h>
|
||||
#include <xrpl/protocol/TER.h>
|
||||
|
||||
#include <expected>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
@@ -91,7 +91,7 @@ isPseudoAccount(
|
||||
* before using a field. The amendment check is **not** performed in
|
||||
* createPseudoAccount.
|
||||
*/
|
||||
[[nodiscard]] std::expected<SLE::pointer, TER>
|
||||
[[nodiscard]] Expected<SLE::pointer, TER>
|
||||
createPseudoAccount(ApplyView& view, uint256 const& pseudoOwnerKey, SField const& ownerField);
|
||||
|
||||
/** Checks the destination and tag.
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <xrpl/protocol/Rules.h>
|
||||
#include <xrpl/protocol/st.h>
|
||||
|
||||
#include <expected>
|
||||
#include <string_view>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -398,7 +397,7 @@ struct LoanStateDeltas
|
||||
nonNegative();
|
||||
};
|
||||
|
||||
std::expected<std::pair<LoanPaymentParts, LoanProperties>, TER>
|
||||
Expected<std::pair<LoanPaymentParts, LoanProperties>, TER>
|
||||
tryOverpayment(
|
||||
Rules const& rules,
|
||||
Asset const& asset,
|
||||
@@ -524,7 +523,7 @@ isRounded(Asset const& asset, Number const& value, std::int32_t scale);
|
||||
// potential extra work at the end.
|
||||
enum class LoanPaymentType { Regular = 0, Late, Full, Overpayment };
|
||||
|
||||
std::expected<LoanPaymentParts, TER>
|
||||
Expected<LoanPaymentParts, TER>
|
||||
loanMakePayment(
|
||||
Asset const& asset,
|
||||
ApplyView& view,
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
boost::system::error_code const& ecResult,
|
||||
int iStatus,
|
||||
std::string const& strData)> complete,
|
||||
beast::Journal const& j);
|
||||
beast::Journal& j);
|
||||
|
||||
static void
|
||||
get(bool bSSL,
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
boost::system::error_code const& ecResult,
|
||||
int iStatus,
|
||||
std::string const& strData)> complete,
|
||||
beast::Journal const& j);
|
||||
beast::Journal& j);
|
||||
|
||||
static void
|
||||
request(
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
boost::system::error_code const& ecResult,
|
||||
int iStatus,
|
||||
std::string const& strData)> complete,
|
||||
beast::Journal const& j);
|
||||
beast::Journal& j);
|
||||
};
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/TaggedCache.ipp>
|
||||
#include <xrpl/nodestore/Backend.h>
|
||||
@@ -9,10 +10,6 @@
|
||||
|
||||
#include <condition_variable>
|
||||
|
||||
namespace xrpl {
|
||||
class Section;
|
||||
} // namespace xrpl
|
||||
|
||||
namespace xrpl::NodeStore {
|
||||
|
||||
/** Persistency layer for NodeObject
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/nodestore/Backend.h>
|
||||
#include <xrpl/nodestore/Scheduler.h>
|
||||
|
||||
#include <nudb/store.hpp>
|
||||
|
||||
namespace xrpl {
|
||||
class Section;
|
||||
} // namespace xrpl
|
||||
|
||||
namespace xrpl::NodeStore {
|
||||
|
||||
/** Base class for backend factories. */
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
#include <xrpl/basics/TaggedCache.h>
|
||||
#include <xrpl/basics/chrono.h>
|
||||
#include <xrpl/config/BasicConfig.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/nodestore/Database.h>
|
||||
|
||||
namespace xrpl::NodeStore {
|
||||
@@ -26,16 +24,16 @@ public:
|
||||
{
|
||||
std::optional<int> cacheSize, cacheAge;
|
||||
|
||||
if (config.exists(Keys::kCacheSize))
|
||||
if (config.exists("cache_size"))
|
||||
{
|
||||
cacheSize = get<int>(config, Keys::kCacheSize);
|
||||
cacheSize = get<int>(config, "cache_size");
|
||||
if (cacheSize.value() < 0)
|
||||
Throw<std::runtime_error>("Specified negative value for cache_size");
|
||||
}
|
||||
|
||||
if (config.exists(Keys::kCacheAge))
|
||||
if (config.exists("cache_age"))
|
||||
{
|
||||
cacheAge = get<int>(config, Keys::kCacheAge);
|
||||
cacheAge = get<int>(config, "cache_age");
|
||||
if (cacheAge.value() < 0)
|
||||
Throw<std::runtime_error>("Specified negative value for cache_age");
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ invalidAMMAssetPair(
|
||||
std::optional<std::uint8_t>
|
||||
ammAuctionTimeSlot(std::uint64_t current, STObject const& auctionSlot);
|
||||
|
||||
/** Return true if required AMM amendment is enabled
|
||||
/** Return true if required AMM amendments are enabled
|
||||
*/
|
||||
bool
|
||||
ammEnabled(Rules const&);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/LocalValue.h>
|
||||
#include <xrpl/basics/Number.h>
|
||||
#include <xrpl/beast/utility/Zero.h>
|
||||
|
||||
@@ -178,4 +179,36 @@ to_string(IOUAmount const& amount);
|
||||
IOUAmount
|
||||
mulRatio(IOUAmount const& amt, std::uint32_t num, std::uint32_t den, bool roundUp);
|
||||
|
||||
// Since many uses of the number class do not have access to a ledger,
|
||||
// getSTNumberSwitchover needs to be globally accessible.
|
||||
|
||||
bool
|
||||
getSTNumberSwitchover();
|
||||
|
||||
void
|
||||
setSTNumberSwitchover(bool v);
|
||||
|
||||
/** RAII class to set and restore the Number switchover.
|
||||
*/
|
||||
|
||||
class NumberSO
|
||||
{
|
||||
bool saved_;
|
||||
|
||||
public:
|
||||
~NumberSO()
|
||||
{
|
||||
setSTNumberSwitchover(saved_);
|
||||
}
|
||||
|
||||
NumberSO(NumberSO const&) = delete;
|
||||
NumberSO&
|
||||
operator=(NumberSO const&) = delete;
|
||||
|
||||
explicit NumberSO(bool v) : saved_(getSTNumberSwitchover())
|
||||
{
|
||||
setSTNumberSwitchover(v);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -122,6 +122,7 @@ private:
|
||||
std::optional<Rules> saved_;
|
||||
};
|
||||
|
||||
class NumberSO;
|
||||
class NumberMantissaScaleGuard;
|
||||
|
||||
bool
|
||||
@@ -130,6 +131,7 @@ useRulesGuards(Rules const& rules);
|
||||
void
|
||||
createGuards(
|
||||
Rules const& rules,
|
||||
std::optional<NumberSO>& stNumberSO,
|
||||
std::optional<CurrentTransactionRulesGuard>& rulesGuard,
|
||||
std::optional<NumberMantissaScaleGuard>& mantissaScaleGuard);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/PublicKey.h>
|
||||
#include <xrpl/protocol/Rules.h>
|
||||
@@ -10,7 +11,6 @@
|
||||
|
||||
#include <boost/container/flat_set.hpp>
|
||||
|
||||
#include <expected>
|
||||
#include <functional>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -108,10 +108,10 @@ public:
|
||||
@param rules The current ledger rules.
|
||||
@return `true` if valid signature. If invalid, the error message string.
|
||||
*/
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
checkSign(Rules const& rules) const;
|
||||
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
checkBatchSign(Rules const& rules) const;
|
||||
|
||||
// SQL Functions with metadata.
|
||||
@@ -138,19 +138,19 @@ private:
|
||||
Will be *this more often than not.
|
||||
@return `true` if valid signature. If invalid, the error message string.
|
||||
*/
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
checkSign(Rules const& rules, STObject const& sigObject) const;
|
||||
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
checkSingleSign(STObject const& sigObject) const;
|
||||
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
checkMultiSign(Rules const& rules, STObject const& sigObject) const;
|
||||
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
checkBatchSingleSign(STObject const& batchSigner) const;
|
||||
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
checkBatchMultiSign(STObject const& batchSigner, Rules const& rules) const;
|
||||
|
||||
STBase*
|
||||
|
||||
@@ -17,8 +17,8 @@ public:
|
||||
STVector256() = default;
|
||||
|
||||
explicit STVector256(SField const& n);
|
||||
explicit STVector256(std::vector<uint256> vector);
|
||||
STVector256(SField const& n, std::vector<uint256> vector);
|
||||
explicit STVector256(std::vector<uint256> const& vector);
|
||||
STVector256(SField const& n, std::vector<uint256> const& vector);
|
||||
STVector256(SerialIter& sit, SField const& name);
|
||||
|
||||
[[nodiscard]] SerializedTypeID
|
||||
@@ -103,12 +103,12 @@ inline STVector256::STVector256(SField const& n) : STBase(n)
|
||||
{
|
||||
}
|
||||
|
||||
inline STVector256::STVector256(std::vector<uint256> vector) : value_(std::move(vector))
|
||||
inline STVector256::STVector256(std::vector<uint256> const& vector) : value_(vector)
|
||||
{
|
||||
}
|
||||
|
||||
inline STVector256::STVector256(SField const& n, std::vector<uint256> vector)
|
||||
: STBase(n), value_(std::move(vector))
|
||||
inline STVector256::STVector256(SField const& n, std::vector<uint256> const& vector)
|
||||
: STBase(n), value_(vector)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/Buffer.h>
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/protocol/AccountID.h>
|
||||
#include <xrpl/protocol/Issue.h>
|
||||
#include <xrpl/protocol/PublicKey.h>
|
||||
@@ -14,7 +15,6 @@
|
||||
#include <boost/container/vector.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <expected>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
// The largest "small object" we can accommodate
|
||||
static constexpr std::size_t kMaxSize = 72;
|
||||
|
||||
alignas(std::max_align_t) std::byte d_[kMaxSize] = {};
|
||||
std::aligned_storage<kMaxSize>::type d_ = {};
|
||||
STBase* p_ = nullptr;
|
||||
|
||||
public:
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// Add new amendments to the top of this list.
|
||||
// Keep it sorted in reverse chronological order.
|
||||
|
||||
XRPL_FIX (Cleanup3_3_0, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(LendingProtocolV1_1, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (Cleanup3_2_0, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(MPTokensV2, Supported::No, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (Cleanup3_1_3, Supported::Yes, VoteBehavior::DefaultYes)
|
||||
@@ -65,6 +65,7 @@ XRPL_FIX (DisallowIncomingV1, Supported::Yes, VoteBehavior::DefaultNo
|
||||
XRPL_FEATURE(XChainBridge, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(AMM, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(Clawback, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (UniversalNumber, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FEATURE(XRPFees, Supported::Yes, VoteBehavior::DefaultNo)
|
||||
XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::Yes, VoteBehavior::DefaultYes)
|
||||
|
||||
@@ -112,7 +113,6 @@ XRPL_RETIRE_FIX(RmSmallIncreasedQOffers)
|
||||
XRPL_RETIRE_FIX(STAmountCanonicalize)
|
||||
XRPL_RETIRE_FIX(TakerDryOfferRemoval)
|
||||
XRPL_RETIRE_FIX(TrustLinesToSelf)
|
||||
XRPL_RETIRE_FIX(UniversalNumber)
|
||||
|
||||
XRPL_RETIRE_FEATURE(Checks)
|
||||
XRPL_RETIRE_FEATURE(CheckCashMakesTrustLine)
|
||||
|
||||
@@ -887,6 +887,7 @@ TRANSACTION(ttVAULT_DELETE, 67, VaultDelete,
|
||||
MustDeleteAcct | DestroyMptIssuance | MustModifyVault,
|
||||
({
|
||||
{sfVaultID, SoeRequired},
|
||||
{sfMemoData, SoeOptional},
|
||||
}))
|
||||
|
||||
/** This transaction trades assets for shares with a vault. */
|
||||
@@ -954,7 +955,7 @@ TRANSACTION(ttLOAN_BROKER_SET, 74, LoanBrokerSet,
|
||||
Delegation::NotDelegable,
|
||||
featureLendingProtocol,
|
||||
CreatePseudoAcct | MayAuthorizeMpt, ({
|
||||
{sfVaultID, SoeRequired},
|
||||
{sfVaultID, SoeOptional},
|
||||
{sfLoanBrokerID, SoeOptional},
|
||||
{sfData, SoeOptional},
|
||||
{sfManagementFeeRate, SoeOptional},
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/protocol/detail/token_errors.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
@@ -13,7 +13,7 @@
|
||||
namespace xrpl {
|
||||
|
||||
template <class T>
|
||||
using B58Result = std::expected<T, std::error_code>;
|
||||
using B58Result = Expected<T, std::error_code>;
|
||||
|
||||
enum class TokenType : std::uint8_t {
|
||||
None = 1, // unused
|
||||
|
||||
@@ -48,14 +48,29 @@ public:
|
||||
// Transaction-specific field getters
|
||||
|
||||
/**
|
||||
* @brief Get sfVaultID (SoeRequired)
|
||||
* @return The field value.
|
||||
* @brief Get sfVaultID (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
SF_UINT256::type::value_type
|
||||
protocol_autogen::Optional<SF_UINT256::type::value_type>
|
||||
getVaultID() const
|
||||
{
|
||||
return this->tx_->at(sfVaultID);
|
||||
if (hasVaultID())
|
||||
{
|
||||
return this->tx_->at(sfVaultID);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfVaultID is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasVaultID() const
|
||||
{
|
||||
return this->tx_->isFieldPresent(sfVaultID);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,17 +243,15 @@ public:
|
||||
/**
|
||||
* @brief Construct a new LoanBrokerSetBuilder with required fields.
|
||||
* @param account The account initiating the transaction.
|
||||
* @param vaultID The sfVaultID field value.
|
||||
* @param sequence Optional sequence number for the transaction.
|
||||
* @param fee Optional fee for the transaction.
|
||||
*/
|
||||
LoanBrokerSetBuilder(SF_ACCOUNT::type::value_type account,
|
||||
std::decay_t<typename SF_UINT256::type::value_type> const& vaultID, std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
|
||||
std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
|
||||
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
|
||||
)
|
||||
: TransactionBuilderBase<LoanBrokerSetBuilder>(ttLOAN_BROKER_SET, account, sequence, fee)
|
||||
{
|
||||
setVaultID(vaultID);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,7 +271,7 @@ public:
|
||||
/** @brief Transaction-specific field setters */
|
||||
|
||||
/**
|
||||
* @brief Set sfVaultID (SoeRequired)
|
||||
* @brief Set sfVaultID (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
LoanBrokerSetBuilder&
|
||||
|
||||
@@ -57,6 +57,32 @@ public:
|
||||
{
|
||||
return this->tx_->at(sfVaultID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get sfMemoData (SoeOptional)
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
protocol_autogen::Optional<SF_VL::type::value_type>
|
||||
getMemoData() const
|
||||
{
|
||||
if (hasMemoData())
|
||||
{
|
||||
return this->tx_->at(sfMemoData);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if sfMemoData is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
hasMemoData() const
|
||||
{
|
||||
return this->tx_->isFieldPresent(sfMemoData);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -112,6 +138,17 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set sfMemoData (SoeOptional)
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
VaultDeleteBuilder&
|
||||
setMemoData(std::decay_t<typename SF_VL::type::value_type> const& value)
|
||||
{
|
||||
object_[sfMemoData] = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Build and return the VaultDelete wrapper.
|
||||
* @param publicKey The public key for signing.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/beast/net/IPEndpoint.h>
|
||||
|
||||
#include <boost/asio/ip/address.hpp>
|
||||
@@ -13,7 +14,6 @@
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace boost::asio::ssl {
|
||||
class context; // NOLINT(readability-identifier-naming) -- external library name
|
||||
@@ -21,8 +21,6 @@ class context; // NOLINT(readability-identifier-naming) -- external library nam
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
class Section;
|
||||
|
||||
/** Configuration information for a Server listening port. */
|
||||
struct Port
|
||||
{
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -54,10 +53,10 @@ public:
|
||||
/** Send a copy of data asynchronously. */
|
||||
/** @{ */
|
||||
void
|
||||
write(std::string_view s)
|
||||
write(std::string const& s)
|
||||
{
|
||||
if (!s.empty())
|
||||
write(s.data(), s.size());
|
||||
write(&s[0], std::distance(s.begin(), s.end()));
|
||||
}
|
||||
|
||||
template <typename BufferSequence>
|
||||
|
||||
@@ -161,7 +161,7 @@ public:
|
||||
setLedgerSeq(std::uint32_t lseq);
|
||||
|
||||
bool
|
||||
fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter const* filter);
|
||||
fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter);
|
||||
|
||||
// normal hash access functions
|
||||
|
||||
@@ -248,7 +248,7 @@ public:
|
||||
@param return The nodes known to be missing
|
||||
*/
|
||||
std::vector<std::pair<SHAMapNodeID, uint256>>
|
||||
getMissingNodes(int maxNodes, SHAMapSyncFilter const* filter);
|
||||
getMissingNodes(int maxNodes, SHAMapSyncFilter* filter);
|
||||
|
||||
bool
|
||||
getNodeFat(
|
||||
@@ -281,9 +281,9 @@ public:
|
||||
serializeRoot(Serializer& s) const;
|
||||
|
||||
SHAMapAddNode
|
||||
addRootNode(SHAMapHash const& hash, Slice const& rootNode, SHAMapSyncFilter const* filter);
|
||||
addRootNode(SHAMapHash const& hash, Slice const& rootNode, SHAMapSyncFilter* filter);
|
||||
SHAMapAddNode
|
||||
addKnownNode(SHAMapNodeID const& nodeID, Slice const& rawNode, SHAMapSyncFilter const* filter);
|
||||
addKnownNode(SHAMapNodeID const& nodeID, Slice const& rawNode, SHAMapSyncFilter* filter);
|
||||
|
||||
// status functions
|
||||
void
|
||||
@@ -343,11 +343,11 @@ private:
|
||||
SHAMapTreeNodePtr
|
||||
fetchNodeNT(SHAMapHash const& hash) const;
|
||||
SHAMapTreeNodePtr
|
||||
fetchNodeNT(SHAMapHash const& hash, SHAMapSyncFilter const* filter) const;
|
||||
fetchNodeNT(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
|
||||
SHAMapTreeNodePtr
|
||||
fetchNode(SHAMapHash const& hash) const;
|
||||
SHAMapTreeNodePtr
|
||||
checkFilter(SHAMapHash const& hash, SHAMapSyncFilter const* filter) const;
|
||||
checkFilter(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
|
||||
|
||||
/** Update hashes up to the root */
|
||||
void
|
||||
@@ -411,7 +411,7 @@ private:
|
||||
descendAsync(
|
||||
SHAMapInnerNode* parent,
|
||||
int branch,
|
||||
SHAMapSyncFilter const* filter,
|
||||
SHAMapSyncFilter* filter,
|
||||
bool& pending,
|
||||
descendCallback&&) const;
|
||||
|
||||
@@ -420,7 +420,7 @@ private:
|
||||
SHAMapInnerNode* parent,
|
||||
SHAMapNodeID const& parentID,
|
||||
int branch,
|
||||
SHAMapSyncFilter const* filter) const;
|
||||
SHAMapSyncFilter* filter) const;
|
||||
|
||||
// Non-storing
|
||||
// Does not hook the returned node to its parent
|
||||
@@ -461,7 +461,7 @@ private:
|
||||
|
||||
// basic parameters
|
||||
int max;
|
||||
SHAMapSyncFilter const* filter;
|
||||
SHAMapSyncFilter* filter;
|
||||
int const maxDefer;
|
||||
std::uint32_t generation;
|
||||
|
||||
@@ -500,11 +500,7 @@ private:
|
||||
// reads
|
||||
std::map<SHAMapInnerNode*, SHAMapNodeID> resumes;
|
||||
|
||||
MissingNodes(
|
||||
int max,
|
||||
SHAMapSyncFilter const* filter,
|
||||
int maxDefer,
|
||||
std::uint32_t generation)
|
||||
MissingNodes(int max, SHAMapSyncFilter* filter, int maxDefer, std::uint32_t generation)
|
||||
: max(max), filter(filter), maxDefer(maxDefer), generation(generation), deferred(0)
|
||||
{
|
||||
missingNodes.reserve(max);
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -128,7 +127,7 @@ operator<<(std::ostream& out, SHAMapNodeID const& node)
|
||||
deserializeSHAMapNodeID(void const* data, std::size_t size);
|
||||
|
||||
[[nodiscard]] inline std::optional<SHAMapNodeID>
|
||||
deserializeSHAMapNodeID(std::string_view s)
|
||||
deserializeSHAMapNodeID(std::string const& s)
|
||||
{
|
||||
return deserializeSHAMapNodeID(s.data(), s.size());
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/Expected.h> //
|
||||
#include <xrpl/beast/utility/Journal.h> // beast::Journal
|
||||
#include <xrpl/protocol/TER.h> // temMALFORMED
|
||||
#include <xrpl/protocol/UintTypes.h> // AccountID
|
||||
#include <xrpl/tx/Transactor.h> // NotTEC
|
||||
|
||||
#include <expected>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
// obj Contains a SignerEntries field that is an STArray.
|
||||
// journal For reporting error conditions.
|
||||
// annotation Source of SignerEntries, like "ledger" or "transaction".
|
||||
static std::expected<std::vector<SignerEntry>, NotTEC>
|
||||
static Expected<std::vector<SignerEntry>, NotTEC>
|
||||
deserialize(STObject const& obj, beast::Journal journal, std::string_view annotation);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/protocol/UintTypes.h>
|
||||
#include <xrpl/tx/Transactor.h>
|
||||
|
||||
#include <expected>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
// NOLINTBEGIN(readability-redundant-member-init)
|
||||
@@ -62,7 +61,7 @@ public:
|
||||
ReadView const& view,
|
||||
beast::Journal const& j) override;
|
||||
|
||||
static std::expected<MPTID, TER>
|
||||
static Expected<MPTID, TER>
|
||||
create(ApplyView& view, beast::Journal journal, MPTCreateArgs const& args);
|
||||
};
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
#include <xrpl/tx/Transactor.h>
|
||||
|
||||
#include <expected>
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
class VaultClawback : public Transactor
|
||||
@@ -36,7 +34,7 @@ public:
|
||||
beast::Journal const& j) override;
|
||||
|
||||
private:
|
||||
std::expected<std::pair<STAmount, STAmount>, TER>
|
||||
Expected<std::pair<STAmount, STAmount>, TER>
|
||||
assetsToClawback(
|
||||
SLE::ref vault,
|
||||
SLE::const_ref sleShareIssuance,
|
||||
|
||||
@@ -10,14 +10,11 @@ cmake --version
|
||||
conan --version
|
||||
curl --version
|
||||
doxygen --version
|
||||
file --version
|
||||
g++ --version
|
||||
gcc --version
|
||||
gcov --version
|
||||
gcovr --version
|
||||
gh --version
|
||||
git --version
|
||||
git-cliff --version
|
||||
gpg --version
|
||||
less --version
|
||||
make --version
|
||||
|
||||
@@ -13,11 +13,8 @@ in
|
||||
conan
|
||||
curlMinimal # needed for codecov/codecov-action
|
||||
doxygen
|
||||
file # needed for cpack in Clio
|
||||
gcovr
|
||||
gh
|
||||
git
|
||||
git-cliff
|
||||
gnumake
|
||||
gnupg # needed for signing commits & codecov/codecov-action
|
||||
llvmPackages_22.clang-tools
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <xrpl/config/BasicConfig.h>
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
|
||||
#include <xrpl/basics/StringUtilities.h>
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
class StatsDHookImpl : public HookImpl, public StatsDMetricBase
|
||||
{
|
||||
public:
|
||||
StatsDHookImpl(HandlerType handler, std::shared_ptr<StatsDCollectorImp> impl);
|
||||
StatsDHookImpl(HandlerType handler, std::shared_ptr<StatsDCollectorImp> const& impl);
|
||||
|
||||
~StatsDHookImpl() override;
|
||||
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
class StatsDCounterImpl : public CounterImpl, public StatsDMetricBase
|
||||
{
|
||||
public:
|
||||
StatsDCounterImpl(std::string name, std::shared_ptr<StatsDCollectorImp> impl);
|
||||
StatsDCounterImpl(std::string name, std::shared_ptr<StatsDCollectorImp> const& impl);
|
||||
|
||||
~StatsDCounterImpl() override;
|
||||
|
||||
@@ -115,7 +115,7 @@ private:
|
||||
class StatsDEventImpl : public EventImpl
|
||||
{
|
||||
public:
|
||||
StatsDEventImpl(std::string name, std::shared_ptr<StatsDCollectorImp> impl);
|
||||
StatsDEventImpl(std::string name, std::shared_ptr<StatsDCollectorImp> const& impl);
|
||||
|
||||
~StatsDEventImpl() override = default;
|
||||
|
||||
@@ -140,7 +140,7 @@ private:
|
||||
class StatsDGaugeImpl : public GaugeImpl, public StatsDMetricBase
|
||||
{
|
||||
public:
|
||||
StatsDGaugeImpl(std::string name, std::shared_ptr<StatsDCollectorImp> impl);
|
||||
StatsDGaugeImpl(std::string name, std::shared_ptr<StatsDCollectorImp> const& impl);
|
||||
|
||||
~StatsDGaugeImpl() override;
|
||||
|
||||
@@ -174,7 +174,7 @@ private:
|
||||
class StatsDMeterImpl : public MeterImpl, public StatsDMetricBase
|
||||
{
|
||||
public:
|
||||
explicit StatsDMeterImpl(std::string name, std::shared_ptr<StatsDCollectorImp> impl);
|
||||
explicit StatsDMeterImpl(std::string name, std::shared_ptr<StatsDCollectorImp> const& impl);
|
||||
|
||||
~StatsDMeterImpl() override;
|
||||
|
||||
@@ -478,8 +478,8 @@ public:
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
StatsDHookImpl::StatsDHookImpl(HandlerType handler, std::shared_ptr<StatsDCollectorImp> impl)
|
||||
: impl_(std::move(impl)), handler_(std::move(handler))
|
||||
StatsDHookImpl::StatsDHookImpl(HandlerType handler, std::shared_ptr<StatsDCollectorImp> const& impl)
|
||||
: impl_(impl), handler_(std::move(handler))
|
||||
{
|
||||
impl_->add(*this);
|
||||
}
|
||||
@@ -497,8 +497,10 @@ StatsDHookImpl::doProcess()
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
StatsDCounterImpl::StatsDCounterImpl(std::string name, std::shared_ptr<StatsDCollectorImp> impl)
|
||||
: impl_(std::move(impl)), name_(std::move(name))
|
||||
StatsDCounterImpl::StatsDCounterImpl(
|
||||
std::string name,
|
||||
std::shared_ptr<StatsDCollectorImp> const& impl)
|
||||
: impl_(impl), name_(std::move(name))
|
||||
{
|
||||
impl_->add(*this);
|
||||
}
|
||||
@@ -548,8 +550,8 @@ StatsDCounterImpl::doProcess()
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
StatsDEventImpl::StatsDEventImpl(std::string name, std::shared_ptr<StatsDCollectorImp> impl)
|
||||
: impl_(std::move(impl)), name_(std::move(name))
|
||||
StatsDEventImpl::StatsDEventImpl(std::string name, std::shared_ptr<StatsDCollectorImp> const& impl)
|
||||
: impl_(impl), name_(std::move(name))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -575,8 +577,8 @@ StatsDEventImpl::doNotify(EventImpl::value_type const& value)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
StatsDGaugeImpl::StatsDGaugeImpl(std::string name, std::shared_ptr<StatsDCollectorImp> impl)
|
||||
: impl_(std::move(impl)), name_(std::move(name))
|
||||
StatsDGaugeImpl::StatsDGaugeImpl(std::string name, std::shared_ptr<StatsDCollectorImp> const& impl)
|
||||
: impl_(impl), name_(std::move(name))
|
||||
{
|
||||
impl_->add(*this);
|
||||
}
|
||||
@@ -662,8 +664,8 @@ StatsDGaugeImpl::doProcess()
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
StatsDMeterImpl::StatsDMeterImpl(std::string name, std::shared_ptr<StatsDCollectorImp> impl)
|
||||
: impl_(std::move(impl)), name_(std::move(name))
|
||||
StatsDMeterImpl::StatsDMeterImpl(std::string name, std::shared_ptr<StatsDCollectorImp> const& impl)
|
||||
: impl_(impl), name_(std::move(name))
|
||||
{
|
||||
impl_->add(*this);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -307,7 +306,7 @@ RFC1751::standard(std::string& strWord)
|
||||
|
||||
// Binary search of dictionary.
|
||||
int
|
||||
RFC1751::wsrch(std::string_view strWord, int iMin, int iMax)
|
||||
RFC1751::wsrch(std::string const& strWord, int iMin, int iMax)
|
||||
{
|
||||
int iResult = -1;
|
||||
|
||||
|
||||
@@ -40,10 +40,14 @@ CanonicalTXSet::accountKey(AccountID const& account)
|
||||
}
|
||||
|
||||
void
|
||||
CanonicalTXSet::insert(std::shared_ptr<STTx const> txn)
|
||||
CanonicalTXSet::insert(std::shared_ptr<STTx const> const& txn)
|
||||
{
|
||||
Key key(accountKey(txn->getAccountID(sfAccount)), txn->getSeqProxy(), txn->getTransactionID());
|
||||
map_.emplace(key, std::move(txn));
|
||||
map_.insert(
|
||||
std::make_pair(
|
||||
Key(accountKey(txn->getAccountID(sfAccount)),
|
||||
txn->getSeqProxy(),
|
||||
txn->getTransactionID()),
|
||||
txn));
|
||||
}
|
||||
|
||||
std::shared_ptr<STTx const>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <xrpl/ledger/helpers/AMMHelpers.h>
|
||||
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/Number.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
@@ -33,7 +34,6 @@
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <tuple>
|
||||
@@ -433,7 +433,7 @@ ammPoolHolds(
|
||||
return std::make_pair(assetInBalance, assetOutBalance);
|
||||
}
|
||||
|
||||
std::expected<std::tuple<STAmount, STAmount, STAmount>, TER>
|
||||
Expected<std::tuple<STAmount, STAmount, STAmount>, TER>
|
||||
ammHolds(
|
||||
ReadView const& view,
|
||||
SLE const& ammSle,
|
||||
@@ -489,7 +489,7 @@ ammHolds(
|
||||
return std::make_optional(std::make_pair(asset1, asset2));
|
||||
}();
|
||||
if (!assets)
|
||||
return std::unexpected(tecAMM_INVALID_TOKENS);
|
||||
return Unexpected(tecAMM_INVALID_TOKENS);
|
||||
auto const [amount1, amount2] = ammPoolHolds(
|
||||
view,
|
||||
ammSle.getAccountID(sfAccount),
|
||||
@@ -821,7 +821,7 @@ initializeFeeAuctionVote(
|
||||
auctionSlot.makeFieldAbsent(sfAuthAccounts);
|
||||
}
|
||||
|
||||
std::expected<bool, TER>
|
||||
Expected<bool, TER>
|
||||
isOnlyLiquidityProvider(ReadView const& view, Issue const& ammIssue, AccountID const& lpAccount)
|
||||
{
|
||||
// Liquidity Provider (LP) must have one LPToken trustline
|
||||
@@ -852,18 +852,18 @@ isOnlyLiquidityProvider(ReadView const& view, Issue const& ammIssue, AccountID c
|
||||
{
|
||||
auto const ownerDir = view.read(currentIndex);
|
||||
if (!ownerDir)
|
||||
return std::unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
return Unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
for (auto const& key : ownerDir->getFieldV256(sfIndexes))
|
||||
{
|
||||
auto const sle = view.read(keylet::child(key));
|
||||
if (!sle)
|
||||
return std::unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
return Unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
auto const entryType = sle->getFieldU16(sfLedgerEntryType);
|
||||
// Only one AMM object
|
||||
if (entryType == ltAMM)
|
||||
{
|
||||
if (hasAMM)
|
||||
return std::unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
return Unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
hasAMM = true;
|
||||
continue;
|
||||
}
|
||||
@@ -873,7 +873,7 @@ isOnlyLiquidityProvider(ReadView const& view, Issue const& ammIssue, AccountID c
|
||||
continue;
|
||||
}
|
||||
if (entryType != ltRIPPLE_STATE)
|
||||
return std::unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
return Unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
auto const lowLimit = sle->getFieldAmount(sfLowLimit);
|
||||
auto const highLimit = sle->getFieldAmount(sfHighLimit);
|
||||
auto const isLPTrustline =
|
||||
@@ -889,12 +889,12 @@ isOnlyLiquidityProvider(ReadView const& view, Issue const& ammIssue, AccountID c
|
||||
{
|
||||
// LP has exactly one LPToken trustline
|
||||
if (++nLPTokenTrustLines > 1)
|
||||
return std::unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
return Unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
}
|
||||
// AMM account has at most two IOU trustlines
|
||||
else if (++nIOUTrustLines > 2)
|
||||
{
|
||||
return std::unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
return Unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
// Another Liquidity Provider LPToken trustline
|
||||
@@ -905,7 +905,7 @@ isOnlyLiquidityProvider(ReadView const& view, Issue const& ammIssue, AccountID c
|
||||
// AMM account has at most two IOU trustlines
|
||||
else if (++nIOUTrustLines > 2)
|
||||
{
|
||||
return std::unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
return Unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
auto const uNodeNext = ownerDir->getFieldU64(sfIndexNext);
|
||||
@@ -913,15 +913,15 @@ isOnlyLiquidityProvider(ReadView const& view, Issue const& ammIssue, AccountID c
|
||||
{
|
||||
if (nLPTokenTrustLines != 1 || (nIOUTrustLines == 0 && nMPT == 0) ||
|
||||
(nIOUTrustLines > 2 || nMPT > 2) || (nIOUTrustLines + nMPT) > 2)
|
||||
return std::unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
return Unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
return true;
|
||||
}
|
||||
currentIndex = keylet::page(root, uNodeNext);
|
||||
}
|
||||
return std::unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
return Unexpected<TER>(tecINTERNAL); // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
std::expected<bool, TER>
|
||||
Expected<bool, TER>
|
||||
verifyAndAdjustLPTokenBalance(
|
||||
Sandbox& sb,
|
||||
STAmount const& lpTokens,
|
||||
@@ -931,7 +931,7 @@ verifyAndAdjustLPTokenBalance(
|
||||
auto const res = isOnlyLiquidityProvider(sb, lpTokens.get<Issue>(), account);
|
||||
if (!res.has_value())
|
||||
{
|
||||
return std::unexpected<TER>(res.error());
|
||||
return Unexpected<TER>(res.error());
|
||||
}
|
||||
|
||||
if (res.value())
|
||||
@@ -944,7 +944,7 @@ verifyAndAdjustLPTokenBalance(
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::unexpected<TER>(tecAMM_INVALID_TOKENS);
|
||||
return Unexpected<TER>(tecAMM_INVALID_TOKENS);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
|
||||
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
@@ -21,7 +22,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
@@ -202,7 +202,7 @@ isPseudoAccount(SLE::const_pointer sleAcct, std::set<SField const*> const& pseud
|
||||
}) > 0;
|
||||
}
|
||||
|
||||
std::expected<SLE::pointer, TER>
|
||||
Expected<SLE::pointer, TER>
|
||||
createPseudoAccount(ApplyView& view, uint256 const& pseudoOwnerKey, SField const& ownerField)
|
||||
{
|
||||
[[maybe_unused]]
|
||||
@@ -216,7 +216,7 @@ createPseudoAccount(ApplyView& view, uint256 const& pseudoOwnerKey, SField const
|
||||
|
||||
auto const accountId = pseudoAccountAddress(view, pseudoOwnerKey);
|
||||
if (accountId == beast::kZero)
|
||||
return std::unexpected(tecDUPLICATE);
|
||||
return Unexpected(tecDUPLICATE);
|
||||
|
||||
// Create pseudo-account.
|
||||
auto account = std::make_shared<SLE>(keylet::account(accountId));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <xrpl/ledger/helpers/CredentialHelpers.h>
|
||||
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/Slice.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
@@ -23,7 +24,6 @@
|
||||
#include <xrpl/protocol/digest.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <limits>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
@@ -43,7 +43,7 @@ checkExpired(SLE const& sleCredential, NetClock::time_point const& closed)
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
static std::expected<bool, TER>
|
||||
static Expected<bool, TER>
|
||||
removeExpired(ApplyView& view, STVector256 const& arr, beast::Journal const j)
|
||||
{
|
||||
auto const closeTime = view.header().parentCloseTime;
|
||||
@@ -61,7 +61,7 @@ removeExpired(ApplyView& view, STVector256 const& arr, beast::Journal const j)
|
||||
// delete expired credentials even if the transaction failed
|
||||
auto const err = deleteSLE(view, sleCred, j);
|
||||
if (view.rules().enabled(fixCleanup3_1_3) && !isTesSuccess(err))
|
||||
return std::unexpected(err);
|
||||
return Unexpected(err);
|
||||
foundExpired = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <xrpl/ledger/helpers/LendingHelpers.h>
|
||||
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/Number.h>
|
||||
#include <xrpl/basics/chrono.h>
|
||||
@@ -24,7 +25,6 @@
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
@@ -514,7 +514,7 @@ doPayment(
|
||||
* The function preserves accumulated rounding errors across the re-amortization
|
||||
* to ensure the loan state remains consistent with its payment history.
|
||||
*/
|
||||
std::expected<std::pair<LoanPaymentParts, LoanProperties>, TER>
|
||||
Expected<std::pair<LoanPaymentParts, LoanProperties>, TER>
|
||||
tryOverpayment(
|
||||
Rules const& rules,
|
||||
Asset const& asset,
|
||||
@@ -643,7 +643,7 @@ tryOverpayment(
|
||||
JLOG(j.warn()) << "Principal overpayment would cause the loan to be in "
|
||||
"an invalid state. Ignore the overpayment";
|
||||
|
||||
return std::unexpected(tesSUCCESS);
|
||||
return Unexpected(tesSUCCESS);
|
||||
}
|
||||
|
||||
// Validate that all computed properties are reasonable. These checks should
|
||||
@@ -660,7 +660,7 @@ tryOverpayment(
|
||||
<< ", PeriodicPayment : " << newLoanProperties.periodicPayment
|
||||
<< ", ManagementFeeOwedToBroker: "
|
||||
<< newLoanProperties.loanState.managementFeeDue;
|
||||
return std::unexpected(tesSUCCESS);
|
||||
return Unexpected(tesSUCCESS);
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -685,7 +685,7 @@ tryOverpayment(
|
||||
{
|
||||
JLOG(j.warn()) << "Principal overpayment would increase the value of "
|
||||
"the loan. Ignore the overpayment";
|
||||
return std::unexpected(tesSUCCESS);
|
||||
return Unexpected(tesSUCCESS);
|
||||
}
|
||||
|
||||
return std::make_pair(
|
||||
@@ -718,7 +718,7 @@ tryOverpayment(
|
||||
* gracefully without corrupting the ledger data.
|
||||
*/
|
||||
template <class NumberProxy>
|
||||
std::expected<LoanPaymentParts, TER>
|
||||
Expected<LoanPaymentParts, TER>
|
||||
doOverpayment(
|
||||
Rules const& rules,
|
||||
Asset const& asset,
|
||||
@@ -760,7 +760,7 @@ doOverpayment(
|
||||
managementFeeRate,
|
||||
j);
|
||||
if (!ret)
|
||||
return std::unexpected(ret.error());
|
||||
return Unexpected(ret.error());
|
||||
|
||||
auto const& [loanPaymentParts, newLoanProperties] = *ret;
|
||||
auto const newRoundedLoanState = newLoanProperties.loanState;
|
||||
@@ -774,7 +774,7 @@ doOverpayment(
|
||||
JLOG(j.warn()) << "Overpayment not allowed: principal "
|
||||
<< "outstanding did not decrease. Before: " << *principalOutstandingProxy
|
||||
<< ". After: " << newRoundedLoanState.principalOutstanding;
|
||||
return std::unexpected(tesSUCCESS);
|
||||
return Unexpected(tesSUCCESS);
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -798,44 +798,44 @@ doOverpayment(
|
||||
// (P * factor) / factor round-trip can leave the new principal one
|
||||
// scale-unit high, so these equalities do not hold on the pre-amendment
|
||||
// code path and must be gated to match the fix they verify.
|
||||
//
|
||||
// The valueChange returned by tryOverpayment satisfies
|
||||
// valueChange = (newInterestDue - oldInterestDue) + untrackedInterest.
|
||||
// Using the loan-state identity v = p + i + m and the adjacent
|
||||
// `principal change agrees` assertion (dp = oldP - newP), this
|
||||
// rearranges into three independently-computable terms:
|
||||
//
|
||||
// 1. TVO change beyond what principal repayment alone explains:
|
||||
// newTVO - (oldTVO - dp)
|
||||
// 2. Management fee released by re-amortization (positive when
|
||||
// mfee decreased; zero when managementFeeRate == 0):
|
||||
// oldMfee - newMfee
|
||||
// 3. The overpayment's penalty interest part (= untrackedInterest
|
||||
// for the overpayment path; see computeOverpaymentComponents):
|
||||
// trackedInterestPart()
|
||||
[[maybe_unused]] bool const fix320Enabled = rules.enabled(fixCleanup3_2_0);
|
||||
XRPL_ASSERT_IF(
|
||||
fix320Enabled,
|
||||
overpaymentComponents.trackedPrincipalDelta ==
|
||||
principalOutstandingProxy - newRoundedLoanState.principalOutstanding,
|
||||
"xrpl::detail::doOverpayment : principal change agrees");
|
||||
if (rules.enabled(fixCleanup3_2_0))
|
||||
{
|
||||
// The valueChange returned by tryOverpayment satisfies
|
||||
// valueChange = (newInterestDue - oldInterestDue) + untrackedInterest.
|
||||
// Using the loan-state identity v = p + i + m and the adjacent
|
||||
// `principal change agrees` assertion (dp = oldP - newP), this
|
||||
// rearranges into three independently-computable terms:
|
||||
//
|
||||
// 1. TVO change beyond what principal repayment alone explains:
|
||||
// newTVO - (oldTVO - dp)
|
||||
// 2. Management fee released by re-amortization (positive when
|
||||
// mfee decreased; zero when managementFeeRate == 0):
|
||||
// oldMfee - newMfee
|
||||
// 3. The overpayment's penalty interest part (= untrackedInterest
|
||||
// for the overpayment path; see computeOverpaymentComponents):
|
||||
// trackedInterestPart()
|
||||
[[maybe_unused]] Number const tvoChange = newRoundedLoanState.valueOutstanding -
|
||||
(totalValueOutstandingProxy - overpaymentComponents.trackedPrincipalDelta);
|
||||
[[maybe_unused]] Number const managementFeeReleased =
|
||||
managementFeeOutstandingProxy - newRoundedLoanState.managementFeeDue;
|
||||
[[maybe_unused]] Number const interestPart = overpaymentComponents.trackedInterestPart();
|
||||
|
||||
XRPL_ASSERT_IF(
|
||||
fix320Enabled,
|
||||
[&] {
|
||||
Number const tvoChange = newRoundedLoanState.valueOutstanding -
|
||||
(totalValueOutstandingProxy - overpaymentComponents.trackedPrincipalDelta);
|
||||
Number const managementFeeReleased =
|
||||
managementFeeOutstandingProxy - newRoundedLoanState.managementFeeDue;
|
||||
Number const interestPart = overpaymentComponents.trackedInterestPart();
|
||||
return loanPaymentParts.valueChange == tvoChange + managementFeeReleased + interestPart;
|
||||
}(),
|
||||
"xrpl::detail::doOverpayment : interest paid agrees");
|
||||
XRPL_ASSERT_PARTS(
|
||||
overpaymentComponents.trackedPrincipalDelta ==
|
||||
principalOutstandingProxy - newRoundedLoanState.principalOutstanding,
|
||||
"xrpl::detail::doOverpayment",
|
||||
"principal change agrees");
|
||||
|
||||
XRPL_ASSERT_IF(
|
||||
fix320Enabled,
|
||||
overpaymentComponents.trackedPrincipalDelta == loanPaymentParts.principalPaid,
|
||||
"xrpl::detail::doOverpayment : principal payment matches");
|
||||
XRPL_ASSERT_PARTS(
|
||||
loanPaymentParts.valueChange == tvoChange + managementFeeReleased + interestPart,
|
||||
"xrpl::detail::doOverpayment",
|
||||
"interest paid agrees");
|
||||
|
||||
XRPL_ASSERT_PARTS(
|
||||
overpaymentComponents.trackedPrincipalDelta == loanPaymentParts.principalPaid,
|
||||
"xrpl::detail::doOverpayment",
|
||||
"principal payment matches");
|
||||
}
|
||||
|
||||
// All validations passed, so update the proxy objects (which will
|
||||
// modify the actual Loan ledger object)
|
||||
@@ -860,7 +860,7 @@ doOverpayment(
|
||||
*
|
||||
* Implements equation (15) from XLS-66 spec, Section A-2 Equation Glossary
|
||||
*/
|
||||
std::expected<ExtendedPaymentComponents, TER>
|
||||
Expected<ExtendedPaymentComponents, TER>
|
||||
computeLatePayment(
|
||||
Asset const& asset,
|
||||
ApplyView const& view,
|
||||
@@ -877,7 +877,7 @@ computeLatePayment(
|
||||
// Check if the due date has passed. If not, reject the payment as
|
||||
// being too soon
|
||||
if (!hasExpired(view, nextDueDate))
|
||||
return std::unexpected(tecTOO_SOON);
|
||||
return Unexpected(tecTOO_SOON);
|
||||
|
||||
// Calculate the penalty interest based on how long the payment is overdue.
|
||||
auto const latePaymentInterest = loanLatePaymentInterest(
|
||||
@@ -929,7 +929,7 @@ computeLatePayment(
|
||||
{
|
||||
JLOG(j.warn()) << "Late loan payment amount is insufficient. Due: " << late.totalDue
|
||||
<< ", paid: " << amount;
|
||||
return std::unexpected(tecINSUFFICIENT_PAYMENT);
|
||||
return Unexpected(tecINSUFFICIENT_PAYMENT);
|
||||
}
|
||||
|
||||
return late;
|
||||
@@ -954,7 +954,7 @@ computeLatePayment(
|
||||
*
|
||||
* Implements equation (26) from XLS-66 spec, Section A-2 Equation Glossary
|
||||
*/
|
||||
std::expected<ExtendedPaymentComponents, TER>
|
||||
Expected<ExtendedPaymentComponents, TER>
|
||||
computeFullPayment(
|
||||
Asset const& asset,
|
||||
ApplyView& view,
|
||||
@@ -979,7 +979,7 @@ computeFullPayment(
|
||||
{
|
||||
// If this is the last payment, it has to be a regular payment
|
||||
JLOG(j.warn()) << "Last payment cannot be a full payment.";
|
||||
return std::unexpected(tecKILLED);
|
||||
return Unexpected(tecKILLED);
|
||||
}
|
||||
|
||||
// Calculate the theoretical principal based on the payment schedule.
|
||||
@@ -1059,7 +1059,7 @@ computeFullPayment(
|
||||
{
|
||||
// If the payment is less than the full payment amount, it's not
|
||||
// sufficient to be a full payment.
|
||||
return std::unexpected(tecINSUFFICIENT_PAYMENT);
|
||||
return Unexpected(tecINSUFFICIENT_PAYMENT);
|
||||
}
|
||||
|
||||
return full;
|
||||
@@ -1326,11 +1326,13 @@ computeOverpaymentComponents(
|
||||
TenthBips32 const overpaymentFeeRate,
|
||||
TenthBips16 const managementFeeRate)
|
||||
{
|
||||
XRPL_ASSERT_IF(
|
||||
rules.enabled(fixCleanup3_2_0),
|
||||
overpayment > 0 && isRounded(asset, overpayment, loanScale),
|
||||
"xrpl::detail::computeOverpaymentComponents : valid overpayment "
|
||||
"amount");
|
||||
if (rules.enabled(fixCleanup3_2_0))
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
overpayment > 0 && isRounded(asset, overpayment, loanScale),
|
||||
"xrpl::detail::computeOverpaymentComponents : valid overpayment "
|
||||
"amount");
|
||||
}
|
||||
|
||||
// First, deduct the fixed overpayment fee from the total amount.
|
||||
// This reduces the effective payment that will be applied to the loan.
|
||||
@@ -1780,7 +1782,7 @@ computeLoanProperties(
|
||||
* It is an implementation of the make_payment function from the XLS-66
|
||||
* spec. Section 3.2.4.4
|
||||
*/
|
||||
std::expected<LoanPaymentParts, TER>
|
||||
Expected<LoanPaymentParts, TER>
|
||||
loanMakePayment(
|
||||
Asset const& asset,
|
||||
ApplyView& view,
|
||||
@@ -1800,7 +1802,7 @@ loanMakePayment(
|
||||
// Loan complete this is already checked in LoanPay::preclaim()
|
||||
// LCOV_EXCL_START
|
||||
JLOG(j.warn()) << "Loan is already paid off.";
|
||||
return std::unexpected(tecKILLED);
|
||||
return Unexpected(tecKILLED);
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -1812,7 +1814,7 @@ loanMakePayment(
|
||||
if (*nextDueDateProxy == 0)
|
||||
{
|
||||
JLOG(j.warn()) << "Loan next payment due date is not set.";
|
||||
return std::unexpected(tecINTERNAL);
|
||||
return Unexpected(tecINTERNAL);
|
||||
}
|
||||
|
||||
std::int32_t const loanScale = loan->at(sfLoanScale);
|
||||
@@ -1850,7 +1852,7 @@ loanMakePayment(
|
||||
<< startDate << ", prev payment due date is " << prevPaymentDateProxy
|
||||
<< ", next payment due date is " << nextDueDateProxy << ", ledger time is "
|
||||
<< view.parentCloseTime().time_since_epoch().count();
|
||||
return std::unexpected(tecEXPIRED);
|
||||
return Unexpected(tecEXPIRED);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
@@ -1900,13 +1902,13 @@ loanMakePayment(
|
||||
// error() will be the TER returned if a payment is not made. It
|
||||
// will only evaluate to true if it's unsuccessful. Otherwise,
|
||||
// tesSUCCESS means nothing was done, so continue.
|
||||
return std::unexpected(fullPaymentComponents.error());
|
||||
return Unexpected(fullPaymentComponents.error());
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START
|
||||
UNREACHABLE("xrpl::loanMakePayment : invalid full payment result");
|
||||
JLOG(j.error()) << "Full payment computation failed unexpectedly.";
|
||||
return std::unexpected(tecINTERNAL);
|
||||
return Unexpected(tecINTERNAL);
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -1968,13 +1970,13 @@ loanMakePayment(
|
||||
{
|
||||
// error() will be the TER returned if a payment is not made. It
|
||||
// will only evaluate to true if it's unsuccessful.
|
||||
return std::unexpected(latePaymentComponents.error());
|
||||
return Unexpected(latePaymentComponents.error());
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START
|
||||
UNREACHABLE("xrpl::loanMakePayment : invalid late payment result");
|
||||
JLOG(j.error()) << "Late payment computation failed unexpectedly.";
|
||||
return std::unexpected(tecINTERNAL);
|
||||
return Unexpected(tecINTERNAL);
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
|
||||
@@ -2041,7 +2043,7 @@ loanMakePayment(
|
||||
{
|
||||
JLOG(j.warn()) << "Regular loan payment amount is insufficient. Due: " << periodic.totalDue
|
||||
<< ", paid: " << amount;
|
||||
return std::unexpected(tecINSUFFICIENT_PAYMENT);
|
||||
return Unexpected(tecINSUFFICIENT_PAYMENT);
|
||||
}
|
||||
|
||||
XRPL_ASSERT_PARTS(
|
||||
@@ -2127,7 +2129,7 @@ loanMakePayment(
|
||||
// made. It will only evaluate to true if it's unsuccessful.
|
||||
// Otherwise, tesSUCCESS means nothing was done, so
|
||||
// continue.
|
||||
return std::unexpected(overResult.error());
|
||||
return Unexpected(overResult.error());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -736,10 +736,10 @@ unlockEscrowMPT(
|
||||
STAmount const& grossAmount,
|
||||
beast::Journal j)
|
||||
{
|
||||
XRPL_ASSERT_IF(
|
||||
!view.rules().enabled(fixTokenEscrowV1),
|
||||
netAmount == grossAmount,
|
||||
"xrpl::unlockEscrowMPT : netAmount == grossAmount");
|
||||
if (!view.rules().enabled(fixTokenEscrowV1))
|
||||
{
|
||||
XRPL_ASSERT(netAmount == grossAmount, "xrpl::unlockEscrowMPT : netAmount == grossAmount");
|
||||
}
|
||||
|
||||
auto const& issuer = netAmount.getIssuer();
|
||||
auto const& mptIssue = netAmount.get<MPTIssue>();
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
boost::asio::io_context& ioContext,
|
||||
unsigned short const port,
|
||||
std::size_t maxResponseSize,
|
||||
beast::Journal const& j)
|
||||
beast::Journal& j)
|
||||
: socket_(
|
||||
ioContext,
|
||||
gHttpClientSslContext->context()) // NOLINT(bugprone-unchecked-optional-access)
|
||||
@@ -552,7 +552,7 @@ HTTPClient::get(
|
||||
std::function<
|
||||
bool(boost::system::error_code const& ecResult, int iStatus, std::string const& strData)>
|
||||
complete,
|
||||
beast::Journal const& j)
|
||||
beast::Journal& j)
|
||||
{
|
||||
auto client = std::make_shared<HTTPClientImp>(ioContext, port, responseMax, j);
|
||||
client->get(bSSL, deqSites, strPath, timeout, complete);
|
||||
@@ -570,7 +570,7 @@ HTTPClient::get(
|
||||
std::function<
|
||||
bool(boost::system::error_code const& ecResult, int iStatus, std::string const& strData)>
|
||||
complete,
|
||||
beast::Journal const& j)
|
||||
beast::Journal& j)
|
||||
{
|
||||
std::deque<std::string> const deqSites(1, strSite);
|
||||
|
||||
@@ -590,7 +590,7 @@ HTTPClient::request(
|
||||
std::function<
|
||||
bool(boost::system::error_code const& ecResult, int iStatus, std::string const& strData)>
|
||||
complete,
|
||||
beast::Journal const& j)
|
||||
beast::Journal& j)
|
||||
{
|
||||
std::deque<std::string> const deqSites(1, strSite);
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
#include <xrpl/nodestore/Database.h>
|
||||
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/beast/core/CurrentThreadName.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/config/BasicConfig.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/json/json_forwards.h>
|
||||
#include <xrpl/json/json_value.h>
|
||||
#include <xrpl/nodestore/Backend.h>
|
||||
@@ -39,8 +38,8 @@ Database::Database(
|
||||
beast::Journal journal)
|
||||
: j_(journal)
|
||||
, scheduler_(scheduler)
|
||||
, earliestLedgerSeq_(get<std::uint32_t>(config, Keys::kEarliestSeq, kXrpLedgerEarliestSeq))
|
||||
, requestBundle_(get<int>(config, Keys::kRqBundle, 4))
|
||||
, earliestLedgerSeq_(get<std::uint32_t>(config, "earliest_seq", kXrpLedgerEarliestSeq))
|
||||
, requestBundle_(get<int>(config, "rq_bundle", 4))
|
||||
, readThreads_(std::max(1, readThreads))
|
||||
{
|
||||
XRPL_ASSERT(readThreads, "xrpl::NodeStore::Database::Database : nonzero threads input");
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include <xrpl/nodestore/detail/DatabaseRotatingImp.h>
|
||||
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/basics/Blob.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/config/BasicConfig.h>
|
||||
#include <xrpl/nodestore/Backend.h>
|
||||
#include <xrpl/nodestore/Database.h>
|
||||
#include <xrpl/nodestore/DatabaseRotating.h>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#include <xrpl/nodestore/detail/ManagerImp.h>
|
||||
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/config/BasicConfig.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/nodestore/Backend.h>
|
||||
#include <xrpl/nodestore/Database.h>
|
||||
#include <xrpl/nodestore/Manager.h>
|
||||
@@ -67,7 +66,7 @@ ManagerImp::makeBackend(
|
||||
Scheduler& scheduler,
|
||||
beast::Journal journal)
|
||||
{
|
||||
std::string const type{get(parameters, Keys::kType)};
|
||||
std::string const type{get(parameters, "type")};
|
||||
if (type.empty())
|
||||
missingBackend();
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/config/BasicConfig.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/nodestore/Backend.h>
|
||||
#include <xrpl/nodestore/Factory.h>
|
||||
#include <xrpl/nodestore/Manager.h>
|
||||
@@ -91,7 +90,7 @@ private:
|
||||
|
||||
public:
|
||||
MemoryBackend(size_t keyBytes, Section const& keyValues, beast::Journal journal)
|
||||
: name_(get(keyValues, Keys::kPath)), journal_(journal)
|
||||
: name_(get(keyValues, "path")), journal_(journal)
|
||||
{
|
||||
boost::ignore_unused(journal_); // Keep unused journal_ just in case.
|
||||
if (name_.empty())
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/beast/core/LexicalCast.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/config/BasicConfig.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/nodestore/Backend.h>
|
||||
#include <xrpl/nodestore/Factory.h>
|
||||
#include <xrpl/nodestore/Manager.h>
|
||||
@@ -73,7 +72,7 @@ public:
|
||||
: j(journal)
|
||||
, keyBytes(keyBytes)
|
||||
, burstSize(burstSize)
|
||||
, name(get(keyValues, Keys::kPath))
|
||||
, name(get(keyValues, "path"))
|
||||
, blockSize(parseBlockSize(name, keyValues, journal))
|
||||
, deletePath(false)
|
||||
, scheduler(scheduler)
|
||||
@@ -92,7 +91,7 @@ public:
|
||||
: j(journal)
|
||||
, keyBytes(keyBytes)
|
||||
, burstSize(burstSize)
|
||||
, name(get(keyValues, Keys::kPath))
|
||||
, name(get(keyValues, "path"))
|
||||
, blockSize(parseBlockSize(name, keyValues, journal))
|
||||
, db(context)
|
||||
, deletePath(false)
|
||||
@@ -360,7 +359,7 @@ private:
|
||||
std::size_t const blockSize = defaultSize;
|
||||
std::string blockSizeStr;
|
||||
|
||||
if (!getIfExists(keyValues, Keys::kNudbBlockSize, blockSizeStr))
|
||||
if (!getIfExists(keyValues, "nudb_block_size", blockSizeStr))
|
||||
{
|
||||
return blockSize; // Early return with default
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/config/BasicConfig.h>
|
||||
#include <xrpl/nodestore/Backend.h>
|
||||
#include <xrpl/nodestore/Factory.h>
|
||||
#include <xrpl/nodestore/Manager.h>
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/beast/utility/Journal.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/config/BasicConfig.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/nodestore/Backend.h>
|
||||
#include <xrpl/nodestore/NodeObject.h>
|
||||
#include <xrpl/nodestore/Scheduler.h>
|
||||
@@ -112,18 +111,17 @@ public:
|
||||
RocksDBEnv* env)
|
||||
: deletePath_(false), journal(journal), keyBytes(keyBytes), batch(*this, scheduler)
|
||||
{
|
||||
if (!getIfExists(keyValues, Keys::kPath, name))
|
||||
if (!getIfExists(keyValues, "path", name))
|
||||
Throw<std::runtime_error>("Missing path in RocksDBFactory backend");
|
||||
|
||||
rocksdb::BlockBasedTableOptions tableOptions;
|
||||
options.env = env;
|
||||
|
||||
bool const hardSet =
|
||||
keyValues.exists(Keys::kHardSet) && get<bool>(keyValues, Keys::kHardSet);
|
||||
bool const hardSet = keyValues.exists("hard_set") && get<bool>(keyValues, "hard_set");
|
||||
|
||||
if (keyValues.exists(Keys::kCacheMb))
|
||||
if (keyValues.exists("cache_mb"))
|
||||
{
|
||||
auto size = get<int>(keyValues, Keys::kCacheMb);
|
||||
auto size = get<int>(keyValues, "cache_mb");
|
||||
|
||||
if (!hardSet && size == 256)
|
||||
size = 1024;
|
||||
@@ -131,14 +129,14 @@ public:
|
||||
tableOptions.block_cache = rocksdb::NewLRUCache(megabytes(size));
|
||||
}
|
||||
|
||||
if (auto const v = get<int>(keyValues, Keys::kFilterBits))
|
||||
if (auto const v = get<int>(keyValues, "filter_bits"))
|
||||
{
|
||||
bool const filterBlocks = !keyValues.exists(Keys::kFilterFull) ||
|
||||
(get<int>(keyValues, Keys::kFilterFull) == 0);
|
||||
bool const filterBlocks =
|
||||
!keyValues.exists("filter_full") || (get<int>(keyValues, "filter_full") == 0);
|
||||
tableOptions.filter_policy.reset(rocksdb::NewBloomFilterPolicy(v, filterBlocks));
|
||||
}
|
||||
|
||||
if (getIfExists(keyValues, Keys::kOpenFiles, options.max_open_files))
|
||||
if (getIfExists(keyValues, "open_files", options.max_open_files))
|
||||
{
|
||||
if (!hardSet && options.max_open_files == 2000)
|
||||
options.max_open_files = 8000;
|
||||
@@ -146,9 +144,9 @@ public:
|
||||
fdMinRequired = options.max_open_files + 128;
|
||||
}
|
||||
|
||||
if (keyValues.exists(Keys::kFileSizeMb))
|
||||
if (keyValues.exists("file_size_mb"))
|
||||
{
|
||||
auto fileSizeMb = get<int>(keyValues, Keys::kFileSizeMb);
|
||||
auto fileSizeMb = get<int>(keyValues, "file_size_mb");
|
||||
|
||||
if (!hardSet && fileSizeMb == 8)
|
||||
fileSizeMb = 256;
|
||||
@@ -158,17 +156,16 @@ public:
|
||||
options.write_buffer_size = 2 * options.target_file_size_base;
|
||||
}
|
||||
|
||||
getIfExists(keyValues, Keys::kFileSizeMult, options.target_file_size_multiplier);
|
||||
getIfExists(keyValues, "file_size_mult", options.target_file_size_multiplier);
|
||||
|
||||
if (keyValues.exists(Keys::kBgThreads))
|
||||
if (keyValues.exists("bg_threads"))
|
||||
{
|
||||
options.env->SetBackgroundThreads(
|
||||
get<int>(keyValues, Keys::kBgThreads), rocksdb::Env::LOW);
|
||||
options.env->SetBackgroundThreads(get<int>(keyValues, "bg_threads"), rocksdb::Env::LOW);
|
||||
}
|
||||
|
||||
if (keyValues.exists(Keys::kHighThreads))
|
||||
if (keyValues.exists("high_threads"))
|
||||
{
|
||||
auto const highThreads = get<int>(keyValues, Keys::kHighThreads);
|
||||
auto const highThreads = get<int>(keyValues, "high_threads");
|
||||
options.env->SetBackgroundThreads(highThreads, rocksdb::Env::HIGH);
|
||||
|
||||
// If we have high-priority threads, presumably we want to
|
||||
@@ -179,10 +176,10 @@ public:
|
||||
|
||||
options.compression = rocksdb::kSnappyCompression;
|
||||
|
||||
getIfExists(keyValues, Keys::kBlockSize, tableOptions.block_size);
|
||||
getIfExists(keyValues, "block_size", tableOptions.block_size);
|
||||
|
||||
if (keyValues.exists(Keys::kUniversalCompaction) &&
|
||||
(get<int>(keyValues, Keys::kUniversalCompaction) != 0))
|
||||
if (keyValues.exists("universal_compaction") &&
|
||||
(get<int>(keyValues, "universal_compaction") != 0))
|
||||
{
|
||||
options.compaction_style = rocksdb::kCompactionStyleUniversal;
|
||||
options.min_write_buffer_number_to_merge = 2;
|
||||
@@ -190,11 +187,11 @@ public:
|
||||
options.write_buffer_size = 6 * options.target_file_size_base;
|
||||
}
|
||||
|
||||
if (keyValues.exists(Keys::kBbtOptions))
|
||||
if (keyValues.exists("bbt_options"))
|
||||
{
|
||||
rocksdb::ConfigOptions const configOptions;
|
||||
auto const s = rocksdb::GetBlockBasedTableOptionsFromString(
|
||||
configOptions, tableOptions, get(keyValues, Keys::kBbtOptions), &tableOptions);
|
||||
configOptions, tableOptions, get(keyValues, "bbt_options"), &tableOptions);
|
||||
if (!s.ok())
|
||||
{
|
||||
Throw<std::runtime_error>(
|
||||
@@ -204,10 +201,10 @@ public:
|
||||
|
||||
options.table_factory.reset(NewBlockBasedTableFactory(tableOptions));
|
||||
|
||||
if (keyValues.exists(Keys::kOptions))
|
||||
if (keyValues.exists("options"))
|
||||
{
|
||||
auto const s =
|
||||
rocksdb::GetOptionsFromString(options, get(keyValues, Keys::kOptions), &options);
|
||||
rocksdb::GetOptionsFromString(options, get(keyValues, "options"), &options);
|
||||
if (!s.ok())
|
||||
{
|
||||
Throw<std::runtime_error>(
|
||||
|
||||
@@ -127,7 +127,7 @@ ammAuctionTimeSlot(std::uint64_t current, STObject const& auctionSlot)
|
||||
bool
|
||||
ammEnabled(Rules const& rules)
|
||||
{
|
||||
return rules.enabled(featureAMM);
|
||||
return rules.enabled(featureAMM) && rules.enabled(fixUniversalNumber);
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <xrpl/protocol/IOUAmount.h>
|
||||
|
||||
#include <xrpl/basics/LocalValue.h>
|
||||
#include <xrpl/basics/Number.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/beast/utility/Zero.h>
|
||||
@@ -16,6 +17,29 @@
|
||||
|
||||
namespace xrpl {
|
||||
|
||||
namespace {
|
||||
|
||||
// Use a static inside a function to help prevent order-of-initialization issues
|
||||
LocalValue<bool>&
|
||||
getStaticSTNumberSwitchover()
|
||||
{
|
||||
static LocalValue<bool> kR{true};
|
||||
return kR;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool
|
||||
getSTNumberSwitchover()
|
||||
{
|
||||
return *getStaticSTNumberSwitchover();
|
||||
}
|
||||
|
||||
void
|
||||
setSTNumberSwitchover(bool v)
|
||||
{
|
||||
*getStaticSTNumberSwitchover() = v;
|
||||
}
|
||||
|
||||
/* The range for the mantissa when normalized */
|
||||
// log(2^63,10) ~ 18.96
|
||||
//
|
||||
@@ -51,20 +75,56 @@ IOUAmount::normalize()
|
||||
return;
|
||||
}
|
||||
|
||||
Number const v{mantissa_, exponent_};
|
||||
*this = IOUAmount(v);
|
||||
if (getSTNumberSwitchover())
|
||||
{
|
||||
Number const v{mantissa_, exponent_};
|
||||
*this = fromNumber(v);
|
||||
if (exponent_ > kMaxExponent)
|
||||
Throw<std::overflow_error>("value overflow");
|
||||
if (exponent_ < kMinExponent)
|
||||
*this = beast::kZero;
|
||||
return;
|
||||
}
|
||||
|
||||
bool const negative = (mantissa_ < 0);
|
||||
|
||||
if (negative)
|
||||
mantissa_ = -mantissa_;
|
||||
|
||||
while ((mantissa_ < kMinMantissa) && (exponent_ > kMinExponent))
|
||||
{
|
||||
mantissa_ *= 10;
|
||||
--exponent_;
|
||||
}
|
||||
|
||||
while (mantissa_ > kMaxMantissa)
|
||||
{
|
||||
if (exponent_ >= kMaxExponent)
|
||||
Throw<std::overflow_error>("IOUAmount::normalize");
|
||||
|
||||
mantissa_ /= 10;
|
||||
++exponent_;
|
||||
}
|
||||
|
||||
if ((exponent_ < kMinExponent) || (mantissa_ < kMinMantissa))
|
||||
{
|
||||
*this = beast::kZero;
|
||||
return;
|
||||
}
|
||||
|
||||
if (exponent_ > kMaxExponent)
|
||||
Throw<std::overflow_error>("value overflow");
|
||||
|
||||
if (negative)
|
||||
mantissa_ = -mantissa_;
|
||||
}
|
||||
|
||||
IOUAmount::IOUAmount(Number const& other) : IOUAmount(fromNumber(other))
|
||||
{
|
||||
if (exponent_ > kMaxExponent)
|
||||
{
|
||||
Throw<std::overflow_error>("value overflow");
|
||||
}
|
||||
if (exponent_ < kMinExponent)
|
||||
{
|
||||
*this = beast::kZero;
|
||||
}
|
||||
}
|
||||
|
||||
IOUAmount&
|
||||
@@ -79,7 +139,37 @@ IOUAmount::operator+=(IOUAmount const& other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
*this = IOUAmount{Number{*this} + Number{other}};
|
||||
if (getSTNumberSwitchover())
|
||||
{
|
||||
*this = IOUAmount{Number{*this} + Number{other}};
|
||||
return *this;
|
||||
}
|
||||
auto m = other.mantissa_;
|
||||
auto e = other.exponent_;
|
||||
|
||||
while (exponent_ < e)
|
||||
{
|
||||
mantissa_ /= 10;
|
||||
++exponent_;
|
||||
}
|
||||
|
||||
while (e < exponent_)
|
||||
{
|
||||
m /= 10;
|
||||
++e;
|
||||
}
|
||||
|
||||
// This addition cannot overflow an std::int64_t but we may throw from
|
||||
// normalize if the result isn't representable.
|
||||
mantissa_ += m;
|
||||
|
||||
if (mantissa_ >= -10 && mantissa_ <= 10)
|
||||
{
|
||||
*this = beast::kZero;
|
||||
return *this;
|
||||
}
|
||||
|
||||
normalize();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <xrpl/beast/hash/uhash.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/protocol/Feature.h>
|
||||
#include <xrpl/protocol/IOUAmount.h>
|
||||
#include <xrpl/protocol/STVector256.h>
|
||||
|
||||
#include <memory>
|
||||
@@ -82,12 +83,15 @@ useRulesGuards(Rules const& rules)
|
||||
void
|
||||
createGuards(
|
||||
Rules const& rules,
|
||||
std::optional<NumberSO>& stNumberSO,
|
||||
std::optional<CurrentTransactionRulesGuard>& rulesGuard,
|
||||
std::optional<NumberMantissaScaleGuard>& mantissaScaleGuard)
|
||||
{
|
||||
if (useRulesGuards(rules))
|
||||
{
|
||||
// raii classes for the current ledger rules.
|
||||
// fixUniversalNumber predates the rulesGuard and should be replaced.
|
||||
stNumberSO.emplace(rules.enabled(fixUniversalNumber));
|
||||
rulesGuard.emplace(rules);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -388,9 +388,47 @@ operator+(STAmount const& v1, STAmount const& v2)
|
||||
if (v1.holds<MPTIssue>())
|
||||
return {v1.asset_, v1.mpt().value() + v2.mpt().value()};
|
||||
|
||||
auto x = v1;
|
||||
x = v1.iou() + v2.iou();
|
||||
return x;
|
||||
if (getSTNumberSwitchover())
|
||||
{
|
||||
auto x = v1;
|
||||
x = v1.iou() + v2.iou();
|
||||
return x;
|
||||
}
|
||||
|
||||
int ov1 = v1.exponent(), ov2 = v2.exponent();
|
||||
std::int64_t vv1 = static_cast<std::int64_t>(v1.mantissa());
|
||||
std::int64_t vv2 = static_cast<std::int64_t>(v2.mantissa());
|
||||
|
||||
if (v1.negative())
|
||||
vv1 = -vv1;
|
||||
|
||||
if (v2.negative())
|
||||
vv2 = -vv2;
|
||||
|
||||
while (ov1 < ov2)
|
||||
{
|
||||
vv1 /= 10;
|
||||
++ov1;
|
||||
}
|
||||
|
||||
while (ov2 < ov1)
|
||||
{
|
||||
vv2 /= 10;
|
||||
++ov2;
|
||||
}
|
||||
|
||||
// This addition cannot overflow an std::int64_t. It can overflow an
|
||||
// STAmount and the constructor will throw.
|
||||
|
||||
std::int64_t const fv = vv1 + vv2;
|
||||
|
||||
if ((fv >= -10) && (fv <= 10))
|
||||
return {v1.getFName(), v1.asset()};
|
||||
|
||||
if (fv >= 0)
|
||||
return STAmount{v1.getFName(), v1.asset(), static_cast<std::uint64_t>(fv), ov1, false};
|
||||
|
||||
return STAmount{v1.getFName(), v1.asset(), static_cast<std::uint64_t>(-fv), ov1, true};
|
||||
}
|
||||
|
||||
STAmount
|
||||
@@ -839,25 +877,53 @@ STAmount::canonicalize()
|
||||
if (asset_.holds<MPTIssue>() && offset_ > 18)
|
||||
Throw<std::runtime_error>("MPT amount out of range");
|
||||
|
||||
Number const num(isNegative_, value_, offset_, Number::Unchecked{});
|
||||
auto set = [&](auto const& val) {
|
||||
auto const value = val.value();
|
||||
isNegative_ = value < 0;
|
||||
value_ = isNegative_ ? -value : value;
|
||||
};
|
||||
if (native())
|
||||
if (getSTNumberSwitchover())
|
||||
{
|
||||
set(XRPAmount{num});
|
||||
}
|
||||
else if (asset_.holds<MPTIssue>())
|
||||
{
|
||||
set(MPTAmount{num});
|
||||
Number const num(isNegative_, value_, offset_, Number::Unchecked{});
|
||||
auto set = [&](auto const& val) {
|
||||
auto const value = val.value();
|
||||
isNegative_ = value < 0;
|
||||
value_ = isNegative_ ? -value : value;
|
||||
};
|
||||
if (native())
|
||||
{
|
||||
set(XRPAmount{num});
|
||||
}
|
||||
else if (asset_.holds<MPTIssue>())
|
||||
{
|
||||
set(MPTAmount{num});
|
||||
}
|
||||
else
|
||||
{
|
||||
Throw<std::runtime_error>("Unknown integral asset type");
|
||||
}
|
||||
offset_ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Throw<std::runtime_error>("Unknown integral asset type"); // LCOV_EXCL_LINE
|
||||
while (offset_ < 0)
|
||||
{
|
||||
value_ /= 10;
|
||||
++offset_;
|
||||
}
|
||||
|
||||
while (offset_ > 0)
|
||||
{
|
||||
// N.B. do not move the overflow check to after the
|
||||
// multiplication
|
||||
if (native() && value_ > kMaxNativeN)
|
||||
{
|
||||
Throw<std::runtime_error>("Native currency amount out of range");
|
||||
}
|
||||
else if (!native() && value_ > kMaxMpTokenAmount)
|
||||
{
|
||||
Throw<std::runtime_error>("MPT amount out of range");
|
||||
}
|
||||
|
||||
value_ *= 10;
|
||||
--offset_;
|
||||
}
|
||||
}
|
||||
offset_ = 0;
|
||||
|
||||
if (native() && value_ > kMaxNativeN)
|
||||
{
|
||||
@@ -871,7 +937,53 @@ STAmount::canonicalize()
|
||||
return;
|
||||
}
|
||||
|
||||
*this = iou();
|
||||
if (getSTNumberSwitchover())
|
||||
{
|
||||
*this = iou();
|
||||
return;
|
||||
}
|
||||
|
||||
if (value_ == 0)
|
||||
{
|
||||
offset_ = -100;
|
||||
isNegative_ = false;
|
||||
return;
|
||||
}
|
||||
|
||||
while ((value_ < kMinValue) && (offset_ > kMinOffset))
|
||||
{
|
||||
value_ *= 10;
|
||||
--offset_;
|
||||
}
|
||||
|
||||
while (value_ > kMaxValue)
|
||||
{
|
||||
if (offset_ >= kMaxOffset)
|
||||
Throw<std::runtime_error>("value overflow");
|
||||
|
||||
value_ /= 10;
|
||||
++offset_;
|
||||
}
|
||||
|
||||
if ((offset_ < kMinOffset) || (value_ < kMinValue))
|
||||
{
|
||||
value_ = 0;
|
||||
isNegative_ = false;
|
||||
offset_ = -100;
|
||||
return;
|
||||
}
|
||||
|
||||
if (offset_ > kMaxOffset)
|
||||
Throw<std::runtime_error>("value overflow");
|
||||
|
||||
XRPL_ASSERT(
|
||||
(value_ == 0) || ((value_ >= kMinValue) && (value_ <= kMaxValue)),
|
||||
"xrpl::STAmount::canonicalize : value inside range");
|
||||
XRPL_ASSERT(
|
||||
(value_ == 0) || ((offset_ >= kMinOffset) && (offset_ <= kMaxOffset)),
|
||||
"xrpl::STAmount::canonicalize : offset inside range");
|
||||
XRPL_ASSERT(
|
||||
(value_ != 0) || (offset_ != -100), "xrpl::STAmount::canonicalize : value or offset set");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1138,34 +1250,16 @@ hasInvalidAmount(STBase const& field, int depth, beast::Journal j)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Dispatch on the serialized type tag rather than RTTI: this is on the invariant-checking path
|
||||
// and a dynamic_cast chain over every field of every modified entry is measurably expensive.
|
||||
// The object-like tags below all denote STObject subclasses (STLedgerEntry, STTx), so the
|
||||
// downcast is sound; nested fields are only ever plain STI_OBJECT / STI_ARRAY containers.
|
||||
// safeDowncast keeps a dynamic_cast validity assert in debug builds while compiling to
|
||||
// static_cast in release.
|
||||
switch (field.getSType())
|
||||
{
|
||||
case STI_AMOUNT: {
|
||||
auto const& amount = safeDowncast<STAmount const&>(field);
|
||||
return !isLegalMPT(amount) || !isLegalNet(amount);
|
||||
}
|
||||
if (auto const amount = dynamic_cast<STAmount const*>(&field))
|
||||
return !isLegalMPT(*amount) || !isLegalNet(*amount);
|
||||
|
||||
case STI_OBJECT:
|
||||
case STI_LEDGERENTRY:
|
||||
case STI_TRANSACTION:
|
||||
return hasInvalidAmount(safeDowncast<STObject const&>(field), depth + 1, j);
|
||||
if (auto const object = dynamic_cast<STObject const*>(&field))
|
||||
return hasInvalidAmount(*object, depth + 1, j);
|
||||
|
||||
case STI_ARRAY:
|
||||
return hasInvalidAmount(safeDowncast<STArray const&>(field), depth + 1, j);
|
||||
if (auto const array = dynamic_cast<STArray const*>(&field))
|
||||
return hasInvalidAmount(*array, depth + 1, j);
|
||||
|
||||
default: {
|
||||
XRPL_ASSERT(
|
||||
dynamic_cast<STObject const*>(&field) == nullptr,
|
||||
"xrpl::hasInvalidAmount : unhandled STObject type");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -1301,8 +1395,44 @@ multiply(STAmount const& v1, STAmount const& v2, Asset const& asset)
|
||||
return STAmount(asset, minV * maxV);
|
||||
}
|
||||
|
||||
auto const r = Number{v1} * Number{v2};
|
||||
return STAmount{asset, r};
|
||||
if (getSTNumberSwitchover())
|
||||
{
|
||||
auto const r = Number{v1} * Number{v2};
|
||||
return STAmount{asset, r};
|
||||
}
|
||||
|
||||
std::uint64_t value1 = v1.mantissa();
|
||||
std::uint64_t value2 = v2.mantissa();
|
||||
int offset1 = v1.exponent();
|
||||
int offset2 = v2.exponent();
|
||||
|
||||
if (v1.integral())
|
||||
{
|
||||
while (value1 < STAmount::kMinValue)
|
||||
{
|
||||
value1 *= 10;
|
||||
--offset1;
|
||||
}
|
||||
}
|
||||
|
||||
if (v2.integral())
|
||||
{
|
||||
while (value2 < STAmount::kMinValue)
|
||||
{
|
||||
value2 *= 10;
|
||||
--offset2;
|
||||
}
|
||||
}
|
||||
|
||||
// We multiply the two mantissas (each is between 10^15
|
||||
// and 10^16), so their product is in the 10^30 to 10^32
|
||||
// range. Dividing their product by 10^14 maintains the
|
||||
// precision, by scaling the result to 10^16 to 10^18.
|
||||
return STAmount(
|
||||
asset,
|
||||
muldiv(value1, value2, kTenTO14) + 7,
|
||||
offset1 + offset2 + 14,
|
||||
v1.negative() != v2.negative());
|
||||
}
|
||||
|
||||
// This is the legacy version of canonicalizeRound. It's been in use
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <xrpl/protocol/STTx.h>
|
||||
|
||||
#include <xrpl/basics/Blob.h>
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/basics/Slice.h>
|
||||
#include <xrpl/basics/StringUtilities.h>
|
||||
@@ -39,7 +40,6 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <expected>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
@@ -248,7 +248,7 @@ STTx::sign(
|
||||
tid_ = getHash(HashPrefix::TransactionId);
|
||||
}
|
||||
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
STTx::checkSign(Rules const& rules, STObject const& sigObject) const
|
||||
{
|
||||
try
|
||||
@@ -263,11 +263,11 @@ STTx::checkSign(Rules const& rules, STObject const& sigObject) const
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return std::unexpected("Internal signature check failure.");
|
||||
return Unexpected("Internal signature check failure.");
|
||||
}
|
||||
}
|
||||
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
STTx::checkSign(Rules const& rules) const
|
||||
{
|
||||
if (auto const ret = checkSign(rules, *this); !ret)
|
||||
@@ -277,12 +277,12 @@ STTx::checkSign(Rules const& rules) const
|
||||
{
|
||||
auto const counterSig = getFieldObject(sfCounterpartySignature);
|
||||
if (auto const ret = checkSign(rules, counterSig); !ret)
|
||||
return std::unexpected("Counterparty: " + ret.error());
|
||||
return Unexpected("Counterparty: " + ret.error());
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
STTx::checkBatchSign(Rules const& rules) const
|
||||
{
|
||||
try
|
||||
@@ -291,7 +291,7 @@ STTx::checkBatchSign(Rules const& rules) const
|
||||
if (getTxnType() != ttBATCH)
|
||||
{
|
||||
JLOG(debugLog().fatal()) << "not a batch transaction";
|
||||
return std::unexpected("Not a batch transaction.");
|
||||
return Unexpected("Not a batch transaction.");
|
||||
}
|
||||
STArray const& signers{getFieldArray(sfBatchSigners)};
|
||||
for (auto const& signer : signers)
|
||||
@@ -309,7 +309,7 @@ STTx::checkBatchSign(Rules const& rules) const
|
||||
{
|
||||
JLOG(debugLog().error()) << "Batch signature check failed: " << e.what();
|
||||
}
|
||||
return std::unexpected("Internal batch signature check failure.");
|
||||
return Unexpected("Internal batch signature check failure.");
|
||||
}
|
||||
|
||||
json::Value
|
||||
@@ -389,14 +389,14 @@ STTx::getMetaSQL(
|
||||
safeCast<char>(status) % rTxn % escapedMetaData);
|
||||
}
|
||||
|
||||
static std::expected<void, std::string>
|
||||
static Expected<void, std::string>
|
||||
singleSignHelper(STObject const& sigObject, Slice const& data)
|
||||
{
|
||||
// We don't allow both a non-empty sfSigningPubKey and an sfSigners.
|
||||
// That would allow the transaction to be signed two ways. So if both
|
||||
// fields are present the signature is invalid.
|
||||
if (sigObject.isFieldPresent(sfSigners))
|
||||
return std::unexpected("Cannot both single- and multi-sign.");
|
||||
return Unexpected("Cannot both single- and multi-sign.");
|
||||
|
||||
bool validSig = false;
|
||||
try
|
||||
@@ -414,19 +414,19 @@ singleSignHelper(STObject const& sigObject, Slice const& data)
|
||||
}
|
||||
|
||||
if (!validSig)
|
||||
return std::unexpected("Invalid signature.");
|
||||
return Unexpected("Invalid signature.");
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
STTx::checkSingleSign(STObject const& sigObject) const
|
||||
{
|
||||
auto const data = getSigningData(*this);
|
||||
return singleSignHelper(sigObject, makeSlice(data));
|
||||
}
|
||||
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
STTx::checkBatchSingleSign(STObject const& batchSigner) const
|
||||
{
|
||||
Serializer msg;
|
||||
@@ -434,7 +434,7 @@ STTx::checkBatchSingleSign(STObject const& batchSigner) const
|
||||
return singleSignHelper(batchSigner, msg.slice());
|
||||
}
|
||||
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
multiSignHelper(
|
||||
STObject const& sigObject,
|
||||
std::optional<AccountID> txnAccountID,
|
||||
@@ -444,18 +444,18 @@ multiSignHelper(
|
||||
// Make sure the MultiSigners are present. Otherwise they are not
|
||||
// attempting multi-signing and we just have a bad SigningPubKey.
|
||||
if (!sigObject.isFieldPresent(sfSigners))
|
||||
return std::unexpected("Empty SigningPubKey.");
|
||||
return Unexpected("Empty SigningPubKey.");
|
||||
|
||||
// We don't allow both an sfSigners and an sfTxnSignature. Both fields
|
||||
// being present would indicate that the transaction is signed both ways.
|
||||
if (sigObject.isFieldPresent(sfTxnSignature))
|
||||
return std::unexpected("Cannot both single- and multi-sign.");
|
||||
return Unexpected("Cannot both single- and multi-sign.");
|
||||
|
||||
STArray const& signers{sigObject.getFieldArray(sfSigners)};
|
||||
|
||||
// There are well known bounds that the number of signers must be within.
|
||||
if (signers.size() < STTx::kMinMultiSigners || signers.size() > STTx::kMaxMultiSigners)
|
||||
return std::unexpected("Invalid Signers array size.");
|
||||
return Unexpected("Invalid Signers array size.");
|
||||
|
||||
// Signers must be in sorted order by AccountID.
|
||||
AccountID lastAccountID(beast::kZero);
|
||||
@@ -468,15 +468,15 @@ multiSignHelper(
|
||||
// If they can, txnAccountID will be unseated, which is not equal to any
|
||||
// value.
|
||||
if (txnAccountID == accountID)
|
||||
return std::unexpected("Invalid multisigner.");
|
||||
return Unexpected("Invalid multisigner.");
|
||||
|
||||
// No duplicate signers allowed.
|
||||
if (lastAccountID == accountID)
|
||||
return std::unexpected("Duplicate Signers not allowed.");
|
||||
return Unexpected("Duplicate Signers not allowed.");
|
||||
|
||||
// Accounts must be in order by account ID. No duplicates allowed.
|
||||
if (lastAccountID > accountID)
|
||||
return std::unexpected("Unsorted Signers array.");
|
||||
return Unexpected("Unsorted Signers array.");
|
||||
|
||||
// The next signature must be greater than this one.
|
||||
lastAccountID = accountID;
|
||||
@@ -502,7 +502,7 @@ multiSignHelper(
|
||||
}
|
||||
if (!validSig)
|
||||
{
|
||||
return std::unexpected(
|
||||
return Unexpected(
|
||||
std::string("Invalid signature on account ") + toBase58(accountID) +
|
||||
errorWhat.value_or("") + ".");
|
||||
}
|
||||
@@ -511,7 +511,7 @@ multiSignHelper(
|
||||
return {};
|
||||
}
|
||||
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
STTx::checkBatchMultiSign(STObject const& batchSigner, Rules const& rules) const
|
||||
{
|
||||
// We can ease the computational load inside the loop a bit by
|
||||
@@ -530,7 +530,7 @@ STTx::checkBatchMultiSign(STObject const& batchSigner, Rules const& rules) const
|
||||
rules);
|
||||
}
|
||||
|
||||
std::expected<void, std::string>
|
||||
Expected<void, std::string>
|
||||
STTx::checkMultiSign(Rules const& rules, STObject const& sigObject) const
|
||||
{
|
||||
// Used inside the loop in multiSignHelper to enforce that
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <xrpl/protocol/tokens.h>
|
||||
|
||||
#include <xrpl/basics/Expected.h>
|
||||
#include <xrpl/basics/safe_cast.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
#include <xrpl/protocol/detail/b58_utils.h>
|
||||
@@ -22,7 +23,6 @@
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <expected>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -353,7 +353,7 @@ b256ToB58Be(std::span<std::uint8_t const> input, std::span<std::uint8_t> out)
|
||||
// (33 bytes for nodepublic + 1 byte token + 4 bytes checksum)
|
||||
if (input.size() > 38)
|
||||
{
|
||||
return std::unexpected(TokenCodecErrc::InputTooLarge);
|
||||
return Unexpected(TokenCodecErrc::InputTooLarge);
|
||||
};
|
||||
|
||||
auto countLeadingZeros = [](std::span<std::uint8_t const> const& col) -> std::size_t {
|
||||
@@ -441,7 +441,7 @@ b256ToB58Be(std::span<std::uint8_t const> input, std::span<std::uint8_t> out)
|
||||
static constexpr std::uint64_t kB5810 = 430804206899405824; // 58^10;
|
||||
if (base5810Coeff[i] >= kB5810)
|
||||
{
|
||||
return std::unexpected(TokenCodecErrc::InputTooLarge);
|
||||
return Unexpected(TokenCodecErrc::InputTooLarge);
|
||||
}
|
||||
std::array<std::uint8_t, 10> const b58Be =
|
||||
xrpl::b58_fast::detail::b5810ToB58Be(base5810Coeff[i]);
|
||||
@@ -453,7 +453,7 @@ b256ToB58Be(std::span<std::uint8_t const> input, std::span<std::uint8_t> out)
|
||||
skipZeros = false;
|
||||
if (out.size() < ((i + 1) * 10) - toSkip)
|
||||
{
|
||||
return std::unexpected(TokenCodecErrc::OutputTooSmall);
|
||||
return Unexpected(TokenCodecErrc::OutputTooSmall);
|
||||
}
|
||||
}
|
||||
for (auto b58Coeff : b58BeS.subspan(toSkip))
|
||||
@@ -476,11 +476,11 @@ b58ToB256Be(std::string_view input, std::span<std::uint8_t> out)
|
||||
// log(2^(38*8),58) ~= 51.9
|
||||
if (input.size() > 52)
|
||||
{
|
||||
return std::unexpected(TokenCodecErrc::InputTooLarge);
|
||||
return Unexpected(TokenCodecErrc::InputTooLarge);
|
||||
};
|
||||
if (out.size() < 8)
|
||||
{
|
||||
return std::unexpected(TokenCodecErrc::OutputTooSmall);
|
||||
return Unexpected(TokenCodecErrc::OutputTooSmall);
|
||||
}
|
||||
|
||||
auto countLeadingZeros = [&](auto const& col) -> std::size_t {
|
||||
@@ -513,7 +513,7 @@ b58ToB256Be(std::string_view input, std::span<std::uint8_t> out)
|
||||
auto curVal = ::xrpl::kAlphabetReverse[c];
|
||||
if (curVal < 0)
|
||||
{
|
||||
return std::unexpected(TokenCodecErrc::InvalidEncodingChar);
|
||||
return Unexpected(TokenCodecErrc::InvalidEncodingChar);
|
||||
}
|
||||
b5810Coeff[0] *= 58;
|
||||
b5810Coeff[0] += curVal;
|
||||
@@ -526,7 +526,7 @@ b58ToB256Be(std::string_view input, std::span<std::uint8_t> out)
|
||||
auto curVal = ::xrpl::kAlphabetReverse[c];
|
||||
if (curVal < 0)
|
||||
{
|
||||
return std::unexpected(TokenCodecErrc::InvalidEncodingChar);
|
||||
return Unexpected(TokenCodecErrc::InvalidEncodingChar);
|
||||
}
|
||||
b5810Coeff[numPartialCoeffs + j] *= 58;
|
||||
b5810Coeff[numPartialCoeffs + j] += curVal;
|
||||
@@ -548,7 +548,7 @@ b58ToB256Be(std::string_view input, std::span<std::uint8_t> out)
|
||||
std::span(&result[0], curResultSize + 1), kB5810);
|
||||
if (code != TokenCodecErrc::Success)
|
||||
{
|
||||
return std::unexpected(code);
|
||||
return Unexpected(code);
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -556,7 +556,7 @@ b58ToB256Be(std::string_view input, std::span<std::uint8_t> out)
|
||||
std::span(&result[0], curResultSize + 1), c);
|
||||
if (code != TokenCodecErrc::Success)
|
||||
{
|
||||
return std::unexpected(code);
|
||||
return Unexpected(code);
|
||||
}
|
||||
}
|
||||
if (result[curResultSize] != 0)
|
||||
@@ -589,7 +589,7 @@ b58ToB256Be(std::string_view input, std::span<std::uint8_t> out)
|
||||
}
|
||||
if ((curOutI + (8 * (curResultSize - 1))) > out.size())
|
||||
{
|
||||
return std::unexpected(TokenCodecErrc::OutputTooSmall);
|
||||
return Unexpected(TokenCodecErrc::OutputTooSmall);
|
||||
}
|
||||
|
||||
for (int i = curResultSize - 2; i >= 0; --i)
|
||||
@@ -614,11 +614,11 @@ encodeBase58Token(
|
||||
std::array<std::uint8_t, kTmpBufSize> buf{};
|
||||
if (input.size() > kTmpBufSize - 5)
|
||||
{
|
||||
return std::unexpected(TokenCodecErrc::InputTooLarge);
|
||||
return Unexpected(TokenCodecErrc::InputTooLarge);
|
||||
}
|
||||
if (input.empty())
|
||||
{
|
||||
return std::unexpected(TokenCodecErrc::InputTooSmall);
|
||||
return Unexpected(TokenCodecErrc::InputTooSmall);
|
||||
}
|
||||
// <type (1 byte)><token (input len)><checksum (4 bytes)>
|
||||
buf[0] = static_cast<std::uint8_t>(tokenType);
|
||||
@@ -648,23 +648,23 @@ decodeBase58Token(TokenType type, std::string_view s, std::span<std::uint8_t> ou
|
||||
|
||||
// Reject zero length tokens
|
||||
if (ret.size() < 6)
|
||||
return std::unexpected(TokenCodecErrc::InputTooSmall);
|
||||
return Unexpected(TokenCodecErrc::InputTooSmall);
|
||||
|
||||
// The type must match.
|
||||
if (type != static_cast<TokenType>(static_cast<std::uint8_t>(ret[0])))
|
||||
return std::unexpected(TokenCodecErrc::MismatchedTokenType);
|
||||
return Unexpected(TokenCodecErrc::MismatchedTokenType);
|
||||
|
||||
// And the checksum must as well.
|
||||
std::array<std::uint8_t, 4> guard{};
|
||||
checksum(guard.data(), ret.data(), ret.size() - guard.size());
|
||||
if (!std::equal(guard.rbegin(), guard.rend(), ret.rbegin()))
|
||||
{
|
||||
return std::unexpected(TokenCodecErrc::MismatchedChecksum);
|
||||
return Unexpected(TokenCodecErrc::MismatchedChecksum);
|
||||
}
|
||||
|
||||
std::size_t const outSize = ret.size() - 1 - guard.size();
|
||||
if (outBuf.size() < outSize)
|
||||
return std::unexpected(TokenCodecErrc::OutputTooSmall);
|
||||
return Unexpected(TokenCodecErrc::OutputTooSmall);
|
||||
// Skip the leading type byte and the trailing checksum.
|
||||
std::copy(ret.begin() + 1, ret.begin() + outSize + 1, outBuf.begin());
|
||||
return outBuf.subspan(0, outSize);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/basics/Log.h>
|
||||
#include <xrpl/config/BasicConfig.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
#include <xrpl/core/Job.h>
|
||||
#include <xrpl/core/JobQueue.h>
|
||||
#include <xrpl/core/ServiceRegistry.h>
|
||||
@@ -54,13 +53,13 @@ getSociSqliteInit(std::string const& name, std::string const& dir, std::string c
|
||||
std::string
|
||||
getSociInit(BasicConfig const& config, std::string const& dbName)
|
||||
{
|
||||
auto const& section = config.section(Sections::kSqdb);
|
||||
auto const backendName = get(section, Keys::kBackend, "sqlite");
|
||||
auto const& section = config.section("sqdb");
|
||||
auto const backendName = get(section, "backend", "sqlite");
|
||||
|
||||
if (backendName != "sqlite")
|
||||
Throw<std::runtime_error>("Unsupported soci backend: " + backendName);
|
||||
|
||||
auto const path = config.legacy(Sections::kDatabasePath);
|
||||
auto const path = config.legacy("database_path");
|
||||
auto const ext = dbName == "validators" || dbName == "peerfinder" ? ".sqlite" : ".db";
|
||||
return detail::getSociSqliteInit(dbName, path, ext);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#include <xrpl/server/Port.h>
|
||||
|
||||
#include <xrpl/basics/BasicConfig.h>
|
||||
#include <xrpl/basics/contract.h>
|
||||
#include <xrpl/basics/safe_cast.h>
|
||||
#include <xrpl/beast/core/LexicalCast.h>
|
||||
#include <xrpl/beast/net/IPEndpoint.h>
|
||||
#include <xrpl/beast/rfc2616.h>
|
||||
#include <xrpl/config/BasicConfig.h>
|
||||
#include <xrpl/config/Constants.h>
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
@@ -196,7 +195,7 @@ parsePort(ParsedPort& port, Section const& section, std::ostream& log)
|
||||
{
|
||||
port.name = section.name();
|
||||
{
|
||||
auto const optResult = section.get(Keys::kIp);
|
||||
auto const optResult = section.get("ip");
|
||||
if (optResult)
|
||||
{
|
||||
try
|
||||
@@ -213,7 +212,7 @@ parsePort(ParsedPort& port, Section const& section, std::ostream& log)
|
||||
}
|
||||
|
||||
{
|
||||
auto const optResult = section.get(Keys::kPort);
|
||||
auto const optResult = section.get("port");
|
||||
if (optResult)
|
||||
{
|
||||
try
|
||||
@@ -234,7 +233,7 @@ parsePort(ParsedPort& port, Section const& section, std::ostream& log)
|
||||
}
|
||||
|
||||
{
|
||||
auto const optResult = section.get(Keys::kProtocol);
|
||||
auto const optResult = section.get("protocol");
|
||||
if (optResult)
|
||||
{
|
||||
for (auto const& s : beast::rfc2616::splitCommas(optResult->begin(), optResult->end()))
|
||||
@@ -243,7 +242,7 @@ parsePort(ParsedPort& port, Section const& section, std::ostream& log)
|
||||
}
|
||||
|
||||
{
|
||||
auto const lim = get(section, Keys::kLimit, "unlimited");
|
||||
auto const lim = get(section, "limit", "unlimited");
|
||||
|
||||
if (!boost::iequals(lim, "unlimited"))
|
||||
{
|
||||
@@ -261,7 +260,7 @@ parsePort(ParsedPort& port, Section const& section, std::ostream& log)
|
||||
}
|
||||
|
||||
{
|
||||
auto const optResult = section.get(Keys::kSendQueueLimit);
|
||||
auto const optResult = section.get("send_queue_limit");
|
||||
if (optResult)
|
||||
{
|
||||
try
|
||||
@@ -286,28 +285,27 @@ parsePort(ParsedPort& port, Section const& section, std::ostream& log)
|
||||
}
|
||||
}
|
||||
|
||||
populate(section, Keys::kAdmin, log, port.adminNetsV4, port.adminNetsV6);
|
||||
populate(
|
||||
section, Keys::kSecureGateway, log, port.secureGatewayNetsV4, port.secureGatewayNetsV6);
|
||||
populate(section, "admin", log, port.adminNetsV4, port.adminNetsV6);
|
||||
populate(section, "secure_gateway", log, port.secureGatewayNetsV4, port.secureGatewayNetsV6);
|
||||
|
||||
set(port.user, Keys::kUser, section);
|
||||
set(port.password, Keys::kPassword, section);
|
||||
set(port.adminUser, Keys::kAdminUser, section);
|
||||
set(port.adminPassword, Keys::kAdminPassword, section);
|
||||
set(port.sslKey, Keys::kSslKey, section);
|
||||
set(port.sslCert, Keys::kSslCert, section);
|
||||
set(port.sslChain, Keys::kSslChain, section);
|
||||
set(port.sslCiphers, Keys::kSslCiphers, section);
|
||||
set(port.user, "user", section);
|
||||
set(port.password, "password", section);
|
||||
set(port.adminUser, "admin_user", section);
|
||||
set(port.adminPassword, "admin_password", section);
|
||||
set(port.sslKey, "ssl_key", section);
|
||||
set(port.sslCert, "ssl_cert", section);
|
||||
set(port.sslChain, "ssl_chain", section);
|
||||
set(port.sslCiphers, "ssl_ciphers", section);
|
||||
|
||||
port.pmdOptions.server_enable = section.valueOr(Keys::kPermessageDeflate, true);
|
||||
port.pmdOptions.client_max_window_bits = section.valueOr(Keys::kClientMaxWindowBits, 15);
|
||||
port.pmdOptions.server_max_window_bits = section.valueOr(Keys::kServerMaxWindowBits, 15);
|
||||
port.pmdOptions.server_enable = section.valueOr("permessage_deflate", true);
|
||||
port.pmdOptions.client_max_window_bits = section.valueOr("client_max_window_bits", 15);
|
||||
port.pmdOptions.server_max_window_bits = section.valueOr("server_max_window_bits", 15);
|
||||
port.pmdOptions.client_no_context_takeover =
|
||||
section.valueOr(Keys::kClientNoContextTakeover, false);
|
||||
section.valueOr("client_no_context_takeover", false);
|
||||
port.pmdOptions.server_no_context_takeover =
|
||||
section.valueOr(Keys::kServerNoContextTakeover, false);
|
||||
port.pmdOptions.compLevel = section.valueOr(Keys::kCompressLevel, 8);
|
||||
port.pmdOptions.memLevel = section.valueOr(Keys::kMemoryLevel, 4);
|
||||
section.valueOr("server_no_context_takeover", false);
|
||||
port.pmdOptions.compLevel = section.valueOr("compress_level", 8);
|
||||
port.pmdOptions.memLevel = section.valueOr("memory_level", 4);
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user