Expose proxy type filtering rules via runtime api#2703
Conversation
…ement runtime api
|
# 🛡️ AI Review — Skeptic (security review) has not yet run on this PR. 🔍 AI Review — Auditor (domain review)VERDICT: 👍 Gittensor: LIKELY; basfroman is not in the allowlists but has repo write permission and a long subtensor PR history, so I treated this as established-contributor work. PR body is substantive and matches the implementation. The macro-generated filter arms preserve the prior Verification attempted: FindingsNo findings. ConclusionI did not find a blocking correctness issue. The main residual risk is environmental: targeted tests and live spec-version confirmation could not run here, so CI should cover those. |
|
🔄 AI review updated — Skeptic: SAFE Auditor: 👍 |
Description
Adds two new runtime api methods to
ProxyFilterRuntimeApi:get_proxy_types()— returns allProxyTypevariants with their index, name, and deprecation statusget_proxy_filter(proxy_type: Option<u8>)— returns the filtering rules for each proxy type, including which extrinsics are allowed/denied, wildcard pallet rules, value conditions, and nested call requirementsThe core change is a
define_proxy_filters!proc-macro that serves as a single source of truth — it generates both the on-chainInstanceFilter::filter()logic and the runtime api metadata from one declarative definition. this eliminates the previous duplication where filter rules and api data had to be maintained separately and could drift apart.If a new
ProxyTypevariant is added without updating the macro, the compiler will reject the build due to non-exhaustive match. if a call name in the dsl doesn't exist in the pallet, the compiler will also reject it.Data types added to
subtensor-runtime-common:CallInfo,CallCondition,FilterMode,ProxyFilterInfo,ProxyTypeInfo. clients (python, js) can call these methods via standard substrate rpc to get the full picture of proxy permissions without hardcoding anything.Type of Change
Breaking Change
Nope
Checklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctlyAdditional Notes
Usage from python (bittensor sdk / async-substrate-interface, e.t.c.):
response structure for
get_proxy_filter:filter_mode— one ofAllowAll,DenyAll,Allow,Denycalls— list of extrinsics the rule applies to. each entry haspallet_name,pallet_index,call_name(null for whole-pallet wildcard),call_index(null for wildcard), and optionalconditionexceptions— calls excluded from the allow list (only relevant whenfilter_modeisAllow)name— proxy type namedeprecated— whether this proxy type is deprecatedinterpreting
filter_mode:AllowAll— proxy can execute any extrinsic,callsis emptyDenyAll— proxy cannot execute anything (deprecated types),callsis emptyAllow— proxy can only execute extrinsics listed incalls(minusexceptions)Deny— proxy can execute everything except extrinsics listed incalls