Skip to content

Add getNetworkRegisteredBlock view to SubnetPrecompile#3

Merged
fine135 merged 6 commits into
devnet-readyfrom
feat/subnet-precompile-network-registered-block
Jul 9, 2026
Merged

Add getNetworkRegisteredBlock view to SubnetPrecompile#3
fine135 merged 6 commits into
devnet-readyfrom
feat/subnet-precompile-network-registered-block

Conversation

@fine135

@fine135 fine135 commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds getNetworkRegisteredBlock(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.

@fine135 fine135 force-pushed the feat/subnet-precompile-network-registered-block branch from a0f8299 to 4408e26 Compare May 13, 2026 10:52
@fine135 fine135 merged commit 20276fa into devnet-ready Jul 9, 2026
11 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant