Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 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
c669984
Allow `memory.fill` and `memory.copy` in Hook
tequdev Oct 26, 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
047b713
update generate_extern.sh
tequdev Nov 4, 2025
0955ab2
fix workflow
tequdev Nov 4, 2025
cdf3008
fix script
tequdev Nov 4, 2025
a8e9749
Merge remote-tracking branch 'upstream/dev' into memory-fill-copy
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
c8b617c
memory page size 2
tequdev Nov 6, 2025
2258548
Merge branch 'refactor-whitelist-api-3' into memory-fill-copy
tequdev Nov 6, 2025
1cd3eb6
Add memory section validation and remove max memory page configuration
tequdev Nov 6, 2025
27eff37
Merge branch 'dev' into memory-fill-copy
tequdev Dec 17, 2025
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
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 -
)
Loading
Loading