@@ -13,10 +13,6 @@ export async function addNewSubnetwork(api: TypedApi<typeof devnet>, hotkey: Key
1313 const alice = getAliceSigner ( )
1414 const totalNetworks = await api . query . SubtensorModule . TotalNetworks . getValue ( )
1515
16- const defaultNetworkLastLockCost = await api . query . SubtensorModule . NetworkMinLockCost . getValue ( )
17-
18- // const defaultNetworkMinLockCost = await api.query.SubtensorModule.NetworkMinLockCost.getValue()
19-
2016 const rateLimit = await api . query . SubtensorModule . NetworkRateLimit . getValue ( )
2117 if ( rateLimit !== BigInt ( 0 ) ) {
2218 const internalCall = api . tx . AdminUtils . sudo_set_network_rate_limit ( { rate_limit : BigInt ( 0 ) } )
@@ -32,8 +28,7 @@ export async function addNewSubnetwork(api: TypedApi<typeof devnet>, hotkey: Key
3228 // could create multiple subnetworks during retry, just return the first created one
3329 assert . ok ( newTotalNetworks > totalNetworks )
3430
35- // reset network last lock cost to 0, to avoid the lock cost calculation error
36- await setNetworkLastLockCost ( api , defaultNetworkLastLockCost )
31+ await resetNetworkLastLockCost ( api )
3732 return totalNetworks
3833}
3934
@@ -408,17 +403,19 @@ export async function sendWasmContractExtrinsic(api: TypedApi<typeof devnet>, co
408403 await waitForTransactionWithRetry ( api , tx , signer )
409404}
410405
411- export async function setNetworkLastLockCost ( api : TypedApi < typeof devnet > , defaultNetworkLastLockCost : bigint ) {
406+ // reset network last lock cost to networkMinLockCost, to avoid the lock cost calculation error
407+ export async function resetNetworkLastLockCost ( api : TypedApi < typeof devnet > ) {
412408 const alice = getAliceSigner ( )
413409 const key = await api . query . SubtensorModule . NetworkLastLockCost . getKey ( )
414410 const codec = await getTypedCodecs ( devnet ) ;
415- const value = codec . query . SubtensorModule . NetworkLastLockCost . value . enc ( defaultNetworkLastLockCost )
411+ const networkMinLockCost = await api . query . SubtensorModule . NetworkMinLockCost . getValue ( )
412+ const value = codec . query . SubtensorModule . NetworkLastLockCost . value . enc ( networkMinLockCost )
416413 const internalCall = api . tx . System . set_storage ( {
417414 items : [ [ Binary . fromHex ( key ) , Binary . fromBytes ( value ) ] ]
418415 } )
419416 const tx = api . tx . Sudo . sudo ( { call : internalCall . decodedCall } )
420417 await waitForTransactionWithRetry ( api , tx , alice )
421418
422419 const valueOnChain = await api . query . SubtensorModule . NetworkLastLockCost . getValue ( )
423- assert . equal ( defaultNetworkLastLockCost , valueOnChain )
420+ assert . equal ( networkMinLockCost , valueOnChain )
424421}
0 commit comments