Skip to content

Apply tx & dispatch extensions conditionally#2812

Merged
sam0x17 merged 2 commits into
mainfrom
conditional-ext
Jun 29, 2026
Merged

Apply tx & dispatch extensions conditionally#2812
sam0x17 merged 2 commits into
mainfrom
conditional-ext

Conversation

@l0r1s

@l0r1s l0r1s commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR reduces the overall fee charged by the subtensor transaction extension by making most dispatch-extension weights conditional on the call they actually validate.

Previously, every transaction paid the benchmarked weight for each subtensor dispatch extension, even when the call could not be affected by that extension. This meant unrelated calls, such as staking calls, could pay for delegate-take, serving-endpoint, EVM-key-association, rate-limit, and weights checks.

The change introduces a shared applicable_call helper that downcasts runtime calls to subtensor calls and filters them through each guard's applies_to predicate. The same filter is used by:

  • DispatchExtension::weight
  • DispatchExtension::pre_dispatch
  • SubtensorTransactionExtension::check

CheckColdkeySwap remains unconditional because coldkey swap state can block any signed runtime call.

Changes

  • Charge CheckDelegateTake weight only for increase_take and decrease_take.
  • Charge CheckWeights weight only for weight commit, reveal, set, batch, and timelocked weight calls.
  • Charge CheckRateLimits weight only for rate-limited weight calls and register_network.
  • Charge CheckServingEndpoints weight only for axon and prometheus serving calls.
  • Charge CheckEvmKeyAssociation weight only for associate_evm_key.
  • Keep CheckColdkeySwap charged for all calls, since it can reject any signed call during a swap.
  • Align transaction validation with dispatch-extension applicability filtering.
  • Add focused tests covering zero weight for unrelated calls and expected weight for applicable calls.

@l0r1s l0r1s added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label Jun 29, 2026
@github-actions github-actions Bot added the hotfix This PR needs to be merged very quickly and will likely skip testing on devnet and testnet label Jun 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚨🚨🚨 HOTFIX DETECTED 🚨🚨🚨

It looks like you are trying to merge a hotfix PR into main. If this isn't what you wanted to do, and you just wanted to make a regular PR, please close this PR, base your changes off the devnet-ready branch and open a new PR into devnet ready.

If you are trying to merge a hotfix PR, please complete the following essential steps:

  1. go ahead and get this PR into main merged, so we can get the change in as quickly as possible!
  2. merge main into testnet, bumping spec_version
  3. deploy testnet
  4. merge testnet into devnet, bumping spec_version
  5. deploy devnet
  6. merge devnet into devnet-ready

If you do not complete these steps, your hotfix may be inadvertently removed in the future when branches are promoted to main, so it is essential that you do so.

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

🛡️ AI Review — Skeptic (security review)

VERDICT: SAFE

LOW scrutiny: established contributor with repo write permission, substantial prior subtensor history, no Gittensor allowlist match; conditional-ext targets main with hotfix label.

Reviewed the runtime/pallet guard changes statically. The new applies_to predicates match the existing non-pass-through branches in each guard's check() method, CheckColdkeySwap remains unconditional, and the PR does not modify dependencies, build scripts, workflows, or trusted AI-review instruction paths.

Findings

No findings.

Conclusion

No malicious behavior or security vulnerability found in the changed dispatch/transaction extension filtering. The direct-to-main branch path is marked as a hotfix and the PR body explains the fee overcharge being corrected.


🔍 AI Review — Auditor (domain review)

VERDICT: 👍

Gittensor UNKNOWN: no allowlist hit; author has repo write permission and substantial prior subtensor history, so calibrated as an established contributor.

PR body is substantive and matches the implementation. The direct main target is covered by the hotfix label.

Overlap check: #2745 and #2723 only overlap through common subtensor files and are not duplicate implementations of this fee/dispatch-extension change.

Auto-fix status: no files modified. I attempted the required Finney spec-version query, but this sandbox could not resolve entrypoint-finney.opentensor.ai; if CI reports live specVersion >= 424, runtime/src/lib.rs will need a bump.

Findings

No findings.

Conclusion

The applicability predicates match the existing guard behavior, coldkey-swap remains unconditional, and the PR adds focused coverage for conditional weights. No blocking domain issue found in static review.

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@sam0x17 sam0x17 merged commit 6d81084 into main Jun 29, 2026
228 of 238 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotfix This PR needs to be merged very quickly and will likely skip testing on devnet and testnet skip-cargo-audit This PR fails cargo audit but needs to be merged anyway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants