Skip to content

Commit 77575e3

Browse files
committed
merge devnet-ready
2 parents 780e6b8 + a7904e0 commit 77575e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2164
-1698
lines changed

.github/workflows/evm-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
uses: Swatinem/rust-cache@v2
4141

4242
- name: Set up Node.js
43-
uses: actions/setup-node@v2
43+
uses: actions/setup-node@v4
4444
with:
4545
node-version: "22"
4646

Cargo.lock

Lines changed: 368 additions & 368 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 188 additions & 188 deletions
Large diffs are not rendered by default.

common/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub enum ProxyType {
154154
Registration,
155155
Transfer,
156156
SmallTransfer,
157-
RootWeights,
157+
RootWeights, // deprecated
158158
ChildKeys,
159159
SudoUncheckedSetCode,
160160
SwapHotkey,

evm-tests/package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,28 @@
77
"license": "ISC",
88
"dependencies": {
99
"@polkadot-api/descriptors": "file:.papi/descriptors",
10-
"@polkadot-labs/hdkd": "^0.0.10",
11-
"@polkadot-labs/hdkd-helpers": "^0.0.11",
12-
"@polkadot/api": "15.1.1",
10+
"@polkadot-labs/hdkd": "^0.0.23",
11+
"@polkadot-labs/hdkd-helpers": "^0.0.23",
12+
"@polkadot/api": "^16.4.6",
1313
"@types/mocha": "^10.0.10",
14-
"crypto": "^1.0.1",
15-
"dotenv": "16.4.7",
14+
"dotenv": "17.2.1",
1615
"ethers": "^6.13.5",
1716
"mocha": "^11.1.0",
1817
"polkadot-api": "^1.9.5",
18+
"rxjs": "^7.8.2",
1919
"scale-ts": "^1.6.1",
2020
"viem": "2.23.4",
2121
"ws": "^8.18.2"
2222
},
2323
"devDependencies": {
2424
"@types/bun": "^1.1.13",
2525
"@types/chai": "^5.0.1",
26+
"@types/node": "^22.18.0",
2627
"assert": "^2.1.0",
27-
"chai": "^5.2.0",
28+
"chai": "^6.0.1",
2829
"prettier": "^3.3.3",
2930
"ts-node": "^10.9.2",
3031
"typescript": "^5.7.2",
31-
"vite": "^5.4.8"
32+
"vite": "^7.1.4"
3233
}
3334
}

evm-tests/src/contracts/alpha.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,5 +315,18 @@ export const IAlphaABI = [
315315
],
316316
"stateMutability": "view",
317317
"type": "function"
318+
},
319+
{
320+
"inputs": [],
321+
"name": "getCKBurn",
322+
"outputs": [
323+
{
324+
"internalType": "uint256",
325+
"name": "",
326+
"type": "uint256"
327+
}
328+
],
329+
"stateMutability": "view",
330+
"type": "function"
318331
}
319332
]

evm-tests/src/subtensor.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,6 @@ export async function setMinDelegateTake(api: TypedApi<typeof devnet>, minDelega
268268
assert.equal(minDelegateTake, await api.query.SubtensorModule.MinDelegateTake.getValue())
269269
}
270270

271-
export async function becomeDelegate(api: TypedApi<typeof devnet>, ss58Address: string, keypair: KeyPair) {
272-
const signer = getSignerFromKeypair(keypair)
273-
274-
const tx = api.tx.SubtensorModule.become_delegate({
275-
hotkey: ss58Address
276-
})
277-
await waitForTransactionWithRetry(api, tx, signer)
278-
}
279-
280271
export async function addStake(api: TypedApi<typeof devnet>, netuid: number, ss58Address: string, amount_staked: bigint, keypair: KeyPair) {
281272
const signer = getSignerFromKeypair(keypair)
282273
let tx = api.tx.SubtensorModule.add_stake({

evm-tests/test/alpha.precompile.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { PublicClient } from "viem";
88
import { PolkadotSigner, TypedApi } from "polkadot-api";
99
import { toViemAddress, convertPublicKeyToSs58 } from "../src/address-utils"
1010
import { IAlphaABI, IALPHA_ADDRESS } from "../src/contracts/alpha"
11+
import { u64 } from "@polkadot-api/substrate-bindings";
1112

1213
describe("Test Alpha Precompile", () => {
1314
// init substrate part
@@ -209,6 +210,24 @@ describe("Test Alpha Precompile", () => {
209210
assert.ok(typeof alphaIssuance === 'bigint', "Alpha issuance should be a bigint");
210211
assert.ok(alphaIssuance >= BigInt(0), "Alpha issuance should be non-negative");
211212
});
213+
214+
it("getCKBurn returns valid CK burn rate", async () => {
215+
const ckBurn = await publicClient.readContract({
216+
abi: IAlphaABI,
217+
address: toViemAddress(IALPHA_ADDRESS),
218+
functionName: "getCKBurn",
219+
args: []
220+
})
221+
222+
const ckBurnOnChain = await api.query.SubtensorModule.CKBurn.getValue()
223+
224+
assert.strictEqual(ckBurn, ckBurnOnChain, "CK burn should match on chain");
225+
assert.ok(ckBurn !== undefined, "CK burn should be defined");
226+
const ckBurnPercentage = BigInt(ckBurn) * BigInt(100) / BigInt(2 ** 64 - 1)
227+
assert.ok(ckBurnPercentage >= BigInt(0), "CK burn percentage should be non-negative");
228+
assert.ok(ckBurnPercentage <= BigInt(100), "CK burn percentage should be less than or equal to 100");
229+
assert.ok(typeof ckBurn === 'bigint', "CK burn should be a bigint");
230+
});
212231
});
213232

214233
describe("Global Functions", () => {

evm-tests/test/staking.precompile.reward.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { tao } from "../src/balance-math"
77
import {
88
forceSetBalanceToSs58Address, addNewSubnetwork, burnedRegister,
99
setTxRateLimit, setTempo, setWeightsSetRateLimit, setSubnetOwnerCut, setMaxAllowedUids,
10-
setMinDelegateTake, becomeDelegate, setActivityCutoff, addStake, setWeight, rootRegister,
10+
setMinDelegateTake, setActivityCutoff, addStake, setWeight, rootRegister,
1111
startCall
1212
} from "../src/subtensor"
1313

@@ -52,8 +52,6 @@ describe("Test neuron precompile reward", () => {
5252
await setActivityCutoff(api, netuid, 65535)
5353
await setMaxAllowedUids(api, netuid, 65535)
5454
await setMinDelegateTake(api, 0)
55-
await becomeDelegate(api, convertPublicKeyToSs58(validator.publicKey), coldkey)
56-
await becomeDelegate(api, convertPublicKeyToSs58(miner.publicKey), coldkey)
5755
})
5856

5957
it("Staker receives rewards", async () => {

0 commit comments

Comments
 (0)