Commit Graph

864 Commits

Author SHA1 Message Date
Bastian Köcher 718ba4e159 Remove node-api (#804)
* Remove `node-api` from `node-consensus` and `node-transaction-pool`

* Remove the `node-api` crate and its last usages

* Remove left over file

* Fixes compilation errors

* Switch to `As` trait

* Rename trait

* Whitespace
2018-09-26 17:57:30 +01:00
snd 58cc0992df best_containing operations (issue 603) (#740)
* add stub for Client.best_chain_containing_block_hash

* add fn blockchain::Backend::leaf_hashes

* fix typo

* sketch out Client.best_chain_containing_block_hash

* fix indent

* Blockchain.leaf_hashes -> Blockchain.leaves

* add unimplemented! stub impls for Blockchain.leaves

* start impl of Blockchain.leaves for in-memory client db

* Client.best_chain_containing...: check canonical first and make compile

* first rough attempt at maintaining leaf list in in-memory db

* fix tab indent

* add test best_chain_containing_single_block

* add failing test best_chain_containing_with_fork

* pub use client::blockchain; in test-client to prevent circular dep in client tests

* best_chain_containing_with_single_block: improve and test leaves

* far improve in-memory Backend::leaves impl

* test blockchain::Backend::leaves more thoroughly

* handle more edge cases in blockchain::Backend::leaves impl for in memory

* fix test best_chain_containing_with_fork (two distinct test blocks had same hash)

* make best_chain_containing_block_hash pass existing tests

* improve docstring for Blockchain::leaves

* Client.best_chain_containing: some cleanup. support max_block_number

* best_chain_containing: remove broken outcommented fast check for best = canonical

* remove blank line

* best_block_containing: return None if target_hash not found

* best_chain_containing: add unreachable! at end of function

* improve tests for best_chain_containing

* renames

* more elaborate test scenario for best_containing

* best_containing: fix restriction of search through maybe_max_number

* best_containing: tests for restriction of search

* get rid of unnecessary clones

* replace Client::new_in_mem by new_with_backend which is useful for testing backends

* add test_client::new_with_backend for testing different backend impls

* add test for in_mem::Backend::leaves

* remove unused imports

* in_mem test_leaves: simplify

* flesh out tests for in_mem leaves impl

* remove tests for leaves from client which are now covered in implementing module

* improve comment

* add Client.new_in_mem again

* unwrap in test_client::new_with_backend

* make test_client::BlockBuilderExt work not just with in-mem backend

* make test client ext not just work with in mem backend

* add failing Backend.leaves test for client-db

* update Cargo.lock

* replace KeccakHasher with Blake2Hasher

* refactor

address grumble https://github.com/paritytech/substrate/pull/740#discussion_r217822862

* refactor using NumberFor

address grumble https://github.com/paritytech/substrate/pull/740#discussion_r217823341

* add test that exposes possible problem

* update docstring for Client.best_containing

* extract test for Backend.leaves for reuse

* improve test blockchain_header_and_hash_return_blocks_from_canonical_chain_given_block_numbers

* extract test_blockchain_query_by_number_gets_canonical to easily test multiple impls

* remove whitespace

* remove todo

* Client.best_containing: pre-empt search loop when target in canonical

* best_containing: prevent race condition by holding import lock

* add todo

* extract leaf list update code into function

* add comment

* client-db: use in-memory-kvdb for tests

* use BTreeSet to store leaves for in-mem which is faster and simpler

* add docstring

* add comments and fix formatting

* add initial raw version of LeafSet

* remove Client::update_leaves which has been superceded by LeafSet

* use LeafSet in in-mem backend

* keccak -> blake2

* don't reexport codec traits in primitives

addresses https://github.com/paritytech/substrate/pull/740#discussion_r219538185

* fix rebase mistake

* improve LeafSet and use it in state-db

* correct Transfer nonces to fix ApplyExtinsicFailed(Stale)

* use given backend in canoncal test

* kill dead tree-route code in util

* fix warnings

* tests for leafset

* reorganizations in in_mem backend

* fix reorganization canon block logic

* DB commit and safe reversion on write error

* fix style nits
2018-09-26 12:34:05 +01:00
Guanqun Lu 1438e15925 clear statedb panics (#797)
* state-db: remove the assertion and replace it with Result<>

* state-db: unit test fixes

* comment fixes

* typo fix
2018-09-26 11:23:33 +01:00
Guanqun Lu 74a5ff7d0d State db random fixes (#802)
* state-db: typo fixes

* use fmt::Result for 'fmt'

* state-db: typo fixes

* state-db: use the same pattern to pass the parameter

* state-db: follow the same style
2018-09-26 11:15:56 +01:00
Pierre Krieger 52dbf0cace Rewrite the libp2p networking (#742)
* Rewrite the libp2p networking

* Fix erroneous replacement during rebase

* Update libp2p

* Update libp2p

* Remove the logic error about useless substreams

* Use the new NodeHandler system of libp2p

* Commit the Cargo.lock

* Upgrade yamux

* Forward port latest changes

* Fix compilation issues

* Implement the external URL

* Update to latest networking fixes

* Forward port rest of v0.2

* Fix reserved peers being dropped when we're full
2018-09-26 11:56:32 +02:00
Robert Habermeier abf799f78f Hard cutoff for non-finalized block state pruning (#798)
* state pruning after window even when nothing is finalized

* rename and alter canonicalization delay

* fix constant

* address grumbles

* add comment on canonicality vs finality
2018-09-26 00:24:11 +02:00
Sergey Pepyakin 98e0a3a55a Contracts: Add transfer event (#801) 2018-09-25 20:49:18 +01:00
Arkadiy Paronyan a613c62dc1 Fixed extrinsic encoding (#794)
* Fixed extrinsic encoding

* Reserve heuristic

* Fixed no-std build
2018-09-25 17:01:10 +01:00
Tomasz Drwięga 68e3e3ee11 Transactions dependency graph (#787)
* Graph transaction pool.

* Start future implementation.

* Future -> Ready promotions.

* Replacement logic.

* Clear extern crates, add docs.

* Move hash externally.

* Implement remove_invalid

* Implement ready transactions pruning.

* Move & rename.

* Add some logs.

* Clean up deps.

* Use Member trait.

* Add missing docs, elaborate on the proof.

* Expand on docs and proofs.
2018-09-25 15:38:23 +01:00
Gav Wood 82d6ca3484 Switch to shiny new fast, RLP-less trie (#795)
* Bump codec

* Fix tests

* Patricia trie builds

* Introduce trie

* Some yak shaving.

* Some fixes

* Remove RLP ref

* Fixes

* It builds!

* Some tests fixed

* Another test fix

* Rejig more hashes

* substrate-trie::iterator_works test

* Update lock

* Polish

* Docs

* Undo incorrect "fix" for tests

* Fix nits
2018-09-25 16:32:22 +02:00
Robert Habermeier b02c274374 Finality notification streams (#791)
* finalization for in_mem

* fetch last finalized block

* pruning: use canonical term instead of final

* finalize blocks in full node

* begin to port light client DB

* add tree-route

* keep number index consistent in full nodes

* fix tests

* disable cache and finish porting light client

* add AsMut to system module

* final leaf is always best

* fix all tests

* Fix comment and trace

* removed unused Into call

* add comment on behavior of `finalize_block`

* move `tree_route` to client common

* tree_route tests

* return slices in TreeRoute

* apply finality up to parent

* add `finalize_block` call

* adjust formatting

* finality notifications and add last finalized block to chain info

* exhaustive match and comments

* fix sync tests by using non-instant finality
2018-09-24 18:45:37 +02:00
Sergey Pepyakin ef97973178 Contracts: clean (#788)
* Extract `runtime` module

* Restructure & comment code to avoid confusion
2018-09-24 13:31:00 +02:00
Arkadiy Paronyan da991efd5f Removed From<H256> bound (#790) 2018-09-23 19:45:06 +01:00
Gav Wood f71200ee3c Bump codec (#786)
* Bump codec

* Fix tests
2018-09-21 17:16:15 +02:00
Robert Habermeier b7d095a2e0 Introduce notion of finality to substrate (#760)
* finalization for in_mem

* fetch last finalized block

* pruning: use canonical term instead of final

* finalize blocks in full node

* begin to port light client DB

* add tree-route

* keep number index consistent in full nodes

* fix tests

* disable cache and finish porting light client

* add AsMut to system module

* final leaf is always best

* fix all tests

* Fix comment and trace

* removed unused Into call

* add comment on behavior of `finalize_block`
2018-09-21 15:56:21 +02:00
Sergey Pepyakin 28cc4d0fd6 Get rid of core::string in sr-std. (#783) 2018-09-21 14:45:04 +02:00
Gav Wood 25393abef8 Rewards & slashes proportional to the least-slashable validator (#781)
* Initial stuff

* Treasury now mints based on lowest staked.

* Tests build

* Fix tests

* Fix hashes

* Fix tests & grumble
2018-09-21 09:10:16 +02:00
Gav Wood ebb688f81f Address grumbles in eras PR (#782)
* Address grumbles

* Fix hash
2018-09-20 23:18:47 +02:00
Gav Wood 67bf1a6eaa Transaction eras (#758)
* Initial groundwork

* A mess.

* Integrate

* Fix tests

* Unit tests

* Tests for unchecked_extrisnic

* fix tab

* Improve binary format.

* fix tests

* Rename extrinsic-pool -> transaction-pool

Closes #770

* Implement unimplemented.

* typo
2018-09-20 14:01:01 +02:00
Guanqun Lu 43068f8fc3 remove duplicate try_into_trie_backend (#779) 2018-09-20 06:36:24 -04:00
Guanghua Guo caa8541ada Delete useless type (#775) 2018-09-20 07:36:27 +02:00
Bastian Köcher 5d64be26c3 Replace JSON metadata with custom metadata structures (#766)
* Move module metadata from json string to custom metadata

* Revisit the metadata structures

1. Move the structures into the metadata crate.
2. Switch to using Cow/MaybeOwnedArray to support Encode/Decode

* Adapt to new metadata structures

* Convert event json metadata to new metadata structures

* Convert storage json metadata to new metadata structures

* Convert runtime metadata from json to new metadata structs

* Implements new metadata structures in client and runtime

* Fixes errors on `no_std`

* Fixes errors after rebasing master

* Do not use `Cow` anymore in metadata

Also replace `String` with our own type definition `StringBuf`.
This fixes compilation on `no_std`.

* Wrap `RuntimeMetadata` in `RuntimeMetadataVersioned` to support versioning

* Move metadata into `srml` and make core unaware of the implementation
2018-09-20 07:35:32 +02:00
Bastian Köcher 3c0da110f3 Bkchr impl macros scope (#774)
* Fixes compilation of sandbox tests

* Make `impl_outer_log!` scope independent
2018-09-20 00:02:29 +02:00
Svyatoslav Nikolsky 1e31b8d8ea log authorities change (#726) 2018-09-19 17:21:46 +02:00
Svyatoslav Nikolsky 04e22cd795 cleanup client errors (#771) 2018-09-19 15:26:36 +02:00
Bastian Köcher 9b369c4150 Fixes compilation of sandbox tests (#773) 2018-09-19 15:26:08 +02:00
Sergey Pepyakin 488830e81a Fix error handling in sandboxing/contracts modules (#744)
* Fix error handling in sandboxing/contracts modules

* Add some docs.

* Add some tests.

* grammar
2018-09-19 10:01:25 +02:00
Wei Tang 400a22ebe5 Implement codec for U256 (#761)
* Implement codec for U256

* Use little endian and add tests
2018-09-19 10:00:50 +02:00
Guanghua Guo 319549f563 Update lib.rs (#768) 2018-09-19 09:56:40 +02:00
Sergey Pepyakin e7d1933d25 Extract well known keys into a single place (#764)
* Extract well known keys into a single place

* Fixes.
2018-09-18 16:20:36 +02:00
Svyatoslav Nikolsky 7fa337afbc Light friendly storage tracking: changes trie + extending over ranges (#628)
* changes_trie

* changs_trie: continue

* changes_trie: adding tests

* fixed TODO

* removed obsolete ExtrinsicChanges

* encodable ChangesTrieConfiguration

* removed polkadot fle

* fixed grumbles

* ext_storage_changes_root returns u32

* moved changes trie root to digest

* removed commented code

* read storage values from native code

* fixed grumbles

* fixed grumbles

* missing comma
2018-09-18 09:14:41 +02:00
Gav Wood 24479cd7f5 Substrate is the one (#759) 2018-09-18 09:12:49 +02:00
Gav Wood f10d8e177d Generalised Transaction Queue API (#741)
* First effort

* API versioning

* Introduce validate_transaction

* Introduce the API plus fixes.

* Docs

* Typo

* Add longevity parameter to transaction validity info.
2018-09-17 18:43:59 +02:00
Maciej Hirsz 263786df05 Telemetry refactor (#757)
* Telemetry Refactor

* Cleanup

* Sleep after clearing Sender on error
2018-09-17 18:43:47 +02:00
Bastian Köcher 597ea41cd4 Implement construct_runtime! macro (#751)
* Make `system` module renamable in `impl_outer_event!`

* Implement `construct_runtime!` macro

This macro generates code for calling all the common `impl_outer_*` macros.

* Add documentation

* Fixes wrong declaration of `contract`

* Update dependencies to work on `no_std`

* One more `Cargo.lock` update

* Address comments
2018-09-17 17:27:22 +02:00
Sergey Pepyakin ea1b9bf026 SRML: fix OOB in srml_staking new_era. (#755) 2018-09-17 17:26:47 +02:00
Guanghua Guo 11578a8319 Not use extern (#748)
* Not use extern

* Update Cargo.lock
2018-09-17 08:26:33 +02:00
Sergey Pepyakin dcd181f31e Contracts: return arbitrary sized buffers (#711)
* WIP

* Direct return of output data.

* Docs and renamings.

* Add get_storage test.

* Overwrite the scratch buffer.
2018-09-15 12:46:59 +02:00
Sergey Pepyakin 56def2a38b Build project with --locked on CI (#743)
* Add --locked to the cargo build

* Remove trailing spaces

* Update Cargo.lock
2018-09-15 10:06:20 +02:00
Guanqun Lu b76660afd4 Sr treasury fix (#739)
* treasury: use 'mutate' and 'retain' to avoid creating a new vec

* treasury: check the underflow case
2018-09-14 09:50:22 +02:00
Drew Stone de4db765f5 Fixed spelling and grammar for clarity (#730)
* Fixed spelling and grammar for clarity

* Update README.adoc

* Three comma club

* gramma grammma grammar

* Update README.adoc

* Remove commas

Corrected the commas.

Consider the sentences:

- "Energy-saving light bulbs which are cheap make for a sensible investment"
- "Energy-saving light bulbs, which are cheap, make for a sensible investment"

They are different. The first one is intimating that energy-saving light bulbs come in many prices and it's only the cheap ones which are a good investment. The second implies that all energy-saving light bulbs are generally cheap and they, regardless of price, make for a good investment.

The commas added (which I just removed) switched the meaning, incorrectly, from one to the other.
2018-09-14 09:43:26 +02:00
Gav Wood 3f96419665 Remove unneeded code (#737) 2018-09-13 18:08:45 +02:00
Gav bd40f05167 Remove stale file 2018-09-13 15:57:18 +02:00
金XX(Aton) ca8f0d6625 bugfix: balances::transfer for new_account issue#722 (#731)
* bugfix: balances::transfer for new_account

issue:#722
would_create flag should depend on dest, not origin.
change 
```rust
let would_create = from_balance.is_zero();
```
to 
```rust
    let to_balance = Self::free_balance(&dest); 
    let would_create = to_balance.is_zero(); 
```
in the other hand, provide `fn new_test_ext2()` and let `transfer_fee=10`, `creation_fee=50` for test case

* Update lib.rs

* Update tests.rs

* Make `impl_outer_origin!` support generic `Origin`s (#732)

* Make `impl_outer_origin!` support generic `Origin`s

* Support empty outer origin

* Contracts: fix transfer function. (#733)

* Remove dependency on the parity repo (#734)

* Fix test

* Anothe fix
2018-09-13 15:54:56 +02:00
Gav Wood a7f8f0f1bd Remove redundant code and merge rest into rt-std (#735)
* Remove redundant code and merge rest into rt-std

* Update lib.rs
2018-09-13 14:54:24 +02:00
Arkadiy Paronyan 0ed48c89ab Remove dependency on the parity repo (#734) 2018-09-13 14:25:38 +02:00
Sergey Pepyakin 88ef57e4bd Contracts: fix transfer function. (#733) 2018-09-13 14:25:20 +02:00
Bastian Köcher 72fb60cb49 Make impl_outer_origin! support generic Origins (#732)
* Make `impl_outer_origin!` support generic `Origin`s

* Support empty outer origin
2018-09-13 11:19:48 +02:00
Bastian Köcher 5bd0ecddd2 Make impl_outer_event! aware of required generic parameters (#729) 2018-09-12 19:12:28 +02:00
Guanqun Lu a813d54965 add a python script to show the runtime packages' dependencies (#725)
* add a python script to show the dependencies

* add the header line and modify the mod
2018-09-12 16:05:15 +02:00