Commit Graph

574 Commits

Author SHA1 Message Date
Marek Kotewicz b57607e7d3
simplify ethcore errors by removing BlockImportError (#9593) 2018-09-24 11:28:54 +01:00
Nicolas Gotchac 4ddd69cc55 Multithreaded snapshot creation (#9239)
* Add Progress to Snapshot Secondary chunks creation

* Use half of CPUs to multithread snapshot creation

* Use env var to define number of threads

* info to debug logs

* Add Snapshot threads as CLI option

* Randomize chunks per thread

* Remove randomness, add debugging

* Add warning

* Add tracing

* Use parity-common fix seek branch

* Fix log

* Fix tests

* Fix tests

* PR Grumbles

* PR Grumble II

* Update Cargo.lock

* PR Grumbles

* Default snapshot threads to half number of CPUs

* Fix default snapshot threads // min 1
2018-09-13 12:58:49 +02:00
Marek Kotewicz ef4a61c769
new ethabi (#9511)
* new ethabi migration in progress

* parity migrated to new ethabi

* migrated secred-store to new ethabi

* bump ethabi to 6.0

* fixed review suggestions
2018-09-13 11:04:39 +02:00
Nicolas Gotchac baf5be09dc Fix Snapshot restoration failure on Windows (#9491)
* Close Blooms DB files before DB restoration

* PR Grumbles I

* PR Grumble

* Grumble
2018-09-10 17:21:57 +02:00
Tomasz Drwięga 61bd47ccc1 Bad blocks RPC + reporting (#9433)
* Bad blocks RPC.

* Return bad blocks via RPC.

* Fix test.

* More verbose bad block message.

* Expose via CLI.

* Remove stray whitespace.

* Remove stray newline.

* Fix tests.
2018-09-08 04:04:28 +02:00
David 72fd1fa58d
Fetch `parity-common` crates from crates.io (#9410)
* Fetch `parity-common` crates from crates.io

* Add doc tests from `patricia-trie` to `patricia-trie-ethereum`
Fix/update a few deps

* [ethkey] upgrade ethereum-types

* [whisper] update deps

* [network] deps

* [network-devp2p] deps

* [journaldb] deps

* [fastmap] deps

* [miner] deps and test fixes

* [machine] deps

* [json] deps

* [hw] deps

* [ethash] deps

* [registrar] deps

* Update a few more dependencies with new ethabi-*

* [updater] Update deps

* deps

* [ethcore] Update deps

* Use new parity-snappy and parity-rocksdb crates

* Updated submodules

* Use parity-snappy 0.1

* Use kvdb-rocksdb 0.1.2

* Don't use latest ethereum/tests

* Fix merge conflicts errors

* Remove superseeded comment

* Address grumbles: add newlines, add/remove spaces
2018-09-04 20:13:51 +02:00
Wei Tang caca3a8048
Add EIP-1014 transition config flag (#9268)
* Add EIP-1014 transition config flag

* Remove EIP-86 configs

* Change CREATE2 opcode index to 0xf5

* Move salt to the last item in the stack

* Change sendersaltandaddress scheme to comply with current EIP-1014

* Fix json configs

* Fix create2 test

* Fix deprecated comments
2018-08-31 23:43:51 +08:00
Andrew Jones bc53e78a04
Remove unused BlockStatus::Pending (#9447)
Pending case never instantiated, and only ever matched together with Unknown
2018-08-31 12:13:01 +01:00
Andrew Jones 0b34579b04
Prevent sync restart if import queue full (#9381) 2018-08-24 09:42:24 +01:00
Wei Tang a6df452841
Implement EIP234 block_hash for eth_getLogs (#9256)
* Implement EIP234

* Make filter conversion returns error if both blockHash and from/toBlock is found

This also changes PollFilter to store the EthFilter type, instead of the jsonrpc one, saving repeated conversion.

* Return error if block filtering target is not found in eth_getLogs

Use the old behavior (unwrap_or_default) for anywhere else.

* fix test: secret_store

* Fix weird indentation

* Make client log filter return error in case a block cannot be found

* Return blockId error in rpc

* test_client: allow return error on logs

* Add a mocked test for eth_getLogs error

* fix: should return error if from_block/to_block greater than best block number

* Add notes on pending

* Add comment for UNSUPPORTED_REQUEST

* Address grumbles

* Return err if from > to
2018-08-13 15:47:10 +08:00
Jongsic Choi 3f2fd610d9 Fix loop start value (#9285) 2018-08-06 12:04:28 +01:00
Tomasz Drwięga 90d7823acb Propagate transactions for next 4 blocks. (#9265)
Closes #9255 

This PR also removes the limit of max 64 transactions per packet, currently we only attempt to prevent the packet size to go over 8MB. This will only be the case for super-large transactions or high-block-gas-limit chains.

Patching this is important only for chains that have blocks that can fit more than 4k transactions (over 86M block gas limit)

For mainnet, we should actually see a tiny bit faster propagation since instead of computing 4k pending set, we only need `4 * 8M / 21k = 1523` transactions.

Running some tests on `dekompile` node right now, to check how it performs in the wild.
2018-08-02 11:58:02 +01:00
Marek Kotewicz b4ae1b6528 decode block rlp less often (#9252)
in total:
- removed 4 redundant rlp deserializations
- avoid 1 redundant block data copy
2018-08-02 10:20:46 +01:00
Nicolas Gotchac c22498066b
Update ref to `parity-common` and update `seek` behaviour (#9257)
* Update ref to `parity-common` and update `seek` behaviour

* Remove reference to `ng-fix-triedb-seek` branch
2018-08-01 18:03:41 +02:00
Marek Kotewicz 10f42a2b39 removed client error (#9253) 2018-07-31 10:55:18 +01:00
Wei Tang 29baccd857
Implement EIP-1052 (EXTCODEHASH) and fix several issues in state account cache (#9234)
* Implement EIP-1052 and fix several issues related to account cache

* Fix jsontests

* Merge two matches together

* Avoid making unnecessary Arc<Vec>

* Address grumbles
2018-07-31 13:27:57 +08:00
Marek Kotewicz c54beba932 block cleanup (#9117)
* blockchain insert expects owned block instead of block reference

* reduce a number of times a block is deserialized

* removed cached uncle_bytes from block

* removed is_finalized from OpenBlock

* removed unused parity_machine::WithMetadata trait

* removed commented out code

* remove unused metadata from block

* remove unused metadata from block

* BlockDetails extras may have at most 5 elements
2018-07-30 10:45:10 +01:00
Marek Kotewicz 143411aaf0
deserialize block only once during verification (#9161) 2018-07-25 14:36:46 +02:00
Wei Tang 4848c384cd Avoid schedule copying in nested call/create (#9190)
* Avoid schedule copying in nested call/create

* Fix tests

* fix test: wrong Schedule used

* Fix private-tx test

* Fix jsontests compilation
2018-07-23 15:48:01 +02:00
Wei Tang 5059619947 Unify engine error to reject blocks (#9085)
* Reject if Engine::on_close_block returns error

* Unify open block behaviors

* Fix tests in ethcore

* Fix Aura tests

* Fix RPC test

* Print a warning if open block failed

* Print the actual error when closing the block

* Update comments for prepare_pending_block

* Add BlockPreparationStatus to distingish three different state after prepare_pending_block
2018-07-16 13:53:55 +02:00
Marek Kotewicz f826ac35e3
Removed redundant struct bounds and unnecessary data copying (#9096)
* Removed redundant struct bounds and unnecessary data copying

* Updated docs, removed redundant bindings
2018-07-15 11:01:47 +02:00
Tomasz Drwięga 5f523f6966 Offload cull to IoWorker. (#9099) 2018-07-13 12:23:57 +02:00
shamardy 526c61e2c0 Transactions hashes missing in trace_replayBlockTransactions method result #8725 (#8883)
* Squashed commit of the following:

commit 1f85076fd584365f1acbbafef5c8bdee722b479b
Author: shamardy <shamardy@yahoo.com>
Date:   Sat Jun 30 03:40:12 2018 +0200

    update

commit 63363cca7354873a8abe3b631b8b7dbd9da6ce1e
Author: shamardy <shamardy@yahoo.com>
Date:   Sat Jun 30 03:36:25 2018 +0200

    Update

commit e05caddc170a4cf0e476c23d443f07184dcb4fb1
Author: shamardy <shamardy@yahoo.com>
Date:   Fri Jun 29 10:04:34 2018 +0200

    Test

commit b0be065eadd0f2dd70f6613c50cbf3eb16d693ec
Author: shamardy <shamardy@yahoo.com>
Date:   Fri Jun 29 09:19:57 2018 +0200

    test_client edit

commit 949205ccdbac75f730639e5f0d8e1bdd9436de1d
Author: shamardy <shamardy@yahoo.com>
Date:   Fri Jun 29 05:14:53 2018 +0200

    Edit Test

commit 7cd44ee379a1e847f3e7d225444e72775bdbd4b5
Author: shamardy <shamardy@yahoo.com>
Date:   Fri Jun 29 04:25:22 2018 +0200

    Updates

commit e90de71e698d29475e8ba5696664b7d7bb335f9c
Author: shamardy <shamardy@yahoo.com>
Date:   Wed Jun 27 13:53:15 2018 +0200

    Test

commit 12a76381561b66ecf6ea636d7eebe43d2dcb7731
Author: shamardy <shamardy@yahoo.com>
Date:   Wed Jun 27 11:43:39 2018 +0200

    Edited Tests

commit 6c21e6de2da24e7b9f33ac8b82abb0b39488bd60
Merge: 87c4c74b8 9550cf766
Author: shamardy <shamardy@yahoo.com>
Date:   Wed Jun 27 10:31:21 2018 +0200

    Merge branch 'Issue#8725' of https://github.com/shamardy/parity into Issue#8725

commit 87c4c74b8f769c8e4b55ba78b5aa1d6716413f6d
Author: shamardy <shamardy@yahoo.com>
Date:   Wed Jun 27 10:31:13 2018 +0200

    Avoided Changing non-RPC Types

commit 9550cf76610953c8492cc9473e4b9f876e770b70
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Wed Jun 27 10:29:03 2018 +0200

    Update traces.rs

commit 3e0b0ef29685b62f0917b80a48054b3379d59a50
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Wed Jun 27 10:27:44 2018 +0200

    Update trace.rs

commit 5078d67a2da7268db2a1064540a3c887e1f1a3cd
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Wed Jun 27 10:26:08 2018 +0200

    Update traces.rs

commit 28f5ba1b035c6919ac11089cf1bdd703c75f0dbd
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Wed Jun 27 10:24:04 2018 +0200

    Update parity.rs

commit 3b86b98ab5860efa61a7cc6a2b20e6c5c0f859cb
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Wed Jun 27 10:23:33 2018 +0200

    Update eth.rs

commit bcad5a40f14a3c5d2d901ae1a9bed87949ab9c66
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Wed Jun 27 10:21:43 2018 +0200

    Update call_analytics.rs

commit e9029e0b8158387b606132b264652d285483870f
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Wed Jun 27 10:20:56 2018 +0200

    Update transaction.rs

commit 0dacc81779bc62713e3f8e405229dfd7f89f33e8
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Wed Jun 27 10:20:01 2018 +0200

    Update executive.rs

commit 3921d4ec77f49460d45603111b98cc07d3c235a0
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Wed Jun 27 10:18:39 2018 +0200

    Update executed.rs

commit 8416df654ebf6f68ad04c8a4a89a29ce704f9ca1
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Wed Jun 27 10:17:34 2018 +0200

    Update client.rs

commit cf0b4dddbc93395bc5ce1f17c3c07a294bf8dd49
Merge: 23bfa78c2 36e05e5f3
Author: shamardy <shamardy@yahoo.com>
Date:   Sun Jun 24 04:54:04 2018 +0200

    Merge branch 'Issue#8725' of https://github.com/shamardy/parity into Issue#8725

commit 23bfa78c2662d697018e7061ab9ad0b864fde0ef
Author: shamardy <shamardy@yahoo.com>
Date:   Sun Jun 24 04:53:50 2018 +0200

    Undo

commit 36e05e5f30c35bd6b57af50fd337f2006df51b86
Merge: 2f6e1ef64 0afc74825
Author: shamardy <shamardy@yahoo.com>
Date:   Sun Jun 24 04:44:33 2018 +0200

    Merge branch 'Issue#8725' of https://github.com/shamardy/parity into Issue#8725

commit 2f6e1ef64763a79ad2ed8baa2aed5a8f3136bafc
Author: shamardy <shamardy@yahoo.com>
Date:   Sun Jun 24 04:44:22 2018 +0200

    Another rpc test output with ("transactionHash":null)

commit 0afc74825828f724d68f3e444655b872a6c51ce0
Author: shamardy <shamardy@yahoo.com>
Date:   Thu Jun 14 07:18:45 2018 +0200

    Another rpc test output with ("transactionHash":null)

commit 138fbac9f02841adfeaaf061c5dd9e647f725e12
Author: shamardy <shamardy@yahoo.com>
Date:   Thu Jun 14 06:30:41 2018 +0200

    Edited some rpc tests output with ("transactionHash":null)

commit 8c129a63109c00f88ce36bad10699dc2f3237d95
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Thu Jun 14 05:48:39 2018 +0200

    Update traces.rs

commit 52c17f6191740637c1d1589a420996dccefe16bb
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Thu Jun 14 05:47:29 2018 +0200

    Update parity.rs

commit d39303aa8c2097ba9e2ed94c7ad2166bf1608d3f
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Thu Jun 14 05:46:25 2018 +0200

    Update eth.rs

commit 49be84bf529c33dc47c8260435fd0d26e137c66d
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Thu Jun 14 05:40:56 2018 +0200

    Update trace.rs

commit 4fc801377fb01ff11867f66b547a307c162d7a56
Merge: d34ba2351 544210439
Author: shamardy <shamardy@yahoo.com>
Date:   Thu Jun 14 05:12:21 2018 +0200

    Merge branch 'Issue#8725' of https://github.com/shamardy/parity into Issue#8725

commit 54421043959e14a76f309fe87d3c7513a95999f8
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Thu Jun 14 05:04:51 2018 +0200

    Update trace.rs

commit 2b2524a31119d741df4076e9d1b3ce8f0b17b479
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Thu Jun 14 05:01:47 2018 +0200

    Update state_diff.rs

commit 2bf9982b8ce29ef69f116142eaeacf3049f7db49
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Thu Jun 14 05:00:50 2018 +0200

    Update transaction.rs

commit da696ea192c0f89cceb38834f6efee280129048c
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Thu Jun 14 05:00:13 2018 +0200

    Update mod.rs

commit cfc194ca0f44bfabec01a52897a322ea5a91930b
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Thu Jun 14 04:59:18 2018 +0200

    Update pod_state.rs

commit 3b3156853535a666778e0ad0e902de79fb138f1d
Author: shamardy <39480341+shamardy@users.noreply.github.com>
Date:   Thu Jun 14 04:57:37 2018 +0200

    Update client.rs

commit d34ba235132c654da6c2ed6ff0dcf96fda0c45ee
Author: shamardy <shamardy@yahoo.com>
Date:   Thu Jun 14 04:53:50 2018 +0200

    RPC Only

commit 8b5c4f19727549ee6f180a6effc228b2693509e9
Merge: 744491632 291b4a01b
Author: shamardy <shamardy@yahoo.com>
Date:   Thu Jun 14 02:55:14 2018 +0200

    Merge branch 'Issue#8725' of https://github.com/shamardy/parity into Issue#8725

commit 74449163222e0ab75c704ac0ad424870e3c321d9
Author: shamardy <shamardy@yahoo.com>
Date:   Thu Jun 14 02:27:13 2018 +0200

    Issue#8725

    Transactions hashes missing in trace_replayBlockTransactions method result #8725

commit 291b4a01be6771acff8f5829c5406fa193665dbe
Author: shamardy <shamardy@yahoo.com>
Date:   Thu Jun 14 01:18:18 2018 +0200

    Edited to make changes to RPC types only

    To make a transactions hash trace with "trace_replayBlockTransactions" add "transactionHash" to parameters

commit 9d082bece73beb8ebddfda51fa5ec279f30b7bea
Author: shamardy <shamardy@yahoo.com>
Date:   Wed Jun 13 09:15:56 2018 +0200

    Issue#8725

    Transactions hashes missing in trace_replayBlockTransactions method result #8725

* update

* Removed unwrap_or

* Update

* test_client update
2018-07-10 15:38:13 +01:00
Niklas Adolfsson 6816f8b489 Updater verification (#8787)
* getting started

* refactor main

* unwrap_or -> unwrap_or_else

* force parity to lower version number to trigger update

* Fix typos

* formating

* some minor refactoring

* enable lints and fix some warnings

* make it compile

* minor tweaks to make it work

* address review comments

* Rename exe to exe_path and minor import changes

* updater: unreleased -> unknown

* Add `debug` configuration to force parity-updater

* Introduce a new feature `test-updater` in order conditionally hardcode
the version number in parity in order to force an update
* This should only be used for debug/dev purposes

* nits

* Pulled latest submodule of `wasm-tests`
2018-07-10 12:17:53 +02:00
Marek Kotewicz 8d171a37f8 remove util-error (#9054)
* remove util-error

* fixed grumbles
2018-07-06 15:09:39 +02:00
Tomasz Drwięga 78e001284f Recently rejected cache for transaction queue (#9005)
* Store recently rejected transactions.

* Don't cache AlreadyImported rejections.

* Make the size of transaction verification queue dependent on pool size.

* Add a test for recently rejected.

* Fix logging for recently rejected.

* Make rejection cache smaller.

* obsolete test removed

* obsolete test removed

* Construct cache with_capacity.
2018-07-02 18:00:06 +01:00
David 9caa868603
Make HashDB generic (#8739)
The `patricia_trie` crate is generic over the hasher (by way of HashDB) and node encoding scheme. Adds a new `patricia_trie_ethereum` crate with concrete impls for Keccak/RLP.
2018-07-02 18:50:05 +02:00
Marek Kotewicz 5ef41ed53e simplify kvdb error types (#8924) 2018-07-02 10:04:48 +01:00
Marek Kotewicz 458afcd230 new blooms database (#8712)
* new blooms database

* fixed conflict in Cargo.lock

* removed bloomchain

* cleanup in progress

* all tests passing in trace db with new blooms-db

* added trace_blooms to BlockChainDB interface, fixed db flushing

* BlockChainDB no longer exposes RwLock in the interface

* automatically flush blooms-db after every insert

* blooms-db uses io::BufReader to read files, wrap blooms-db into Mutex, cause fs::File is just a shared file handle

* fix json_tests

* blooms-db can filter multiple possibilities at the same time

* removed enum trace/db.rs CacheId

* lint fixes

* fixed tests

* kvdb-rocksdb uses fs-swap crate

* update Cargo.lock

* use fs::rename

* fixed failing test on linux

* fix tests

* use fs_swap

* fixed failing test on linux

* cleanup after swap

* fix tests

* fixed osx permissions

* simplify parity database opening functions

* added migration to blooms-db

* address @niklasad1 grumbles

* fix license and authors field of blooms-db Cargo.toml

* restore blooms-db after snapshot
2018-06-20 15:13:07 +02:00
David 05e7c133fb Block 0 is valid in queries (#8891)
Early exit for block nr 0 leads to spurious error about pruning: `…your node is running with state pruning…`.

Fixes #7547, #8762
2018-06-14 19:56:27 +01:00
Tomasz Drwięga 4938d5dde5 Limit the number of transactions in pending set (#8777)
* Unordered iterator.

* Use unordered and limited set if full not required.

* Split timeout work into smaller timers.

* Avoid collecting all pending transactions when mining

* Remove println.

* Use priority ordering in eth-filter.

* Fix ethcore-miner tests and tx propagation.

* Review grumbles addressed.

* Add test for unordered not populating the cache.

* Fix ethcore tests.

* Fix light tests.

* Fix ethcore-sync tests.

* Fix RPC tests.
2018-06-12 08:22:54 +02:00
Alex Baranov a6d267abc0 added from and to to Receipt (#8756) 2018-06-07 16:47:41 +02:00
André Silva c8877d4098 ethcore: fix ancient block error msg handling (#8832) 2018-06-07 11:15:21 +02:00
Marek Kotewicz 107f0fa4c6
Removed obsolete IpcMode enum (#8819) 2018-06-06 14:14:45 +02:00
Tomasz Drwięga 6771539a90 Fix ancient blocks queue deadlock (#8751)
* Revert "Fix not downloading old blocks (#8642)"

This reverts commit d1934363e7.

* Make sure only one thread actually imports old blocks.

* Add some trace timers.

* Bring back pending hashes set.

* Separate locks so that queue can happen while we are importing.

* Address grumbles.
2018-06-05 19:49:46 +02:00
Niklas Adolfsson 98b7c07171 Update `license header` and `scripts` (#8666)
* Update `add_license` script

* run script

* add `remove duplicate lines script` and run it

* Revert changes `English spaces`

* strip whitespaces

* Revert `GPL` in files with `apache/mit license`

* don't append `gpl license` in files with other lic

* Don't append `gpl header` in files with other lic.

* re-ran script

* include c and cpp files too

* remove duplicate header

* rebase nit
2018-06-04 10:19:50 +02:00
Wei Tang 00b209a29e Fix PoW blockchains sealing notifications in chain_new_blocks (#8656) 2018-05-31 15:28:25 +02:00
Nicolas Gotchac d1934363e7 Fix not downloading old blocks (#8642) 2018-05-17 10:58:35 +02:00
Wei Tang 0ecbb3ec02
Fork choice and metadata framework for Engine (#8401)
* Add light client TODO item

* Move existing total-difficulty-based fork choice check to Engine

* Abstract total difficulty and block provider as Machine::BlockMetadata and Machine::BlockProvider

* Decouple "generate_metadata" logic to Engine

* Use fixed BlockMetadata and BlockProvider type for null and instantseal

In this way they can use total difficulty fork choice check

* Extend blockdetails with metadatas and finalized info

* Extra data update: mark_finalized and update_metadatas

* Check finalized block in Blockchain

* Fix a test constructor in verification mod

* Add total difficulty trait

* Fix type import

* Db migration to V13 with metadata column

* Address grumbles

* metadatas -> metadata

* Use generic type for update_metadata to avoid passing HashMap all around

* Remove metadata in blockdetails

* [WIP] Implement a generic metadata architecture

* [WIP] Metadata insertion logic in BlockChain

* typo: Value -> Self::Value

* [WIP] Temporarily remove Engine::is_new_best interface

So that we don't have too many type errors.

* [WIP] Fix more type errors

* [WIP] ExtendedHeader::PartialEq

* [WIP] Change metadata type Option<Vec<u8>> to Vec<u8>

* [WIP] Remove Metadata Error

* [WIP] Clean up error conversion

* [WIP] finalized -> is_finalized

* [WIP] Mark all fields in ExtrasInsert as pub

* [WIP] Remove unused import

* [WIP] Keep only local metadata info

* Mark metadata as optional

* [WIP] Revert metadata db change in BlockChain

* [WIP] Put finalization in unclosed state

* Use metadata interface in BlockDetail

* [WIP] Fix current build failures

* [WIP] Remove unused blockmetadata struct

* Remove DB migration info

* [WIP] Typo

* Use ExtendedHeader to implement fork choice check

* Implement is_new_best using Ancestry iterator

* Use expect instead of panic

* [WIP] Add ancestry Engine support via on_new_block

* Fix tests

* Emission of ancestry actions

* use_short_version should take account of metadata

* Engine::is_new_best -> Engine::fork_choice

* Use proper expect format as defined in #1026

* panic -> expect

* ancestry_header -> ancestry_with_metadata

* Boxed iterator -> &mut iterator

* Fix tests

* is_new_best -> primitive_fork_choice

* Document how fork_choice works

* Engine::fork_choice -> Engine::primitive_fork_choice

* comment: clarify types of finalization where Engine::primitive_fork_choice works

* Expose FinalizationInfo to Engine

* Fix tests due to merging

* Remove TotalDifficulty trait

* Do not pass FinalizationInfo to Engine

If there's finalized blocks in from route, choose the old branch without calling `Engine::fork_choice`.

* Fix compile

* Fix unused import

* Remove is_to_route_finalized

When no block reorg passes a finalized block, this variable is always false.

* Address format grumbles

* Fix docs: mark_finalized returns None if block hash is not found

`blockchain` mod does not yet have an Error type, so we still temporarily use None here.

* Fix inaccurate tree_route None expect description
2018-05-16 14:58:01 +08:00
David 842b75c0e6 Decoding headers can fail (#8570)
* rlp::decode returns Result

* Fix journaldb to handle rlp::decode Result

* Fix ethcore to work with rlp::decode returning Result

* Light client handles rlp::decode returning Result

* Fix tests in rlp_derive

* Fix tests

* Cleanup

* cleanup

* Allow panic rather than breaking out of iterator

* Let decoding failures when reading from disk blow up

* syntax

* Fix the trivial grumbles

* Fix failing tests

* Make Account::from_rlp return Result

* Syntx, sigh

* Temp-fix for decoding failures

* Header::decode returns Result

Handle new return type throughout the code base.

* Do not continue reading from the DB when a value could not be read

* Fix tests

* Handle header decoding in light_sync

* Handling header decoding errors

* Let the DecodeError bubble up unchanged

* Remove redundant error conversion
2018-05-09 12:05:56 +02:00
Tomasz Drwięga 24838bbcd3 Don't block sync when importing old blocks (#8530)
* Alter IO queueing.

* Don't require IoMessages to be Clone

* Ancient blocks imported via IoChannel.

* Get rid of private transactions io message.

* Get rid of deadlock and fix disconnected handler.

* Revert to old disconnect condition.

* Fix tests.

* Fix deadlock.
2018-05-09 08:49:34 +02:00
Wei Tang 528497b86a Keep all enacted blocks notify in order (#8524)
* Keep all enacted blocks notify in order

* Collect is unnecessary

* Update ChainNotify to use ChainRouteType

* Fix all ethcore fn defs

* Wrap the type within ChainRoute

* Fix private-tx and sync api

* Fix secret_store API

* Fix updater API

* Fix rpc api

* Fix informant api

* Eagerly cache enacted/retracted and remove contain_enacted/retracted

* Fix indent

* tests: should use full expr form for struct constructor

* Use into_enacted_retracted to further avoid copy

* typo: not a function

* rpc/tests: ChainRoute -> ChainRoute::new
2018-05-07 12:58:25 +02:00
Andrew Jones 66c0638f3b Don't panic in import_block if invalid rlp (#8522)
* Don't panic in import_block if invalid rlp

* Remove redundant type annotation

* Replace RLP header view usage with safe decoding

Using the view will panic with invalid RLP. Here we use Rlp decoding directly which will return a `Result<_, DecoderError>`. While this path currently should not have any invalid RLP - it makes it safer if ever called with invalid RLP from other code paths.
2018-05-03 09:01:13 +02:00
Wei Tang b10094508f Fetching logs by hash in blockchain database (#8463)
* Fetch logs by hash in blockchain database

* Fix tests

* Add unit test for branch block logs fetching

* Add docs that blocks must already be sorted

* Handle branch block cases properly

* typo: empty -> is_empty

* Remove return_empty_if_none by using a closure

* Use BTreeSet to avoid sorting again

* Move is_canon to BlockChain

* typo: pass value by reference

* Use loop and wrap inside blocks to simplify the code

Borrowed from https://github.com/paritytech/parity/pull/8463#discussion_r183453326

* typo: missed a comment
2018-05-02 09:40:27 +02:00
Wei Tang 7a76916143 Directly return None if tracing is disabled (#8504)
* Directly return None if tracing is disabled

* Address gumbles: release read locks as fast as possible
2018-05-01 14:47:04 +02:00
Niklas Adolfsson e36c4ecc98 `duration_ns: u64 -> duration: Duration` (#8457)
* duration_ns: u64 -> duration: Duration

* format on millis {:.2} -> {}
2018-04-27 15:04:27 +02:00
Anton Gavrilov 01d399ad66 Return error if RLP size of transaction exceeds the limit (#8473)
* Return error if RLP size of transaction exceeds the limit

* Review comments fixed

* RLP check moved to verifier, corresponding pool test added
2018-04-27 15:02:45 +02:00
Andrew Jones 14361cc7b1 Move ethcore::Error to error_chain (#8386)
* WIP

* Convert Ethcore error to use error_chain

* Use error_chain for ImportError and BlockImportError

* Fix error pattern matches for error_chain in miner

* Implement explicit From for AccountsError

* Fix pattern matches for ErrorKinds

* Handle ethcore error_chain in light client

* Explicitly define Result type to avoid shadowing

* Fix remaining Error pattern matches

* Fix tab space formatting

* Helps if the tests compile

* Fix error chain matching after merge
2018-04-19 11:52:54 +02:00
Tomasz Drwięga 461b2d4853 Fix receipts stripping. (#8414) 2018-04-19 10:25:15 +01:00
Andrew Jones a04c5b180a Replace legacy Rlp with UntrustedRlp and use in ethcore rlp views (#8316)
* WIP

* Replace Rlp with UntrustedRlp in views, explicity unwrap with expect

First pass to get it to compile. Need to figure out whether to do this or to propogate Errors upstream, which would require many more changes to dependent code. If we do this way we are assuming that the views are always used in a context where the rlp is trusted to be valid e.g. when reading from our own DB. So need to fid out whether views are used with data received from an untrusted (e.g. extrernal peer).

* Remove original Rlp impl, rename UntrustedRlp -> Rlp

* Create rlp views with view! macro to record debug info

Views are assumed to be over valid rlp, so if there is a decoding error we record where the view was created in the first place and report it in the expect

* Use $crate in view! macro to avoid import, fix tests

* Expect valid rlp in decode functions for now

* Replace spaces with tabs in new file

* Add doc tests for creating views with macro

* Update rlp docs to reflect removing of UntrustedRlp

* Replace UntrustedRlp usages in private-tx merge
2018-04-16 15:52:12 +02:00