Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
75fa698
use patched polkadot-sdk
liamaharon Aug 7, 2025
0f404cb
basic babe block check in aura mode
liamaharon Aug 7, 2025
19ea395
aura to babe keystore migration
liamaharon Aug 7, 2025
81da4de
remove grandpa specific patch
liamaharon Aug 7, 2025
9c6b06e
clippy
liamaharon Aug 8, 2025
30b09fa
use otf patch
liamaharon Aug 8, 2025
c5124b2
bump spec version
liamaharon Aug 8, 2025
17b8674
Merge branch 'devnet-ready' into hybrid-node
liamaharon Aug 8, 2025
32d2c71
match devnet-ready
liamaharon Aug 8, 2025
5227bad
cargo +nightly fmt
liamaharon Aug 8, 2025
8d6b090
improve comment
liamaharon Aug 8, 2025
8cf0dc8
update polkadot-sdk patch
liamaharon Aug 8, 2025
dd2431f
Merge branch 'devnet-ready' into hybrid-node
liamaharon Aug 9, 2025
f19b42c
slot duration
liamaharon Aug 9, 2025
fb4157c
better babe to aura handling
liamaharon Aug 9, 2025
8c29e38
update polkadot sdk
liamaharon Aug 9, 2025
386fb16
fix benchmark compile
liamaharon Aug 9, 2025
8895c8f
use cargo patch
liamaharon Aug 9, 2025
5ce881d
cargo +nightly fmt
liamaharon Aug 11, 2025
0340cb4
fix tests
liamaharon Aug 11, 2025
2d2484b
remove redundant comment
liamaharon Aug 11, 2025
4bb7eff
bump spec version
liamaharon Aug 11, 2025
c596106
Merge branch 'devnet-ready' into hybrid-node
liamaharon Aug 12, 2025
12ab174
update cargo.lock
liamaharon Aug 12, 2025
8994c41
cargo +nightly fmt
liamaharon Aug 12, 2025
868268f
auto-update benchmark weights
github-actions[bot] Aug 12, 2025
0066b48
Merge branch 'devnet-ready' into hybrid-node
liamaharon Aug 12, 2025
5d564f7
Merge branch 'devnet-ready' into hybrid-node
liamaharon Aug 13, 2025
8124dbc
reset grandpa rpc change
liamaharon Aug 13, 2025
df46cc9
reset frontier changes
liamaharon Aug 13, 2025
1d4e5f6
cleanup
liamaharon Aug 13, 2025
e2265cd
auto-update benchmark weights
github-actions[bot] Aug 13, 2025
4d8ea1f
update to psdk without aura try-state auth len checks
liamaharon Aug 13, 2025
6ed1c0e
Skip checks that include execution, if being told so or when importin…
liamaharon Aug 14, 2025
db19d00
Merge branch 'devnet-ready' into hybrid-node
liamaharon Aug 14, 2025
708c01a
Merge branch 'devnet-ready' into hybrid-node
liamaharon Aug 14, 2025
2cd77ec
update cargo.lock
liamaharon Aug 14, 2025
65269c2
fix devnet-ready test
liamaharon Aug 14, 2025
f68452d
auto-update benchmark weights
github-actions[bot] Aug 14, 2025
7480dff
Merge branch 'devnet-ready' into hybrid-node
liamaharon Aug 18, 2025
177747b
fix test compile
liamaharon Aug 18, 2025
f92fa17
reset test to devnet-ready
liamaharon Aug 18, 2025
dc78a0a
auto-update benchmark weights
github-actions[bot] Aug 18, 2025
2d8caf7
wip fix warp sync across aura / babe boundary
liamaharon Aug 20, 2025
d16989e
Merge branch 'hybrid-node' of github.com:opentensor/subtensor into hy…
liamaharon Aug 20, 2025
2cb28ee
todo comment
liamaharon Aug 20, 2025
baedfcf
improve naming
liamaharon Aug 20, 2025
b81862a
cherry pick
liamaharon Aug 20, 2025
fb40725
fix warp sync
liamaharon Aug 21, 2025
be10e98
update psdk patch version
liamaharon Aug 22, 2025
4c1ca4a
comment
liamaharon Aug 22, 2025
0f37b9a
merge devnet-ready
liamaharon Aug 25, 2025
c81e02b
comment
liamaharon Aug 25, 2025
8b8951d
Merge branch 'devnet-ready' into hybrid-node
liamaharon Aug 25, 2025
29f9d37
clippy
liamaharon Aug 25, 2025
dc90812
cargo +nightly fmt
liamaharon Aug 25, 2025
c0c7938
use conditional block import
liamaharon Aug 26, 2025
36b65b3
auto-update benchmark weights
github-actions[bot] Aug 26, 2025
4cb23b2
merge devnet-ready
liamaharon Sep 1, 2025
7f8a2d0
simplify check_block
liamaharon Sep 1, 2025
a234096
improve comment
liamaharon Sep 1, 2025
00d5003
unify spawn_essential_handles params into SpawnEssentialHandlesParams
liamaharon Sep 1, 2025
914030d
Revert "unify spawn_essential_handles params into SpawnEssentialHandl…
liamaharon Sep 2, 2025
eb88056
consistent naming for custom_service_signal
liamaharon Sep 2, 2025
8f2b47e
replace _otf with _subtensor_
liamaharon Sep 4, 2025
780e6b8
auto-update benchmark weights
github-actions[bot] Sep 4, 2025
77575e3
merge devnet-ready
liamaharon Sep 4, 2025
c93bebd
bump spec version
liamaharon Sep 4, 2025
ca1b59b
merge devnet-ready
liamaharon Sep 18, 2025
edc68a1
zepter
liamaharon Sep 18, 2025
bc3d66d
update psdk patch
liamaharon Sep 19, 2025
a698f22
Merge branch 'devnet-ready' into hybrid-node
liamaharon Sep 23, 2025
a80cb71
bump spec version
liamaharon Sep 23, 2025
a5f6538
update cargo.lock
liamaharon Sep 23, 2025
52808e0
revert to pay no
open-junius Sep 25, 2025
aaae3ef
fix unit test, evm test
open-junius Sep 25, 2025
9505c18
commit Cargo.lock
open-junius Sep 25, 2025
99df7c6
commit Cargo.lock
open-junius Sep 25, 2025
fd19737
commit Cargo.lock
open-junius Sep 25, 2025
eb5155e
fix unit test
open-junius Sep 26, 2025
bf29ffa
update doc
open-junius Sep 26, 2025
2251551
bump version
open-junius Sep 26, 2025
9e5a0c9
add test cases
open-junius Sep 26, 2025
fb62d2f
update rate
open-junius Sep 26, 2025
c22a38f
cargo clippy
open-junius Sep 26, 2025
a1d7488
fix unit test
open-junius Sep 26, 2025
af9aafc
update doc
open-junius Sep 26, 2025
0a41ca6
Merge pull request #2079 from opentensor/evm-associate-key-rate-limit
sam0x17 Sep 26, 2025
760af5a
Merge branch 'devnet-ready' into hybrid-node
liamaharon Sep 28, 2025
40945a9
Merge pull request #1927 from opentensor/hybrid-node
sam0x17 Sep 28, 2025
4ac0e73
update trim test to check UID map changed
camfairchild Sep 29, 2025
3e00e41
bump spec
camfairchild Sep 29, 2025
b0590ec
renumber UIDs during trim
camfairchild Sep 29, 2025
29974a9
clpy
camfairchild Sep 29, 2025
0ac67c9
chore: clpy
camfairchild Sep 29, 2025
930ba5c
handle AssociatedEvmAddress in trim
camfairchild Sep 29, 2025
20db6a0
chore: lock
camfairchild Sep 29, 2025
7974e99
fix h160 literals
camfairchild Sep 29, 2025
94d5ce1
added assert for remapped evm address
l0r1s Sep 29, 2025
82b3f31
make immune limit error more explicit
l0r1s Sep 29, 2025
e00abe3
Merge pull request #2085 from opentensor/hotfix/trim-uids-doesnt-renu…
l0r1s Sep 30, 2025
ca6e1be
Add StakeWeight to persist function
gztensor Sep 30, 2025
57c2b11
Add StakeWeight to clean_neuron
gztensor Sep 30, 2025
5ad0e70
Merge pull request #2091 from opentensor/fix/stake-weights
sam0x17 Sep 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13,109 changes: 8,710 additions & 4,399 deletions Cargo.lock

