router-perf@1.0 — Erlang Execution Device for Performance-Based Routing#741
router-perf@1.0 — Erlang Execution Device for Performance-Based Routing#741Lucifer0x17 wants to merge 22 commits intoneo/edgefrom
router-perf@1.0 — Erlang Execution Device for Performance-Based Routing#741Conversation
Arweave v2 TXIDs are SHA-256(signature), which differs from the unsigned content hash used by HyperBEAM messages. Add a fallback in is_tx_admissible that checks the commitment-based ID via hb_message:id(CommittedMsg, all, Opts) when the unsigned content hash doesn't match.
…ed routing Introduces dev_router_perf.erl, an Erlang execution device for process@1.0 that replaces dynamic-router.lua for Arweave gateway routing. Fixes gaps in the Lua version: supports match/with route format. Key functionality: - register: adds nodes to routes with http_reference for the feedback loop - duration: updates node performance via exponential weighted average (EMA) - recalculate: recomputes weights using decay-based percentile scoring - Supports both match/with and prefix Registers router-perf@1.0 in hb_opts preloaded_devices. Comments added in the file by: Claude Opus 4.6 <noreply@anthropic.com>
Add `is_admissible_hook_routed_test_` that validates the full perf-router feedback loop: gateway registration, TX fetch through routed stack, async monitor duration posts, and performance score updates via EMA.
|
Amazing! If it is like the original the registration process should just be either:
Congrats! Let's ship it and test a beta 🙂 |
This reverts commit dba1bd3.
Lightweight device that gates HTTP monitor invocations via 1-in-N probabilistic sampling. Reads `sample-rate` from the request message and rolls `rand:uniform(Rate) =:= 1`. If absent, all requests pass.
- Gate monitor invocations via monitor-sampler@1.0 when `sample-rate` is set in the http_monitor config
- When `is-wasm-process` is set, strip the reserved `path` key from the monitor body and move it to `monitor-type`.
opts example
---
``` json
"http_monitor": {
"device": "relay@1.0",
"method": "POST",
"peer": "http://localhost:9000",
"path": "call",
"relay-path": "/<process-id>/push",
"commit-request": true,
"sample-rate": 10,
"is-wasm-process": true
}
```
|
@samcamwilliams Okay so I tested it by spawning an aos process from an HB instace from And when i did 35 requests I did get around 4 msgs on the process: Config i used was as following: {
"port": "8734",
"relay_allow_commit_request": true,
"on": {
"request": [
{
"device": "router@1.0",
"path": "preprocess",
"template": "^/[a-zA-Z0-9_-]{43}$"
}
]
},
"routes": [
{
"template": "^/[a-zA-Z0-9_-]{43}",
"strategy": "Random",
"choose": 2,
"parallel": true,
"nodes": [
{
"prefix": "https://blue.hyperbeam.zephyrdev.xyz",
"opts": { "http_reference": "blue" }
},
{
"prefix": "https://neo.hyperbeam.zephyrdev.xyz",
"opts": { "http_reference": "neo" }
},
{
"prefix": "https://neo2.hyperbeam.zephyrdev.xyz",
"opts": { "http_reference": "neo2" }
}
]
}
],
"http_monitor": {
"device": "relay@1.0",
"method": "POST",
"peer": "http://localhost:9000",
"path": "call",
"relay-path": "/Slu1LZ-PNgaRq0_CsCyloSi9WQkmTwztetN1l3R3t1Y/push",
"commit-request": true,
"sample-rate": 10,
"is-wasm-process": true
}
}
|
src/dev_arweave.erl
Outdated
| } | ||
| ), | ||
| to_message(Path, Method, best_response(Res), LogExtra, Opts). | ||
| case to_message(Path, Method, best_response(Res), LogExtra, Opts) of |
There was a problem hiding this comment.
The raw path unfortunately doesn't emit the user's message as-is, so I don't think this change can work/is needed?
src/hb_http_client.erl
Outdated
| %% When the target is a WASM process (`is-wasm-process' in the monitor config), | ||
| %% the reserved `path' key is moved to `monitor-type' to avoid interfering | ||
| %% with AO-Core routing. | ||
| maybe_invoke_monitor(Details, Opts) -> |
There was a problem hiding this comment.
on/http-client/response: UserPath
dev_hook:on(<<"http-client/response">>, MonitoringInfo, Opts)
src/hb_http_client.erl
Outdated
|
|
||
| %% @doc Check whether this request should be forwarded to the monitor. | ||
| %% If `sample-rate' is not set in the monitor config, all requests are forwarded. | ||
| should_forward(Monitor, Opts) -> |
There was a problem hiding this comment.
Can be hook-implementation level:
on/http-client/response: ~chance/20/your/path/to/execute
src/dev_monitor_sampler.erl
Outdated
| %%% ~1-in-N requests will be forwarded. If absent, every request is forwarded. | ||
|
|
||
| info(_Base) -> | ||
| #{default => fun should_sample/3}. |
There was a problem hiding this comment.
Default should be...
handle(X, Base, _, Opts) ->
if roll(X) -> {ok, Base}; true -> {error, Base} end.
Change find/3 to use hb_util:deep_get instead of maps:get so that slash-separated hook names like <<"http-client/response">> resolve to nested keys in the on config map
Add dev_chance.erl as a composable 1-in-N probabilistic gate using the 4-arity default handler pattern.
- Replace ~60 lines of custom monitor invocation (maybe_invoke_monitor, should_forward, do_invoke_monitor, sanitize_body) with a single `dev_hook:on(<<"http-client/response">>, ...)` call. - Reorder relay-path priority in dev_relay:call so that the explicit relay-path key is checked before the generic path key, fixing a conflict where the handler's dispatch path shadowed the relay URL.
The multirequest-admissible check was in the generic request/5 function which also handles /raw paths that don't emit the user's message as-is. Moved the admissibility + tx-admissible hook logic into get_tx where it belongs.

Continuation of #737
Summary
Introduces
dev_router_perf.erl, an Erlang execution device forprocess@1.0that provides performance-based routing with automatic weight adjustment. It replacesdynamic-router.luafor Arweave gateway routing, supportingmatch/withroute format — Arweave gateways usematch/withinstead ofprefix/price/topupHow It Works
The device runs as a
process@1.0node process. The feedback loop:Actions
registermatch/withandprefixformats. Setshttp_referencefor the feedback loop.durationhttp_reference.recalculateregister.Configuration
Set these on the node process definition:
performance-periodinitial-performancesampling-rateperformance-weightpricing-weightscore-preferenceProduction Setup
1. Node configuration:
2. Register gateways (once, at startup or via admin script):
3. Verify: