Skip to content

Commit

Permalink
Align types with recent iterations (#96)
Browse files Browse the repository at this point in the history
* Move storage to types repo

* Use asU8a instead of aasU8a256

* Update types (in the dark)

* Bump deps

* Bump

* Update with manual db endpoint creation

* Ok, here we are - ready to align with genesis setups again

* Rework key handling

* Cleanup comments

* Align with Rust dev network keys

* Fix state tests

* Address test failures

* Update for latest types

* Update deps

* Re-introduce genesis checks

* Cleanup interfaces

* Make CLI run

* Bump versions

* Upgrade libp2p, used dialProtocol

* Bump dev (type definitions)

* Cleanup tests after libp2p upgrade

* Skip long-running test
  • Loading branch information
jacogr committed May 31, 2018
1 parent 395ba28 commit 464096c
Show file tree
Hide file tree
Showing 115 changed files with 2,507 additions and 3,336 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

2 changes: 0 additions & 2 deletions .flowconfig
Expand Up @@ -14,5 +14,3 @@ all=warn
include_warnings=true
module.name_mapper='^@polkadot/client-\(chains\|db-chain\|db\|keyring\|p2p\|rpc\|runtime\|wasm\)\(.*\)$' -> '<PROJECT_ROOT>/packages/client-\1/src\2'
module.name_mapper='^@polkadot/client\(.*\)$' -> '<PROJECT_ROOT>/packages/client/src\1'
module.name_mapper='^@polkadot/storage-\(polkadot\|substrate\)\(.*\)$' -> '<PROJECT_ROOT>/packages/storage-\1/src\2'
module.name_mapper='^@polkadot/storage\(.*\)$' -> '<PROJECT_ROOT>/packages/storage/src\1'
3 changes: 3 additions & 0 deletions babel.config.js
@@ -0,0 +1,3 @@
module.exports = {
extends: '@polkadot/dev/config/babel'
};
4 changes: 1 addition & 3 deletions jest.config.js
Expand Up @@ -2,8 +2,6 @@ const config = require('@polkadot/dev/config/jest');

module.exports = Object.assign({}, config, {
moduleNameMapper: {
'@polkadot/client-(chains|db-chain|db|keyring|p2p|rpc|runtime|wasm)(.*)$': '<rootDir>/packages/client-$1/src/$2',
'@polkadot/storage-(polkadot|substrate)(.*)$': '<rootDir>/packages/storage-$1/src/$2',
'@polkadot/storage(.*)$': '<rootDir>/packages/storage/src/$1'
'@polkadot/client-(chains|db-chain|db|p2p|rpc|runtime|wasm)(.*)$': '<rootDir>/packages/client-$1/src/$2'
}
});
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -10,5 +10,5 @@
"packages": [
"packages/*"
],
"version": "0.10.4"
"version": "0.11.0"
}
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -7,12 +7,13 @@
"scripts": {
"build": "polkadot-dev-build-babel",
"check": "eslint packages && flow check",
"clean": "polkadot-dev-clean-build",
"start": "node packages/client/scripts/polkadot.js",
"start2": "node packages/client/scripts/polkadot.js --db-path=./tmp --p2p-peers=/ip4/127.0.0.1/tcp/39933 --p2p-port=39934 --rpc-port=9934",
"test": "jest --coverage"
},
"devDependencies": {
"@polkadot/dev": "^0.17.13",
"lerna": "^2.5.1"
"@polkadot/dev": "^0.19.12",
"lerna": "^2.11.0"
}
}
29 changes: 15 additions & 14 deletions packages/client-chains/package.json
@@ -1,6 +1,6 @@
{
"name": "@polkadot/client-chains",
"version": "0.10.4",
"version": "0.11.0",
"description": "Node configuration definitions for specific chains",
"main": "index.js",
"keywords": [
Expand Down Expand Up @@ -29,21 +29,22 @@
"test": "echo \"Tests only available from root wrapper\""
},
"dependencies": {
"@polkadot/client-db-chain": "^0.10.4",
"@polkadot/client-runtime": "^0.10.4",
"@polkadot/client-wasm": "^0.10.4",
"@polkadot/storage-substrate": "^0.10.4",
"@polkadot/util": "^0.19.4",
"@polkadot/util-crypto": "^0.19.4",
"babel-runtime": "^6.26.0"
"@babel/runtime": "^7.0.0-beta.47",
"@polkadot/client-db-chain": "^0.11.0",
"@polkadot/client-runtime": "^0.11.0",
"@polkadot/client-wasm": "^0.11.0",
"@polkadot/storage": "^0.17.7",
"@polkadot/util": "^0.22.2",
"@polkadot/util-crypto": "^0.22.2",
"@polkadot/util-keyring": "^0.22.2"
},
"devDependencies": {
"@polkadot/client": "^0.10.4",
"@polkadot/client-db": "^0.10.4",
"@polkadot/primitives-builder": "^0.11.1",
"@polkadot/primitives-codec": "^0.11.1",
"@polkadot/storage": "^0.10.4",
"@polkadot/util-keyring": "^0.19.4",
"@polkadot/client": "^0.11.0",
"@polkadot/client-db": "^0.11.0",
"@polkadot/primitives-builder": "^0.17.7",
"@polkadot/primitives-codec": "^0.17.7",
"@polkadot/storage": "^0.17.7",
"@polkadot/util-keyring": "^0.22.2",
"@polkadot/wasm-bin": "paritytech/polkadot-wasm-bin#bfc718615463a2763b25f7b231792201a4593113"
}
}
8 changes: 0 additions & 8 deletions packages/client-chains/src/chain-demo/block.js

This file was deleted.

51 changes: 0 additions & 51 deletions packages/client-chains/src/chain-demo/config.js

This file was deleted.

16 changes: 0 additions & 16 deletions packages/client-chains/src/chain-demo/index.js

This file was deleted.

12 changes: 0 additions & 12 deletions packages/client-chains/src/chain-demo/state.js

This file was deleted.

74 changes: 74 additions & 0 deletions packages/client-chains/src/chain-dev/config.js
@@ -0,0 +1,74 @@
// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
// @flow

import type { ChainConfig } from '../types';

const BN = require('bn.js');

const blake2AsU8a = require('@polkadot/util-crypto/blake2/asU8a');
const keyring = require('@polkadot/util-keyring/testingPairs')();

const code = require('../wasm/polkadot_runtime_wasm');
const codeHash = blake2AsU8a(code, 256);

const authorities = [ keyring.alice.publicKey() ];
const endowed = authorities.concat([ keyring.bob.publicKey(), keyring.charlie.publicKey(), keyring.dave.publicKey(), keyring.eve.publicKey(), keyring.ferdie.publicKey() ]);

module.exports = ({
name: 'Development',
description: 'An initial @polkadot/client development network. Network follows the Rust implementation config for the development chain.',
type: 'polkadot',
blockTime: 5,
code,
codeHash,
networkId: 12345,
genesis: {
consensus: {
authorities,
code
},
council: {
activeCouncil: authorities.map((accountId) => ({
accountId,
duration: 1000000
})),
candidacyBond: 10,
carryCount: 4,
desiredSeats: endowed.length - authorities.length,
inactiveGracePeriod: 1,
presentationDuration: 10,
presentSlashPerVoter: 1,
termDuration: 1000000,
votingBond: 2,
votingPeriod: 20
},
councilVoting: {
cooloffPeriod: 75,
votingPeriod: 20
},
democracy: {
launchPeriod: 9,
minimumDeposit: 10,
votingPeriod: 18
},
session: {
validators: authorities,
length: 10
},
staking: {
bondingDuration: 2,
balances: endowed.map((accountId) => ({
accountId,
balance: new BN(1).iushln(60)
})),
currentEra: 0,
intentions: authorities,
sessionsPerEra: 5,
transactionFee: 1,
validatorCount: 2
}
},
nodes: []
}: ChainConfig);
Expand Up @@ -6,11 +6,11 @@
import type { ChainDefinition } from '../types';

const config = require('./config');
const executor = require('./executor');
const genesis = require('./genesis');
const initExecutor = require('../executor');
const initGenesis = require('../substrate/genesis');

module.exports = ({
config,
executor,
genesis
initExecutor,
initGenesis
}: ChainDefinition);
44 changes: 44 additions & 0 deletions packages/client-chains/src/chain-dev/index.spec.js
@@ -0,0 +1,44 @@
// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.

const memDb = require('@polkadot/client-db/memory');
const hexToU8a = require('@polkadot/util/hex/toU8a');

const init = require('../init');
const config = require('./index');

describe('genesis', () => {
let genesis;

beforeEach(() => {
const stateDb = memDb();
const blockDb = memDb();

genesis = init({ chain: 'test' }, config, stateDb, blockDb).genesis;
});

it('creates a correct genesis block (stateRoot)', () => {
expect(
genesis.header.stateRoot
).toEqual(
new Uint8Array([133, 218, 140, 182, 43, 145, 77, 72, 119, 152, 247, 190, 16, 37, 199, 164, 59, 142, 238, 150, 62, 132, 122, 69, 112, 213, 167, 118, 182, 71, 247, 210])
);
});

it('creates a correct genesis block (extrinsicsRoot)', () => {
expect(
genesis.header.extrinsicsRoot
).toEqual(
hexToU8a('0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421')
);
});

it('creates a correct block hash', () => {
expect(
genesis.hash
).toEqual(
new Uint8Array([84, 57, 249, 216, 185, 26, 248, 116, 15, 160, 105, 99, 44, 179, 200, 161, 64, 248, 104, 240, 111, 84, 182, 134, 130, 50, 37, 138, 242, 42, 27, 135])
);
});
});
8 changes: 0 additions & 8 deletions packages/client-chains/src/chain-nelson/block.js

This file was deleted.

38 changes: 0 additions & 38 deletions packages/client-chains/src/chain-nelson/config.js

This file was deleted.

14 changes: 0 additions & 14 deletions packages/client-chains/src/chain-nelson/genesis.js

This file was deleted.

0 comments on commit 464096c

Please sign in to comment.