Skip to content

Add getNetworkRegistrationBlock view to SubnetPrecompile#2674

Merged
open-junius merged 6 commits into
opentensor:devnet-readyfrom
bittensor-church:feat/subnet-precompile-network-registered-block
Jun 3, 2026
Merged

Add getNetworkRegistrationBlock view to SubnetPrecompile#2674
open-junius merged 6 commits into
opentensor:devnet-readyfrom
bittensor-church:feat/subnet-precompile-network-registered-block

Conversation

@fine135
Copy link
Copy Markdown

@fine135 fine135 commented May 19, 2026

Description

Adds getNetworkRegistrationBlock(uint16) as a view function to SubnetPrecompile, allowing smart contracts to query the block number at which a given subnet was registered. The function reads directly from NetworkRegisteredAt storage and explicitly records db_read_gas_cost so callers are correctly charged when invoked from within a contract.

Also adds the corresponding ABI entry to contract-tests/src/contracts/subnet.ts and an e2e test in contract-tests/test/precompileWrapper.direct-call.test.ts.

Related Issue(s)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Breaking Change

N/A

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have run ./scripts/fix_rust.sh to ensure my code is formatted and linted correctly
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Screenshots (if applicable)

N/A

Additional Notes

The function follows the same pattern as other view functions in SubnetPrecompile (e.g. getServingRateLimit), with the addition of explicit gas metering via handle.record_cost(RuntimeHelper::<R>::db_read_gas_cost()) - unlike the existing view functions which omit this.

open-junius
open-junius previously approved these changes May 20, 2026
@open-junius open-junius added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label May 20, 2026
@open-junius
Copy link
Copy Markdown
Contributor

Thanks for the contribution. I will scan all view functions defined in precompiles, record the cost of reading data from storage.

Comment thread contract-tests/src/contracts/precompileWrapper.sol Outdated
@fine135 fine135 changed the title Add getNetworkRegisteredBlock view to SubnetPrecompile Add getNetworkRegistrationBlock view to SubnetPrecompile May 22, 2026
open-junius
open-junius previously approved these changes May 27, 2026
@open-junius open-junius requested a review from l0r1s May 27, 2026 15:10
l0r1s
l0r1s previously approved these changes May 27, 2026
Copy link
Copy Markdown
Collaborator

@l0r1s l0r1s left a comment

Choose a reason for hiding this comment

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

Looks good, @fine135 you need to merge devnet-ready and then bump spec version and we should be good to merge

evgeny-s
evgeny-s previously approved these changes May 28, 2026
@fine135 fine135 dismissed stale reviews from evgeny-s, l0r1s, and open-junius via 060ad39 June 1, 2026 14:51
@fine135
Copy link
Copy Markdown
Author

fine135 commented Jun 1, 2026

Done! @l0r1s @open-junius I've merged devnet-ready and bumped the spec version to 414.

l0r1s
l0r1s previously approved these changes Jun 2, 2026
JohnReedV
JohnReedV previously approved these changes Jun 2, 2026
@fine135
Copy link
Copy Markdown
Author

fine135 commented Jun 3, 2026

Hi @l0r1s and @JohnReedV, it looks like there are merge conflicts in lib.rs again. Should I merge the devnet-ready branch and bump the version one more time?
Also, to avoid these recurring conflicts while the PR is waiting, is there a better workflow I should follow? For example, should I ping you on Discord once it's green? I'd love to get this merged smoothly. Thank you!

fine135 added 2 commits June 3, 2026 13:58
…-precompile-network-registered-block

# Conflicts:
#	runtime/src/lib.rs
@fine135 fine135 dismissed stale reviews from JohnReedV and l0r1s via b1ca9a5 June 3, 2026 11:59
@fine135
Copy link
Copy Markdown
Author

fine135 commented Jun 3, 2026

Hi @l0r1s @JohnReedV @sam0x17, just a quick update: I've merged devnet-ready and bumped the version in lib.rs, so the conflicts are resolved. Could you please give it a quick review and merge it when you have a moment? I'm hoping to get it in before any new conflicts pop up. Thanks!

@open-junius open-junius merged commit 20276fa into opentensor:devnet-ready Jun 3, 2026
215 of 217 checks passed
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.

5 participants