Compare commits

...

66 Commits

Author SHA1 Message Date
tequ
96aa775f31 Merge branch 'dev' into hook-api-unittest 2026-01-07 17:56:54 +09:00
Niq Dudfield
a8d7b2619e fix: restore [ips_fixed] to use addFixedPeer instead of addFallbackStrings (#641) 2026-01-05 13:46:02 +10:00
tequ
048c4cfd7b Merge branch 'dev' into hook-api-unittest 2025-12-24 12:23:09 +09:00
Niq Dudfield
775fb3a8b2 fix: increment manifest sequence for client code cache invalidation (#631) 2025-12-24 11:16:00 +10:00
tequ
c5cf0cf32c Merge branch 'dev' into hook-api-unittest 2025-12-17 10:03:08 +09:00
Niq Dudfield
5a118a4e2b fix(logs): formatting fixes, color handling, and debug build defaults (#607) 2025-12-17 09:45:41 +10:00
tequ
960f87857e Self hosted macos runner (#652) 2025-12-17 09:43:25 +10:00
tequ
f731bcfeba Increase ccache size from 10G to 100G in release-builder.sh for improved build performance (#643) 2025-12-16 14:45:45 +10:00
tequ
374b361daa Use Self hosted runner (#639) 2025-12-16 14:16:36 +10:00
tequ
c2f948173d refactor emit 2025-12-03 15:15:19 +09:00
tequ
df357438d7 add state tests 2025-12-03 13:43:02 +09:00
tequ
59e5650521 add sto_erase tests 2025-12-02 22:10:32 +09:00
tequ
a875fd36b3 fix build error 2025-12-02 14:33:53 +09:00
tequ
5dfbadc100 Merge remote-tracking branch 'upstream/dev' into hook-api-unittest 2025-12-02 13:23:01 +09:00
tequ
e28c1db0ef fix header 2025-11-29 00:40:58 +09:00
tequ
e9011d0433 refactor sto_emplace test 2025-11-28 20:03:24 +09:00
tequ
d0eb251c1e add sto_validate test 2025-11-28 16:47:06 +09:00
tequ
88b993257b add sto_subfield test 2025-11-28 16:37:35 +09:00
tequ
6806fa063e add sto_subarray test 2025-11-28 16:24:55 +09:00
tequ
0502f12ee3 add hook_skip test 2025-11-28 15:48:19 +09:00
tequ
181090278f add hook_hash test 2025-11-28 15:35:35 +09:00
tequ
255a516a29 Merge branch 'dev' into hook-api-unittest 2025-11-28 14:44:34 +09:00
tequ
df5b6c9528 add sto_emplace tests 2025-11-25 18:13:07 +09:00
tequ
15a4497adf add xpop_slot test 2025-11-25 14:14:58 +09:00
tequ
71d52585ce add meta_slot test 2025-11-25 13:17:27 +09:00
tequ
6b0271c2a8 add ledger_keylet test 2025-11-25 12:47:25 +09:00
tequ
4f9794461e add tests for fixEtxnFeeBase 2025-11-25 12:05:49 +09:00
tequ
abac045e20 Merge remote-tracking branch 'upstream/dev' into hook-api-unittest 2025-11-25 11:54:30 +09:00
tequ
641197d4dd add util tests 2025-11-24 15:06:39 +09:00
tequ
3d4ca8417a add slot tests 2025-11-24 15:06:30 +09:00
tequ
bb96e63e2e refactor pattern tests 2025-11-24 01:22:19 +09:00
tequ
be9cf1c8f6 add tests 2025-11-24 00:35:44 +09:00
tequ
8e5ea9a44b remove un-needed header 2025-11-23 11:26:46 +09:00
tequ
f1b64e1f28 add etxn_fee_base test 2025-11-20 20:34:42 +09:00
tequ
a0d46f0f85 move createApplyContext to private 2025-11-20 20:10:40 +09:00
tequ
1a1b1bae83 add emit tests 2025-11-20 19:27:19 +09:00
tequ
0e9946e186 add HookAPI_test.cpp 2025-11-20 16:20:20 +09:00
tequ
10bddc173a fix 2025-11-20 15:14:38 +09:00
tequ
a2e3ac4f66 fix 2025-11-12 16:44:20 +09:00
tequ
6704f2b8b6 Merge branch 'dev' into hook-api-unittest 2025-11-12 16:19:34 +09:00
tequ
11d0c3486c fix comment 2025-10-24 17:11:07 +09:00
tequ
bf7ea28b3d Merge remote-tracking branch 'upstream/dev' into hook-api-unittest 2025-10-24 16:54:31 +09:00
tequ
010951e8d7 fix gcc build error 2025-10-06 17:02:01 +09:00
tequ
19032e5a2b use uint256 instead ripple::base_uint<256> 2025-10-06 14:28:06 +09:00
tequ
c83bfe1987 add slot_type API 2025-10-06 13:49:07 +09:00
tequ
bc7a28f6af add sto_float API 2025-10-06 13:01:46 +09:00
tequ
3db217058b add emit tests 2025-10-06 11:30:08 +09:00
tequ
bf9765753f refactor 2025-09-29 16:48:19 +09:00
tequ
cf59180660 add util_raddr, util_accid 2025-09-29 13:55:23 +09:00
tequ
4ff8d688e2 add sto APIs 2025-09-29 13:38:05 +09:00
tequ
e3c4644151 float_sto_set 2025-09-29 12:50:03 +09:00
tequ
a62bac3fcd add meta_slot, xpop_slot 2025-09-29 12:25:41 +09:00
tequ
27e4e4b510 add slot APIs 2025-09-29 12:18:01 +09:00
tequ
962fdbceb6 sort HookAPI.cpp 2025-09-29 11:31:00 +09:00
tequ
2466289a1e add util_verify, util_sha512h 2025-09-29 11:17:16 +09:00
tequ
7b79e7d390 state_foreign, state_foreign_set 2025-09-23 18:35:48 +09:00
tequ
4d33603f39 ledger_last_time 2025-09-23 16:17:15 +09:00
tequ
3f65b57997 ledger Hook APIs 2025-09-23 14:53:50 +09:00
tequ
22c71a9801 fix to const params 2025-09-23 14:33:03 +09:00
tequ
0290b73a9e hook Hook APIs 2025-09-23 14:28:28 +09:00
tequ
cf9eef03e5 Merge remote-tracking branch 'upstream/dev' into hook-api-unittest 2025-09-23 13:14:30 +09:00
tequ
dfd93e9ab2 etxn APIs 2025-09-06 17:08:29 +09:00
tequ
ed68a53f6c otxn Hook APIs 2025-09-06 03:59:19 +09:00
tequ
6e49f7d1b1 add float APIs 2025-09-06 02:42:34 +09:00
tequ
4a36ca527e refactor 2025-09-05 21:12:17 +09:00
tequ
c732609f46 Hook API Unit Testing 2025-09-05 19:55:46 +09:00
24 changed files with 9087 additions and 2906 deletions

View File

@@ -28,6 +28,10 @@ inputs:
description: 'Cache version for invalidation'
required: false
default: '1'
gha_cache_enabled:
description: 'Whether to use actions/cache (disable for self-hosted with volume mounts)'
required: false
default: 'true'
ccache_enabled:
description: 'Whether to use ccache'
required: false
@@ -71,56 +75,30 @@ runs:
SAFE_BRANCH=$(echo "${{ github.ref_name }}" | tr -c 'a-zA-Z0-9_.-' '-')
echo "name=${SAFE_BRANCH}" >> $GITHUB_OUTPUT
- name: Restore ccache directory for main branch
if: inputs.ccache_enabled == 'true'
id: ccache-restore
uses: ./.github/actions/xahau-ga-cache-restore
with:
path: ~/.ccache-main
key: ${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-${{ inputs.main_branch }}
restore-keys: |
${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-
${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-
cache-type: ccache-main
- name: Restore ccache directory for current branch
if: inputs.ccache_enabled == 'true' && steps.safe-branch.outputs.name != inputs.main_branch
id: ccache-restore-current-branch
uses: ./.github/actions/xahau-ga-cache-restore
with:
path: ~/.ccache-current
key: ${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-${{ steps.safe-branch.outputs.name }}
restore-keys: |
${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-${{ inputs.main_branch }}
${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.configuration }}-
${{ runner.os }}-ccache-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-
cache-type: ccache-current
- name: Configure ccache
if: inputs.ccache_enabled == 'true'
shell: bash
run: |
# Create cache directories
mkdir -p ~/.ccache-main ~/.ccache-current
mkdir -p ~/.ccache-cache
# Keep config separate from cache_dir so configs aren't swapped when CCACHE_DIR changes between steps
mkdir -p ~/.config/ccache
export CCACHE_CONFIGPATH="$HOME/.config/ccache/ccache.conf"
echo "CCACHE_CONFIGPATH=$CCACHE_CONFIGPATH" >> $GITHUB_ENV
# Keep config separate from cache_dir so configs aren't swapped when CCACHE_DIR changes between steps
mkdir -p ~/.config/ccache
export CCACHE_CONFIGPATH="$HOME/.config/ccache/ccache.conf"
echo "CCACHE_CONFIGPATH=$CCACHE_CONFIGPATH" >> $GITHUB_ENV
# Configure ccache settings AFTER cache restore (prevents stale cached config)
ccache --set-config=max_size=${{ inputs.ccache_max_size }}
ccache --set-config=hash_dir=${{ inputs.ccache_hash_dir }}
ccache --set-config=compiler_check=${{ inputs.ccache_compiler_check }}
# Determine if we're on the main branch
if [ "${{ steps.safe-branch.outputs.name }}" = "${{ inputs.main_branch }}" ]; then
# Main branch: use main branch cache only
ccache --set-config=cache_dir="$HOME/.ccache-main"
echo "CCACHE_DIR=$HOME/.ccache-main" >> $GITHUB_ENV
echo "📦 Main branch: using ~/.ccache-main"
else
# Feature branch: use current branch cache with main as secondary (read-only fallback)
ccache --set-config=cache_dir="$HOME/.ccache-current"
ccache --set-config=secondary_storage="file:$HOME/.ccache-main"
echo "CCACHE_DIR=$HOME/.ccache-current" >> $GITHUB_ENV
echo "📦 Feature branch: using ~/.ccache-current with ~/.ccache-main as secondary"
fi
ccache --set-config=cache_dir="$HOME/.ccache-cache"
echo "CCACHE_DIR=$HOME/.ccache-cache" >> $GITHUB_ENV
echo "📦 using ~/.ccache-cache as ccache cache directory"
# Print config for verification
echo "=== ccache configuration ==="
@@ -235,17 +213,3 @@ runs:
if: inputs.ccache_enabled == 'true'
shell: bash
run: ccache -s
- name: Save ccache directory for main branch
if: success() && inputs.ccache_enabled == 'true' && steps.safe-branch.outputs.name == inputs.main_branch
uses: actions/cache/save@v4
with:
path: ~/.ccache-main
key: ${{ steps.ccache-restore.outputs.cache-primary-key }}
- name: Save ccache directory for current branch
if: success() && inputs.ccache_enabled == 'true' && steps.safe-branch.outputs.name != inputs.main_branch
uses: actions/cache/save@v4
with:
path: ~/.ccache-current
key: ${{ steps.ccache-restore-current-branch.outputs.cache-primary-key }}

View File

@@ -17,10 +17,6 @@ inputs:
description: 'Cache version for invalidation'
required: false
default: '1'
cache_enabled:
description: 'Whether to use caching'
required: false
default: 'true'
main_branch:
description: 'Main branch name for restore keys'
required: false
@@ -63,18 +59,25 @@ outputs:
runs:
using: 'composite'
steps:
- name: Restore Conan cache
if: inputs.cache_enabled == 'true'
id: cache-restore-conan
uses: ./.github/actions/xahau-ga-cache-restore
with:
path: ~/.conan2
# Note: compiler-id format is compiler-version-stdlib[-gccversion]
key: ${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ hashFiles('**/conanfile.py') }}-${{ inputs.configuration }}
restore-keys: |
${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ hashFiles('**/conanfile.py') }}-
${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-
cache-type: Conan
- name: Configure Conan cache paths
if: inputs.os == 'Linux'
shell: bash
run: |
mkdir -p /.conan-cache/conan2 /.conan-cache/conan2_download /.conan-cache/conan2_sources
echo 'core.cache:storage_path=/.conan-cache/conan2' > ~/.conan2/global.conf
echo 'core.download:download_cache=/.conan-cache/conan2_download' >> ~/.conan2/global.conf
echo 'core.sources:download_cache=/.conan-cache/conan2_sources' >> ~/.conan2/global.conf
- name: Configure Conan cache paths
if: inputs.gha_cache_enabled == 'false'
shell: bash
# For self-hosted runners, register cache paths to be used as volumes
# This allows the cache to be shared between containers
run: |
mkdir -p /.conan-cache/conan2 /.conan-cache/conan2_download /.conan-cache/conan2_sources
echo 'core.cache:storage_path=/.conan-cache/conan2' > ~/.conan2/global.conf
echo 'core.download:download_cache=/.conan-cache/conan2_download' >> ~/.conan2/global.conf
echo 'core.sources:download_cache=/.conan-cache/conan2_sources' >> ~/.conan2/global.conf
- name: Configure Conan
shell: bash
@@ -150,10 +153,3 @@ runs:
--build missing \
--settings build_type=${{ inputs.configuration }} \
..
- name: Save Conan cache
if: success() && inputs.cache_enabled == 'true' && steps.cache-restore-conan.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ~/.conan2
key: ${{ steps.cache-restore-conan.outputs.cache-primary-key }}

View File

@@ -33,7 +33,7 @@ jobs:
fetch-depth: 2 # Only get the last 2 commits, to avoid fetching all history
build:
runs-on: [self-hosted, vanity]
runs-on: [self-hosted, xahaud-build]
needs: [checkout]
defaults:
run:
@@ -74,7 +74,7 @@ jobs:
fi
tests:
runs-on: [self-hosted, vanity]
runs-on: [self-hosted, xahaud-build]
needs: [build, checkout]
defaults:
run:
@@ -84,7 +84,7 @@ jobs:
run: /bin/bash docker-unit-tests.sh
cleanup:
runs-on: [self-hosted, vanity]
runs-on: [self-hosted, xahaud-build]
needs: [tests, checkout]
if: always()
steps:

View File

@@ -20,7 +20,7 @@ jobs:
- Ninja
configuration:
- Debug
runs-on: macos-15
runs-on: [self-hosted, macOS]
env:
build_dir: .build
# Bump this number to invalidate all caches globally.
@@ -30,61 +30,29 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Get commit message
id: get-commit-message
uses: ./.github/actions/xahau-ga-get-commit-message
with:
event-name: ${{ github.event_name }}
head-commit-message: ${{ github.event.head_commit.message }}
pr-head-sha: ${{ github.event.pull_request.head.sha }}
- name: Install Conan
- name: Add Homebrew to PATH
run: |
brew install conan
# Verify Conan 2 is installed
conan --version
echo "/opt/homebrew/bin" >> "$GITHUB_PATH"
echo "/opt/homebrew/sbin" >> "$GITHUB_PATH"
- name: Install Coreutils
run: |
brew install coreutils
echo "Num proc: $(nproc)"
- name: Install Ninja
if: matrix.generator == 'Ninja'
run: brew install ninja
# To isolate environments for each Runner, instead of installing globally with brew,
# use mise to isolate environments for each Runner directory.
- name: Setup toolchain (mise)
uses: jdx/mise-action@v2
with:
install: true
- name: Install Python
- name: Install tools via mise
run: |
if which python3 > /dev/null 2>&1; then
echo "Python 3 executable exists"
python3 --version
else
brew install python@3.12
fi
# Create 'python' symlink if it doesn't exist (for tools expecting 'python')
if ! which python > /dev/null 2>&1; then
sudo ln -sf $(which python3) /usr/local/bin/python
fi
- name: Install CMake
run: |
# Install CMake 3.x to match local dev environments
# With Conan 2 and the policy args passed to CMake, newer versions
# can have issues with dependencies that require cmake_minimum_required < 3.5
brew uninstall cmake --ignore-dependencies 2>/dev/null || true
# Download and install CMake 3.31.7 directly
curl -L https://github.com/Kitware/CMake/releases/download/v3.31.7/cmake-3.31.7-macos-universal.tar.gz -o cmake.tar.gz
tar -xzf cmake.tar.gz
# Move the entire CMake.app to /Applications
sudo mv cmake-3.31.7-macos-universal/CMake.app /Applications/
echo "/Applications/CMake.app/Contents/bin" >> $GITHUB_PATH
/Applications/CMake.app/Contents/bin/cmake --version
- name: Install ccache
run: brew install ccache
mise install
mise use cmake@3.23.1 python@3.12 pipx@latest conan@2 ninja@latest ccache@latest
mise reshim
echo "$HOME/.local/share/mise/shims" >> "$GITHUB_PATH"
- name: Check environment
run: |
@@ -98,6 +66,14 @@ jobs:
echo "---- Full Environment ----"
env
- name: Get commit message
id: get-commit-message
uses: ./.github/actions/xahau-ga-get-commit-message
with:
event-name: ${{ github.event_name }}
head-commit-message: ${{ github.event.head_commit.message }}
pr-head-sha: ${{ github.event.pull_request.head.sha }}
- name: Detect compiler version
id: detect-compiler
run: |
@@ -129,6 +105,7 @@ jobs:
cache_version: ${{ env.CACHE_VERSION }}
main_branch: ${{ env.MAIN_BRANCH_NAME }}
stdlib: libcxx
ccache_max_size: '100G'
- name: Test
run: |

View File

@@ -14,7 +14,7 @@ concurrency:
jobs:
matrix-setup:
runs-on: ubuntu-latest
runs-on: [self-hosted, generic, 20.04]
container: python:3-slim
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
@@ -176,7 +176,15 @@ jobs:
build:
needs: matrix-setup
runs-on: ubuntu-latest
runs-on: [self-hosted, generic, 20.04]
container:
image: ubuntu:24.04
volumes:
- /home/runner/.conan-cache:/.conan-cache
- /home/runner/.ccache-cache:/github/home/.ccache-cache
defaults:
run:
shell: bash
outputs:
artifact_name: ${{ steps.set-artifact-name.outputs.artifact_name }}
strategy:
@@ -191,23 +199,22 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Get commit message
id: get-commit-message
uses: ./.github/actions/xahau-ga-get-commit-message
with:
event-name: ${{ github.event_name }}
head-commit-message: ${{ github.event.head_commit.message }}
pr-head-sha: ${{ github.event.pull_request.head.sha }}
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y ninja-build ${{ matrix.cc }} ${{ matrix.cxx }} ccache
apt-get update
apt-get install -y software-properties-common
add-apt-repository ppa:ubuntu-toolchain-r/test -y
apt-get update
apt-get install -y python3 python-is-python3 pipx
pipx ensurepath
apt-get install -y cmake ninja-build ${{ matrix.cc }} ${{ matrix.cxx }} ccache
apt-get install -y perl # for openssl build
apt-get install -y libsqlite3-dev # for xahaud build
# Install the specific GCC version needed for Clang
if [ -n "${{ matrix.clang_gcc_toolchain }}" ]; then
echo "=== Installing GCC ${{ matrix.clang_gcc_toolchain }} for Clang ==="
sudo apt-get install -y gcc-${{ matrix.clang_gcc_toolchain }} g++-${{ matrix.clang_gcc_toolchain }} libstdc++-${{ matrix.clang_gcc_toolchain }}-dev
apt-get install -y gcc-${{ matrix.clang_gcc_toolchain }} g++-${{ matrix.clang_gcc_toolchain }} libstdc++-${{ matrix.clang_gcc_toolchain }}-dev
echo "=== GCC versions available after installation ==="
ls -la /usr/lib/gcc/x86_64-linux-gnu/ | grep -E "^d"
@@ -238,7 +245,7 @@ jobs:
echo "Hiding GCC $version -> renaming to $counter (will be seen as GCC version $counter)"
# Safety check: ensure target doesn't already exist
if [ ! -e "/usr/lib/gcc/x86_64-linux-gnu/$counter" ]; then
sudo mv "$dir" "/usr/lib/gcc/x86_64-linux-gnu/$counter"
mv "$dir" "/usr/lib/gcc/x86_64-linux-gnu/$counter"
else
echo "ERROR: Cannot rename GCC $version - /usr/lib/gcc/x86_64-linux-gnu/$counter already exists"
exit 1
@@ -262,11 +269,12 @@ jobs:
# Install libc++ dev packages if using libc++ (not needed for libstdc++)
if [ "${{ matrix.stdlib }}" = "libcxx" ]; then
sudo apt-get install -y libc++-${{ matrix.compiler_version }}-dev libc++abi-${{ matrix.compiler_version }}-dev
apt-get install -y libc++-${{ matrix.compiler_version }}-dev libc++abi-${{ matrix.compiler_version }}-dev
fi
# Install Conan 2
pip install --upgrade "conan>=2.0,<3"
pipx install "conan>=2.0,<3"
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Check environment
run: |
@@ -280,6 +288,14 @@ jobs:
echo "---- Full Environment ----"
env
- name: Get commit message
id: get-commit-message
uses: ./.github/actions/xahau-ga-get-commit-message
with:
event-name: ${{ github.event_name }}
head-commit-message: ${{ github.event.head_commit.message }}
pr-head-sha: ${{ github.event.pull_request.head.sha }}
- name: Install dependencies
uses: ./.github/actions/xahau-ga-dependencies
with:
@@ -293,6 +309,7 @@ jobs:
cc: ${{ matrix.cc }}
cxx: ${{ matrix.cxx }}
stdlib: ${{ matrix.stdlib }}
gha_cache_enabled: 'false' # Disable caching for self hosted runner
- name: Build
uses: ./.github/actions/xahau-ga-build
@@ -307,6 +324,7 @@ jobs:
main_branch: ${{ env.MAIN_BRANCH_NAME }}
stdlib: ${{ matrix.stdlib }}
clang_gcc_toolchain: ${{ matrix.clang_gcc_toolchain || '' }}
ccache_max_size: '100G'
- name: Set artifact name
id: set-artifact-name

View File

@@ -48,13 +48,9 @@ target_sources (xrpl_core PRIVATE
src/ripple/beast/net/impl/IPAddressV6.cpp
src/ripple/beast/net/impl/IPEndpoint.cpp
src/ripple/beast/utility/src/beast_Journal.cpp
src/ripple/beast/utility/src/beast_PropertyStream.cpp)
# Conditionally add enhanced logging source when BEAST_ENHANCED_LOGGING is enabled
if(DEFINED BEAST_ENHANCED_LOGGING AND BEAST_ENHANCED_LOGGING)
target_sources(xrpl_core PRIVATE
src/ripple/beast/utility/src/beast_EnhancedLogging.cpp)
endif()
src/ripple/beast/utility/src/beast_PropertyStream.cpp
# Enhanced logging - compiles to empty when BEAST_ENHANCED_LOGGING is not defined
src/ripple/beast/utility/src/beast_EnhancedLogging.cpp)
#[===============================[
core sources
@@ -162,12 +158,16 @@ target_link_libraries (xrpl_core
date::date
Ripple::opts)
# Link date-tz library when enhanced logging is enabled
if(DEFINED BEAST_ENHANCED_LOGGING AND BEAST_ENHANCED_LOGGING)
if(TARGET date::date-tz)
target_link_libraries(xrpl_core PUBLIC date::date-tz)
endif()
# date-tz for enhanced logging (always linked, code is #ifdef guarded)
if(TARGET date::date-tz)
target_link_libraries(xrpl_core PUBLIC date::date-tz)
endif()
# BEAST_ENHANCED_LOGGING: enable for Debug builds OR when explicitly requested
# Uses generator expression so it works with multi-config generators (Xcode, VS, Ninja Multi-Config)
target_compile_definitions(xrpl_core PUBLIC
$<$<OR:$<CONFIG:Debug>,$<BOOL:${BEAST_ENHANCED_LOGGING}>>:BEAST_ENHANCED_LOGGING=1>
)
#[=================================[
main/core headers installation
#]=================================]
@@ -488,6 +488,7 @@ target_sources (rippled PRIVATE
src/ripple/app/tx/impl/apply.cpp
src/ripple/app/tx/impl/applySteps.cpp
src/ripple/app/hook/impl/applyHook.cpp
src/ripple/app/hook/impl/HookAPI.cpp
src/ripple/app/tx/impl/details/NFTokenUtils.cpp
#[===============================[
main sources:
@@ -749,6 +750,7 @@ if (tests)
src/test/app/Freeze_test.cpp
src/test/app/GenesisMint_test.cpp
src/test/app/HashRouter_test.cpp
src/test/app/HookAPI_test.cpp
src/test/app/Import_test.cpp
src/test/app/Invoke_test.cpp
src/test/app/LedgerHistory_test.cpp

View File

@@ -37,20 +37,11 @@ endif() #git
set(SOURCE_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/")
add_definitions(-DSOURCE_ROOT_PATH="${SOURCE_ROOT_PATH}")
# BEAST_ENHANCED_LOGGING option - adds file:line numbers and formatting to logs
# Default to ON for Debug builds, OFF for Release
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
option(BEAST_ENHANCED_LOGGING "Include file and line numbers in log messages" ON)
else()
option(BEAST_ENHANCED_LOGGING "Include file and line numbers in log messages" OFF)
endif()
if(BEAST_ENHANCED_LOGGING)
add_definitions(-DBEAST_ENHANCED_LOGGING=1)
message(STATUS "Log line numbers enabled")
else()
message(STATUS "Log line numbers disabled")
endif()
# BEAST_ENHANCED_LOGGING - adds file:line numbers and formatting to logs
# Automatically enabled for Debug builds via generator expression
# Can be explicitly controlled with -DBEAST_ENHANCED_LOGGING=ON/OFF
option(BEAST_ENHANCED_LOGGING "Include file and line numbers in log messages (auto: Debug=ON, Release=OFF)" OFF)
message(STATUS "BEAST_ENHANCED_LOGGING option: ${BEAST_ENHANCED_LOGGING}")
if(thread_safety_analysis)
add_compile_options(-Wthread-safety -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DRIPPLE_ENABLE_THREAD_SAFETY_ANNOTATIONS)

View File

@@ -192,7 +192,7 @@ ENV PATH=/usr/local/bin:$PATH
# Configure ccache and Conan 2
# NOTE: Using echo commands instead of heredocs because heredocs in Docker RUN commands are finnicky
RUN /hbb_exe/activate-exec bash -c "ccache -M 10G && \
RUN /hbb_exe/activate-exec bash -c "ccache -M 100G && \
ccache -o cache_dir=/cache/ccache && \
ccache -o compiler_check=content && \
mkdir -p ~/.conan2 /cache/conan2 /cache/conan2_download /cache/conan2_sources && \

View File

@@ -0,0 +1,341 @@
#include <ripple/app/hook/Enum.h>
#include <ripple/app/misc/Transaction.h>
namespace hook {
using namespace ripple;
using HookReturnCode = hook_api::hook_return_code;
using Bytes = std::vector<std::uint8_t>;
struct HookContext; // defined in applyHook.h
class HookAPI
{
public:
explicit HookAPI(HookContext& ctx) : hookCtx(ctx)
{
}
/// control APIs
// _g
// accept
// rollback
/// util APIs
Expected<std::string, HookReturnCode>
util_raddr(Bytes const& accountID) const;
Expected<Bytes, HookReturnCode>
util_accid(std::string raddress) const;
Expected<bool, HookReturnCode>
util_verify(Slice const& data, Slice const& sig, Slice const& key) const;
uint256
util_sha512h(Slice const& data) const;
// util_keylet()
/// sto APIs
Expected<bool, HookReturnCode>
sto_validate(Bytes const& data) const;
Expected<std::pair<uint32_t, uint32_t>, HookReturnCode>
sto_subfield(Bytes const& data, uint32_t field_id) const;
Expected<std::pair<uint32_t, uint32_t>, HookReturnCode>
sto_subarray(Bytes const& data, uint32_t index_id) const;
Expected<Bytes, HookReturnCode>
sto_emplace(
Bytes const& source_object,
std::optional<Bytes> const& field_object,
uint32_t field_id) const;
// sto_erase(): same as sto_emplace with field_object = nullopt
/// etxn APIs
Expected<std::shared_ptr<Transaction>, HookReturnCode>
emit(Slice const& txBlob) const;
Expected<uint64_t, HookReturnCode>
etxn_burden() const;
Expected<uint64_t, HookReturnCode>
etxn_fee_base(Slice const& txBlob) const;
Expected<uint64_t, HookReturnCode>
etxn_details(uint8_t* out_ptr) const;
Expected<uint64_t, HookReturnCode>
etxn_reserve(uint64_t count) const;
uint32_t
etxn_generation() const;
Expected<uint256, HookReturnCode>
etxn_nonce() const;
/// float APIs
Expected<uint64_t, HookReturnCode>
float_set(int32_t exponent, int64_t mantissa) const;
Expected<uint64_t, HookReturnCode>
float_multiply(uint64_t float1, uint64_t float2) const;
Expected<uint64_t, HookReturnCode>
float_mulratio(
uint64_t float1,
uint32_t round_up,
uint32_t numerator,
uint32_t denominator) const;
uint64_t
float_negate(uint64_t float1) const;
Expected<uint64_t, HookReturnCode>
float_compare(uint64_t float1, uint64_t float2, uint32_t mode) const;
Expected<uint64_t, HookReturnCode>
float_sum(uint64_t float1, uint64_t float2) const;
Expected<Bytes, HookReturnCode>
float_sto(
std::optional<Currency> currency,
std::optional<AccountID> issuer,
uint64_t float1,
uint32_t field_code,
uint32_t write_len) const;
Expected<uint64_t, HookReturnCode>
float_sto_set(Bytes const& data) const;
Expected<uint64_t, HookReturnCode>
float_invert(uint64_t float1) const;
Expected<uint64_t, HookReturnCode>
float_divide(uint64_t float1, uint64_t float2) const;
uint64_t
float_one() const;
Expected<uint64_t, HookReturnCode>
float_mantissa(uint64_t float1) const;
uint64_t
float_sign(uint64_t float1) const;
Expected<uint64_t, HookReturnCode>
float_int(uint64_t float1, uint32_t decimal_places, uint32_t absolute)
const;
Expected<uint64_t, HookReturnCode>
float_log(uint64_t float1) const;
Expected<uint64_t, HookReturnCode>
float_root(uint64_t float1, uint32_t n) const;
/// otxn APIs
uint64_t
otxn_burden() const;
uint32_t
otxn_generation() const;
Expected<const STBase*, HookReturnCode>
otxn_field(uint32_t field_id) const;
Expected<uint256, HookReturnCode>
otxn_id(uint32_t flags) const;
TxType
otxn_type() const;
Expected<uint32_t, HookReturnCode>
otxn_slot(uint32_t slot_into) const;
Expected<Blob, HookReturnCode>
otxn_param(Bytes const& param_name) const;
/// hook APIs
AccountID
hook_account() const;
Expected<ripple::uint256, HookReturnCode>
hook_hash(int32_t hook_no) const;
Expected<int64_t, HookReturnCode>
hook_again() const;
Expected<Blob, HookReturnCode>
hook_param(Bytes const& paramName) const;
Expected<uint64_t, HookReturnCode>
hook_param_set(
uint256 const& hash,
Bytes const& paramName,
Bytes const& paramValue) const;
Expected<uint64_t, HookReturnCode>
hook_skip(uint256 const& hash, uint32_t flags) const;
uint8_t
hook_pos() const;
/// ledger APIs
uint64_t
fee_base() const;
uint32_t
ledger_seq() const;
uint256
ledger_last_hash() const;
uint64_t
ledger_last_time() const;
Expected<uint256, HookReturnCode>
ledger_nonce() const;
Expected<Keylet, HookReturnCode>
ledger_keylet(Keylet const& klLo, Keylet const& klHi) const;
/// state APIs
// state(): same as state_foreign with ns = 0 and account = hook_account()
Expected<Bytes, HookReturnCode>
state_foreign(
uint256 const& key,
uint256 const& ns,
AccountID const& account) const;
// state_set(): same as state_foreign_set with ns = 0 and account =
Expected<uint64_t, HookReturnCode>
state_foreign_set(
uint256 const& key,
uint256 const& ns,
AccountID const& account,
Bytes& data) const;
/// slot APIs
Expected<const STBase*, HookReturnCode>
slot(uint32_t slot_no) const;
Expected<uint64_t, HookReturnCode>
slot_clear(uint32_t slot_no) const;
Expected<uint64_t, HookReturnCode>
slot_count(uint32_t slot_no) const;
Expected<uint32_t, HookReturnCode>
slot_set(Bytes const& data, uint32_t slot_no) const;
Expected<uint64_t, HookReturnCode>
slot_size(uint32_t slot_no) const;
Expected<uint32_t, HookReturnCode>
slot_subarray(uint32_t parent_slot, uint32_t array_id, uint32_t new_slot)
const;
Expected<uint32_t, HookReturnCode>
slot_subfield(uint32_t parent_slot, uint32_t field_id, uint32_t new_slot)
const;
Expected<std::variant<STBase, STAmount>, HookReturnCode>
slot_type(uint32_t slot_no, uint32_t flags) const;
Expected<uint64_t, HookReturnCode>
slot_float(uint32_t slot_no) const;
/// trace APIs
// trace
// trace_num
// trace_float
Expected<uint32_t, HookReturnCode>
meta_slot(uint32_t slot_into) const;
Expected<std::pair<uint32_t, uint32_t>, HookReturnCode>
xpop_slot(uint32_t slot_into_tx, uint32_t slot_into_meta) const;
private:
HookContext& hookCtx;
inline int32_t
no_free_slots() const;
inline std::optional<int32_t>
get_free_slot() const;
inline Expected<uint64_t, HookReturnCode>
float_multiply_internal_parts(
uint64_t man1,
int32_t exp1,
bool neg1,
uint64_t man2,
int32_t exp2,
bool neg2) const;
inline Expected<uint64_t, HookReturnCode>
mulratio_internal(
int64_t& man1,
int32_t& exp1,
bool round_up,
uint32_t numerator,
uint32_t denominator) const;
inline Expected<uint64_t, HookReturnCode>
float_divide_internal(uint64_t float1, uint64_t float2) const;
inline Expected<uint64_t, HookReturnCode>
double_to_xfl(double x) const;
std::optional<ripple::Keylet>
unserialize_keylet(Bytes const& data) const;
// update the state cache
inline std::optional<
std::reference_wrapper<std::pair<bool, ripple::Blob> const>>
lookup_state_cache(
AccountID const& acc,
uint256 const& ns,
uint256 const& key) const;
// check the state cache
inline Expected<uint64_t, HookReturnCode>
set_state_cache(
AccountID const& acc,
uint256 const& ns,
uint256 const& key,
Bytes const& data,
bool modified) const;
// these are only used by get_stobject_length below
enum parse_error {
pe_unexpected_end = -1,
pe_unknown_type_early = -2, // detected early
pe_unknown_type_late = -3, // end of function
pe_excessive_nesting = -4,
pe_excessive_size = -5
};
inline Expected<
int32_t,
parse_error>
get_stobject_length(
unsigned char* start, // in - begin iterator
unsigned char* maxptr, // in - end iterator
int& type, // out - populated by serialized type code
int& field, // out - populated by serialized field code
int& payload_start, // out - the start of actual payload data for
// this type
int& payload_length, // out - the length of actual payload data for
// this type
int recursion_depth = 0) // used internally
const;
};
} // namespace hook

View File

@@ -477,7 +477,6 @@ struct HookResult
ripple::uint256 const hookHash;
ripple::uint256 const hookCanEmit;
ripple::Keylet const accountKeylet;
ripple::Keylet const ownerDirKeylet;
ripple::Keylet const hookKeylet;
ripple::AccountID const account;
ripple::AccountID const otxnAccount;
@@ -799,12 +798,13 @@ public:
ADD_HOOK_FUNCTION(util_accid, ctx);
ADD_HOOK_FUNCTION(util_verify, ctx);
ADD_HOOK_FUNCTION(util_sha512h, ctx);
ADD_HOOK_FUNCTION(util_keylet, ctx);
ADD_HOOK_FUNCTION(sto_validate, ctx);
ADD_HOOK_FUNCTION(sto_subfield, ctx);
ADD_HOOK_FUNCTION(sto_subarray, ctx);
ADD_HOOK_FUNCTION(sto_emplace, ctx);
ADD_HOOK_FUNCTION(sto_erase, ctx);
ADD_HOOK_FUNCTION(util_keylet, ctx);
ADD_HOOK_FUNCTION(emit, ctx);
ADD_HOOK_FUNCTION(etxn_burden, ctx);
@@ -843,6 +843,11 @@ public:
ADD_HOOK_FUNCTION(hook_account, ctx);
ADD_HOOK_FUNCTION(hook_hash, ctx);
ADD_HOOK_FUNCTION(hook_again, ctx);
ADD_HOOK_FUNCTION(hook_param, ctx);
ADD_HOOK_FUNCTION(hook_param_set, ctx);
ADD_HOOK_FUNCTION(hook_skip, ctx);
ADD_HOOK_FUNCTION(hook_pos, ctx);
ADD_HOOK_FUNCTION(fee_base, ctx);
ADD_HOOK_FUNCTION(ledger_seq, ctx);
ADD_HOOK_FUNCTION(ledger_last_hash, ctx);
@@ -850,11 +855,6 @@ public:
ADD_HOOK_FUNCTION(ledger_nonce, ctx);
ADD_HOOK_FUNCTION(ledger_keylet, ctx);
ADD_HOOK_FUNCTION(hook_param, ctx);
ADD_HOOK_FUNCTION(hook_param_set, ctx);
ADD_HOOK_FUNCTION(hook_skip, ctx);
ADD_HOOK_FUNCTION(hook_pos, ctx);
ADD_HOOK_FUNCTION(state, ctx);
ADD_HOOK_FUNCTION(state_foreign, ctx);
ADD_HOOK_FUNCTION(state_set, ctx);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -471,6 +471,10 @@ ManifestCache::applyManifest(Manifest m)
auto masterKey = m.masterKey;
map_.emplace(std::move(masterKey), std::move(m));
// Increment sequence to invalidate cached manifest messages
seq_++;
return ManifestDisposition::accepted;
}

View File

@@ -137,14 +137,14 @@ class [[nodiscard]] Expected
public:
template <typename U>
requires std::convertible_to<U, T> constexpr Expected(U && r)
: Base(T(std::forward<U>(r)))
: Base(boost::outcome_v2::success(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(E(std::move(e.value())))
: Base(boost::outcome_v2::failure(E(std::move(e.value()))))
{
}
@@ -220,7 +220,7 @@ public:
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())))
: Base(boost::outcome_v2::failure(E(std::move(e.value()))))
{
}

View File

@@ -360,7 +360,8 @@ Logs::format(
if (!partition.empty())
{
#ifdef BEAST_ENHANCED_LOGGING
output += beast::detail::get_log_highlight_color();
if (beast::detail::should_log_use_colors())
output += beast::detail::get_log_highlight_color();
#endif
output += partition + ":";
}
@@ -392,7 +393,8 @@ Logs::format(
}
#ifdef BEAST_ENHANCED_LOGGING
output += "\033[0m";
if (beast::detail::should_log_use_colors())
output += "\033[0m";
#endif
output += message;

View File

@@ -41,6 +41,14 @@ get_log_highlight_color();
constexpr const char*
strip_source_root(const char* file)
{
// Handle relative paths from build/ directory (common with ccache)
// e.g., "../src/ripple/..." -> "ripple/..."
if (file && file[0] == '.' && file[1] == '.' && file[2] == '/' &&
file[3] == 's' && file[4] == 'r' && file[5] == 'c' && file[6] == '/')
{
return file + 7; // skip "../src/"
}
#ifdef SOURCE_ROOT_PATH
constexpr const char* sourceRoot = SOURCE_ROOT_PATH;
constexpr auto strlen_constexpr = [](const char* s) constexpr

View File

@@ -17,6 +17,8 @@
*/
//==============================================================================
#ifdef BEAST_ENHANCED_LOGGING
#include <ripple/beast/utility/EnhancedLogging.h>
#include <cstdlib>
#include <cstring>
@@ -112,3 +114,5 @@ log_write_location_string(std::ostream& os, const char* file, int line)
} // namespace detail
} // namespace beast
#endif // BEAST_ENHANCED_LOGGING

View File

@@ -155,14 +155,43 @@ Journal::ScopedStream::~ScopedStream()
#ifdef BEAST_ENHANCED_LOGGING
// Add suffix if location is enabled
if (file_ && detail::should_show_location() && !s.empty() && s != "\n")
if (file_ && detail::should_show_location() && !s.empty())
{
std::ostringstream combined;
combined << s;
if (!s.empty() && s.back() != ' ')
combined << " ";
detail::log_write_location_string(combined, file_, line_);
s = combined.str();
// Single optimized scan from the end
size_t const lastNonWhitespace = s.find_last_not_of(" \n\r\t");
// Skip if message is only whitespace (e.g., just "\n" or " \n\n")
if (lastNonWhitespace != std::string::npos)
{
// Count only the trailing newlines (tiny range)
size_t trailingNewlines = 0;
for (size_t i = lastNonWhitespace + 1; i < s.length(); ++i)
{
if (s[i] == '\n')
++trailingNewlines;
}
// Build location string once
std::ostringstream locStream;
detail::log_write_location_string(locStream, file_, line_);
std::string const location = locStream.str();
// Pre-allocate exact size → zero reallocations
size_t const finalSize = lastNonWhitespace + 1 + 1 +
location.length() + trailingNewlines;
std::string result;
result.reserve(finalSize);
// Direct string ops (no ostringstream overhead)
result.append(s, 0, lastNonWhitespace + 1);
result.push_back(' ');
result += location;
if (trailingNewlines > 0)
result.append(trailingNewlines, '\n');
s = std::move(result); // Move, no copy
}
}
#endif

View File

@@ -484,44 +484,61 @@ OverlayImpl::start()
m_peerFinder->setConfig(config);
m_peerFinder->start();
auto addIps = [&](std::vector<std::string> bootstrapIps) -> void {
auto addIps = [this](std::vector<std::string> ips, bool fixed) {
beast::Journal const& j = app_.journal("Overlay");
for (auto& ip : bootstrapIps)
for (auto& ip : ips)
{
std::size_t pos = ip.find('#');
if (pos != std::string::npos)
ip.erase(pos);
JLOG(j.trace()) << "Found boostrap IP: " << ip;
JLOG(j.trace())
<< "Found " << (fixed ? "fixed" : "bootstrap") << " IP: " << ip;
}
m_resolver.resolve(
bootstrapIps,
[&](std::string const& name,
ips,
[this, fixed](
std::string const& name,
std::vector<beast::IP::Endpoint> const& addresses) {
std::vector<std::string> ips;
ips.reserve(addresses.size());
beast::Journal const& j = app_.journal("Overlay");
std::string const base("config: ");
std::vector<beast::IP::Endpoint> eps;
eps.reserve(addresses.size());
for (auto const& addr : addresses)
{
std::string addrStr = addr.port() == 0
? to_string(addr.at_port(DEFAULT_PEER_PORT))
: to_string(addr);
JLOG(j.trace()) << "Parsed boostrap IP: " << addrStr;
ips.push_back(addrStr);
auto ep = addr.port() == 0 ? addr.at_port(DEFAULT_PEER_PORT)
: addr;
JLOG(j.trace())
<< "Parsed " << (fixed ? "fixed" : "bootstrap")
<< " IP: " << ep;
eps.push_back(ep);
}
std::string const base("config: ");
if (!ips.empty())
m_peerFinder->addFallbackStrings(base + name, ips);
if (eps.empty())
return;
if (fixed)
{
m_peerFinder->addFixedPeer(base + name, eps);
}
else
{
std::vector<std::string> strs;
strs.reserve(eps.size());
for (auto const& ep : eps)
strs.push_back(to_string(ep));
m_peerFinder->addFallbackStrings(base + name, strs);
}
});
};
if (!app_.config().IPS.empty())
addIps(app_.config().IPS);
addIps(app_.config().IPS, false);
if (!app_.config().IPS_FIXED.empty())
addIps(app_.config().IPS_FIXED);
addIps(app_.config().IPS_FIXED, true);
auto const timer = std::make_shared<Timer>(*this);
std::lock_guard lock(mutex_);

File diff suppressed because it is too large Load Diff

View File

@@ -2579,6 +2579,7 @@ public:
auto const alice = Account{"alice"};
auto const bob = Account{"bob"};
env.fund(XRP(10000), alice);
env.fund(XRP(10000), bob);
@@ -3094,6 +3095,7 @@ public:
extern int64_t rollback (uint32_t read_ptr, uint32_t read_len, int64_t error_code);
extern int64_t etxn_details (uint32_t, uint32_t);
extern int64_t etxn_reserve(uint32_t);
extern int64_t hook_hash (uint32_t, uint32_t, int32_t);
#define TOO_SMALL -4
#define OUT_OF_BOUNDS -1
#define PREREQUISITE_NOT_MET -9
@@ -3116,6 +3118,45 @@ public:
etxn_reserve(1);
ASSERT(etxn_details((uint32_t)det, 116) == 116);
uint8_t expected1[49] = {
0xEDU, 0x20U, 0x2EU, 0x00U, 0x00U, 0x00U, 0x01U, 0x3DU, 0x00U, 0x00U,
0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x01U, 0x5BU, 0xB8U, 0x05U, 0xD6U,
0xC3U, 0x52U, 0xDFU, 0x7AU, 0x27U, 0x76U, 0x6DU, 0xC0U, 0x20U, 0x47U,
0xB7U, 0x64U, 0x22U, 0x5AU, 0xB7U, 0x5DU, 0xF3U, 0xFAU, 0x0DU, 0xE3U,
0xBDU, 0xC6U, 0x40U, 0xBAU, 0xD0U, 0x0AU, 0x66U, 0xEBU, 0x68U,
};
// 0x5CU
// EmitNonce 32bytes
uint8_t expected_emit_nonce[32] = {
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
0xFFU, 0xFFU
};
// 0x5DU,
// EmitHookHash
uint8_t expected_hook_hash[32] = {
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
0xFFU, 0xFFU,
};
// 0xE1U
// current hook hash
ASSERT(hook_hash((uint32_t)expected_hook_hash, 32, -1) == 32);
for (int i = 0; GUARD(49), i < sizeof(expected1); ++i)
ASSERT(det[i] == expected1[i]);
ASSERT(det[49] == 0x5CU);
// TODO: need to test this
// for (int i = 0; GUARD(32), i < sizeof(expected_emit_nonce); ++i)
// ASSERT(det[50 + i] == expected_emit_nonce[i]);
ASSERT(det[82] == 0x5DU);
for (int i = 0; GUARD(32), i < sizeof(expected_hook_hash); ++i)
ASSERT(det[83 + i] == expected_hook_hash[i]);
ASSERT(det[115] == 0xE1);
return accept(0,0,0);
}
)[test.hook]"];
@@ -3280,6 +3321,7 @@ public:
}
ASSERT(etxn_nonce((uint32_t)nonce, 116) == TOO_MANY_NONCES);
ASSERT(etxn_nonce((uint32_t)nonce, 31) == TOO_MANY_NONCES);
return accept(0,0,0);
}

View File

@@ -1168,6 +1168,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
extern int64_t rollback (uint32_t read_ptr, uint32_t read_len, int64_t error_code);
extern int64_t etxn_details (uint32_t, uint32_t);
extern int64_t etxn_reserve(uint32_t);
extern int64_t hook_hash (uint32_t, uint32_t, int32_t);
#define TOO_SMALL -4
#define OUT_OF_BOUNDS -1
#define PREREQUISITE_NOT_MET -9
@@ -1190,78 +1191,178 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
etxn_reserve(1);
ASSERT(etxn_details((uint32_t)det, 116) == 116);
uint8_t expected1[49] = {
0xEDU, 0x20U, 0x2EU, 0x00U, 0x00U, 0x00U, 0x01U, 0x3DU, 0x00U, 0x00U,
0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x01U, 0x5BU, 0xB8U, 0x05U, 0xD6U,
0xC3U, 0x52U, 0xDFU, 0x7AU, 0x27U, 0x76U, 0x6DU, 0xC0U, 0x20U, 0x47U,
0xB7U, 0x64U, 0x22U, 0x5AU, 0xB7U, 0x5DU, 0xF3U, 0xFAU, 0x0DU, 0xE3U,
0xBDU, 0xC6U, 0x40U, 0xBAU, 0xD0U, 0x0AU, 0x66U, 0xEBU, 0x68U,
};
// 0x5CU
// EmitNonce 32bytes
uint8_t expected_emit_nonce[32] = {
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
0xFFU, 0xFFU
};
// 0x5DU,
// EmitHookHash
uint8_t expected_hook_hash[32] = {
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU,
0xFFU, 0xFFU,
};
// 0xE1U
// current hook hash
ASSERT(hook_hash((uint32_t)expected_hook_hash, 32, -1) == 32);
for (int i = 0; GUARD(49), i < sizeof(expected1); ++i)
ASSERT(det[i] == expected1[i]);
ASSERT(det[49] == 0x5CU);
// TODO: need to test this
// for (int i = 0; GUARD(32), i < sizeof(expected_emit_nonce); ++i)
// ASSERT(det[50 + i] == expected_emit_nonce[i]);
ASSERT(det[82] == 0x5DU);
for (int i = 0; GUARD(32), i < sizeof(expected_hook_hash); ++i)
ASSERT(det[83 + i] == expected_hook_hash[i]);
ASSERT(det[115] == 0xE1);
return accept(0,0,0);
}
)[test.hook]",
{
0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x19U,
0x04U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x02U, 0x7FU,
0x00U, 0x61U, 0x73U, 0x6DU, 0x01U, 0x00U, 0x00U, 0x00U, 0x01U, 0x20U,
0x05U, 0x60U, 0x02U, 0x7FU, 0x7FU, 0x01U, 0x7FU, 0x60U, 0x02U, 0x7FU,
0x7FU, 0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7EU, 0x01U, 0x7EU,
0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x02U, 0x4CU, 0x05U, 0x03U, 0x65U,
0x6EU, 0x76U, 0x02U, 0x5FU, 0x67U, 0x00U, 0x00U, 0x03U, 0x65U, 0x6EU,
0x76U, 0x0CU, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U,
0x61U, 0x69U, 0x6CU, 0x73U, 0x00U, 0x01U, 0x03U, 0x65U, 0x6EU, 0x76U,
0x08U, 0x72U, 0x6FU, 0x6CU, 0x6CU, 0x62U, 0x61U, 0x63U, 0x6BU, 0x00U,
0x02U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x0CU, 0x65U, 0x74U, 0x78U, 0x6EU,
0x5FU, 0x72U, 0x65U, 0x73U, 0x65U, 0x72U, 0x76U, 0x65U, 0x00U, 0x03U,
0x03U, 0x65U, 0x6EU, 0x76U, 0x06U, 0x61U, 0x63U, 0x63U, 0x65U, 0x70U,
0x74U, 0x00U, 0x02U, 0x03U, 0x02U, 0x01U, 0x03U, 0x05U, 0x03U, 0x01U,
0x00U, 0x02U, 0x06U, 0x21U, 0x05U, 0x7FU, 0x01U, 0x41U, 0xF0U, 0x89U,
0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xE5U, 0x09U, 0x0BU, 0x7FU, 0x00U,
0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xF0U, 0x89U, 0x04U,
0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U,
0x04U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x05U, 0x0AU, 0x84U, 0x82U,
0x00U, 0x01U, 0x80U, 0x82U, 0x00U, 0x02U, 0x01U, 0x7FU, 0x01U, 0x7EU,
0x23U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0x80U, 0x01U, 0x6BU,
0x22U, 0x01U, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0x01U,
0x41U, 0x01U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x02U,
0x40U, 0x41U, 0xC0U, 0x84U, 0x3DU, 0x41U, 0xF4U, 0x00U, 0x10U, 0x81U,
0x60U, 0x01U, 0x7FU, 0x01U, 0x7EU, 0x60U, 0x03U, 0x7FU, 0x7FU, 0x7FU,
0x01U, 0x7EU, 0x02U, 0x5CU, 0x06U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x02U,
0x5FU, 0x67U, 0x00U, 0x00U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x0CU, 0x65U,
0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U, 0x61U, 0x69U, 0x6CU,
0x73U, 0x00U, 0x01U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x08U, 0x72U, 0x6FU,
0x6CU, 0x6CU, 0x62U, 0x61U, 0x63U, 0x6BU, 0x00U, 0x02U, 0x03U, 0x65U,
0x6EU, 0x76U, 0x0CU, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x72U, 0x65U,
0x73U, 0x65U, 0x72U, 0x76U, 0x65U, 0x00U, 0x03U, 0x03U, 0x65U, 0x6EU,
0x76U, 0x09U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x5FU, 0x68U, 0x61U, 0x73U,
0x68U, 0x00U, 0x04U, 0x03U, 0x65U, 0x6EU, 0x76U, 0x06U, 0x61U, 0x63U,
0x63U, 0x65U, 0x70U, 0x74U, 0x00U, 0x02U, 0x03U, 0x02U, 0x01U, 0x03U,
0x05U, 0x03U, 0x01U, 0x00U, 0x02U, 0x06U, 0x21U, 0x05U, 0x7FU, 0x01U,
0x41U, 0xD0U, 0x8BU, 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xC6U, 0x0BU,
0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U,
0xD0U, 0x8BU, 0x04U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU,
0x07U, 0x08U, 0x01U, 0x04U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x06U,
0x0AU, 0xF4U, 0x84U, 0x00U, 0x01U, 0xF0U, 0x84U, 0x00U, 0x02U, 0x03U,
0x7FU, 0x01U, 0x7EU, 0x23U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U,
0xA0U, 0x01U, 0x6BU, 0x22U, 0x01U, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U,
0x00U, 0x41U, 0x01U, 0x41U, 0x01U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U,
0x00U, 0x1AU, 0x02U, 0x40U, 0x41U, 0xC0U, 0x84U, 0x3DU, 0x41U, 0xF4U,
0x00U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x7FU, 0x51U,
0x0DU, 0x00U, 0x41U, 0x80U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x2CU,
0x42U, 0x16U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU,
0x02U, 0x40U, 0x41U, 0x00U, 0x41U, 0xC0U, 0x84U, 0x3DU, 0x10U, 0x81U,
0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x7FU, 0x51U, 0x0DU, 0x00U, 0x41U,
0x80U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x2CU, 0x42U, 0x15U, 0x10U,
0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x41U,
0x00U, 0x41U, 0xC0U, 0x84U, 0x3DU, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U,
0x00U, 0x42U, 0x7FU, 0x51U, 0x0DU, 0x00U, 0x41U, 0xACU, 0x88U, 0x80U,
0x80U, 0x00U, 0x41U, 0x2AU, 0x42U, 0x16U, 0x10U, 0x82U, 0x80U, 0x80U,
0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x20U, 0x01U, 0x41U, 0xF3U,
0x00U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x7CU, 0x51U,
0x0DU, 0x00U, 0x41U, 0xD6U, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x2EU,
0x42U, 0x18U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU,
0x02U, 0x40U, 0x20U, 0x01U, 0x41U, 0xF4U, 0x00U, 0x10U, 0x81U, 0x80U,
0x80U, 0x80U, 0x00U, 0x42U, 0x77U, 0x51U, 0x0DU, 0x00U, 0x41U, 0x84U,
0x89U, 0x80U, 0x80U, 0x00U, 0x41U, 0x39U, 0x42U, 0x1AU, 0x10U, 0x82U,
0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x01U, 0x10U, 0x83U,
0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x02U, 0x40U, 0x20U, 0x01U, 0x41U,
0xF4U, 0x00U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0xF4U,
0x00U, 0x51U, 0x0DU, 0x00U, 0x41U, 0xBDU, 0x89U, 0x80U, 0x80U, 0x00U,
0x41U, 0x28U, 0x42U, 0x1DU, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U,
0x1AU, 0x0BU, 0x41U, 0x00U, 0x41U, 0x00U, 0x42U, 0x00U, 0x10U, 0x84U,
0x80U, 0x80U, 0x80U, 0x00U, 0x21U, 0x02U, 0x20U, 0x01U, 0x41U, 0x80U,
0x01U, 0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x20U, 0x02U,
0x0BU, 0x0BU, 0xEDU, 0x01U, 0x01U, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU,
0xE5U, 0x01U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U,
0x61U, 0x69U, 0x6CU, 0x73U, 0x28U, 0x31U, 0x30U, 0x30U, 0x30U, 0x30U,
0x30U, 0x30U, 0x2CU, 0x20U, 0x31U, 0x31U, 0x36U, 0x29U, 0x20U, 0x3DU,
0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U,
0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU,
0x5FU, 0x64U, 0x65U, 0x74U, 0x61U, 0x69U, 0x6CU, 0x73U, 0x28U, 0x30U,
0x2CU, 0x20U, 0x31U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x29U,
0x20U, 0x3DU, 0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU, 0x46U,
0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x65U, 0x74U,
0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U, 0x61U, 0x69U, 0x6CU, 0x73U,
0x28U, 0x28U, 0x75U, 0x69U, 0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU, 0x74U,
0x29U, 0x64U, 0x65U, 0x74U, 0x2CU, 0x20U, 0x31U, 0x31U, 0x35U, 0x29U,
0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x53U, 0x4DU,
0x41U, 0x4CU, 0x4CU, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U,
0x65U, 0x74U, 0x61U, 0x69U, 0x6CU, 0x73U, 0x28U, 0x28U, 0x75U, 0x69U,
0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU, 0x74U, 0x29U, 0x64U, 0x65U, 0x74U,
0x2CU, 0x20U, 0x31U, 0x31U, 0x36U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U,
0x50U, 0x52U, 0x45U, 0x52U, 0x45U, 0x51U, 0x55U, 0x49U, 0x53U, 0x49U,
0x54U, 0x45U, 0x5FU, 0x4EU, 0x4FU, 0x54U, 0x5FU, 0x4DU, 0x45U, 0x54U,
0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U, 0x61U,
0x69U, 0x6CU, 0x73U, 0x28U, 0x28U, 0x75U, 0x69U, 0x6EU, 0x74U, 0x33U,
0x32U, 0x5FU, 0x74U, 0x29U, 0x64U, 0x65U, 0x74U, 0x2CU, 0x20U, 0x31U,
0x31U, 0x36U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x31U, 0x31U, 0x36U,
0x00U,
0xACU, 0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x2AU, 0x42U, 0x17U, 0x10U,
0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x20U,
0x01U, 0x41U, 0x20U, 0x6AU, 0x41U, 0xF3U, 0x00U, 0x10U, 0x81U, 0x80U,
0x80U, 0x80U, 0x00U, 0x42U, 0x7CU, 0x51U, 0x0DU, 0x00U, 0x41U, 0xD6U,
0x88U, 0x80U, 0x80U, 0x00U, 0x41U, 0x2EU, 0x42U, 0x19U, 0x10U, 0x82U,
0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x20U, 0x01U,
0x41U, 0x20U, 0x6AU, 0x41U, 0xF4U, 0x00U, 0x10U, 0x81U, 0x80U, 0x80U,
0x80U, 0x00U, 0x42U, 0x77U, 0x51U, 0x0DU, 0x00U, 0x41U, 0x84U, 0x89U,
0x80U, 0x80U, 0x00U, 0x41U, 0x39U, 0x42U, 0x1BU, 0x10U, 0x82U, 0x80U,
0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x01U, 0x10U, 0x83U, 0x80U,
0x80U, 0x80U, 0x00U, 0x1AU, 0x02U, 0x40U, 0x20U, 0x01U, 0x41U, 0x20U,
0x6AU, 0x41U, 0xF4U, 0x00U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U,
0x42U, 0xF4U, 0x00U, 0x51U, 0x0DU, 0x00U, 0x41U, 0xBDU, 0x89U, 0x80U,
0x80U, 0x00U, 0x41U, 0x28U, 0x42U, 0x1EU, 0x10U, 0x82U, 0x80U, 0x80U,
0x80U, 0x00U, 0x1AU, 0x0BU, 0x20U, 0x01U, 0x41U, 0x18U, 0x6AU, 0x42U,
0x7FU, 0x37U, 0x03U, 0x00U, 0x20U, 0x01U, 0x41U, 0x10U, 0x6AU, 0x42U,
0x7FU, 0x37U, 0x03U, 0x00U, 0x20U, 0x01U, 0x42U, 0x7FU, 0x37U, 0x03U,
0x08U, 0x20U, 0x01U, 0x42U, 0x7FU, 0x37U, 0x03U, 0x00U, 0x02U, 0x40U,
0x20U, 0x01U, 0x41U, 0x20U, 0x41U, 0x7FU, 0x10U, 0x84U, 0x80U, 0x80U,
0x80U, 0x00U, 0x42U, 0x20U, 0x51U, 0x0DU, 0x00U, 0x41U, 0xA1U, 0x8AU,
0x80U, 0x80U, 0x00U, 0x41U, 0x36U, 0x42U, 0x3AU, 0x10U, 0x82U, 0x80U,
0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0xBCU, 0x80U, 0x80U, 0x80U,
0x78U, 0x41U, 0x32U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU,
0x41U, 0x00U, 0x21U, 0x02U, 0x03U, 0x40U, 0x41U, 0xBCU, 0x80U, 0x80U,
0x80U, 0x78U, 0x41U, 0x32U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U,
0x1AU, 0x02U, 0x40U, 0x20U, 0x01U, 0x41U, 0x20U, 0x6AU, 0x20U, 0x02U,
0x6AU, 0x2DU, 0x00U, 0x00U, 0x20U, 0x02U, 0x41U, 0xF0U, 0x89U, 0x80U,
0x80U, 0x00U, 0x6AU, 0x2DU, 0x00U, 0x00U, 0x46U, 0x0DU, 0x00U, 0x41U,
0xD7U, 0x8AU, 0x80U, 0x80U, 0x00U, 0x41U, 0x17U, 0x42U, 0x3DU, 0x10U,
0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x20U, 0x02U, 0x41U,
0x01U, 0x6AU, 0x22U, 0x02U, 0x41U, 0x31U, 0x47U, 0x0DU, 0x00U, 0x0BU,
0x02U, 0x40U, 0x20U, 0x01U, 0x2DU, 0x00U, 0x51U, 0x41U, 0xDCU, 0x00U,
0x46U, 0x0DU, 0x00U, 0x41U, 0xEEU, 0x8AU, 0x80U, 0x80U, 0x00U, 0x41U,
0x11U, 0x42U, 0x3EU, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU,
0x0BU, 0x02U, 0x40U, 0x20U, 0x01U, 0x2DU, 0x00U, 0x72U, 0x41U, 0xDDU,
0x00U, 0x46U, 0x0DU, 0x00U, 0x41U, 0xFFU, 0x8AU, 0x80U, 0x80U, 0x00U,
0x41U, 0x11U, 0x42U, 0xC2U, 0x00U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U,
0x00U, 0x1AU, 0x0BU, 0x41U, 0xC3U, 0x80U, 0x80U, 0x80U, 0x78U, 0x41U,
0x21U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x20U, 0x01U,
0x41U, 0xF3U, 0x00U, 0x6AU, 0x21U, 0x03U, 0x41U, 0x00U, 0x21U, 0x02U,
0x03U, 0x40U, 0x41U, 0xC3U, 0x80U, 0x80U, 0x80U, 0x78U, 0x41U, 0x21U,
0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x02U, 0x40U, 0x20U,
0x03U, 0x20U, 0x02U, 0x6AU, 0x2DU, 0x00U, 0x00U, 0x20U, 0x01U, 0x20U,
0x02U, 0x6AU, 0x2DU, 0x00U, 0x00U, 0x46U, 0x0DU, 0x00U, 0x41U, 0x90U,
0x8BU, 0x80U, 0x80U, 0x00U, 0x41U, 0x25U, 0x42U, 0xC4U, 0x00U, 0x10U,
0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x20U, 0x02U, 0x41U,
0x01U, 0x6AU, 0x22U, 0x02U, 0x41U, 0x20U, 0x47U, 0x0DU, 0x00U, 0x0BU,
0x02U, 0x40U, 0x20U, 0x01U, 0x2DU, 0x00U, 0x93U, 0x01U, 0x41U, 0xE1U,
0x01U, 0x46U, 0x0DU, 0x00U, 0x41U, 0xB5U, 0x8BU, 0x80U, 0x80U, 0x00U,
0x41U, 0x11U, 0x42U, 0xC5U, 0x00U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U,
0x00U, 0x1AU, 0x0BU, 0x41U, 0x00U, 0x41U, 0x00U, 0x42U, 0x00U, 0x10U,
0x85U, 0x80U, 0x80U, 0x80U, 0x00U, 0x21U, 0x04U, 0x20U, 0x01U, 0x41U,
0xA0U, 0x01U, 0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x20U,
0x04U, 0x0BU, 0x0BU, 0xCEU, 0x03U, 0x01U, 0x00U, 0x41U, 0x80U, 0x08U,
0x0BU, 0xC6U, 0x03U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U,
0x74U, 0x61U, 0x69U, 0x6CU, 0x73U, 0x28U, 0x31U, 0x30U, 0x30U, 0x30U,
0x30U, 0x30U, 0x30U, 0x2CU, 0x20U, 0x31U, 0x31U, 0x36U, 0x29U, 0x20U,
0x3DU, 0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU, 0x46U, 0x5FU,
0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x65U, 0x74U, 0x78U,
0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U, 0x61U, 0x69U, 0x6CU, 0x73U, 0x28U,
0x30U, 0x2CU, 0x20U, 0x31U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U,
0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU,
0x46U, 0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x65U,
0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U, 0x61U, 0x69U, 0x6CU,
0x73U, 0x28U, 0x28U, 0x75U, 0x69U, 0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU,
0x74U, 0x29U, 0x64U, 0x65U, 0x74U, 0x2CU, 0x20U, 0x31U, 0x31U, 0x35U,
0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x53U,
0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU,
0x64U, 0x65U, 0x74U, 0x61U, 0x69U, 0x6CU, 0x73U, 0x28U, 0x28U, 0x75U,
0x69U, 0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU, 0x74U, 0x29U, 0x64U, 0x65U,
0x74U, 0x2CU, 0x20U, 0x31U, 0x31U, 0x36U, 0x29U, 0x20U, 0x3DU, 0x3DU,
0x20U, 0x50U, 0x52U, 0x45U, 0x52U, 0x45U, 0x51U, 0x55U, 0x49U, 0x53U,
0x49U, 0x54U, 0x45U, 0x5FU, 0x4EU, 0x4FU, 0x54U, 0x5FU, 0x4DU, 0x45U,
0x54U, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x64U, 0x65U, 0x74U,
0x61U, 0x69U, 0x6CU, 0x73U, 0x28U, 0x28U, 0x75U, 0x69U, 0x6EU, 0x74U,
0x33U, 0x32U, 0x5FU, 0x74U, 0x29U, 0x64U, 0x65U, 0x74U, 0x2CU, 0x20U,
0x31U, 0x31U, 0x36U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x31U, 0x31U,
0x36U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U,
0x00U, 0x00U, 0x00U, 0xEDU, 0x20U, 0x2EU, 0x00U, 0x00U, 0x00U, 0x01U,
0x3DU, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x00U, 0x01U, 0x5BU,
0xB8U, 0x05U, 0xD6U, 0xC3U, 0x52U, 0xDFU, 0x7AU, 0x27U, 0x76U, 0x6DU,
0xC0U, 0x20U, 0x47U, 0xB7U, 0x64U, 0x22U, 0x5AU, 0xB7U, 0x5DU, 0xF3U,
0xFAU, 0x0DU, 0xE3U, 0xBDU, 0xC6U, 0x40U, 0xBAU, 0xD0U, 0x0AU, 0x66U,
0xEBU, 0x68U, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x5FU, 0x68U, 0x61U, 0x73U,
0x68U, 0x28U, 0x28U, 0x75U, 0x69U, 0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU,
0x74U, 0x29U, 0x65U, 0x78U, 0x70U, 0x65U, 0x63U, 0x74U, 0x65U, 0x64U,
0x5FU, 0x68U, 0x6FU, 0x6FU, 0x6BU, 0x5FU, 0x68U, 0x61U, 0x73U, 0x68U,
0x2CU, 0x20U, 0x33U, 0x32U, 0x2CU, 0x20U, 0x2DU, 0x31U, 0x29U, 0x20U,
0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, 0x64U, 0x65U, 0x74U, 0x5BU,
0x69U, 0x5DU, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x65U, 0x78U, 0x70U, 0x65U,
0x63U, 0x74U, 0x65U, 0x64U, 0x31U, 0x5BU, 0x69U, 0x5DU, 0x00U, 0x64U,
0x65U, 0x74U, 0x5BU, 0x34U, 0x39U, 0x5DU, 0x20U, 0x3DU, 0x3DU, 0x20U,
0x30U, 0x78U, 0x35U, 0x43U, 0x55U, 0x00U, 0x64U, 0x65U, 0x74U, 0x5BU,
0x38U, 0x32U, 0x5DU, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x30U, 0x78U, 0x35U,
0x44U, 0x55U, 0x00U, 0x64U, 0x65U, 0x74U, 0x5BU, 0x38U, 0x33U, 0x20U,
0x2BU, 0x20U, 0x69U, 0x5DU, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x65U, 0x78U,
0x70U, 0x65U, 0x63U, 0x74U, 0x65U, 0x64U, 0x5FU, 0x68U, 0x6FU, 0x6FU,
0x6BU, 0x5FU, 0x68U, 0x61U, 0x73U, 0x68U, 0x5BU, 0x69U, 0x5DU, 0x00U,
0x64U, 0x65U, 0x74U, 0x5BU, 0x31U, 0x31U, 0x35U, 0x5DU, 0x20U, 0x3DU,
0x3DU, 0x20U, 0x30U, 0x78U, 0x45U, 0x31U, 0x00U,
}},
/* ==== WASM: 8 ==== */
@@ -1422,6 +1523,7 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
}
ASSERT(etxn_nonce((uint32_t)nonce, 116) == TOO_MANY_NONCES);
ASSERT(etxn_nonce((uint32_t)nonce, 31) == TOO_MANY_NONCES);
return accept(0,0,0);
}
@@ -1437,12 +1539,12 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
0x6FU, 0x6CU, 0x6CU, 0x62U, 0x61U, 0x63U, 0x6BU, 0x00U, 0x02U, 0x03U,
0x65U, 0x6EU, 0x76U, 0x06U, 0x61U, 0x63U, 0x63U, 0x65U, 0x70U, 0x74U,
0x00U, 0x02U, 0x03U, 0x02U, 0x01U, 0x03U, 0x05U, 0x03U, 0x01U, 0x00U,
0x02U, 0x06U, 0x21U, 0x05U, 0x7FU, 0x01U, 0x41U, 0xA0U, 0x8AU, 0x04U,
0x0BU, 0x7FU, 0x00U, 0x41U, 0x9EU, 0x0AU, 0x0BU, 0x7FU, 0x00U, 0x41U,
0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xA0U, 0x8AU, 0x04U, 0x0BU,
0x02U, 0x06U, 0x21U, 0x05U, 0x7FU, 0x01U, 0x41U, 0xE0U, 0x8AU, 0x04U,
0x0BU, 0x7FU, 0x00U, 0x41U, 0xD1U, 0x0AU, 0x0BU, 0x7FU, 0x00U, 0x41U,
0x80U, 0x08U, 0x0BU, 0x7FU, 0x00U, 0x41U, 0xE0U, 0x8AU, 0x04U, 0x0BU,
0x7FU, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0x07U, 0x08U, 0x01U, 0x04U,
0x68U, 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x04U, 0x0AU, 0xE1U, 0x82U, 0x00U,
0x01U, 0xDDU, 0x82U, 0x00U, 0x02U, 0x02U, 0x7FU, 0x01U, 0x7EU, 0x23U,
0x68U, 0x6FU, 0x6FU, 0x6BU, 0x00U, 0x04U, 0x0AU, 0x84U, 0x83U, 0x00U,
0x01U, 0x80U, 0x83U, 0x00U, 0x02U, 0x02U, 0x7FU, 0x01U, 0x7EU, 0x23U,
0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0xC0U, 0x00U, 0x6BU, 0x22U,
0x01U, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x41U, 0x01U, 0x41U,
0x01U, 0x10U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x02U, 0x40U,
@@ -1474,39 +1576,48 @@ std::map<std::string, std::vector<uint8_t>> wasm = {
0x20U, 0x01U, 0x41U, 0xF4U, 0x00U, 0x10U, 0x81U, 0x80U, 0x80U, 0x80U,
0x00U, 0x42U, 0x74U, 0x51U, 0x0DU, 0x00U, 0x41U, 0xEAU, 0x89U, 0x80U,
0x80U, 0x00U, 0x41U, 0x34U, 0x42U, 0x23U, 0x10U, 0x82U, 0x80U, 0x80U,
0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U, 0x00U, 0x41U, 0x00U, 0x42U, 0x00U,
0x10U, 0x83U, 0x80U, 0x80U, 0x80U, 0x00U, 0x21U, 0x03U, 0x20U, 0x01U,
0x41U, 0xC0U, 0x00U, 0x6AU, 0x24U, 0x80U, 0x80U, 0x80U, 0x80U, 0x00U,
0x20U, 0x03U, 0x0BU, 0x0BU, 0xA6U, 0x02U, 0x01U, 0x00U, 0x41U, 0x80U,
0x08U, 0x0BU, 0x9EU, 0x02U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x6EU,
0x6FU, 0x6EU, 0x63U, 0x65U, 0x28U, 0x31U, 0x30U, 0x30U, 0x30U, 0x30U,
0x30U, 0x30U, 0x2CU, 0x20U, 0x31U, 0x31U, 0x36U, 0x29U, 0x20U, 0x3DU,
0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U,
0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU,
0x5FU, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x28U, 0x30U, 0x2CU, 0x20U,
0x31U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x29U, 0x20U, 0x3DU,
0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U, 0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U,
0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU,
0x5FU, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x28U, 0x28U, 0x75U, 0x69U,
0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU, 0x74U, 0x29U, 0x6EU, 0x6FU, 0x6EU,
0x63U, 0x65U, 0x2CU, 0x20U, 0x33U, 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU,
0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU,
0x80U, 0x00U, 0x1AU, 0x0BU, 0x02U, 0x40U, 0x20U, 0x01U, 0x41U, 0x1FU,
0x10U, 0x81U, 0x80U, 0x80U, 0x80U, 0x00U, 0x42U, 0x74U, 0x51U, 0x0DU,
0x00U, 0x41U, 0x9EU, 0x8AU, 0x80U, 0x80U, 0x00U, 0x41U, 0x33U, 0x42U,
0x24U, 0x10U, 0x82U, 0x80U, 0x80U, 0x80U, 0x00U, 0x1AU, 0x0BU, 0x41U,
0x00U, 0x41U, 0x00U, 0x42U, 0x00U, 0x10U, 0x83U, 0x80U, 0x80U, 0x80U,
0x00U, 0x21U, 0x03U, 0x20U, 0x01U, 0x41U, 0xC0U, 0x00U, 0x6AU, 0x24U,
0x80U, 0x80U, 0x80U, 0x80U, 0x00U, 0x20U, 0x03U, 0x0BU, 0x0BU, 0xD9U,
0x02U, 0x01U, 0x00U, 0x41U, 0x80U, 0x08U, 0x0BU, 0xD1U, 0x02U, 0x65U,
0x74U, 0x78U, 0x6EU, 0x5FU, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x28U,
0x31U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x30U, 0x2CU, 0x20U, 0x31U,
0x31U, 0x36U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U,
0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U,
0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x6EU, 0x6FU, 0x6EU, 0x63U,
0x65U, 0x28U, 0x30U, 0x2CU, 0x20U, 0x31U, 0x30U, 0x30U, 0x30U, 0x30U,
0x30U, 0x30U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x4FU, 0x55U, 0x54U,
0x5FU, 0x4FU, 0x46U, 0x5FU, 0x42U, 0x4FU, 0x55U, 0x4EU, 0x44U, 0x53U,
0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x6EU, 0x6FU, 0x6EU, 0x63U,
0x65U, 0x28U, 0x28U, 0x75U, 0x69U, 0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU,
0x74U, 0x29U, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x20U, 0x2BU, 0x20U,
0x28U, 0x28U, 0x69U, 0x20U, 0x25U, 0x20U, 0x32U, 0x29U, 0x20U, 0x2AU,
0x20U, 0x33U, 0x32U, 0x29U, 0x2CU, 0x20U, 0x33U, 0x32U, 0x29U, 0x20U,
0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U, 0x00U, 0x21U, 0x28U, 0x2AU, 0x28U,
0x6EU, 0x31U, 0x20U, 0x2BU, 0x20U, 0x30U, 0x29U, 0x20U, 0x3DU, 0x3DU,
0x20U, 0x2AU, 0x28U, 0x6EU, 0x32U, 0x20U, 0x2BU, 0x20U, 0x30U, 0x29U,
0x20U, 0x26U, 0x26U, 0x20U, 0x2AU, 0x28U, 0x6EU, 0x31U, 0x20U, 0x2BU,
0x20U, 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x2AU, 0x28U, 0x6EU,
0x32U, 0x20U, 0x2BU, 0x20U, 0x31U, 0x29U, 0x29U, 0x00U, 0x65U, 0x74U,
0x78U, 0x6EU, 0x5FU, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x28U, 0x28U,
0x75U, 0x69U, 0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU, 0x74U, 0x29U, 0x6EU,
0x6FU, 0x6EU, 0x63U, 0x65U, 0x2CU, 0x20U, 0x31U, 0x31U, 0x36U, 0x29U,
0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU, 0x4DU, 0x41U,
0x4EU, 0x59U, 0x5FU, 0x4EU, 0x4FU, 0x4EU, 0x43U, 0x45U, 0x53U, 0x00U,
0x74U, 0x29U, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x2CU, 0x20U, 0x33U,
0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U, 0x4FU, 0x4FU, 0x5FU,
0x53U, 0x4DU, 0x41U, 0x4CU, 0x4CU, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU,
0x5FU, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x28U, 0x28U, 0x75U, 0x69U,
0x6EU, 0x74U, 0x33U, 0x32U, 0x5FU, 0x74U, 0x29U, 0x6EU, 0x6FU, 0x6EU,
0x63U, 0x65U, 0x20U, 0x2BU, 0x20U, 0x28U, 0x28U, 0x69U, 0x20U, 0x25U,
0x20U, 0x32U, 0x29U, 0x20U, 0x2AU, 0x20U, 0x33U, 0x32U, 0x29U, 0x2CU,
0x20U, 0x33U, 0x32U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x33U, 0x32U,
0x00U, 0x21U, 0x28U, 0x2AU, 0x28U, 0x6EU, 0x31U, 0x20U, 0x2BU, 0x20U,
0x30U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x2AU, 0x28U, 0x6EU, 0x32U,
0x20U, 0x2BU, 0x20U, 0x30U, 0x29U, 0x20U, 0x26U, 0x26U, 0x20U, 0x2AU,
0x28U, 0x6EU, 0x31U, 0x20U, 0x2BU, 0x20U, 0x31U, 0x29U, 0x20U, 0x3DU,
0x3DU, 0x20U, 0x2AU, 0x28U, 0x6EU, 0x32U, 0x20U, 0x2BU, 0x20U, 0x31U,
0x29U, 0x29U, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU, 0x6EU, 0x6FU,
0x6EU, 0x63U, 0x65U, 0x28U, 0x28U, 0x75U, 0x69U, 0x6EU, 0x74U, 0x33U,
0x32U, 0x5FU, 0x74U, 0x29U, 0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x2CU,
0x20U, 0x31U, 0x31U, 0x36U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U, 0x54U,
0x4FU, 0x4FU, 0x5FU, 0x4DU, 0x41U, 0x4EU, 0x59U, 0x5FU, 0x4EU, 0x4FU,
0x4EU, 0x43U, 0x45U, 0x53U, 0x00U, 0x65U, 0x74U, 0x78U, 0x6EU, 0x5FU,
0x6EU, 0x6FU, 0x6EU, 0x63U, 0x65U, 0x28U, 0x28U, 0x75U, 0x69U, 0x6EU,
0x74U, 0x33U, 0x32U, 0x5FU, 0x74U, 0x29U, 0x6EU, 0x6FU, 0x6EU, 0x63U,
0x65U, 0x2CU, 0x20U, 0x33U, 0x31U, 0x29U, 0x20U, 0x3DU, 0x3DU, 0x20U,
0x54U, 0x4FU, 0x4FU, 0x5FU, 0x4DU, 0x41U, 0x4EU, 0x59U, 0x5FU, 0x4EU,
0x4FU, 0x4EU, 0x43U, 0x45U, 0x53U, 0x00U,
}},
/* ==== WASM: 10 ==== */

