Commit Graph

142 Commits

Author SHA1 Message Date
Robert Habermeier 4eefa5ee60 update script targets 2018-08-15 13:43:41 +02:00
Gav Wood 3d6aaab26c Refactor/substrate state machine generic (#553)
* Genric over hasher

* WIP start adding NodeCodec

* Add codec to TrieBackend

* Typechecks

* Fix error type

* Cleanup

* Tests build (and fail)

* Fix tests: don't use MemoryDB::default()

* Lockfile

* Address grumbles

* Teach environmental! about generics

* Add Finder artifacts

* whitespace

* Add a toy impl of Hasher and plug it in to Externalities

* Use `uint` and `fixed-hash` from `parity-common`
Remove unused U512
Add test to ensure H256 impls heapsizeof

* lock file updates

* Make hashes Encodable/Decodable

* lock file updates

* Impl FromIterator for TestExternalities so we can collect() and use map!

* Use rustc-hex from crates
Use rlp from master so dependencies do not mess up the scope

* Fix tests in runtime-io

* lockfile shenanigans

* Add a BlakeHasher impl

* Use BlakeHasher in runtime-io

* lockfile updates

* ws

* Add a Blake2/RLP-flavoured NodeCodec

* Use Blake-flavoured Hasher and NodeCodec

* lockfile

* Implement PartialEq and Default for TestExternalities

* Add note about limitations of environmental!

* Make it compile, but this is probably broken

* Derive Debug so tests in executor can work

* Make executor use BlakeHasher

* ws

* WIP make client generic

* typechecks

* cleanup

* client tests pass

* Fix client/db

* cleanup

* Fix network

* Fix rpc

* Fix service

* Make TestExternalities work better au lieu d'un HashMap

* Fix tests in council

* Fix tests in contract

* Fix tests in council

* Fix democracy

* Add comment about odd-looking reexports in tests

* Don't need to load branch

* Fix staking

* Fix session

* Some polkadot fixes and lockfile

* Fix executive

* fixup lockfile

* Fix polkadot/api

* Fix polkadot/service

* Fix polkadot/runtime tests

* Fix tests in test-runtime

* Test fixes

* Fix missing component in the `std` feature

* Use PhantomData and Result from core

* Fix paths
Use core

* load heapsize on wasm

* implement `HeapSizeOf` for wasm

* Add toy impl of `blake2_256` for no_std

* lockfile

* Use kvdb* from parity-common and fix errors

* rebuilt lockfile

* Add dummy impl of `on_advance_round` for rhododendron::Context

* Fix build after merge

* Add HeapSizeOf bound where needed

* Sort out dependencies for no_std

* Add HeapSizeOf bound where needed

* use temp branch pending PR merges

* Remove unneeded tests

* Lock file and wasm artifacts

* lockfile

* Use magic commit for libp2p

* Cleanup

* Implement blake2_256 for no_std

* Back on parity-common master

* missing type params

* Update Cargo.lock

* whitespace

* Rename concrete Rlp node codec "RlpCodec" and use everywhere
Implement a Keccak-flavoured Rlp NodeCodec and use everywhere
Add a KeccakHasher

* Switch to use KeccakHasher

* Lock file and runtimes

* fixup lockfile

* Fix outstanding issue using concrete types (thanks @gnunicorn)

* Cleanup

* More cleanup

* Comment out Blake2 Hasher

* implement ext_keccak256

* Address todo: FetchChecker is generic

* all tests passing
2018-08-15 13:13:11 +02:00
shamardy 548332da4f Ensure total tokens in system is kept up to date (#428)
* Squashed commit of the following:

commit 802b219d86a63f2a68a2f2fbc406229d192ce99f
Author: shamardy <shamardy@yahoo.com>
Date:   Tue Aug 14 19:13:52 2018 +0200

    Removed set_bad_validators function

commit 53d17fc4c7798a5cf180bc8783213e0b50068ecc
Merge: 671c53a6 a079be3e
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Tue Aug 14 18:00:56 2018 +0200

    Merge branch 'master' into Issue#303

commit 671c53a68f0357171d1bbbcd46f1ed7dd68755af
Author: shamardy <shamardy@yahoo.com>
Date:   Tue Aug 14 08:16:55 2018 +0200

    Updated test

commit 6c7d8f455841cfe1902e700d230844b393a2aa16
Author: shamardy <shamardy@yahoo.com>
Date:   Tue Aug 14 08:14:07 2018 +0200

    Squashed commit of the following:

    commit f5a74b4804bc1a244d35f679c2a60cffe556ca3c
    Author: shamardy <shamardy@yahoo.com>
    Date:   Tue Aug 14 07:30:36 2018 +0200

        Update Tests

    commit 39724da56d1782e9d5303ea8764dfdf8d7f517ec
    Author: shamardy <shamardy@yahoo.com>
    Date:   Tue Aug 14 06:45:34 2018 +0200

        fix

    commit 9d564c707fe5d0e4de005ab55c63c136722e6591
    Author: shamardy <shamardy@yahoo.com>
    Date:   Tue Aug 14 06:36:50 2018 +0200

        fix

    commit 0c2bad1da22488ea8cae2a6119a374bf9b628596
    Author: shamardy <shamardy@yahoo.com>
    Date:   Tue Aug 14 05:53:35 2018 +0200

        fix

    commit f7069b3784579a2d20b6298d021b0d99d3f9beb6
    Author: shamardy <shamardy@yahoo.com>
    Date:   Tue Aug 14 00:34:10 2018 +0200

        Function to set bad validators

    commit 7c9bb146ba7adacde29a11e16b0194a29d0d77c8
    Author: shamardy <shamardy@yahoo.com>
    Date:   Mon Aug 13 23:35:46 2018 +0200

        fix

    commit 641eb4267031478d60e4e1476231629052d10549
    Author: shamardy <shamardy@yahoo.com>
    Date:   Mon Aug 13 23:00:08 2018 +0200

        Edit

    commit 5981f5fd5ee65dac9c3e19275ae4647cb173d798
    Author: shamardy <shamardy@yahoo.com>
    Date:   Mon Aug 13 22:25:56 2018 +0200

        Edit fix

    commit db3dd37c435ddc5dad0f9dde56cf7be539a0e1d0
    Author: shamardy <shamardy@yahoo.com>
    Date:   Mon Aug 13 21:39:57 2018 +0200

        fix

    commit bdb34c4f14fd68b3d307980da1182075bc74f156
    Author: shamardy <shamardy@yahoo.com>
    Date:   Mon Aug 13 21:11:08 2018 +0200

        Edit for early exit slashing tests by adding bad validators manually

    commit 8134bc6d13f9bf81050d37e8db39e819342af023
    Author: shamardy <shamardy@yahoo.com>
    Date:   Mon Aug 13 15:06:57 2018 +0200

        Update header root to match storage root in wasm test

    commit ee893f65a653c8826bb177bcf378d795bd1b9351
    Author: shamardy <shamardy@yahoo.com>
    Date:   Sun Aug 12 15:27:57 2018 +0200

        Update header root to match storage root in test

    commit eb1fb61b928ca13b4ab1b76301b577154858f425
    Author: shamardy <shamardy@yahoo.com>
    Date:   Sun Aug 12 14:07:40 2018 +0200

        Update tests

    commit f27559b3364ffe1255b01e7d3f09d87fe5d9c3a2
    Author: shamardy <shamardy@yahoo.com>
    Date:   Sun Aug 12 13:14:13 2018 +0200

        Squashed commit of the following:

        commit ac244e219f6e4c5f1b19463f33ce2edb3b66f6c3
        Author: shamardy <shamardy@yahoo.com>
        Date:   Sun Aug 12 12:55:25 2018 +0200

            Edited Tests

        commit 93ac939024da55bb90479b3fcbaf82fc4407727f
        Author: shamardy <shamardy@yahoo.com>
        Date:   Sun Aug 12 12:08:47 2018 +0200

            Squashed commit of the following:

            commit 910ff83a3b0405546f0a7a1d8727e69ec22f2513
            Author: shamardy <shamardy@yahoo.com>
            Date:   Sun Aug 12 03:53:40 2018 +0200

                Edited Test

            commit 2758bc44007652fd05bab221df3f349fe7daeb6a
            Author: shamardy <shamardy@yahoo.com>
            Date:   Sun Aug 12 03:16:38 2018 +0200

                Check that block 4 is the final block in session

            commit 49f4043e0fb44118c833b3063f4820213d279bac
            Author: shamardy <shamardy@yahoo.com>
            Date:   Sun Aug 12 02:31:12 2018 +0200

                LastLengthChange should change to block number when setting length

            commit eb5873550810a25ca093a635405bb069a0610d10
            Author: shamardy <shamardy@yahoo.com>
            Date:   Sun Aug 12 00:17:22 2018 +0200

                Squashed commit of the following:

                commit 48fae25a49b0aa3294ab04651f0c2cb530994d9a
                Author: shamardy <shamardy@yahoo.com>
                Date:   Sat Aug 11 23:32:25 2018 +0200

                    Increase TotalStake by ReclaimRebate if NewAccountOutcome::GoodHint

                commit d1166230ad3dcda00cc6916efe5d0d18007ecc4f
                Author: shamardy <shamardy@yahoo.com>
                Date:   Fri Aug 10 01:45:48 2018 +0200

                    Updating set_free_balance_creating

                commit fbdabd802a618af5311d21c5ec7e4b25d50cd705
                Author: shamardy <shamardy@yahoo.com>
                Date:   Fri Aug 10 00:52:40 2018 +0200

                    fix for TotalStake tracking in transfer and set_free_balance_creating fn

                commit f26bb1d6faeab3bb9a997ea0498009bc25dae244
                Author: shamardy <shamardy@yahoo.com>
                Date:   Fri Aug 10 00:03:17 2018 +0200

                    Fix if account created on an old account with more balance

                commit f0952094de2b3ab8528fb42794d98504c647cc7a
                Author: shamardy <shamardy@yahoo.com>
                Date:   Thu Aug 9 22:32:48 2018 +0200

                    fix

                commit 28260e570c3b81b79cb390d097a7a941f44dfc0a
                Author: shamardy <shamardy@yahoo.com>
                Date:   Thu Aug 9 21:36:27 2018 +0200

                    fix totalstake update in set_free_balance_creating fn if account exists

                commit b72fd6fab556eb0ad653d805ee4c415cbf88561d
                Author: shamardy <shamardy@yahoo.com>
                Date:   Thu Aug 9 20:26:30 2018 +0200

                    TotalStake is updated in contract_transfer_max_depth function

                commit 2fa1cc27dc75229b941eba686a33fa6906f7b1a8
                Author: shamardy <shamardy@yahoo.com>
                Date:   Thu Aug 9 20:22:17 2018 +0200

                    Squashed commit of the following:

                    commit 7fbf74c5e55038b006d6ac57621ed42c00fdd0e4
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Thu Aug 9 19:08:49 2018 +0200

                        fix for tests with set_free_balance calls

                    commit c6b4196f853191467d8a99c9604ba692425bbbaa
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Thu Aug 9 18:28:03 2018 +0200

                        Update TotalStake where set_free_balance is called

                    commit e827abc5184d48728168fbb57be6e8f03a8504e9
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Thu Aug 9 16:57:36 2018 +0200

                        Update TotalStake where set_reserved_balance is called

                    commit f73bec9c1a8376360b992e39333d762892ca8735
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Fri Aug 3 16:44:59 2018 +0200

                        fix

                    commit 5a498c5f4660429f7a24c09e715f7b083266c93d
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Fri Aug 3 15:47:03 2018 +0200

                        Test for full_native_block_import_works to check storage root

                    commit 024249ca52ae7ef0f5d39e99c585617a3db1dc0c
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Fri Aug 3 14:38:07 2018 +0200

                        Use <FreeBalance<Test>>::insert in this fn to avoid TotalStake Overflow

                    commit d602839cd59dd8550c87ec2c0bf103c806daedab
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Fri Aug 3 13:59:47 2018 +0200

                        Removed <TotalStake<Test>>::put from tests

                    commit 38586043912b40c9004bb5232cb7ca3c01ec9144
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Fri Aug 3 13:56:15 2018 +0200

                        Replace Balance::insert in tests to set balance fn to update TotalStake

                    commit 170ab6f8cd152adbc525bcc32fa012e3c11b6177
                    Merge: 9b0b22bd 2230b61c
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Fri Aug 3 12:32:05 2018 +0200

                        Merge branch 'Issue#303' of https://github.com/shamardy/polkadot into Issue#303

                    commit 9b0b22bd2084083f610e4870d5866bbd8e8d7229
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Fri Aug 3 12:31:45 2018 +0200

                        Edit

                    commit 2230b61c261296f6d09d0ec5353c0f207b281a67
                    Merge: 2fe9c528 05f49f1d
                    Author: shamardy <39480341+shamardy@users.noreply.github.com>
                    Date:   Fri Aug 3 11:12:19 2018 +0200

                        Merge branch 'master' into Issue#303

                    commit 2fe9c528bef62b0f43ef98c5166408d7d048f513
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Fri Aug 3 11:09:08 2018 +0200

                        commented out some tests

                    commit a6c2d8412e1d8e409d4fe2ca6545be5e525d80b0
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Fri Aug 3 10:35:17 2018 +0200

                        fix

                    commit ceb34d873b48ea7debd878a78f57ce235acd6ee8
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Thu Aug 2 16:52:16 2018 +0200

                        Update

                    commit a363120bd1b72597deb6ee945f9c51d32a851b14
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Thu Aug 2 16:05:40 2018 +0200

                        Edit

                    commit e45a92847a4beb28aa6f876ec109585467f4d732
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Wed Aug 1 16:49:40 2018 +0200

                        Edit

                    commit 07c5dcec22e43d6ccb49b42356590fb370bbcfae
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Tue Jul 31 15:44:40 2018 +0200

                        Instead of update_total_stake => 2 functions to increase and decrease

                    commit 7eb03b29e429a86d206244779d383af9437f208d
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Tue Jul 31 14:24:36 2018 +0200

                        Removed update_total_stake from set_free_balance_creating

                    commit 234ff798c6a7e035c7d3f7a9a668e311f9940dc5
                    Author: shamardy <shamardy@yahoo.com>
                    Date:   Tue Jul 31 14:22:48 2018 +0200

                        Squashed commit of the following:

                        commit 8f2e421a731f353394c611dc6e93ad48ba811a1a
                        Author: shamardy <shamardy@yahoo.com>
                        Date:   Tue Jul 31 13:24:30 2018 +0200

                            added balances to trait Store

                        commit b64c3a99467895b042f6a30219caf87f8265fa90
                        Author: shamardy <shamardy@yahoo.com>
                        Date:   Tue Jul 31 12:52:16 2018 +0200

                            update_total_stake iterates through balances

                        commit bf503ecc6b3664a6be7eac6adef3f83f72e4a8fa
                        Author: shamardy <shamardy@yahoo.com>
                        Date:   Tue Jul 31 11:06:25 2018 +0200

                            Removed update_total_stake from inside transfer function for now to test

                        commit d91a8a666b5b52e1c77b72e3ae59040e71cd8d9c
                        Author: shamardy <shamardy@yahoo.com>
                        Date:   Mon Jul 30 21:26:09 2018 +0200

                            update_total_stake function fix

                        commit 2465361fe9f631ae790d3f24ef69f9972b6adae5
                        Author: shamardy <shamardy@yahoo.com>
                        Date:   Mon Jul 30 21:10:02 2018 +0200

                            fix

                        commit 2351f3532d6ba28491231bcb0717f8e76fc35629
                        Author: shamardy <shamardy@yahoo.com>
                        Date:   Mon Jul 30 19:36:21 2018 +0200

                            fix

                        commit 7139371e5c07cc41112468e82d7ec901e8361d60
                        Author: shamardy <shamardy@yahoo.com>
                        Date:   Mon Jul 30 18:38:50 2018 +0200

                            update

                        commit e6602d1f98190f35565d3c31e3b7a2d3df64607e
                        Author: shamardy <shamardy@yahoo.com>
                        Date:   Mon Jul 30 18:36:43 2018 +0200

                            Squashed commit of the following:

                            commit dcb597a60c960ff40623e98c6a1210f5df196794
                            Author: shamardy <shamardy@yahoo.com>
                            Date:   Mon Jul 30 18:31:49 2018 +0200

                                update

                            commit c41382eb135eda3bffa957e8887fcffd0388a745
                            Author: shamardy <shamardy@yahoo.com>
                            Date:   Mon Jul 30 18:23:59 2018 +0200

                                Update

                            commit f828c69e055489b69739b0ea082afa1ceca23b9c
                            Author: shamardy <shamardy@yahoo.com>
                            Date:   Mon Jul 30 18:12:18 2018 +0200

                                Created function to update total stake

                            commit e398a587edb7e57378bd61c9f9940aadfb94e82a
                            Author: shamardy <shamardy@yahoo.com>
                            Date:   Mon Jul 30 15:02:07 2018 +0200

                                TotalStake tracks transfer fees + added test for account removal

                            commit 0cfb26ce508578ce386bac5e02856cb6f298c6ba
                            Author: shamardy <shamardy@yahoo.com>
                            Date:   Mon Jul 30 14:21:06 2018 +0200

                                TotalStake tracks accounts removal when free/reserved balance is too low

                            commit 6054dcf171eddfbe58c4e01f2b32b6f576e3d9c7
                            Merge: 5740c8fc 6fa9c949
                            Author: shamardy <shamardy@yahoo.com>
                            Date:   Mon Jul 30 14:16:37 2018 +0200

                                Merge branch 'Issue#303' of https://github.com/shamardy/polkadot into Issue#303

                            commit 5740c8fc09cdac9ec2228a66626b1c1ecb5dbeaf
                            Author: shamardy <shamardy@yahoo.com>
                            Date:   Mon Jul 30 14:15:41 2018 +0200

                                Resolved merge conflict by incorporating both suggestions.

                            commit 6fa9c949b9257bccb7ee48c32af35182a4dbf5f8
                            Merge: 2b29fe85 8c527f29
                            Author: shamardy <39480341+shamardy@users.noreply.github.com>
                            Date:   Mon Jul 30 14:12:11 2018 +0200

                                Merge branch 'master' into Issue#303

                            commit 2b29fe85ff0802594ad203d430ec4653f980296d
                            Author: shamardy <shamardy@yahoo.com>
                            Date:   Mon Jul 30 13:48:48 2018 +0200

                                Squashed commit of the following:

                                commit 773cdb913f671f575cc2933b14f2e783f49ffd7e
                                Author: shamardy <shamardy@yahoo.com>
                                Date:   Mon Jul 30 13:13:21 2018 +0200

                                    Squashed commit of the following:

                                    commit 07dc1945c3b51438028494f7691343638d647a93
                                    Author: shamardy <shamardy@yahoo.com>
                                    Date:   Mon Jul 30 13:08:00 2018 +0200

                                        TotalStake tracks accounts removal when free/reserved balance is too low

                                    commit 1b04d3afab44c99751c389ac6cddd865c0f77015
                                    Author: shamardy <shamardy@yahoo.com>
                                    Date:   Thu Jul 26 21:29:35 2018 +0200

                                        Edited slashing reserved balance tests

                                    commit 52482d5ac5828e927afcd7f27010ef64c085353f
                                    Author: shamardy <shamardy@yahoo.com>
                                    Date:   Thu Jul 26 20:46:17 2018 +0200

                                        Edited some tests

                                    commit 7c98f96d2ea1952b241054581bc1430863e4aab4
                                    Author: shamardy <shamardy@yahoo.com>
                                    Date:   Thu Jul 26 20:11:54 2018 +0200

                                        TotalStake tracks slashing of reserved balance

                                    commit 1d9f942ede81281218c1b4f84201388cf0908a4e
                                    Author: shamardy <shamardy@yahoo.com>
                                    Date:   Thu Jul 26 18:43:36 2018 +0200

                                        Ensure total tokens in system is kept up to date

* Fix Test
2018-08-14 21:43:54 +02:00
Tomasz Drwięga 41b7b2a943 RPC: Pending Extrinsics (#563)
* Expose extrinsics in pool.

* Add test.

* Use latest transaction pool.

* Fix compilation.
2018-08-14 18:51:30 +02:00
Robert Habermeier e8f21cf0c9 Vote out offline authorities (#524)
* notify when an authority appears to have missed their block

* Runtime API

* offline tracker

* Move to consensus

* generating reports of offline indices

* stubbed-out evaluation logic

* Slashing data pathwat

* usize -> u32

* Slash bad validators.

* update to rhododendron 0.3

* fix compilation of polkadot-consensus

* Support offline noting in checked_block

* include offline reports in block authorship voting

* do not vote validators offline after some time

* add test for offline-tracker

* fix test build

* bump spec version

* update wasm

* Only allow validators that are possible to slash

* Fix grumble

* More idiomatic

* New Wasm.

* update rhododendron

* improve logging and reduce round time exponent

* format offline validators in ss58
2018-08-11 11:29:30 +02:00
Gav Wood 36122833a1 Remove safe-mix (#521) 2018-08-09 15:26:01 +02:00
Tomasz Drwięga 96b3a8f92f Derivable Encode & Decode (#509)
* Derive macro for simple structs.

* Derive Encode/Decode wherever we can.

* Derive for enums.

* Support discriminant.

* Get rid of some repetition.

* Support custom indices.

* Derive codec for enums wherever possible.

* Fix no_std

* WASM rebuilt

* Avoid excessive import.

* Fix compilation.

* Address review grumbles.
2018-08-08 17:47:22 +02:00
Robert Habermeier 21346f34f8 Availability/Extrinsic store (#465) 2018-08-06 11:55:55 +02:00
Robert Habermeier bd3890da7e Collator for the "adder" (formerly basic-add) parachain and various small fixes (#438)
* update basic_add wasm

* wasm feature and collator feature

* move test parachains around a little

* fix wasm build for basic_add

* move basic_add to adder, introduce README

* minimal basic_add collator

* ensure collator messages are sent in the right order

* more logging

* route consensus statements to all peers

* minor bugfixes for parachains

* genesis builder accounts for parachain heads

* fix parachains tests

* targets for txpool

* tweak runtime + collator

* fix version in adder-collator

* consistency for overflowing

* adjust comment

* fix stable test run

* remove dummy registration test

* final grumbles
2018-08-01 17:04:04 +02:00
Tomasz Drwięga 503bcb5686 Storage changes subscription (#464)
* Initial implementation of storage events.

* Attaching storage events.

* Expose storage modification stream over RPC.

* Use FNV for hashing small keys.

* Fix and add tests.

* Swap alias and RPC name.

* Fix demo.

* Addressing review grumbles.

* Fix comment.
2018-08-01 15:29:52 +03:00
Arkadiy Paronyan 098cfcd319 Wasm execution optimizations (#466)
* WASM execution optimizations

* Dropped min-heap-pages

* Fixed tests

* Fixed tests 2
2018-08-01 12:29:45 +01:00
Gav Wood 307dcbde1a Fix session phase in early-exit (#453)
* Fix up session phase.

* Version bump

* Fix session rotation properly and add test

* Update runtimes

* Docs
2018-07-31 16:29:34 +01:00
Sergey Pepyakin 8c527f2999 Make contract a separate runtime module (#345)
* decl_module and extract runtime mod

* Invert dependency staking←→contract

* Remove CodeOf

* Remove StorageOf and move double_map

* Comment staking test

* Clean

* Add gas_price and gas_limit

* Commit.

* Renames

* Params

* WIP

* Rename transfer to call

* WIP

* Rebuild binaries.

* WIP

* Backport ctro changes

* Call wiring

* Commit overlay.

* Rename merge → commit, into_state → ..._change_set

* WIP

* Contract creation routines

* Set code of the created account.

* Fix the ID of `create` Call

* Fix most of the warning.

* Add the simplest test in the contract crate

* Transfers work!

* Add contract_create test.

* Clean

* Add top-level create test

* Clean a bit.

* Pass gas_limit and data via create.

* Introduce OnAccountKill callback in staking

* Hook up OnAccountKill

* Comments

* Pay for gas.

* Refund unused gas in call

* Tests for zero call and zero endownment.

* Add todo about rewriting docs

* Pay for gas in create transactions

* Fix refunds

* Clean unrelevant comments

* fixup! Fix refunds

* fixup! Clean unrelevant comments

* Move DetermineContractAddress to contract

Also restore account removal test

* fixup! Clean unrelevant comments

* Inline effect_transfer, remove effect_create

Remove account_db!

* Use own new_test_ext.

* Don't account for liability

* Add some docs

* Move contract_fee into contract module

* Take GasMeter in vm::execute

* Use GasMeter throughout contract module for meter

* gas module refactoring

* Clean

* Add base call fee

* note about gas price should be taken from storage

* Add base fee for create

* Rename send → call

* Clean

* Take fee expressed in dots in gas

* Add Checked{Add,Sub,Mul,Div} to SimpleArithmetic

* Make Gas generic

* Store {call,create}_base_fee in storage

* Clean

* Rename buy_gas

* Store gas_price in the storage

* Remove unneeded comment.

* Bail out if contract already has code.

* Todos

* Refund even if top-level contract fails.

* Fix error msg

* Fix caller issue

* Extract tests module

* Add max_depth var in storage

* Remove left over gas_left

* Refactor exec

* Add test oog test.

* set_free_balance_creating

* Docs and comments.

* Update storage roots because of ContractFee move

* Rebuild binaries.

* Simplify vm code.

* Wrapping.

* Refactor a bit.

* Typo

* UpdateBalanceOutcome enum

* Style grumbles.

* Rebuild binaries.

* Always consume the given amount of gas.

* [skip ci] endownment → endowment

* Rename `AccountId` generic in on_account_kill

* Fix Cargo.lock

* Refine docs for gas meter.

* [skip ci] Add comments for gas module

* Directly assign to `return_data` at declaration

* Use slices instead of vecs to pass the input data

* Add todo about passing return data without copy

* Use checked_add instead of add with overflow

* Use return_data directly.

* Rebuild binaries.

* Rebuild binaries.
2018-07-29 14:55:55 +01:00
Arkadiy Paronyan 916131b073 Prevent building invalid blocks (#430)
* Commit extrinsics changes

* Removed panic=abort

* Commit when needed

* Resotre default hook for the native call

* Revert test

* Proper test

* Sorted errors and fixed wasm build
2018-07-27 11:11:47 +02:00
Tomasz Drwięga 7ce2a8552f Extrinsics PubSub (#349)
* Extrinsic subscriptions.

* Handle RPC errors better.

* Add tests for extrinsics and unignored others.

* Handle client errors.

* Fix compilation.
2018-07-17 23:57:08 +02:00
Gav Wood 07fbd871d9 Final tweaks for PoC-2 runtime upgrade (#348)
* Final tweaks for PoC-2 runtime upgrade

* Address grumble

* Avoid slow wasm

* New poc-2-era bootnodes

* Fix warning

* Typo

* Fix for allocation in wasm

* Fix & runtimes.

* PoC-1 should be default.

* Name testnet Krumme Lanke, update README

* YML update

* Use the right port
2018-07-17 18:55:28 +02:00
Gav Wood e75d7d8fda Adaptive heap size (#328)
* heap-size is a CLI arg, make it 512 by default

* Fix tests

* Adaptive heap size.

* Allow storage_exists
2018-07-16 20:59:10 +02:00
Arkadiy Paronyan 1aeb2825af Refactored Slicable (#324)
* Refactored Slicable

* Docs

* Wasm build

* Wasm build

* Renamed traits

* Review nits

* Renamed Slicable as well
2018-07-15 22:51:21 +02:00
Sergey Pepyakin b45020175a Use --export-table from the latest LLD [2] (#325)
* It turned out that "table" was renamed.

To `__indirect_function_table`.

* Rebuild binaries.
2018-07-15 20:12:34 +02:00
Sergey Pepyakin fed50df6ed Use --export-table from the latest LLD (#316)
* Remove unused build.sh

* Don't use wasm-export-table anymore.

* Rebuild binaries.

* Fix build script.
2018-07-15 14:09:29 +02:00
Gav Wood ae5298f8b7 Fix and cleanups (#314)
* Cleanups (remove genesis.wasm & nicer errors)

- Pretty errors for version mismatch
- Remove the need for genesis wasm

* Remove unneeded wasm files

* Improve code of conduct

* Leaner code

* Test fixes

* fix tests

* Fix consensus checking
2018-07-15 00:30:13 +02:00
Arkadiy Paronyan 5b3050293a Fixed a few authoring issues (#315) 2018-07-14 22:27:25 +02:00
Arkadiy Paronyan b8216372c7 Split polkadot-service (#310)
* Substrate service

* Splitting polkadot service

* Specialised components

* Specialised components

* Docs and style

* Docs and style

* Final touches

* Added db key assertion
2018-07-14 18:07:11 +02:00
Gav Wood ee31955969 Dual execution (#311)
* Initial logic

* Remove accidental file

* Config

* Remove accidental

* Apply CLI config

* Additional work. Sadly pointless.

* Rearrange everything

* Loop into CLI param

* Implement dual execution

* typo

* fix tests.

* Better docs

* Fix bug

* Add some tests

* Report block information on consensus failure, tests

* Fix test
2018-07-14 16:10:20 +02:00
Gav Wood c8fe9e86bd Improve Wasm extern errors and increase heap (#299)
* Improve Wasm extern errors

* Increase heap size

* Update heap size further
2018-07-11 22:40:30 +02:00
Sergey Pepyakin a3b1b98a90 Fix for nightly 2018-07-10 (#296)
* Use [alloc_error_handler] instead of oom lang item

* Same fix for basic_add

* Drive by fix for duplicate generic parameter

* Rebuild binaries.
2018-07-11 15:40:33 +02:00
Sergey Pepyakin a472fe4430 Update pwasm to the latest nightly (#290)
- Update parity-wasm to 0.31
- Update pwasm-utils to 0.3.1
- Update usages of btree map in runtime-std
2018-07-09 19:18:01 +02:00
Robert Habermeier be5ff4e62f Minimal parachains part 2: Parachain statement and data routing (#173)
* dynamic inclusion threshold calculator

* collators interface

* collation helpers

* initial proposal-creation future

* create proposer when asked to propose

* remove local_availability duty

* statement table tracks includable parachain count

* beginnings of timing future

* finish proposal logic

* remove stray println

* extract shared table to separate module

* change ordering

* includability tracking

* fix doc

* initial changes to parachains module

* initialise dummy block before API calls

* give polkadot control over round proposer based on random seed

* propose only after enough candidates

* flesh out parachains module a bit more

* set_heads

* actually introduce set_heads to runtime

* update block_builder to accept parachains

* split block validity errors from real errors in evaluation

* update WASM runtimes

* polkadot-api methods for parachains additions

* delay evaluation until candidates are ready

* comments

* fix dynamic inclusion with zero initial

* test for includability tracker

* wasm validation of parachain candidates

* move primitives to primitives crate

* remove runtime-std dependency from codec

* adjust doc

* polkadot-parachain-primitives

* kill legacy polkadot-validator crate

* basic-add test chain

* test for basic_add parachain

* move to test-chains dir

* use wasm-build

* new wasm directory layout

* reorganize a bit more

* Fix for rh-minimal-parachain (#141)

* Remove extern "C"

We already encountered such behavior (bug?) in pwasm-std, I believe.

* Fix `panic_fmt` signature by adding `_col`

Wrong `panic_fmt` signature can inhibit some optimizations in LTO mode.

* Add linker flags and use wasm-gc in build script

Pass --import-memory to LLD to emit wasm binary with imported memory.

Also use wasm-gc instead of wasm-build.

* Fix effective_max.

I'm not sure why it was the way it was actually.

* Recompile wasm.

* Fix indent

* more basic_add tests

* validate parachain WASM

* produce statements on receiving statements

* tests for reactive statement production

* fix build

* add OOM lang item to runtime-io

* use dynamic_inclusion when evaluating as well

* fix update_includable_count

* remove dead code

* grumbles

* actually defer round_proposer logic

* update wasm

* address a few more grumbles

* schedule collation work as soon as BFT is started

* impl future in collator

* fix comment

* governance proposals for adding and removing parachains

* bump protocol version

* tear out polkadot-specific pieces of substrate-network

* extract out polkadot-specific stuff from substrate-network

* begin polkadot network subsystem

* grumbles

* update WASM checkins

* parse status from polkadot peer

* allow invoke of network specialization

* begin statement router implementation

* remove dependency on tokio-timer

* fix sanity check and have proposer factory create communication streams

* pull out statement routing from consensus library

* fix comments

* adjust typedefs

* extract consensus_gossip out of main network protocol handler

* port substrate-bft to new tokio

* port polkadot-consensus to new tokio

* fix typo

* start message processing task

* initial consensus network implementation

* remove known tracking from statement-table crate

* extract router into separate module

* defer statements until later

* double signature is invalid

* propagating statements

* grumbles

* request block data

* fix compilation

* embed new consensus network into service

* port demo CLI to tokio

* all test crates compile

* some tests for fetching block data

* whitespace

* adjusting some tokio stuff

* update exit-future

* remove overly noisy warning

* clean up collation work a bit

* address review grumbles

* fix lock order in protocol handler

* rebuild wasm artifacts

* tag AuthorityId::from_slice for std only

* address formatting grumbles

* rename event_loop to executor

* some more docs for polkadot-network crate
2018-07-06 14:17:03 +02:00
Gav Wood 7b175ea0a9 Update versions, docs. (#282) 2018-07-05 17:03:08 +02:00
Sergey Pepyakin 2510774f3b Prevent account storage leakage (#270)
* WIP

* Iteration over all keys with the specified prefix

* Add clear_prefix in runtime-io

* Introduce a custom storage impl: Double Map

* Remove prefix

* Impl for_keys_with_prefix for light client

* Fix wasm_executor

* Test storage removal leads to removal of stroage

* Check for ok result in storage tests.

* Add docs.

* Remove commented code under decl_storage!

* Add clear_prefix test in runtime-io

* Add test for wasm_executor

* Prefix walking test.

* Rebuild binaries.
2018-07-03 20:52:08 +02:00
Arkadiy Paronyan 12268ae700 Runtime version (#256)
* Runtime version

* Updated genesis.wasm

* Minor fixes

* Fresh runtime

* Default version for pre Poc-2; Fixed authorship interface check

* Fixed authoring check
2018-07-03 17:44:43 +02:00
Arkadiy Paronyan 9b885ba092 Serialisable genesis config (#229)
* Genesis serialization

* Custom type for AuthorityId

* Merge w master

* Fixed a few minor issues

* Fixed unmerged file

* Renamed tag

* Deferred genesis loading

* Upated wasm runtime

* Minor issues
2018-07-03 15:56:01 +02:00
Gav Wood 079a448454 Rewards and slashing, early-exit of bad sessions (#234)
* Recompile runtime.

* Introduce and enforce block time

* Introduce early session ending.

* Report most of staking module

* rewards, proper early exit and slashing

* Fix build & session logic, introduce tests

* Fixed staking tests.

* Initial test for reward

* Fix test

* Tests for slashing

* Update/fix preset configs

* Fix some tests.

* Fix some staking tests

* Minor fix

* minor cleanups

* Fix build

* Rename timestamp::Value -> Moment

* Require final block of session to be timely
2018-06-28 16:41:11 +02:00
Liu-Cheng Xu 323c055d5a Use #!/usr/bin/env bash instead of #!/bin/bash (#254)
Refer to https://github.com/dylanaraps/pure-bash-bible#shebang
2018-06-27 11:40:22 +02:00
Tomasz Drwięga bb8344b76b Handle AccountIndices in transaction pool (#225)
* Merge remote-tracking branch 'origin/master' into gav-xts-dont-panic

* Update wasm.

* consensus, session and staking all panic-safe.

* Democracy doesn't panic in apply.

* Fix tests.

* Extra helper macro, council depanicked.

* Fix one test.

* Fix up all council tests. No panics!

* Council voting depanicked.

* Dispatch returns result.

* session & staking tests updated

* Fix democracy tests.

* Fix council tests.

* Fix up polkadot parachains in runtime

* Fix borked merge

* More Slicable support

Support general `Option` and array types.

* Basic storage types.

* Existential deposit for contract creation

* Basic implemnetation along with removals

* Fix tests.

* externalities builder fix.

* Tests.

* Fix up the runtime.

* Fix tests.

* Add generic `Address` type.

* Initial function integration of Address into Extrinsic.

* Fix build

* All tests compile.

* Fix (some) tests.

* Fix signing.

* Push error.

* transfer can accept Address

* Make Address generic over AccountIndex

* Fix test

* Make Council use Address for dispatch.

* Fix build

* Bend over backwards to support braindead derive.

* Repot some files.

* Fix tests.

* Fix grumbles

* Remove Default bound

* Fix build for new nightly.

* Make `apply_extrinsic` never panic, return useful Result.

* More merge hell

* Doesn't build, but might do soon

* Serde woes

* get substrate-runtime-staking compiling

* Polkadot builds again!

* Fix all build.

* Fix tests & binaries.

* Reserve some extra initial byte values of address for future format changes

* Make semantic of `ReservedBalance` clear.

* Fix panic handler.

* Integrate other balance transformations into the new model

Fix up staking tests.

* Fix runtime tests.

* Fix panic build.

* Tests for demonstrating interaction between balance types.

* Repot some runtime code

* Fix checkedblock in non-std builds

* Get rid of `DoLookup` phantom.

* Attempt to make transaction_pool work with lookups.

* Remove vscode settings

* New attempt at making transaction pool work.

* It builds again!

* --all builds

* Fix tests.

* New build.

* Test account nonce reset.

* polkadot transaction pool tests/framework.

* Address grumbles.

* Pool support non-verified transactions.

* Revert bad `map_or`

* Rebuild binaries, workaround.

* Avoid casting to usize early.

* Make verification use provided block_id.

* Fix tests.

* Alter tests to use retry.

* Fix tests & add call to re-verify.

* Semi-refactor.

* Integrate new queue with the rest of the code.

* Fix tests.

* Add reverify_transaction method.

* Use result.
2018-06-26 11:45:57 +02:00
Tomasz Drwięga e6995cc997 Bump error-chain (#245)
* Bump error-chain

* Fix compilation errors
2018-06-25 19:41:33 +02:00
Sergey Pepyakin b3e2a9e89c Restore previous version of ext_sandbox_invoke (#236)
* Restore previous version of ext_sandbox_invoke.

* Rebuild binaries.
2018-06-25 12:12:27 +02:00
Gav Wood cd4a1e2211 Revert "Introduce and enforce block time (#232)" (#233)
This reverts commit ad392a0ef0.
2018-06-22 19:04:50 +02:00
Gav Wood ad392a0ef0 Introduce and enforce block time (#232)
* Recompile runtime.

* Introduce and enforce block time
2018-06-22 19:04:18 +02:00
Gav Wood 60f7b897a8 Dump genesis to JSON file (#218)
* Merge remote-tracking branch 'origin/master' into gav-xts-dont-panic

* Update wasm.

* consensus, session and staking all panic-safe.

* Democracy doesn't panic in apply.

* Fix tests.

* Extra helper macro, council depanicked.

* Fix one test.

* Fix up all council tests. No panics!

* Council voting depanicked.

* Dispatch returns result.

* session & staking tests updated

* Fix democracy tests.

* Fix council tests.

* Fix up polkadot parachains in runtime

* Fix borked merge

* More Slicable support

Support general `Option` and array types.

* Basic storage types.

* Existential deposit for contract creation

* Basic implemnetation along with removals

* Fix tests.

* externalities builder fix.

* Tests.

* Fix up the runtime.

* Fix tests.

* Add generic `Address` type.

* Initial function integration of Address into Extrinsic.

* Fix build

* All tests compile.

* Fix (some) tests.

* Fix signing.

* Push error.

* transfer can accept Address

* Make Address generic over AccountIndex

* Fix test

* Make Council use Address for dispatch.

* Fix build

* Bend over backwards to support braindead derive.

* Repot some files.

* Fix tests.

* Fix grumbles

* Remove Default bound

* Fix build for new nightly.

* Make `apply_extrinsic` never panic, return useful Result.

* More merge hell

* Doesn't build, but might do soon

* Serde woes

* get substrate-runtime-staking compiling

* Polkadot builds again!

* Fix all build.

* Fix tests & binaries.

* Reserve some extra initial byte values of address for future format changes

* Make semantic of `ReservedBalance` clear.

* Fix panic handler.

* Integrate other balance transformations into the new model

Fix up staking tests.

* Fix runtime tests.

* Fix panic build.

* Tests for demonstrating interaction between balance types.

* Repot some runtime code

* Fix checkedblock in non-std builds

* Get rid of `DoLookup` phantom.

* Attempt to make transaction_pool work with lookups.

* Remove vscode settings

* New attempt at making transaction pool work.

* It builds again!

* --all builds

* Fix tests.

* New build.

* Test account nonce reset.

* polkadot transaction pool tests/framework.

* Initial draft (working).

* Address grumbles.

* Revert bad `map_or`

* Rebuild binaries, workaround.

* Avoid checking in vscode

* reconnecting, shared, slog

* CLI options for name and telemetry url

* ensure telemetry url imples enabled

* Avoid casting to usize early.

* Provide on-connect event for session message

* Better port

* heartbeat and some renaming

* transaction pool stuff

* minor renaming.

* report telemetry

* cleanups.

* Fix for previous cleanup

* dump genesis, dev mode, renaming

* Rework chain spec/config &c. to allow for genesis file loading.

* Avoid producing genesis storage when unneeded

* Allow reading JSON genesis state dumps

* tests work again

* better logging.

* Fix wasm build.

* Introduce PoC-1 spec

* Made block message compatible with poc-1

* Squashed changes for dumping genesis block.

* Binaries.

* Made block message compatible with poc-1

* Remove dead code.

* Fix bad merge.

* Argument passing and returning values when invoking sandboxed funcs (#189)

* Fixed block download sequence (#223)

* Trie-based execution proof (#177)

* TrieBasedBackend

* trie tests

* redunant return_value removed

* use Trie::get_with to record trie proofs

* Relaying tx/blocks by light clients (#190)

* do not import external transactions into light tx pool

* do not announce blocks on light clients

* blocks_are_not_announced_by_light_nodes
2018-06-21 19:18:05 +02:00
Sergey Pepyakin f1b851871e Argument passing and returning values when invoking sandboxed funcs (#189) 2018-06-19 16:24:08 +03:00
Gav Wood e53c17d646 Enumeratable accounts (#195)
* Merge remote-tracking branch 'origin/master' into gav-xts-dont-panic

* Update wasm.

* consensus, session and staking all panic-safe.

* Democracy doesn't panic in apply.

* Fix tests.

* Extra helper macro, council depanicked.

* Fix one test.

* Fix up all council tests. No panics!

* Council voting depanicked.

* Dispatch returns result.

* session & staking tests updated

* Fix democracy tests.

* Fix council tests.

* Fix up polkadot parachains in runtime

* Fix borked merge

* More Slicable support

Support general `Option` and array types.

* Basic storage types.

* Existential deposit for contract creation

* Basic implemnetation along with removals

* Fix tests.

* externalities builder fix.

* Tests.

* Fix up the runtime.

* Fix tests.

* Add generic `Address` type.

* Initial function integration of Address into Extrinsic.

* Fix build

* All tests compile.

* Fix (some) tests.

* Fix signing.

* Push error.

* transfer can accept Address

* Make Address generic over AccountIndex

* Fix test

* Make Council use Address for dispatch.

* Fix build

* Bend over backwards to support braindead derive.

* Repot some files.

* Fix tests.

* Fix grumbles

* Remove Default bound

* Fix build for new nightly.

* Make `apply_extrinsic` never panic, return useful Result.

* More merge hell

* Doesn't build, but might do soon

* Serde woes

* get substrate-runtime-staking compiling

* Polkadot builds again!

* Fix all build.

* Fix tests & binaries.

* Reserve some extra initial byte values of address for future format changes

* Make semantic of `ReservedBalance` clear.

* Fix panic handler.

* Integrate other balance transformations into the new model

Fix up staking tests.

* Fix runtime tests.

* Fix panic build.

* Tests for demonstrating interaction between balance types.

* Repot some runtime code

* Fix checkedblock in non-std builds

* Get rid of `DoLookup` phantom.

* Attempt to make transaction_pool work with lookups.

* Remove vscode settings

* New attempt at making transaction pool work.

* It builds again!

* --all builds

* Fix tests.

* New build.

* Test account nonce reset.

* polkadot transaction pool tests/framework.

* Address grumbles.

* Revert bad `map_or`

* Rebuild binaries, workaround.

* Avoid casting to usize early.

* reenable sync tests
2018-06-18 20:23:41 +02:00
Sergey Pepyakin ca48416968 Refactor build scripts. 2018-06-08 19:59:15 +03:00
Gav Wood b94cf078af Make substrate generic (#169)
* Some initial work on RPC and client

* Rephrase as params

* More work on traitifying substrate.

* Traitify in_mem.rs

* traitify client.rs

* Make new primitives (mainly traits) build again.

* Many (superficial) build fixes throughout.

* Fix remaining build issues up to bft interface.

* Make bft primitives be generic.

* Switch out MisBehaviorReport for generic version.

* Merge Hashing into Header.

* Update runtime for new generics (with Hashing).

* Update demo runtime.

* Make runtime compile.

* Build fixes for runtime

* Remove old modules.

* port substrate-bft to use generic substrate types

* port client

* port substrate-test-runtime

* mostly port test-runtime to get compiling for std

* Ensure `AccountId` has a `Default`.

* Fix type deps.

* finish porting

* initialize test_runtime from genesis correctly

* remove commented code

* maybe unsigned signatures

* runtimes compile

* port over most of network

* serialization for generic types

* fix comment

* remove some unnecessary trait bounds

* network compiles

* tests compile for sync

* fix deserialization

* temporarily remove deserialize derives

* workarounds for serde issues for deriving deserialization

* get demo-runtime compiling on std

* port extrinsic-pool

* primitives reshuffling

* get network compiling again

* remove debugging file

* runtime tests now passing

* port client-db

* start to port over substrate-rpc

* mostly port over PolkadotApi

* test_runtime follows normal conventions

* substrate runtime tests pass

* deal with inherent extrinsics correctly in polkadot-api

* port transaction-pool

* port polkadot-consensus

* port substrate-rpc

* everything compiles

* tests compile

* fix grumbles

* test-runtime uses its own transfer type

* switch to master branch of jsonrpc

* fix network tests and some warnings

* all tests pass locally

* [ci-skip] add another comment about issue

* remove some curlies
2018-06-06 17:58:45 +02:00
Sergey Pepyakin ff0d9c3359 Extract smart-contract runtime into the separate crate (#179)
* Apply inversion of control to contract module.

* Extract contract to it's own crate.

* Rebuild binaries.
2018-06-05 14:18:08 +02:00
Sergey Pepyakin 68e468f59c Use #[panic_implementation] attribute that was landed in the recent nightly (#199)
* Use [panic_implementation] instead of lang item

* Rebuild binaries.
2018-06-04 19:11:42 +02:00
Tomasz Drwięga 1dada4f7a0 Extrinsic pool (#182)
* Use latest version of txpool.

* Initial version of the pool.

* Fix abstraction.

* Implement watchers and notifications.

* Return hash from RPC.

* Remove commented code.

* Remove client dep.

* Fix tests.
2018-05-31 22:49:17 +02:00
Gav Wood 44eaa4a180 Public extrinsic apply doesn't panic (#178)
* Merge remote-tracking branch 'origin/master' into gav-xts-dont-panic

* Update wasm.

* consensus, session and staking all panic-safe.

* Democracy doesn't panic in apply.

* Fix tests.

* Extra helper macro, council depanicked.

* Fix one test.

* Fix up all council tests. No panics!

* Council voting depanicked.

* utilise hygene
2018-05-31 22:11:09 +02:00
Gav Wood 1204a560aa RPCs for versioning (#175)
* RPCs for versioning.

* Build fix for bad merge.

* Add system_name RPC

* Fix tests.

* Fix demo build.

* Remove BadFormat.
2018-05-29 09:58:48 +01:00
Svyatoslav Nikolsky 58ba901ccc Preparing light client structure [v2] (#150)
* light client structure + remote call requests
2018-05-28 10:27:59 +03:00