diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index e1e38ec..2c2de8f 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -8,23 +8,18 @@ jobs: - uses: actions/checkout@v2 - name: Install jq and curl run: sudo apt-get update && sudo apt-get install -y jq curl make - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - path: | - '**/node_modules' - '**/metadata/node_modules' - key: ${{ runner.os }}-modules-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - name: Compile runtime run: bash .github/workflows/scripts/compile.sh - name: Run the node and insert Aura keys - run: make run-node-demo spec=./raw-chain-spec.json detached=1 && bash .github/workflows/scripts/insert-aura.sh + run: | + make run-node \ + NAME=node01 \ + PORT=30333 \ + WS-PORT=9944 \ + RPC-PORT=9933 \ + spec=raw-chain-spec.json detached=1 \ + && bash .github/workflows/scripts/insert-keys.sh \ + && docker restart node01 - name: Sleep for 10 seconds uses: jakejarvis/wait-action@master with: @@ -32,7 +27,8 @@ jobs: - name: Get latest header id: check-header run: | - echo "::set-output name=tx-output::$(bash .github/workflows/scripts/get-latest-header.sh)\n" + docker start node01 \ + && echo "::set-output name=tx-output::$(bash .github/workflows/scripts/get-latest-header.sh)\n" - name: | Check the latest header If it contains number":"0x0", diff --git a/.github/workflows/scripts/compile.sh b/.github/workflows/scripts/compile.sh index af63660..d05a9b1 100644 --- a/.github/workflows/scripts/compile.sh +++ b/.github/workflows/scripts/compile.sh @@ -1,6 +1,6 @@ -npm install -g yarn +sudo npm install -g yarn yarn install npm run build node ./cli/dist/src/index.js spec --to=./chain-spec.json node ./cli/dist/src/index.js spec --src=./chain-spec.json -npm uninstall -g yarn \ No newline at end of file +sudo npm uninstall -g yarn \ No newline at end of file diff --git a/.github/workflows/scripts/insert-aura.sh b/.github/workflows/scripts/insert-aura.sh deleted file mode 100644 index ae3ebfe..0000000 --- a/.github/workflows/scripts/insert-aura.sh +++ /dev/null @@ -1,9 +0,0 @@ -lsof -n | grep LISTEN > /dev/null -curl --location --request POST '0.0.0.0:9933' \ ---header 'Content-Type: application/json' \ ---data-raw '{ - "jsonrpc": "2.0", - "method": "author_insertKey", - "params": ["aura","dice height enter anger ahead chronic easily wave curious banana era happy","0xdcc1461cba689c60dcae053ef09bc9e9524cdceb696ce39c7ed43bf3a5fa9659"], - "id": 1 -}' \ No newline at end of file diff --git a/.github/workflows/scripts/insert-keys.sh b/.github/workflows/scripts/insert-keys.sh new file mode 100644 index 0000000..30f324f --- /dev/null +++ b/.github/workflows/scripts/insert-keys.sh @@ -0,0 +1,18 @@ +lsof -n | grep LISTEN > /dev/null +curl --location --request POST '0.0.0.0:9933' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "jsonrpc": "2.0", + "method": "author_insertKey", + "params": ["aura","clip organ olive upper oak void inject side suit toilet stick narrow","0x9effc1668ca381c242885516ec9fa2b19c67b6684c02a8a3237b6862e5c8cd7e"], + "id": 1 +}' +lsof -n | grep LISTEN > /dev/null +curl --location --request POST '0.0.0.0:9933' \ +--header 'Content-Type: application/json' \ +--data-raw '{ + "jsonrpc": "2.0", + "method": "author_insertKey", + "params": ["gran","clip organ olive upper oak void inject side suit toilet stick narrow","0xb48004c6e1625282313b07d1c9950935e86894a2e4f21fb1ffee9854d180c781"], + "id": 1 +}' diff --git a/Makefile b/Makefile index 2077904..e5cd35c 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,8 @@ endif run-node: ifdef help @docker run -it limechain/as-substrate:node-v1 --help +else detached + @docker run -p ${RPC-PORT}:${RPC-PORT} -p ${WS-PORT}:${WS-PORT} -p ${PORT}:${PORT} -v "$(CURDIR)/${spec}":/raw-chain-spec.json -v /tmp:/tmp --name ${NAME} -d limechain/as-substrate:grandpa --base-path /tmp/${NAME} --port ${PORT} --ws-port ${WS-PORT} --rpc-port ${RPC-PORT} --execution Wasm --offchain-worker Never --validator --name=${NAME} ${OTHER} else - docker run -p ${RPC-PORT}:${RPC-PORT} -p ${WS-PORT}:${WS-PORT} -p ${PORT}:${PORT} -v "$(CURDIR)/${spec}":/raw-chain-spec.json limechain/as-substrate:test --base-path /tmp/${NAME} --port ${PORT} --ws-port ${WS-PORT} --rpc-port ${RPC-PORT} --execution Wasm --offchain-worker Never --name=${NAME} ${OTHER} + @docker run -p ${RPC-PORT}:${RPC-PORT} -p ${WS-PORT}:${WS-PORT} -p ${PORT}:${PORT} -v "$(CURDIR)/${spec}":/raw-chain-spec.json -v /tmp:/tmp limechain/as-substrate:grandpa --base-path /tmp/${NAME} --port ${PORT} --ws-port ${WS-PORT} --rpc-port ${RPC-PORT} --execution Wasm --offchain-worker Never --validator --name=${NAME} ${OTHER} endif \ No newline at end of file diff --git a/assembly/index.ts b/assembly/index.ts index a86844a..9d976a5 100644 --- a/assembly/index.ts +++ b/assembly/index.ts @@ -2,6 +2,7 @@ export const __heap_base = 0; export * from "./runtime/api/aura-api"; -export * from "./runtime/api/core"; export * from "./runtime/api/block-builder"; +export * from "./runtime/api/core"; +export * from "./runtime/api/grandpa-api"; export * from "./runtime/api/others"; diff --git a/assembly/pallets/aura/aura.ts b/assembly/pallets/aura/aura.ts index 9b0ee2c..92ef85c 100644 --- a/assembly/pallets/aura/aura.ts +++ b/assembly/pallets/aura/aura.ts @@ -39,7 +39,6 @@ export class Aura { /** * @description Creates Aura inherent - * NOTE: Draft implementation * @param data Inherent data */ static _createInherent(data: InherentData): u8[] { diff --git a/assembly/pallets/grandpa/grandpa.ts b/assembly/pallets/grandpa/grandpa.ts new file mode 100644 index 0000000..f0e0478 --- /dev/null +++ b/assembly/pallets/grandpa/grandpa.ts @@ -0,0 +1,34 @@ +import { ByteArray } from "as-scale-codec"; +import { Storage, Utils } from "subsembly-core"; + +/** + * @descritption Storage entries for Grandpa + */ +export namespace GrandpaStorageEntries { +} + +/** + * @description Class representing GRANDPA module + */ +export class Grandpa { + public static readonly GRANDPA_AUTHORITIES: string = ":grandpa_authorities"; + + /** + * @description Get GRANDPA authorities from the storage + * concatenated list of Grandpa authorities + */ + static _authorities(): u8[] { + const entry = Storage.get(Utils.stringsToBytes([this.GRANDPA_AUTHORITIES], false)); + const auths = entry.isSome() ? (entry.unwrap()).unwrap() : [0]; + // first byte is option byte + return auths; + } + + /** + * @description Set GRANDPA authorities + * @param auths list of Grandpa authorities + */ + static _setAuthorities(auths: u8[]): void { + Storage.set(Utils.stringsToBytes([this.GRANDPA_AUTHORITIES], false), auths); + } +} \ No newline at end of file diff --git a/assembly/pallets/index.ts b/assembly/pallets/index.ts index a7055f1..ab1592f 100644 --- a/assembly/pallets/index.ts +++ b/assembly/pallets/index.ts @@ -1,5 +1,5 @@ export * from "./aura/aura"; export * from "./balances/balances"; +export * from "./grandpa/grandpa"; export * from "./timestamp/timestamp"; export * from "./transaction-payment/transaction-payment"; - diff --git a/assembly/runtime/api/grandpa-api.ts b/assembly/runtime/api/grandpa-api.ts index f20e041..ef2c198 100644 --- a/assembly/runtime/api/grandpa-api.ts +++ b/assembly/runtime/api/grandpa-api.ts @@ -1,5 +1,5 @@ import { Serialiser } from 'subsembly-core'; - +import { Grandpa } from '../../pallets/grandpa/grandpa'; /** * @description Attempt to extract a pending set-change signal from a digest. @@ -25,5 +25,6 @@ export function GrandpaApi_grandpa_forced_change(data: i32, len: i32): u64 { * @param len i32 length (in bytes) of the arguments passed */ export function GrandpaApi_grandpa_authorities(data: i32, len: i32): u64 { - return Serialiser.serialiseResult([]); + const authorities = Grandpa._authorities(); + return Serialiser.serialiseResult(authorities.slice(1)); } diff --git a/assembly/runtime/api/index.ts b/assembly/runtime/api/index.ts deleted file mode 100644 index 0659e48..0000000 --- a/assembly/runtime/api/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from "./aura-api"; -export * from "./block-builder"; -export * from "./core"; -export * from "./grandpa-api"; -export * from "./others"; -export * from "./parachain-host"; diff --git a/cli/package-lock.json b/cli/package-lock.json index ad2979e..6dd9013 100644 --- a/cli/package-lock.json +++ b/cli/package-lock.json @@ -1,6 +1,6 @@ { "name": "subsembly", - "version": "1.0.5", + "version": "1.0.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/cli/package.json b/cli/package.json index dbc1674..90b1754 100644 --- a/cli/package.json +++ b/cli/package.json @@ -4,7 +4,7 @@ "description": "CLI tool for Subsembly", "main": "dist/src/index.js", "scripts": { - "test": "mocha 'test/**/*.js' --timeout 10000 && cd ./src/commands/spec/builder && npm run test", + "test": "npx mocha 'test/**/*.js' --timeout 10000 && cd ./src/commands/spec/builder && npm run test", "dev": "ts-node src/index.ts", "build-spec": "npm install --prefix ./src/commands/spec/builder && npm run asbuild --prefix ./src/commands/spec/builder", "copy-wasm": "mkdir -p ./dist/src/commands/spec/builder/build/ && cp ./src/commands/spec/builder/build/build-spec.wasm ./dist/src/commands/spec/builder/build/", diff --git a/cli/src/commands/spec/builder/assembly/index.ts b/cli/src/commands/spec/builder/assembly/index.ts index d94a9e1..2fadcf4 100644 --- a/cli/src/commands/spec/builder/assembly/index.ts +++ b/cli/src/commands/spec/builder/assembly/index.ts @@ -1,8 +1,9 @@ import { u128 } from 'as-bignum'; -import { BytesReader, CompactInt, UInt128 } from 'as-scale-codec'; +import { BytesReader, CompactInt, UInt128, UInt64 } from 'as-scale-codec'; import { AccountData, AccountId, Utils } from 'subsembly-core'; export type Balance = UInt128; +export type Weight = UInt64; /** * @description Gets the AccountData converted to the bytes diff --git a/cli/src/commands/spec/builder/customSpec-template.json b/cli/src/commands/spec/builder/customSpec-template.json index e5ed63f..d94429c 100644 --- a/cli/src/commands/spec/builder/customSpec-template.json +++ b/cli/src/commands/spec/builder/customSpec-template.json @@ -38,7 +38,12 @@ }, "aura": { "authorities": [ - "5H49oi57ktRnYTbhVtKpGGk79rB9QXNcApYELLWcKa9W8nfs" + "5FfBQ3kwXrbdyoqLPvcXRp7ikWydXawpNs2Ceu3WwFdhZ8W4" + ] + }, + "grandpa": { + "authorities": [ + ["5G9NWJ5P9uk7am24yCKeLZJqXWW6hjuMyRJDmw4ofqxG8Js2", 1] ] } } diff --git a/cli/src/commands/spec/builder/package.json b/cli/src/commands/spec/builder/package.json index 2a5d734..d1e399c 100644 --- a/cli/src/commands/spec/builder/package.json +++ b/cli/src/commands/spec/builder/package.json @@ -8,7 +8,7 @@ "asbuild:optimized": "asc assembly/index.ts -b build/build-spec.wasm -t build/build-spec.wat --runtime full --optimize", "asbuild": "npm run asbuild:optimized" }, - "author": "", + "author": "Dastanbek Samatov", "license": "ISC", "dependencies": { "@assemblyscript/loader": "^0.17.9", diff --git a/cli/src/commands/spec/builder/src/genesis-builder.js b/cli/src/commands/spec/builder/src/genesis-builder.js index 459ee97..812c036 100644 --- a/cli/src/commands/spec/builder/src/genesis-builder.js +++ b/cli/src/commands/spec/builder/src/genesis-builder.js @@ -1,6 +1,7 @@ const Balances = require("./modules/balances"); const System = require("./modules/system"); const Aura = require('./modules/aura'); +const Grandpa = require('./modules/grandpa'); /** * Class for the genesis configuration @@ -40,6 +41,10 @@ class GenesisBuilder { const rawAura = Aura.toRaw(genesisConfig.genesis.runtime.aura.authorities); Object.assign(rawGenesis.raw.top, rawAura); } + if(genesisConfig.genesis.runtime.grandpa) { + const rawGrandpa = Grandpa.toRaw(genesisConfig.genesis.runtime.grandpa.authorities); + Object.assign(rawGenesis.raw.top, rawGrandpa); + } rawGenesis['raw']["childrenDefault"] = {}; return rawGenesis; } diff --git a/cli/src/commands/spec/builder/src/modules/aura.js b/cli/src/commands/spec/builder/src/modules/aura.js index 04f8a77..3d89db6 100644 --- a/cli/src/commands/spec/builder/src/modules/aura.js +++ b/cli/src/commands/spec/builder/src/modules/aura.js @@ -1,9 +1,5 @@ const { u8aToHex } = require('@polkadot/util'); const { Keyring } = require('@polkadot/api'); -const { - __newArray, __getArray, - UInt8Array_ID, getAccountIdBytes -} = require('../wasm-loader'); const Utils = require('../utils'); class Aura { @@ -22,7 +18,7 @@ class Aura { * @param authorities list of authorities */ static toRaw(authorities){ - validateIsArray(authorities); + Utils.validateIsArray(authorities, "Aura: Invalid or no Aura array provided"); if (authorities.length === 0){ throw new Error("Aura: Array of authorities is empty"); @@ -36,32 +32,11 @@ class Aura { const keyringInstance = keyring.addFromAddress(element); rawAuthorities = rawAuthorities.concat(Array.from(keyringInstance.publicKey)); }); - const auths = getAuthoritiesBytes(rawAuthorities); + const auths = Utils.getAuthoritiesBytes(rawAuthorities); return { [key]: u8aToHex(auths) } } } -/** - * Validates whether the provided parameter is array. Throws otherwise - * @param {*} arr - */ -function validateIsArray (arr) { - if (!Array.isArray(arr)) { - throw new Error("Aura: Invalid or no authorities array provided"); - } -} - -/** - * Get scale encoded list of Aura authorities - * @param authorities list of authorities - */ -const getAuthoritiesBytes = (authorities) => { - const aPtr = __newArray(UInt8Array_ID, authorities); - const auths = getAccountIdBytes(aPtr); - const result = __getArray(auths); - return result; -} - module.exports = Aura; \ No newline at end of file diff --git a/cli/src/commands/spec/builder/src/modules/balances.js b/cli/src/commands/spec/builder/src/modules/balances.js index edc12d9..46e4819 100644 --- a/cli/src/commands/spec/builder/src/modules/balances.js +++ b/cli/src/commands/spec/builder/src/modules/balances.js @@ -20,43 +20,33 @@ class Balances { * @param balances array with accountId and balances */ static toRaw(balancesArray) { - validateIsArray(balancesArray); + Utils.validateIsArray(balancesArray, "Balances: Invalid or no balances array provided"); const rawBalances = {}; const keyring = new Keyring({ type: 'sr25519' }); const typeReg = new TypeRegistry(); balancesArray.forEach(balanceArray => { - validateIsArray(balanceArray); + Utils.validateIsArray(balanceArray, "Balances: Invalid or no balances array provided"); const keyringInstance = keyring.addFromAddress(balanceArray[0]); const key = Utils.getHashKey(this.MODULE_PREFIX, this.MODULE_KEY, keyringInstance.publicKey); const systemKey = Utils.getHashKey(System.MODULE_PREFIX, System.MODULE_KEY, keyringInstance.publicKey); - const accData = accDataToHex(typeReg.createType("U128", balanceArray[1].toString()).toU8a()); + const accData = this.accDataToHex(typeReg.createType("U128", balanceArray[1].toString()).toU8a()); const accInfo = System.getAccountInfo(accData); rawBalances[key] = accData; rawBalances[systemKey] = accInfo; }); return rawBalances; } -} - -/** - * Validates whether the provided parameter is array. Throws otherwise - * @param {*} arr - */ -function validateIsArray (arr) { - if (!Array.isArray(arr)) { - throw new Error("Balances: Invalid or no balances array provided"); + /** + * + * @param value encodes AccountData instance to hex + */ + static accDataToHex = (value) => { + const accData = getAccountDataBytes(__newArray(UInt8Array_ID, value)); + const res = __getArray(accData); + return u8aToHex(res); } -} - -/** - * - * @param value encodes AccountData instance to hex - */ -const accDataToHex = (value) => { - const accData = getAccountDataBytes(__newArray(UInt8Array_ID, value)); - const res = __getArray(accData); - return u8aToHex(res); + } module.exports = Balances \ No newline at end of file diff --git a/cli/src/commands/spec/builder/src/modules/grandpa.js b/cli/src/commands/spec/builder/src/modules/grandpa.js new file mode 100644 index 0000000..dd9f69e --- /dev/null +++ b/cli/src/commands/spec/builder/src/modules/grandpa.js @@ -0,0 +1,43 @@ +const Utils = require('../utils'); +const { u8aToHex, hexStripPrefix } = require('@polkadot/util'); +const { Keyring } = require('@polkadot/api'); +const { TypeRegistry } = require('@polkadot/types'); + +const { stringToHex } = require('@polkadot/util'); + +class Grandpa { + /** + * @description Well known key for GRANDPA authorities + */ + static GRANDPA_AUTHORITIES = ":grandpa_authorities"; + /** + * @description Convert GRANDPA module to raw + * @param {*} authorities list of Grandpa authorities with weights + */ + static toRaw(authorities) { + const typeReg = new TypeRegistry(); + Utils.validateIsArray(authorities); + + if (authorities.length === 0){ + throw new Error("Grandpa: Array of authorities is empty"); + } + // boolean byte indicating if authorities are present + let rawAuthorities = "0x01"; + const authsLen = typeReg.createType('Compact', authorities.length); + rawAuthorities = rawAuthorities.concat(hexStripPrefix(u8aToHex(authsLen.toU8a()))) + const keyring = new Keyring({ type: 'ed25519' }); + + authorities.forEach(([accountId, weight]) => { + const keyringInstance = keyring.addFromAddress(accountId); + const weightU8a = typeReg.createType("U64", weight).toU8a(); + rawAuthorities = rawAuthorities.concat(hexStripPrefix(u8aToHex(keyringInstance.publicKey))); + rawAuthorities = rawAuthorities.concat(hexStripPrefix(u8aToHex(weightU8a))); + }); + + return { + [stringToHex(this.GRANDPA_AUTHORITIES)]: rawAuthorities + } + } +} + +module.exports = Grandpa; \ No newline at end of file diff --git a/cli/src/commands/spec/builder/src/modules/system.js b/cli/src/commands/spec/builder/src/modules/system.js index 82a324c..fb68b67 100644 --- a/cli/src/commands/spec/builder/src/modules/system.js +++ b/cli/src/commands/spec/builder/src/modules/system.js @@ -1,4 +1,4 @@ -const { stringToHex, hexAddPrefix, hexStripPrefix } = require('@polkadot/util'); +const { stringToHex, hexStripPrefix } = require('@polkadot/util'); class System { diff --git a/cli/src/commands/spec/builder/src/utils.js b/cli/src/commands/spec/builder/src/utils.js index fb1af92..da8fd65 100644 --- a/cli/src/commands/spec/builder/src/utils.js +++ b/cli/src/commands/spec/builder/src/utils.js @@ -1,6 +1,9 @@ const { xxhashAsU8a } = require("@polkadot/util-crypto"); const { u8aToHex } = require('@polkadot/util'); -const { stringToU8a, __newString, __getArray } = require('./wasm-loader'); +const { stringToU8a, __newString, + __newArray, __getArray, + getAccountIdBytes, UInt8Array_ID, +} = require('./wasm-loader'); /** * @description Utility functions */ @@ -30,6 +33,27 @@ class Utils { const bytes = __getArray(bytesPtr); return bytes; } + + /** + * Validates whether the provided parameter is array. Throws otherwise + * @param {*} arr + */ + static validateIsArray (arr, errorMessage) { + if (!Array.isArray(arr)) { + throw new Error(errorMessage); + } + } + + /** + * Get scale encoded list of Aura authorities + * @param authorities list of authorities + */ + static getAuthoritiesBytes = (authorities) => { + const aPtr = __newArray(UInt8Array_ID, authorities); + const auths = getAccountIdBytes(aPtr); + const result = __getArray(auths); + return result; + } } module.exports = Utils; \ No newline at end of file diff --git a/cli/src/commands/spec/builder/test/build-spec.js b/cli/src/commands/spec/builder/test/build-spec.js index c93882f..363f36c 100644 --- a/cli/src/commands/spec/builder/test/build-spec.js +++ b/cli/src/commands/spec/builder/test/build-spec.js @@ -28,6 +28,15 @@ describe('Build spec tests', () => { assert.deepEqual(actualRaw, MockedConstants.CUSTOM_SPEC_NO_AURA); }) + it('correctly converts customSpec without Grandpa authorities', async function() { + await Utils.spec('./test/json-files/customspec-noGrandpa.json', './test/actual-raw-files/customSpecRaw-noGrandpa.json', './test/utils/wasm-exmpl'); + + assert.isTrue(fs.existsSync('./test/actual-raw-files/customSpecRaw-noGrandpa.json'), 'file does not exist'); + + const actualRaw = require('./actual-raw-files/customSpecRaw-noGrandpa.json'); + assert.deepEqual(actualRaw, MockedConstants.CUSTOM_SPEC_NO_GRANDPA); + }) + it('correctly converts customSpec with system property only', async function() { await Utils.spec('./test/json-files/customSpec-code.json', './test/actual-raw-files/customSpecRaw-code.json', './test/utils/wasm-exmpl'); diff --git a/cli/src/commands/spec/builder/test/json-files/customSpec.json b/cli/src/commands/spec/builder/test/json-files/customSpec.json index 2fd5e73..8b1d0b7 100644 --- a/cli/src/commands/spec/builder/test/json-files/customSpec.json +++ b/cli/src/commands/spec/builder/test/json-files/customSpec.json @@ -15,23 +15,43 @@ "balances": { "balances": [ [ - "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", - 1152921504606846976 + "5F25Yb9PB9GV6RcqKpWceyx1X48TfnBxWn9m84A1JUYvsEF2", + 10000000000000000 ], [ - "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", - 1152921504606846976 + "5CnyWwRgxbjqPyi4y9zMFjUWPjgw7M1SLzzehHRnp4K52M1L", + 10000000000000000 + ], + [ + "5H49oi57ktRnYTbhVtKpGGk79rB9QXNcApYELLWcKa9W8nfs", + 10000000000000000 ], [ - "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y", - 1152921504606846976 + "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + 10000000000000000 + ], + [ + "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", + 10000000000000000 ] ] }, "aura": { "authorities": [ - "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", - "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" + "5H49oi57ktRnYTbhVtKpGGk79rB9QXNcApYELLWcKa9W8nfs", + "5G9NWJ5P9uk7am24yCKeLZJqXWW6hjuMyRJDmw4ofqxG8Js2" + ] + }, + "grandpa": { + "authorities": [ + [ + "5C72o78Mfepmgmf2UCA6zSHiZ236V7Zr6cjhSLGXEVMtzqQ8", + 1 + ], + [ + "5G9NWJ5P9uk7am24yCKeLZJqXWW6hjuMyRJDmw4ofqxG8Js2", + 1 + ] ] } } diff --git a/cli/src/commands/spec/builder/test/json-files/customspec-noGrandpa.json b/cli/src/commands/spec/builder/test/json-files/customspec-noGrandpa.json new file mode 100644 index 0000000..9571fcb --- /dev/null +++ b/cli/src/commands/spec/builder/test/json-files/customspec-noGrandpa.json @@ -0,0 +1,39 @@ +{ + "name": "Local Testnet", + "id": "local_testnet", + "chainType": "Local", + "bootNodes": [], + "telemetryEndpoints": null, + "protocolId": null, + "properties": null, + "consensusEngine": null, + "genesis": { + "runtime": { + "system": { + "code": "0x" + }, + "balances": { + "balances": [ + [ + "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + 1152921504606846976 + ], + [ + "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", + 1152921504606846976 + ], + [ + "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y", + 1152921504606846976 + ] + ] + }, + "aura": { + "authorities": [ + "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", + "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" + ] + } + } + } + } \ No newline at end of file diff --git a/cli/src/commands/spec/builder/test/utils/mocked-constants.json b/cli/src/commands/spec/builder/test/utils/mocked-constants.json index 64e2853..f06fb2f 100644 --- a/cli/src/commands/spec/builder/test/utils/mocked-constants.json +++ b/cli/src/commands/spec/builder/test/utils/mocked-constants.json @@ -1,5 +1,35 @@ { "CUSTOM_SPEC_RAW_FULL": { + "name": "Local Testnet", + "id": "local_testnet", + "chainType": "Local", + "bootNodes": [], + "telemetryEndpoints": null, + "protocolId": null, + "properties": null, + "consensusEngine": null, + "genesis": { + "raw": { + "top": { + "0x3a636f6465": "0x0061736d0100000001360a60017f017f60037f7f7f0060027f7f017f60027f7f0060017f0060037f7f7f017f6000017f60027f7f017e60027f7e0060017f017e02100103656e76066d656d6f727902008102033534030301060002010502000403000102000003050202030501010100010002000006030800020001030000020000090707040404040610037f0041000b7f0141000b7f0141000b075405066d656d6f727902000b5f5f686561705f6261736503000c436f72655f76657273696f6e002e12436f72655f657865637574655f626c6f636b002f15436f72655f696e697469616c697a655f626c6f636b002f0ac73a34c30101047f2001280200417c71220241800249044020024104762103052002411f2002676b220241046b764110732103200241076b21040b20012802142102200128021022050440200520023602140b20020440200220053602100b20012000200320044104746a4102746a2802604604402000200320044104746a4102746a20023602602002450440200020044102746a22022802044101200374417f73712101200220013602042001450440200020002802004101200474417f73713602000b0b0b0be40201077f20012802002104200141106a2001280200417c716a2205280200220241017104402004417c7141106a2002417c716a220341f0ffffff03490440027f200020051000200120032004410371722204360200200141106a2001280200417c716a22052802000b21020b0b20044102710440200141046b28020022032802002207417c7141106a2004417c716a220841f0ffffff03490440027f20002003100020032008200741037172220436020020030b21010b0b20052002410272360200200541046b20013602002004417c71220341800249044020034104762103052003411f2003676b220441046b764110732103200441076b21060b2000200320064104746a4102746a2802602104200141003602102001200436021420040440200420013602100b2000200320064104746a4102746a200136026020002000280200410120067472360200200020064102746a220020002802044101200374723602040b7a01017f2002027f20002802a00c220204402002200141106b460440027f20022802002103200141106b0b21010b0b20010b6b220241304904400f0b20012003410271200241206b410172723602002001410036021020014100360214200120026a41106b22024102360200200020023602a00c2000200110010bab0101037f230122004504404181023f0022004a047f41810220006b40004100480541000b0440000b41c08180082200410036020041e08d80084100360200034020014117490440200141027441c08180086a410036020441002102034020024110490440200141047420026a41027441c08180086a4100360260200241016a21020c010b0b200141016a21010c010b0b41c081800841f08d80083f00411074100241c081800824010b20000b2100200041f0ffffff034f0440000b2000410f6a41707122004110200041104b1b0ba70101017f2001418002490440200141047621010520014101411b2001676b746a41016b2001200141f8ffffff01491b2201411f2001676b220241046b764110732101200241076b21020b200020024102746a280204417f200174712201047f200020016820024104746a4102746a280260052000280200417f200241016a74712201047f2000200020016822014102746a2802046820014104746a4102746a2802600541000b0b0b7001027f20012802002203417c7120026b220441204f0440200120022003410271723602002002200141106a6a2201200441106b4101723602002000200110010520012003417e71360200200141106a22002001280200417c716a20002001280200417c716a280200417d713602000b0bc30101037f027f2000200110042204100522034504402000200410052203450440027f41103f00220341107441106b20002802a00c477420044101411b2004676b7441016b6a2004200441f8ffffff01491b6a41ffff036a4180807c71411076210520032005200320054a1b40004100480440200540004100480440000b0b200020034110743f0041107410022000200410050b21030b0b20030b2802001a20034100360204200320023602082003200136020c200020031000200020032004100620030b0d00100320002001100741106a0b2d01027f200041c08180084b0440200041106b220128020421022001200241016a36020420012802001a0b20000b1400200041c08180084b0440200041106b10300b0bbb0201017f02402001450d00200041003a0000200020016a41046b220241003a0003200141024d0d00200041003a0001200041003a0002200241003a0002200241003a0001200141064d0d00200041003a0003200241003a0000200141084d0d002000410020006b41037122026a220041003602002000200120026b417c7122026a411c6b22014100360218200241084d0d0020004100360204200041003602082001410036021020014100360214200241184d0d002000410036020c2000410036021020004100360214200041003602182001410036020020014100360204200141003602082001410036020c2000200041047141186a22016a2100200220016b21010340200141204f044020004200370300200042003703082000420037031020004200370318200141206b2101200041206a21000c010b0b0b0b2101017f200041f0ffffff034b0440000b20004100100822012000100b200110090bb00201027f02402002210420002001460d0020002001490440200141077120004107714604400340200041077104402004450d04200441016b21042000220241016a21002001220341016a2101200220032d00003a00000c010b0b0340200441084f044020002001290300370300200441086b2104200041086a2100200141086a21010c010b0b0b0340200404402000220241016a21002001220341016a2101200220032d00003a0000200441016b21040c010b0b05200141077120004107714604400340200020046a41077104402004450d04200441016b220420006a200120046a2d00003a00000c010b0b0340200441084f0440200441086b220420006a200120046a2903003703000c010b0b0b034020040440200441016b220420006a200120046a2d00003a00000c010b0b0b0b0b4301037f41104109100822022104200041001008210320010440200320012000100d0b20042003100936020020022003360204200220003602082002200036020c20020b3d01017f027f4108410a1008100922014504404108410b1008100921010b20010b410036020020014100360204200120003602042001410436020020010b4100200041ff017141c5bbf288787341938380086c200041087641ff01717341938380086c200041107641ff01717341938380086c20004118767341938380086c0b8c0201087f200141016a2205410274100c2106200541037441036d2207410c6c100c2105200028020822042000280210410c6c6a21082005210303402004200847044020042202280208410171450440027f2003200228020036020020032002280204360204200228020010092209101021022009100a2003200620012002714102746a2202280200360208200220033602002003410c6a0b21030b2004410c6a21040c010b0b200622042000220228020022034704402004100921042003100a0b20022004360200200220013602042002210120052202200128020822044704402002100921022004100a0b200120023602082001200736020c200120012802143602102006100a2005100a0bc40201047f200110092104200210092105200410092201101021022001100a200410092103200028020020022000280204714102746a280200210102400340200104402001280208410171047f41000520032001280200460b04402003100a0c030b2001280208417e7121010c010b0b2003100a410021010b200104402005200128020422024704402001200510093602042002100a0b052000280210200028020c46044020002000280214200028020c41036c41046d48047f20002802040520002802044101744101720b10110b20002802081009210620002000280210220141016a36021020062001410c6c6a2203200410093602002003200510093602042000200028021441016a3602142003200028020020022000280204714102746a2201280200360208200120033602002006100a0b2000100921002004100a2005100a20000b850101037f027f2000450440411041091008100921000b20000b410036020020004100360204200041003602082000410036020c200141f0ffffff034b0440000b20014100100822022001100b200221032002200028020022044704402003100921032004100a0b2000200336020020002002360204200020013602082000200136020c20000b19002001200028020c4f0440000b200028020420016a2d00000b1500200120012802004101723602002000200110010bb60101047f20021004220320012802002205417c714d044020002001200310062001200236020c20010f0b200141106a2001280200417c716a2206280200220441017104402005417c7141106a2004417c716a220420034f0440200020061000200120054103712004723602002001200236020c200020012003100620010f0b0b200020022001280208100722032001280204360204200341106a200141106a2002100d200141c08180084f04402000200110150b20030b920101047f2001200028020822052002764b0440200141f0ffffff032002764b0440000b2000280200210310032106200341106b21042003410f7145410020031b047f2004280200410171450541000b044020042802041a0b2006200420012002742202101641106a220120056a200220056b100b2001200347044020002001360200200020013602040b200020023602080b0b3901017f2001200028020c4f044020014100480440000b2000200141016a2203410010172000200336020c0b200028020420016a20023a00000b4901017f20001009210020011009210103402003200128020c480440200028020c20034a04402001200220036a2000200310141018200341016a21030c020b0b0b2000100a2001100a0b970101047f2000100922042200200041106b28020c6a210203402000200249044020002f0100220341800149047f200141016a05200341801049047f200141026a05200041026a200249410020034180f803714180b003461b044020002f01024180f803714180b803460440200141046a2101200041046a21000c050b0b200141036a0b0b2101200041026a21000c010b0b2004100a20010bac0201027f200020014101746a21032002210103402000200349044020002f0100220241800149047f200120023a0000200141016a05200241801049047f2001200241067641c001722002413f7141800172410874723b0100200141026a05200041026a200349410020024180f803714180b003461b044020002f010222044180f803714180b8034604402001200241ff0771410a74418080046a200441ff0771722202413f71418001724118742002410676413f7141800172411074722002410c76413f714180017241087472200241127641f0017272360200200141046a2101200041046a21000c050b0b20012002410c7641e001722002410676413f7141800172410874723b010020012002413f71418001723a0002200141036a0b0b2101200041026a21000c010b0b0b830101037f024002400240230241016b0e03010102000b000b417f21010b41002000100922031009220241106b28020c22004b0440000b200141004804402001417f46047f200005000b210105200120004a0440000b0b410c410f100822002002100936020020002001360208200020023602042000100921002002100a2003100a20000b1900200120002802084f0440000b200120002802046a2d00000bf00101067f411441041008100922014100360210200010092100410041c0818008100e100922052103027f2001450440411041051008100921010b20010b047f20010541104108100810090b20031009220328020c1013210120032001410010192003100a2001210220002203200128021022044704402003100921032004100a0b20022003360210200010092203101a4100100821022003200341106b28020c4101762002101b2002100921022003100a410124022002101c21030340200620032802084804402001200620032006101d1018200641016a21060c010b0b2005100a2002100a2003100a2000100a20010bf50101037f411c4103100810092202410036020020024100360204200241003602082002410036020c20024100360210200241003602142002410036021820001009210141c0808008101e21002002280200100a2002200036020041f0808008101e21002002280204100a200220003602044101100f21002002280208100a200220003602084101100f2100200228020c100a2002200036020c4101100f21002002280210100a2002200036021020012200200228021422034704402000100921002003100a0b200220003602144101100f21002002280218100a2002200036021841c0808008100a41f0808008100a2001100a20020b2b01027f41044110100810092200410036020041004100101321012000280200100a2000200136020020000b2a01027f2000200028020c220241016a220341001017200220002802046a20013a00002000200336020c0bbe0402057f017e200142c0005304402000280200100922022001a7410274220410214101210003402000b844000000000000f03f6304402002200441ff01712000410374761021200041016a21000c010b0b2002100a052001428080015304402000280200100922022001420286a741016a220410214101210003402000b84400000000000000406304402002200441ffff0371200041037441ff0171761021200041016a21000c010b0b2002100a0520014280808080045304402000280200100922022001420286a741026a220410214101210003402000b844000000000000104063044020022004200041037441ff0171761021200041016a21000c010b0b2002100a054100410810132104200121070340200742005241002002418002481b044020074208872107200241016a21020c010b0b2000280200100922054100200241027441736a220610184101210303402003b844000000000000f03f6304402005200341ff0171200641ff01712003410374761018200341016a21030c010b0b2005100a20041009220541002001a710184101210303402003b84400000000000020406304402005200341ff01712001200341037441ff0171ad88a71018200341016a21030c010b0b2005100a4100200428020c220341002003481b21052002410048047f200220036a22024100200241004a1b052002200320022003481b0b20056b22024100200241004a1b22034100100e10092202280204200520042802046a2003100d20022000280200410110192004100a2002100a0b0b0b0ba20101067f10202202200028020cac102203402004200028020c48044020002004101421034108410610081009220141003a000020014100360204200120033a00002001410136020420011009210341014100100e1009220528020420032d00003a00002005100922062002280200200228020028020c10192006100a2001100a2003100a2005100a200441016a21040c010b0b2002280200100921002002100a20000b5701047f200110092101200028020c2203200128020c410020011b22046a220241f0ffffff034b0440000b20024100100e10092202280204220520002802042003100d200320056a20012802042004100d2001100a20020b6102037f017c4100200028020010132101200028020421022000280200b721042001100922034100200210184101210003402000b820046304402003200041ff01712002200041037441ff0171751018200041016a21000c010b0b2003100a20010b6301017f2002100921022001200028020c4f044020014100480440000b2000200141016a2203410210172000200336020c0b200210092203200028020420014102746a220028020022014704402000200310093602002001100a0b2003100a2002100a0b5001037f200028020c220220014a04402000280204220420014102746a2103200420024102746a210203402003280200100a200341046a22032002490d000b0520002001410210170b2000200136020c0bd20101097f2000280208210520002802102208210741104111100810092200410036020020004100360204200041003602082000410036020c200841fcffffff004b0440000b200741027422064100100822032006100b200321022003200028020022044704402002100921022004100a0b2000200236020020002003360204200020063602082000200736020c03402009200848044020052009410c6c6a2203280208410171450440027f2000200120032802001026200141016a0b21010b200941016a21090c010b0b20002001102720000bd20101097f2000280208210520002802102208210741104112100810092200410036020020004100360204200041003602082000410036020c200841fcffffff004b0440000b200741027422064100100822032006100b200321022003200028020022044704402002100921022004100a0b2000200236020020002003360204200020063602082000200736020c03402009200848044020052009410c6c6a2203280208410171450440027f2000200120032802041026200141016a0b21010b200941016a21090c010b0b20002001102720000b27002001200028020c4f0440000b200028020420014102746a28020010092200450440000b20000b8c02020a7f017e200028020010282106200028020010292107410041001013210320002802002802142102410c411310081009220142003703002001410036020820012002ac220b370300200b42c0005304402001410136020805200b428080015304402001410236020805200b4280808080045304402001410436020805200141083602080b0b0b10202202200129030010222002280200100921082002100a20032008102421042003100a034020052000280200280214480440200420062005102a220a102421092004100a200920072005102a220310252202102421042009100a200a100a2003100a2002100a200541016a21050c010b0b2006100a2007100a2001100a2008100a20040b8d01010c7f2000280200102322012000280204102322021024220320002802081025220410242205200028020c1025220610242207200028021010252208102422092000280214102b220a1024220b2000280218102522001024210c2001100a2002100a2003100a2004100a2005100a2006100a2007100a2008100a2009100a200a100a200b100a2000100a200c0b2701027f20001009220028020c21012000280204220210091a2000100a2002ad2001ac422086840ba50102027f017e4104410c10081009220141003602004118410d1008100922004110100c3602002000410336020420004130100c3602082000410436020c20004100360210200041003602142001280200100a20012000360200410841a0818008100e100922021009210020012802002000410a100f22031012100a2003100a2000100a2001101f21002001100a2002100a2000102c2201102d21042000100a2001100a20040b6702037f017e2001100c220320002001100d41012402410021002003101c22041009210141004102101321020340200020012802084804402002200020012000101d1018200041016a21000c010b0b2001100a2004100a2003100a2002102d21052002100a20050b4201027f20002802001a2000280204220141ffffffff007122024101460440200041106a1033230120001015052000200241016b200141808080807f71723602040b0b1500200041c08180084904400f0b200041106b10300b3f01037f20002802042201200028020c4102746a2102034020012002490440200128020022030440200310310b200141046a21010c010b0b200028020010310bb90201027f024002400240024002400240024002400240024002400240200041086b2802000e1400000102030900000a0b00000104050101060700080b0f0b200028020022000440200010310b0f0b200028020022010440200110310b200028020422010440200110310b200028020822010440200110310b200028020c22010440200110310b200028021022010440200110310b200028021422010440200110310b200028021822000440200010310b0f0b200028020010310c050b200028020010312000280208220222012000280210410c6c6a2100034020012000490440200128020841017145044020012802001031200128020410310b2001410c6a21010c010b0b200210310f0b200028020010310f0b200010320f0b200010320f0b000b200028020010310b200028020010310b200028020010310b0bbd01050041808080080b2f20000000010000000100000020000000300031003200330034003500360037003800390061006200630064006500660041b08080080b21120000000100000001000000120000004e006f00640065002d00740065007300740041e08080080b2b1c00000001000000010000001c00000041007300730065006d0062006c00790053006300720069007000740041908180080b180800000001000000000000000800000001010101010101010041b48180080b0101", + "0xc2261276cc9d1f8598ea4b6a74b15c2fb99d880ec681799c0cf30e8886371da9d03d56e603c165d01a5d30685d13a92a": "0x0000c16ff2862300000000000000000000000000000000000000000000000000", + "0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9d03d56e603c165d01a5d30685d13a92a": "0x00000000000000c16ff2862300000000000000000000000000000000000000000000000000", + "0xc2261276cc9d1f8598ea4b6a74b15c2fb99d880ec681799c0cf30e8886371da9e81ba99a0bb95d747f27a3ead08fe418": "0x0000c16ff2862300000000000000000000000000000000000000000000000000", + "0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9e81ba99a0bb95d747f27a3ead08fe418": "0x00000000000000c16ff2862300000000000000000000000000000000000000000000000000", + "0xc2261276cc9d1f8598ea4b6a74b15c2fb99d880ec681799c0cf30e8886371da9c6ebe5ded0e8dd4d0db5692e34d8116a": "0x0000c16ff2862300000000000000000000000000000000000000000000000000", + "0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9c6ebe5ded0e8dd4d0db5692e34d8116a": "0x00000000000000c16ff2862300000000000000000000000000000000000000000000000000", + "0xc2261276cc9d1f8598ea4b6a74b15c2fb99d880ec681799c0cf30e8886371da9518366b5b1bc7c99bae0ba710af1ac66": "0x0000c16ff2862300000000000000000000000000000000000000000000000000", + "0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9518366b5b1bc7c99bae0ba710af1ac66": "0x00000000000000c16ff2862300000000000000000000000000000000000000000000000000", + "0xc2261276cc9d1f8598ea4b6a74b15c2fb99d880ec681799c0cf30e8886371da9a647e755c30521d3d8cb3b41eccb98ea": "0x0000c16ff2862300000000000000000000000000000000000000000000000000", + "0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9a647e755c30521d3d8cb3b41eccb98ea": "0x00000000000000c16ff2862300000000000000000000000000000000000000000000000000", + "0x57f8dc2f5ab09467896f47300f0424385e0621c4869aa60c02be9adcc98a0d1d":"0x08dcc1461cba689c60dcae053ef09bc9e9524cdceb696ce39c7ed43bf3a5fa9659b48004c6e1625282313b07d1c9950935e86894a2e4f21fb1ffee9854d180c781", + "0x3a6772616e6470615f617574686f726974696573": "0x010801c63e66c26b10d8587eb82b8879e773222f9c9a75a61a43358c23073a5d5cfc0100000000000000b48004c6e1625282313b07d1c9950935e86894a2e4f21fb1ffee9854d180c7810100000000000000" + }, + "childrenDefault": {} + } + } + }, + "CUSTOM_SPEC_NO_GRANDPA": { "name": "Local Testnet", "id": "local_testnet", "chainType": "Local", @@ -18,7 +48,7 @@ "0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9a647e755c30521d3d8cb3b41eccb98ea": "0x00000000001800000000000010000000000000000000000000000000000000000000000000", "0xc2261276cc9d1f8598ea4b6a74b15c2fb99d880ec681799c0cf30e8886371da9dd4e3f25f5378a6d4521688f9255a43f": "0x1800000000000010000000000000000000000000000000000000000000000000", "0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9dd4e3f25f5378a6d4521688f9255a43f": "0x00000000001800000000000010000000000000000000000000000000000000000000000000", - "0x57f8dc2f5ab09467896f47300f0424385e0621c4869aa60c02be9adcc98a0d1d": "0x088eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d" + "0x57f8dc2f5ab09467896f47300f0424385e0621c4869aa60c02be9adcc98a0d1d":"0x088eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d" }, "childrenDefault": {} } diff --git a/yarn.lock b/yarn.lock index 7ec5323..831c5e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -95,9 +95,9 @@ assemblyscript@^0.16.1: long "^4.0.0" assemblyscript@^0.17.1: - version "0.17.11" - resolved "https://registry.yarnpkg.com/assemblyscript/-/assemblyscript-0.17.11.tgz#dfc7559c26e05d6302dafc88cf2f2071f9538fe7" - integrity sha512-mynMSe3DOYKI2MsIdD5WSMOD8Gggt2PVVaVfVvFvpCpslJb5YMKCtcSe2pgd74+X2duHox9xg5jBgiYXjBBXTQ== + version "0.17.14" + resolved "https://registry.yarnpkg.com/assemblyscript/-/assemblyscript-0.17.14.tgz#9ea4a04a50dc53042b35d492fff947101ae00248" + integrity sha512-TLuwNvZAIH26wu2puKpAJokzLp10kJkVXxbgDjFFmbW9VF/qg7rkmi0hjsiu41bjoH1UaVgY4vYvbbUeOHtKyg== dependencies: binaryen "98.0.0-nightly.20201109" long "^4.0.0"