View File

@@ -20,9 +20,13 @@
#ifndef RIPPLE_TEST_JTX_HOOK_H_INCLUDED
#define RIPPLE_TEST_JTX_HOOK_H_INCLUDED
#include <ripple/app/hook/applyHook.h>
#include <ripple/json/json_value.h>
#include <cstdint>
#include <map>
#include <optional>
#include <test/jtx/Account.h>
#include <vector>
namespace ripple {
namespace test {
@@ -43,6 +47,75 @@ hso(std::string const& wasmHex, void (*f)(Json::Value& jv) = 0);
Json::Value
hso_delete(void (*f)(Json::Value& jv) = 0);
struct StubHookResult
{
ripple::uint256 const hookSetTxnID = ripple::uint256();
ripple::uint256 const hookHash = ripple::uint256();
ripple::uint256 const hookCanEmit = ripple::uint256();
ripple::uint256 const hookNamespace = ripple::uint256();
std::queue<std::shared_ptr<ripple::Transaction>> emittedTxn{};
std::optional<hook::HookStateMap> stateMap = std::nullopt;
uint16_t changedStateCount = 0;
std::map<
ripple::uint256, // hook hash
std::map<
std::vector<uint8_t>, // hook param name
std::vector<uint8_t> // hook param value
>>
hookParamOverrides = {};
std::optional<std::map<std::vector<uint8_t>, std::vector<uint8_t>>>
hookParams = std::nullopt;
std::set<ripple::uint256> hookSkips = {};
hook_api::ExitType exitType = hook_api::ExitType::ROLLBACK;
std::string exitReason{""};
int64_t exitCode{-1};
uint64_t instructionCount{0};
bool hasCallback = false;
bool isCallback = false;
bool isStrong = false;
uint32_t wasmParam = 0;
uint32_t overrideCount = 0;
uint8_t hookChainPosition = 0;
bool foreignStateSetDisabled = false;
bool executeAgainAsWeak = false;
std::shared_ptr<STObject const> provisionalMeta = nullptr;
};
struct StubHookContext
{
std::map<uint32_t, hook::SlotEntry> slot{};
std::queue<uint32_t> slot_free{};
uint32_t slot_counter{0};
uint16_t emit_nonce_counter{0};
uint16_t ledger_nonce_counter{0};
int64_t expected_etxn_count{-1};
std::map<ripple::uint256, bool> nonce_used{};
uint32_t generation = 0;
uint64_t burden = 0;
std::map<uint32_t, uint32_t> guard_map{};
StubHookResult result = {};
std::optional<ripple::STObject> emitFailure = std::nullopt;
const hook::HookExecutor* module = 0;
};
// Overload that takes external stateMap to avoid dangling reference
hook::HookContext
makeStubHookContext(
ripple::ApplyContext& applyCtx,
ripple::AccountID const& hookAccount,
ripple::AccountID const& otxnAccount,
StubHookContext const& stubHookContext,
hook::HookStateMap& stateMap);
hook::HookContext
makeStubHookContext(
ripple::ApplyContext& applyCtx,
ripple::AccountID const& hookAccount,
ripple::AccountID const& otxnAccount,
StubHookContext const& stubHookContext);
} // namespace jtx
} // namespace test
} // namespace ripple