Large diffs are not rendered by default.

233 changes: 215 additions & 18 deletions Cargo.toml

Large diffs are not rendered by default.

121 changes: 60 additions & 61 deletions evm-tests/test/evm-uid.precompile.lookup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,77 +14,76 @@ import { keccak256 } from 'ethers';
import { addNewSubnetwork, forceSetBalanceToSs58Address, startCall } from "../src/subtensor";

describe("Test the UID Lookup precompile", () => {
const hotkey = getRandomSubstrateKeypair();
const coldkey = getRandomSubstrateKeypair();
const evmWallet = generateRandomEthersWallet();
let publicClient: PublicClient;
const hotkey = getRandomSubstrateKeypair();
const coldkey = getRandomSubstrateKeypair();
const evmWallet = generateRandomEthersWallet();
let publicClient: PublicClient;

let api: TypedApi<typeof devnet>
let api: TypedApi<typeof devnet>

let alice: PolkadotSigner;
let alice: PolkadotSigner;

let uid: number;
let blockNumber: number;
let netuid: number;
let blockNumberAssociated: bigint;
let uid: number;
let blockNumber: number;
let netuid: number;
let blockNumberAssociated: bigint;

before(async () => {
publicClient = await getPublicClient(ETH_LOCAL_URL)
api = await getDevnetApi()
alice = await getAliceSigner();
before(async () => {
publicClient = await getPublicClient(ETH_LOCAL_URL)
api = await getDevnetApi()
alice = await getAliceSigner();

await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(alice.publicKey))
await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(hotkey.publicKey))
await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(coldkey.publicKey))
await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(alice.publicKey))
await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(hotkey.publicKey))
await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(coldkey.publicKey))

netuid = await addNewSubnetwork(api, hotkey, coldkey)
await startCall(api, netuid, coldkey)
netuid = await addNewSubnetwork(api, hotkey, coldkey)
await startCall(api, netuid, coldkey)

const maybeUid = await api.query.SubtensorModule.Uids.getValue(netuid, convertPublicKeyToSs58(hotkey.publicKey))
const maybeUid = await api.query.SubtensorModule.Uids.getValue(netuid, convertPublicKeyToSs58(hotkey.publicKey))

if (maybeUid === undefined) {
throw new Error("UID should be defined")
}
uid = maybeUid
if (maybeUid === undefined) {
throw new Error("UID should be defined")
}
uid = maybeUid

// Associate EVM key
blockNumber = await api.query.System.Number.getValue();
const blockNumberBytes = u64.enc(BigInt(blockNumber));
const blockNumberHash = hexToU8a(keccak256(blockNumberBytes));
const concatenatedArray = new Uint8Array([...hotkey.publicKey, ...blockNumberHash]);
const signature = await evmWallet.signMessage(concatenatedArray);
const associateEvmKeyTx = api.tx.SubtensorModule.associate_evm_key({
netuid: netuid,
hotkey: convertPublicKeyToSs58(hotkey.publicKey),
evm_key: convertToFixedSizeBinary(evmWallet.address, 20),
block_number: BigInt(blockNumber),
signature: convertToFixedSizeBinary(signature, 65)
});
const signer = getSignerFromKeypair(coldkey);
await waitForTransactionCompletion(api, associateEvmKeyTx, signer)
.then(() => { })
.catch((error) => { console.log(`transaction error ${error}`) });
// Associate EVM key
blockNumber = await api.query.System.Number.getValue();
const blockNumberBytes = u64.enc(BigInt(blockNumber));
const blockNumberHash = hexToU8a(keccak256(blockNumberBytes));
const concatenatedArray = new Uint8Array([...hotkey.publicKey, ...blockNumberHash]);
const signature = await evmWallet.signMessage(concatenatedArray);
const associateEvmKeyTx = api.tx.SubtensorModule.associate_evm_key({
netuid: netuid,
evm_key: convertToFixedSizeBinary(evmWallet.address, 20),
block_number: BigInt(blockNumber),
signature: convertToFixedSizeBinary(signature, 65)
});
const signer = getSignerFromKeypair(hotkey);
await waitForTransactionCompletion(api, associateEvmKeyTx, signer)
.then(() => { })
.catch((error) => { console.log(`transaction error ${error}`) });

const storedEvmKey = await api.query.SubtensorModule.AssociatedEvmAddress.getValue(netuid, uid)
assert.notEqual(storedEvmKey, undefined, "storedEvmKey should be defined")
if (storedEvmKey !== undefined) {
assert.equal(storedEvmKey[0].asHex(), convertToFixedSizeBinary(evmWallet.address, 20).asHex())
blockNumberAssociated = storedEvmKey[1]
}
})

it("UID lookup via precompile contract works correctly", async () => {
// Get UID for the EVM address
const uidArray = await publicClient.readContract({
abi: IUIDLookupABI,
address: toViemAddress(IUID_LOOKUP_ADDRESS),
functionName: "uidLookup",
args: [netuid, evmWallet.address, 1024]
})
const storedEvmKey = await api.query.SubtensorModule.AssociatedEvmAddress.getValue(netuid, uid)
assert.notEqual(storedEvmKey, undefined, "storedEvmKey should be defined")
if (storedEvmKey !== undefined) {
assert.equal(storedEvmKey[0].asHex(), convertToFixedSizeBinary(evmWallet.address, 20).asHex())
blockNumberAssociated = storedEvmKey[1]
}
})

assert.notEqual(uidArray, undefined, "UID should be defined")
assert.ok(Array.isArray(uidArray), `UID should be an array, got ${typeof uidArray}`)
assert.ok(uidArray.length > 0, "UID array should not be empty")
assert.deepStrictEqual(uidArray[0], { uid: uid, block_associated: blockNumberAssociated })
it("UID lookup via precompile contract works correctly", async () => {
// Get UID for the EVM address
const uidArray = await publicClient.readContract({
abi: IUIDLookupABI,
address: toViemAddress(IUID_LOOKUP_ADDRESS),
functionName: "uidLookup",
args: [netuid, evmWallet.address, 1024]
})

assert.notEqual(uidArray, undefined, "UID should be defined")
assert.ok(Array.isArray(uidArray), `UID should be an array, got ${typeof uidArray}`)
assert.ok(uidArray.length > 0, "UID array should not be empty")
assert.deepStrictEqual(uidArray[0], { uid: uid, block_associated: blockNumberAssociated })
})
});
8 changes: 6 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ serde_json.workspace = true
sc-chain-spec-derive.workspace = true
sc-cli.workspace = true
sc-consensus-babe.workspace = true
sc-consensus-epochs.workspace = true
sp-consensus.workspace = true
sp-consensus-slots.workspace = true
sp-core.workspace = true
Expand Down Expand Up @@ -73,8 +74,9 @@ sp-crypto-ec-utils = { workspace = true, default-features = true, features = [
"bls12-381",
] }
sp-keystore.workspace = true
cumulus-primitives-proof-size-hostfunction.workspace = true

polkadot-sdk = { workspace = true, features = [
"cumulus-primitives-proof-size-hostfunction",
] }

# These dependencies are used for the subtensor's RPCs
jsonrpsee = { workspace = true, features = ["server"] }
Expand Down Expand Up @@ -151,6 +153,7 @@ runtime-benchmarks = [
"pallet-commitments/runtime-benchmarks",
"pallet-drand/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"polkadot-sdk/runtime-benchmarks",
]
pow-faucet = []

Expand All @@ -163,6 +166,7 @@ try-runtime = [
"sp-runtime/try-runtime",
"pallet-commitments/try-runtime",
"pallet-drand/try-runtime",
"polkadot-sdk/try-runtime",
]

metadata-hash = ["node-subtensor-runtime/metadata-hash"]
2 changes: 1 addition & 1 deletion node/src/chain_spec/localnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn localnet_config(single_authority: bool) -> Result<ChainSpec, String> {
.with_name("Bittensor")
.with_protocol_id("bittensor")
.with_id("bittensor")
.with_chain_type(ChainType::Development)
.with_chain_type(ChainType::Local)
.with_genesis_config_patch(localnet_genesis(
// Initial PoA authorities (Validators)
// aura | grandpa
Expand Down
2 changes: 1 addition & 1 deletion node/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cumulus_primitives_proof_size_hostfunction::storage_proof_size::HostFunctions as ProofSize;
use node_subtensor_runtime::{RuntimeApi, opaque::Block};
use polkadot_sdk::cumulus_primitives_proof_size_hostfunction::storage_proof_size::HostFunctions as ProofSize;
use sc_executor::WasmExecutor;

/// Full backend.
Expand Down
16 changes: 11 additions & 5 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ fn start_babe_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> {
return start_babe_service(arg_matches);
// Unknown error, return it.
} else {
log::error!("Failed to start Babe service: {e:?}");
Err(e.into())
}
}
Expand All @@ -288,16 +289,21 @@ fn start_aura_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> {
//
// Passing this atomic bool is a hacky solution, allowing the node to set it to true to indicate
// a Babe service should be spawned on exit instead of a regular shutdown.
let babe_switch = Arc::new(AtomicBool::new(false));
let babe_switch_clone = babe_switch.clone();
let custom_service_signal = Arc::new(AtomicBool::new(false));
let custom_service_signal_clone = custom_service_signal.clone();
match runner.run_node_until_exit(|config| async move {
let config = customise_config(arg_matches, config);
service::build_full::<AuraConsensus>(config, cli.eth, cli.sealing, Some(babe_switch_clone))
.await
service::build_full::<AuraConsensus>(
config,
cli.eth,
cli.sealing,
Some(custom_service_signal_clone),
)
.await
}) {
Ok(()) => Ok(()),
Err(e) => {
if babe_switch.load(std::sync::atomic::Ordering::Relaxed) {
if custom_service_signal.load(std::sync::atomic::Ordering::Relaxed) {
start_babe_service(arg_matches)
} else {
Err(e.into())
Expand Down
Loading
Loading