feat: add global default hooks to MultiHookRouter#28
feat: add global default hooks to MultiHookRouter#28JhiNResH wants to merge 2 commits intoerc-8183:mainfrom
Conversation
…ate acp submodule
Jobs without per-job hooks now fall back to owner-configured global defaults — useful when all jobs share the same pipeline (e.g. trust gate → trust update → attestation) without per-job setup or extra gas. Adds: addGlobalHook, removeGlobalHook, reorderGlobalHooks, resolveHooks view, and 13 tests covering admin, resolution fallback, and per-job override. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hi @JhiNResH, I looked at your PR and saw that it is using MultiHookRouter V1 from PR #21. I've since updated PR #21 with MultiHookRouter V2, which addresses some scalability limitations in V1. In MultiHookRouter V1, every hook receives the same optParams bytes, so hooks that need their own parameters must share a combined encoding where each reads specific byte offsets. This works fine for 1-2 hooks, but adding a third means every existing hook needs to know the new field layout. The coordination cost grows with each hook added. MultiHookRouter V2 dispatches a separate optParams slice to each hook, so they don't need to know about each other's data format. Each cross-contract call carries its own isolated payload. It also lets you register hooks per selector instead of a single list for all functions, so hooks only run where they're actually needed. Feel free to pull the latest changes, open a new PR with your improvements, and keep it small so it's easier to review. |
Summary
Builds on #21 — adds global default hooks that run for all jobs without per-job configuration.
Use case
When all jobs share the same hook pipeline (e.g. trust gate → trust update → attestation), the operator sets global hooks once at deploy time. New jobs automatically inherit them — zero per-job config, zero extra gas per job creation.
Changes
MultiHookRouter.sol_globalHooksstorage,addGlobalHook/removeGlobalHook/reorderGlobalHooks,_resolveHooksfallback,resolveHooksviewtest/MultiHookRouter.t.solDesign decisions
_resolveHooksreturns per-job iflength > 0, else globalTest plan
forge test --match-contract MultiHookRouterGlobalTest— 13/13 pass