Add getNetworkRegistrationBlock view to SubnetPrecompile#2674
Conversation
|
Thanks for the contribution. I will scan all view functions defined in precompiles, record the cost of reading data from storage. |
…-precompile-network-registered-block
060ad39
|
Done! @l0r1s @open-junius I've merged devnet-ready and bumped the spec version to 414. |
|
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? |
…-precompile-network-registered-block # Conflicts: # runtime/src/lib.rs
|
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! |
Description
Adds
getNetworkRegistrationBlock(uint16)as a view function toSubnetPrecompile, allowing smart contracts to query the block number at which a given subnet was registered. The function reads directly fromNetworkRegisteredAtstorage and explicitly recordsdb_read_gas_costso callers are correctly charged when invoked from within a contract.Also adds the corresponding ABI entry to
contract-tests/src/contracts/subnet.tsand an e2e test incontract-tests/test/precompileWrapper.direct-call.test.ts.Related Issue(s)
Type of Change
Breaking Change
N/A
Checklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctlyScreenshots (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 viahandle.record_cost(RuntimeHelper::<R>::db_read_gas_cost())- unlike the existing view functions which omit this.