View File

@@ -18,7 +18,9 @@
//==============================================================================
#include <ripple/app/hook/Enum.h>
#include <ripple/app/hook/applyHook.h>
#include <ripple/basics/contract.h>
#include <ripple/protocol/Keylet.h>
#include <ripple/protocol/jss.h>
#include <stdexcept>
#include <test/jtx/hook.h>
@@ -102,6 +104,81 @@ hso(std::string const& wasmHex, void (*f)(Json::Value& jv))
return jv;
}
// Helper function to create HookContext with external stateMap
hook::HookContext
makeStubHookContext(
ripple::ApplyContext& applyCtx,
ripple::AccountID const& hookAccount,
ripple::AccountID const& otxnAccount,
StubHookContext const& stubHookContext,
hook::HookStateMap& stateMap)
{
auto& result = stubHookContext.result;
auto hookParams = result.hookParams.value_or(
std::map<std::vector<uint8_t>, std::vector<uint8_t>>{});
return hook::HookContext{
.applyCtx = applyCtx,
.slot = stubHookContext.slot,
.slot_free = stubHookContext.slot_free,
.slot_counter = stubHookContext.slot_counter,
.emit_nonce_counter = stubHookContext.emit_nonce_counter,
.ledger_nonce_counter = stubHookContext.ledger_nonce_counter,
.expected_etxn_count = stubHookContext.expected_etxn_count,
.nonce_used = stubHookContext.nonce_used,
.generation = stubHookContext.generation,
.burden = stubHookContext.burden,
.guard_map = stubHookContext.guard_map,
.result =
{
.hookSetTxnID = result.hookSetTxnID,
.hookHash = result.hookHash,
.hookCanEmit = result.hookCanEmit,
.accountKeylet = keylet::account(hookAccount),
.hookKeylet = keylet::hook(hookAccount),
.account = hookAccount,
.otxnAccount = otxnAccount,
.hookNamespace = result.hookNamespace,
.emittedTxn = result.emittedTxn,
.stateMap = stateMap,
.changedStateCount = result.changedStateCount,
.hookParamOverrides = result.hookParamOverrides,
.hookParams = hookParams,
.hookSkips = result.hookSkips,
.exitType = result.exitType,
.exitReason = result.exitReason,
.exitCode = result.exitCode,
.instructionCount = result.instructionCount,
.hasCallback = result.hasCallback,
.isCallback = result.isCallback,
.isStrong = result.isStrong,
.wasmParam = result.wasmParam,
.overrideCount = result.overrideCount,
.hookChainPosition = result.hookChainPosition,
.foreignStateSetDisabled = result.foreignStateSetDisabled,
.executeAgainAsWeak = result.executeAgainAsWeak,
.provisionalMeta = result.provisionalMeta,
},
.emitFailure = stubHookContext.emitFailure,
.module = nullptr};
}
// Original function - WARNING: stateMap reference may become dangling
// Only use when stateMap access is not needed after HookContext creation
hook::HookContext
makeStubHookContext(
ripple::ApplyContext& applyCtx,
ripple::AccountID const& hookAccount,
ripple::AccountID const& otxnAccount,
StubHookContext const& stubHookContext)
{
// Use thread_local to keep stateMap alive
// Note: This is a workaround; each call resets the stateMap
thread_local hook::HookStateMap stateMap;
stateMap = stubHookContext.result.stateMap.value_or(hook::HookStateMap{});
return makeStubHookContext(
applyCtx, hookAccount, otxnAccount, stubHookContext, stateMap);
}
} // namespace jtx
} // namespace test
} // namespace ripple