Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
cc37a96
Refactor: Whitelisted Hook APIs
tequdev Oct 22, 2025
6f83efe
Merge branch 'dev' into refactor-enum-whitelist-api
tequdev Oct 23, 2025
88bb543
Refactor: Whitelisted Hook APIs
tequdev Oct 22, 2025
0b1cfb5
Support for execution costs per Hook APIs
tequdev Oct 26, 2025
2187bce
Merge branch 'dev' into HookFeeV2
tequdev Oct 27, 2025
d611e16
refactor whitelist APIs to enable amendment guard outside Guard.h
tequdev Oct 30, 2025
4269ef7
additional refactor
tequdev Oct 30, 2025
9c0feaf
fix
tequdev Oct 30, 2025
24e18c9
Refactor2: Hook APIs Amendment Guards
tequdev Oct 30, 2025
adebc3c
refactor: rulesVersion
tequdev Oct 30, 2025
c89967e
bad merge
tequdev Oct 30, 2025
df81b7a
Merge branch 'dev' into refactor-enum-whitelist-api
tequdev Oct 30, 2025
96417f3
Merge commit 'df81b7ae5d28176aaa93b181aeff5b8a12195633' into refactor…
tequdev Oct 31, 2025
fce6ced
Refactor3: Consolidate the Hook API definitions from Enum.h and Apply…
tequdev Oct 31, 2025
e92b993
add `xpop_slot` test before featureHooksUpdate1
tequdev Oct 31, 2025
2e6e64b
Merge branch 'refactor-whitelist-api-2' into refactor-whitelist-api-3
tequdev Oct 31, 2025
65af101
Merge branch 'dev' into refactor-enum-whitelist-api
tequdev Nov 3, 2025
047b713
update generate_extern.sh
tequdev Nov 4, 2025
0955ab2
fix workflow
tequdev Nov 4, 2025
cdf3008
fix script
tequdev Nov 4, 2025
8c7ccd1
Merge commit 'cdf3008d9dd4ca23c2559ede4cfdbfdca5e03412' into HookFeeV2
tequdev Nov 4, 2025
5e60bdf
fix
tequdev Nov 5, 2025
bfb037d
Merge branch 'refactor-whitelist-api-2' into refactor-whitelist-api-3
tequdev Nov 5, 2025
158def4
Merge branch 'dev' into refactor-enum-whitelist-api
tequdev Nov 7, 2025
a28baff
Use HookCost field and add `HookDefinitionUpdate` transaction to re-e…
tequdev Nov 8, 2025
5ae6885
update hook/sfcodes.h
tequdev Nov 8, 2025
2d77acf
add comments
tequdev Nov 8, 2025
79e1cc2
update hook/tts.h
tequdev Nov 8, 2025
350410f
Merge branch 'HookFeeV2-instructioncost' into HookFeeV2
tequdev Nov 8, 2025
6288a6e
Merge branch 'dev' into refactor-enum-whitelist-api
tequdev Nov 20, 2025
7c96052
remove unused DECLARE_HOOK_FUNCNARG macro
tequdev Nov 20, 2025
4c0d3ab
fix DECLARE_HOOK_FUNCTION macro
tequdev Nov 20, 2025
2fc0795
refactor DEFINE_HOOK_FUNCNARG
tequdev Nov 20, 2025
6dedbf9
fix
tequdev Nov 20, 2025
c898eda
Merge branch 'dev' into refactor-enum-whitelist-api
tequdev Nov 25, 2025
ee3285b
Merge branch 'dev' into refactor-enum-whitelist-api
tequdev Nov 27, 2025
c1c367d
Merge branch 'dev' into refactor-enum-whitelist-api
tequdev Dec 1, 2025
6f11085
Merge remote-tracking branch 'origin/refactor-enum-whitelist-api' int…
tequdev Dec 3, 2025
64f17b8
Merge branch 'refactor-whitelist-api-2' into refactor-whitelist-api-3
tequdev Dec 3, 2025
4d9f766
Merge remote-tracking branch 'upstream/dev' into refactor-whitelist-a…
tequdev Dec 10, 2025
9a7e856
Merge branch 'refactor-whitelist-api-2' into refactor-whitelist-api-3
tequdev Dec 10, 2025
53bf635
Merge branch 'refactor-whitelist-api-3' into HookFeeV2
tequdev Dec 11, 2025
0da64a8
Update SetHook_wasm.h
tequdev Dec 11, 2025
8a9eb1f
Fix to use macros only top of Enum.h
tequdev Dec 11, 2025
379fb0f
format hook_api.macro
tequdev Dec 12, 2025
f036976
Merge branch 'refactor-whitelist-api-2' into refactor-whitelist-api-3
tequdev Dec 12, 2025
3c0e288
Merge branch 'refactor-whitelist-api-3' into HookFeeV2
tequdev Dec 12, 2025
ad623c0
update header
tequdev Dec 12, 2025
3be9830
Add GasPrice voting
tequdev Dec 16, 2025
6088502
Merge remote-tracking branch 'upstream/dev' into HookFeeV2
tequdev Dec 16, 2025
3b4924b
Merge branch 'dev' into HookFeeV2
tequdev Dec 22, 2025
a4ca4e9
Update sfcodes.h
tequdev Dec 22, 2025
3d04cbf
Update tests
tequdev Dec 22, 2025
0e400a2
fix
tequdev Dec 22, 2025
5a07f7f
fix test
tequdev Dec 23, 2025
ef8381e
Organizing Hook API costs
tequdev Jan 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/verify-generated-headers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,23 @@ jobs:
generator: bash ./hook/generate_sfcodes.sh
- target: hook/tts.h
generator: ./hook/generate_tts.sh
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
env:
CLANG_VERSION: 10
name: ${{ matrix.target }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download and install clang-format
run: |
sudo apt-get update -y
sudo apt-get install -y libtinfo5
curl -LO https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/clang+llvm-10.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz
tar -xf clang+llvm-10.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz
sudo mv clang+llvm-10.0.1-x86_64-linux-gnu-ubuntu-16.04 /opt/clang-10
sudo ln -s /opt/clang-10/bin/clang-format /usr/local/bin/clang-format-10

- name: Verify ${{ matrix.target }}
run: |
set -euo pipefail
Expand Down
1 change: 1 addition & 0 deletions Builds/CMake/RippledCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ target_sources (rippled PRIVATE
src/ripple/app/tx/impl/DepositPreauth.cpp
src/ripple/app/tx/impl/Escrow.cpp
src/ripple/app/tx/impl/GenesisMint.cpp
src/ripple/app/tx/impl/HookDefinitionUpdate.cpp
src/ripple/app/tx/impl/Import.cpp
src/ripple/app/tx/impl/InvariantCheck.cpp
src/ripple/app/tx/impl/Invoke.cpp
Expand Down
9 changes: 9 additions & 0 deletions cfg/xahaud-example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,15 @@
# Example:
# owner_reserve = 2000000 # 2 XAH
#
# hook_gas_price = <uint32_t>
#
# The gas price for hooks is used to calculate the execution fee for hooks.
#
# If this parameter is unspecified, xahaud will use an internal
# default. Don't change this without understanding the consequences.
#
# Example:
# hook_gas_price = 1000000
#-------------------------------------------------------------------------------
#
# 9. Misc Settings
Expand Down
22 changes: 11 additions & 11 deletions hook/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ sto_erase(
uint32_t field_id);

extern int64_t
etxn_burden(void);
etxn_burden();

extern int64_t
etxn_details(uint32_t write_ptr, uint32_t write_len);
Expand All @@ -94,7 +94,7 @@ extern int64_t
etxn_reserve(uint32_t count);

extern int64_t
etxn_generation(void);
etxn_generation();

extern int64_t
etxn_nonce(uint32_t write_ptr, uint32_t write_len);
Expand Down Expand Up @@ -149,7 +149,7 @@ extern int64_t
float_divide(int64_t float1, int64_t float2);

extern int64_t
float_one(void);
float_one();

extern int64_t
float_mantissa(int64_t float1);
Expand All @@ -167,13 +167,13 @@ extern int64_t
float_root(int64_t float1, uint32_t n);

extern int64_t
fee_base(void);
fee_base();

extern int64_t
ledger_seq(void);
ledger_seq();

extern int64_t
ledger_last_time(void);
ledger_last_time();

extern int64_t
ledger_last_hash(uint32_t write_ptr, uint32_t write_len);
Expand Down Expand Up @@ -213,13 +213,13 @@ hook_param(
uint32_t read_len);

extern int64_t
hook_again(void);
hook_again();

extern int64_t
hook_skip(uint32_t read_ptr, uint32_t read_len, uint32_t flags);

extern int64_t
hook_pos(void);
hook_pos();

extern int64_t
slot(uint32_t write_ptr, uint32_t write_len, uint32_t slot);
Expand Down Expand Up @@ -299,19 +299,19 @@ extern int64_t
trace_float(uint32_t read_ptr, uint32_t read_len, int64_t float1);

extern int64_t
otxn_burden(void);
otxn_burden();

extern int64_t
otxn_field(uint32_t write_ptr, uint32_t write_len, uint32_t field_id);

extern int64_t
otxn_generation(void);
otxn_generation();

extern int64_t
otxn_id(uint32_t write_ptr, uint32_t write_len, uint32_t flags);

extern int64_t
otxn_type(void);
otxn_type();

extern int64_t
otxn_slot(uint32_t slot_no);
Expand Down
137 changes: 23 additions & 114 deletions hook/generate_extern.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eu
SCRIPT_DIR=$(dirname "$0")
SCRIPT_DIR=$(cd "$SCRIPT_DIR" && pwd)

APPLY_HOOK="$SCRIPT_DIR/../src/ripple/app/hook/applyHook.h"
APPLY_HOOK="$SCRIPT_DIR/../src/ripple/app/hook/hook_api.macro"

{
echo '// For documentation please see: https://xrpl-hooks.readme.io/reference/'
Expand All @@ -19,127 +19,36 @@ APPLY_HOOK="$SCRIPT_DIR/../src/ripple/app/hook/applyHook.h"
return s;
}

function emit(ret, name, argc, argt, argn) {
attr = (name == "_g") ? " __attribute__((noduplicate))" : "";
if (!first)
printf("\n");
first = 0;
printf("extern %s%s\n", ret, attr);
if (argc == 0) {
printf("%s(void);\n", name);
return;
}
if (argc <= 3) {
line = argt[1] " " argn[1];
for (i = 2; i <= argc; ++i)
line = line ", " argt[i] " " argn[i];
printf("%s(%s);\n", name, line);
return;
}
printf("%s(\n", name);
for (i = 1; i <= argc; ++i) {
sep = (i < argc) ? "," : ");";
printf(" %s %s%s\n", argt[i], argn[i], sep);
}
}

function process(buffer, kind, payload, parts, n, i, arg, tokens, argc, argt, argn) {
if (kind == "func")
sub(/^DECLARE_HOOK_FUNCTION[[:space:]]*\(/, "", buffer);
else
sub(/^DECLARE_HOOK_FUNCNARG[[:space:]]*\(/, "", buffer);
buffer = trim(buffer);
sub(/\)[[:space:]]*$/, "", buffer);
n = split(buffer, parts, ",");
for (i = 1; i <= n; ++i)
parts[i] = trim(parts[i]);
ret = parts[1];
name = parts[2];
argc = 0;
delete argt;
delete argn;
for (i = 3; i <= n; ++i) {
arg = parts[i];
if (arg == "")
continue;
split(arg, tokens, /[[:space:]]+/);
if (length(tokens) < 2)
continue;
++argc;
argt[argc] = tokens[1];
argn[argc] = tokens[2];
}
emit(ret, name, argc, argt, argn);
}

BEGIN {
first = 1;
in_block = 0;
in_macro = 0;
}

{
line = $0;
if (in_block) {
if (line ~ /\*\//) {
sub(/.*\*\//, "", line);
in_block = 0;
}
else
next;
}
while (line ~ /\/\*/) {
if (line ~ /\/\*.*\*\//) {
gsub(/\/\*.*\*\//, "", line);
}
else {
sub(/\/\*.*/, "", line);
in_block = 1;
break;
}
}
sub(/\/\/.*$/, "", line);
line = trim(line);
if (line == "")
next;

if (!in_macro && line ~ /^DECLARE_HOOK_FUNCTION\(/) {
buffer = line;
kind = "func";
if (line ~ /\);[[:space:]]*$/) {
sub(/\);[[:space:]]*$/, "", buffer);
process(buffer, kind);
}
else
in_macro = 1;

# Skip block comments
if (line ~ /\/\*/) {
next;
}
if (!in_macro && line ~ /^DECLARE_HOOK_FUNCNARG\(/) {
buffer = line;
kind = "narg";
if (line ~ /\);[[:space:]]*$/) {
sub(/\);[[:space:]]*$/, "", buffer);
process(buffer, kind);
}
else
in_macro = 1;
next;
}
if (in_macro) {
buffer = buffer " " line;
if (line ~ /\);[[:space:]]*$/) {
sub(/\);[[:space:]]*$/, "", buffer);
process(buffer, kind);
in_macro = 0;

# Look for comment lines that start with // and contain function signature
if (line ~ /^[[:space:]]*\/\/[[:space:]]*[a-zA-Z_][a-zA-Z0-9_]*[[:space:]]+[a-zA-Z_][a-zA-Z0-9_]*[[:space:]]*\(/) {
# Remove leading // and trim
sub(/^[[:space:]]*\/\/[[:space:]]*/, "", line);
line = trim(line);

# Check if function name is "_g" to add attribute
if (line ~ /[[:space:]]+_g[[:space:]]*\(/) {
# Insert __attribute__((noduplicate)) before _g
sub(/[[:space:]]+_g/, " __attribute__((noduplicate)) _g", line);
}

# printf("\n");

printf("extern %s\n\n", line);
}
}

END {
printf("\n");
}
' "$APPLY_HOOK"

echo '#define HOOK_EXTERN'
echo '#endif // HOOK_EXTERN'
}
} | (
cd "$SCRIPT_DIR/.."
clang-format --style=file -
)
3 changes: 3 additions & 0 deletions hook/sfcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#define sfEmitGeneration ((2U << 16U) + 46U)
#define sfLockCount ((2U << 16U) + 49U)
#define sfFirstNFTokenSequence ((2U << 16U) + 50U)
#define sfHookGasPrice ((2U << 16U) + 92U)
#define sfStartTime ((2U << 16U) + 93U)
#define sfRepeatCount ((2U << 16U) + 94U)
#define sfDelaySeconds ((2U << 16U) + 95U)
Expand All @@ -87,6 +88,8 @@
#define sfHookInstructionCount ((3U << 16U) + 17U)
#define sfHookReturnCode ((3U << 16U) + 18U)
#define sfReferenceCount ((3U << 16U) + 19U)
#define sfHookCallbackCost ((3U << 16U) + 95U)
#define sfHookCost ((3U << 16U) + 96U)
#define sfTouchCount ((3U << 16U) + 97U)
#define sfAccountIndex ((3U << 16U) + 98U)
#define sfAccountCount ((3U << 16U) + 99U)
Expand Down
1 change: 1 addition & 0 deletions hook/tts.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#define ttURITOKEN_BUY 47
#define ttURITOKEN_CREATE_SELL_OFFER 48
#define ttURITOKEN_CANCEL_SELL_OFFER 49
#define ttHOOK_DEFINITION_UPDATE 91
#define ttCRON 92
#define ttCRON_SET 93
#define ttREMARKS_SET 94
Expand Down
Loading
Loading