Skip to content

BlockEmission RPC#2778

Open
JohnReedV wants to merge 13 commits into
devnet-readyfrom
block-emission-rpc
Open

BlockEmission RPC#2778
JohnReedV wants to merge 13 commits into
devnet-readyfrom
block-emission-rpc

Conversation

@JohnReedV

@JohnReedV JohnReedV commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Description

This PR replaces the BlockEmission storage-map update path with a custom block-emission RPC. The goal is to avoid writing the same derived emission value to storage every block while still exposing the current block emission to callers.

What Changed

  • Added subnetInfo_getBlockEmission to the subtensor custom RPC surface.
  • Added get_block_emission() to the subtensor runtime API and wired the runtime implementation to SubtensorModule::calculate_block_emission().
  • Stopped updating BlockEmission inside calculate_block_emission().
  • Marked the BlockEmission storage value as deprecated in favor of calculate_block_emission() or the new RPC.
  • Bumped runtime/src/lib.rs spec_version from 421 to 422.

Behavioral Impact

Block emission is now computed on demand for the RPC instead of being persisted to BlockEmission during block execution. Coinbase minting continues to use the same calculation path, so the emission formula and mint amount are unchanged.

Migration / Runtime Version

This is runtime-affecting and includes a spec_version bump. No storage migration is introduced; the existing BlockEmission storage item remains present but deprecated.

Testing

CI should run the runtime/RPC compile checks. The Auditor pass verified formatting for the changed Rust files with rustfmt --edition 2024 --check and git diff --check; a local targeted cargo check attempt was blocked by the sandboxed read-only Cargo/rustup cache paths.

@JohnReedV JohnReedV added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label Jun 22, 2026
@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

🛡️ AI Review — Skeptic (security review)

VERDICT: SAFE

BASELINE scrutiny: established @opentensor contributor with write permission; no Gittensor allowlist hit; branch block-emission-rpc -> devnet-ready.

Reviewed the trusted instructions, prefetched metadata, prior Skeptic sticky, contributor signals, comments, changed-file list, and full patch. The PR does not modify .github/ review instructions, .github/copilot-instructions.md, Cargo manifests, lockfiles, build scripts, dependencies, origins, or extrinsics. The executable change adds a read-only RPC/runtime API path backed by the existing checked/saturating block-emission calculation, removes persistence of the derived BlockEmission value from block execution, and updates generated weights/spec version accordingly.

Findings

No findings.

Conclusion

No malicious behavior or security vulnerability was found in the static diff. The prior Skeptic sticky has no finding IDs, so there is nothing to reconcile.


🔍 AI Review — Auditor (domain review)

VERDICT: 👍

Gittensor UNKNOWN; author has write permission and substantial prior subtensor activity, so review is calibrated as established contributor domain review.

PR body is substantive and implementation is aligned with the stated behavior, except for one stale detail: the body says spec_version was bumped from 421 to 422, while the current diff bumps 422 to 423. The overlapping PRs appear to be mechanical overlap on shared runtime/weights files rather than competing BlockEmission RPC implementations.

git diff --check is clean; no auto-fix was needed or run.

Findings

Sev File Finding
LOW pallets/subtensor/runtime-api/src/lib.rs:64 Bump the runtime API version for the new method inline

Prior-comment reconciliation

  • c4631490: not addressedget_block_emission is still added without a new runtime API version marker, and the runtime implementation remains #[api_version(2)].

Conclusion

The PR removes the derived per-block BlockEmission storage write and exposes the value via an RPC backed by the existing checked/saturating calculation, with the runtime spec_version bumped. I found one low-severity runtime API versioning cleanup, but no blocking domain issues.


📜 Previous run (superseded)
Sev File Finding Status
LOW pallets/subtensor/runtime-api/src/lib.rs:64 Bump the runtime API version for the new method ➡️ Carried forward to current findings
get_block_emission is still added without a new runtime API version marker, and the runtime implementation remains #[api_version(2)].

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@sam0x17

sam0x17 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

conflicts

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review — see the sticky summary comment for the verdict and the inline comments below for specific findings.

Comment thread pallets/subtensor/runtime-api/src/lib.rs
@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review — see the sticky summary comment for the verdict and the inline comments below for specific findings.

Comment thread pallets/subtensor/runtime-api/src/lib.rs
@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review — see the sticky summary comment for the verdict and the inline comments below for specific findings.

Comment thread pallets/subtensor/runtime-api/src/lib.rs
@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review — see the sticky summary comment for the verdict and the inline comments below for specific findings.

Comment thread pallets/subtensor/runtime-api/src/lib.rs
@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review — see the sticky summary comment for the verdict and the inline comments below for specific findings.

Comment thread pallets/subtensor/runtime-api/src/lib.rs
@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants