Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
776d886
add stake amount to priority
JohnReedV Feb 17, 2025
a0ffb6a
bring in utility pallet code
JohnReedV Feb 19, 2025
702ceb4
fix tests
JohnReedV Feb 19, 2025
67e23ef
fmt
JohnReedV Feb 19, 2025
9bdc8c6
skip adding weight if pays::no
JohnReedV Feb 19, 2025
abdb88b
address lints
JohnReedV Feb 19, 2025
cd90326
zepter
JohnReedV Feb 19, 2025
53154e4
Merge branch 'devnet-ready' into utility-pallet-fees
JohnReedV Feb 19, 2025
d237a0a
add types e2e test for evm
open-junius Mar 7, 2025
1c8e45a
fix comments
open-junius Mar 10, 2025
8ce14e1
update readme
open-junius Mar 10, 2025
4ef30b2
Merge branch 'devnet-ready' into feat/evm-typed-test
open-junius Mar 10, 2025
19be9c6
update test case name
open-junius Mar 10, 2025
6f3ce2c
EMA price halving period hyperparameter - in progress
gztensor Mar 10, 2025
ae4a15e
bring in proxy pallet code & skip pays::No
JohnReedV Mar 10, 2025
e28f934
address lints
JohnReedV Mar 10, 2025
d31e278
Add ema price period pallet type
gztensor Mar 10, 2025
0eedabe
lints
JohnReedV Mar 10, 2025
a0af732
Merge branch 'devnet-ready' into utility-pallet-fees
JohnReedV Mar 10, 2025
d75e442
Update chainspecs
JohnReedV Mar 10, 2025
470a73f
clippy
JohnReedV Mar 10, 2025
449bab0
Merge branch 'utility-pallet-fees' of github.com:opentensor/subtensor…
JohnReedV Mar 10, 2025
a8d1596
Split target folders for fast and non-fast block's chain
Mar 10, 2025
f293e46
Merge pull request #1388 from opentensor/feat/roman/split-targets-for…
sam0x17 Mar 11, 2025
def4b93
update readme
open-junius Mar 11, 2025
4892604
upgrade ring
open-junius Mar 11, 2025
0bf13a6
Add view specifier for stake getters in saking precompile
ales-otf Mar 11, 2025
194da70
Reformat
ales-otf Mar 11, 2025
0479ad1
Merge branch 'devnet-ready' into feat/ema-slowdown-hyperparam
gztensor Mar 11, 2025
b8cbd8d
Merge pull request #1390 from opentensor/fix/staking-precompile
sam0x17 Mar 11, 2025
9d018c0
Enforce ema price halving hyperparameter and add tests
gztensor Mar 11, 2025
cff4153
remove unnecessary subscription
open-junius Mar 11, 2025
c771436
Merge pull request #1374 from opentensor/feat/evm-typed-test
sam0x17 Mar 11, 2025
5903742
Merge pull request #1317 from opentensor/utility-pallet-fees
sam0x17 Mar 11, 2025
f19a566
Add flag `--build-only`
Mar 11, 2025
88df14e
Merge pull request #1393 from opentensor/feat/roman/add-flag-build-only
sam0x17 Mar 11, 2025
de04903
Update pallets/admin-utils/src/tests/mod.rs
gztensor Mar 11, 2025
47dacb6
Merge pull request #1313 from opentensor/staking-amount-priority
sam0x17 Mar 11, 2025
f6e6ee4
Merge pull request #1392 from opentensor/feat/ema-slowdown-hyperparam
sam0x17 Mar 11, 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
76 changes: 63 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,16 @@ pallet-insecure-randomness-collective-flip = { git = "https://github.com/parityt
pallet-membership = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
pallet-proxy = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
pallet-proxy = { path = "pallets/proxy", default-features = false }
pallet-safe-mode = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
pallet-scheduler = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
pallet-utility = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
pallet-utility = { path = "pallets/utility", default-features = false }
pallet-root-testing = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }

sc-basic-authorship = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" }
sc-cli = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" }
Expand Down
3 changes: 3 additions & 0 deletions evm-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.papi
.env
27 changes: 27 additions & 0 deletions evm-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# type-test

test with ts

## polkadot api

```bash
npx papi add devnet -w ws://10.0.0.11:9944
```

## get the new metadata

```bash
sh get-metadata.sh
```

## run all tests

```bash
yarn run test
```

## To run a particular test case, you can pass an argument with the name or part of the name. For example:

```bash
yarn run test -- -g "Can set subnet parameter"
```
3 changes: 3 additions & 0 deletions evm-tests/get-metadata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rm -rf .papi
npx papi add devnet -w ws://localhost:9944

53 changes: 53 additions & 0 deletions evm-tests/local.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import * as assert from "assert";
import { getAliceSigner, getClient, getDevnetApi, getRandomSubstrateKeypair } from "../src/substrate"
import { SUB_LOCAL_URL, } from "../src/config";
import { devnet } from "@polkadot-api/descriptors"
import { PolkadotSigner, TypedApi } from "polkadot-api";
import { convertPublicKeyToSs58, convertH160ToSS58 } from "../src/address-utils"
import { ethers } from "ethers"
import { INEURON_ADDRESS, INeuronABI } from "../src/contracts/neuron"
import { generateRandomEthersWallet } from "../src/utils"
import { forceSetBalanceToEthAddress, forceSetBalanceToSs58Address, addNewSubnetwork, burnedRegister } from "../src/subtensor"

describe("Test neuron precompile Serve Axon Prometheus", () => {
// init eth part
// const wallet1 = generateRandomEthersWallet();
// const wallet2 = generateRandomEthersWallet();
// const wallet3 = generateRandomEthersWallet();

// init substrate part

// const coldkey = getRandomSubstrateKeypair();

let api: TypedApi<typeof devnet>

// sudo account alice as signer
let alice: PolkadotSigner;
before(async () => {
// init variables got from await and async
const subClient = await getClient(SUB_LOCAL_URL)
api = await getDevnetApi()
// alice = await getAliceSigner();

// await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(coldkey.publicKey))
// await forceSetBalanceToEthAddress(api, wallet1.address)
// await forceSetBalanceToEthAddress(api, wallet2.address)
// await forceSetBalanceToEthAddress(api, wallet3.address)


let index = 0;
while (index < 30) {
const hotkey = getRandomSubstrateKeypair();
const coldkey = getRandomSubstrateKeypair();
await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(hotkey.publicKey))
await forceSetBalanceToSs58Address(api, convertPublicKeyToSs58(coldkey.publicKey))
let netuid = await addNewSubnetwork(api, hotkey, coldkey)
}


})

it("Serve Axon", async () => {

});
});
31 changes: 31 additions & 0 deletions evm-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"scripts": {
"test": "mocha --timeout 999999 --require ts-node/register test/*test.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@polkadot-api/descriptors": "file:.papi/descriptors",
"@polkadot-labs/hdkd": "^0.0.10",
"@polkadot-labs/hdkd-helpers": "^0.0.11",
"@polkadot/api": "15.1.1",
"crypto": "^1.0.1",
"dotenv": "16.4.7",
"ethers": "^6.13.5",
"polkadot-api": "^1.9.5",
"viem": "2.23.4"
},
"devDependencies": {
"@types/bun": "^1.1.13",
"@types/chai": "^5.0.1",
"@types/mocha": "^10.0.10",
"assert": "^2.1.0",
"chai": "^5.2.0",
"mocha": "^11.1.0",
"prettier": "^3.3.3",
"ts-node": "^10.9.2",
"typescript": "^5.7.2",
"vite": "^5.4.8"
}
}
77 changes: 77 additions & 0 deletions evm-tests/src/address-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Address } from "viem"
import { encodeAddress } from "@polkadot/util-crypto";
import { ss58Address } from "@polkadot-labs/hdkd-helpers";
import { hexToU8a } from "@polkadot/util";
import { blake2AsU8a, decodeAddress } from "@polkadot/util-crypto";
import { Binary } from "polkadot-api";
import { SS58_PREFIX } from "./config"

export function toViemAddress(address: string): Address {
let addressNoPrefix = address.replace("0x", "")
return `0x${addressNoPrefix}`
}

export function convertH160ToSS58(ethAddress: string) {
// get the public key
const hash = convertH160ToPublicKey(ethAddress);

// Convert the hash to SS58 format
const ss58Address = encodeAddress(hash, SS58_PREFIX);
return ss58Address;
}

export function convertPublicKeyToSs58(publickey: Uint8Array) {
return ss58Address(publickey, SS58_PREFIX);
}

export function convertH160ToPublicKey(ethAddress: string) {
const prefix = "evm:";
const prefixBytes = new TextEncoder().encode(prefix);
const addressBytes = hexToU8a(
ethAddress.startsWith("0x") ? ethAddress : `0x${ethAddress}`
);
const combined = new Uint8Array(prefixBytes.length + addressBytes.length);

// Concatenate prefix and Ethereum address
combined.set(prefixBytes);
combined.set(addressBytes, prefixBytes.length);

// Hash the combined data (the public key)
const hash = blake2AsU8a(combined);
return hash;
}

export function ss58ToEthAddress(ss58Address: string) {
// Decode the SS58 address to a Uint8Array public key
const publicKey = decodeAddress(ss58Address);

// Take the first 20 bytes of the hashed public key for the Ethereum address
const ethereumAddressBytes = publicKey.slice(0, 20);

// Convert the 20 bytes into an Ethereum H160 address format (Hex string)
const ethereumAddress = '0x' + Buffer.from(ethereumAddressBytes).toString('hex');

return ethereumAddress;
}

export function ss58ToH160(ss58Address: string): Binary {
// Decode the SS58 address to a Uint8Array public key
const publicKey = decodeAddress(ss58Address);

// Take the first 20 bytes of the hashed public key for the Ethereum address
const ethereumAddressBytes = publicKey.slice(0, 20);


return new Binary(ethereumAddressBytes);
}

export function ethAddressToH160(ethAddress: string): Binary {
// Decode the SS58 address to a Uint8Array public key
const publicKey = hexToU8a(ethAddress);

// Take the first 20 bytes of the hashed public key for the Ethereum address
// const ethereumAddressBytes = publicKey.slice(0, 20);


return new Binary(publicKey);
}
Loading
Loading