This repository was archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Move snapshot related traits to their proper place #11012
Merged
dvdplm
merged 24 commits into
master
from
dp/chore/extract-snapshot-with-traits-in-the-right-place
Sep 10, 2019
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
28434d1
Move snapshot to own crate
dvdplm b83d0cb
WIP cargo toml
dvdplm 11dada9
Make snapshotting generic over the client
dvdplm a4fc0f2
Sort out types from blockchain and client
dvdplm 8acf2d1
Sort out sync
dvdplm fd67d2f
Sort out imports and generics
dvdplm 67820ae
Sort out main binary
dvdplm d5a9a81
Fix sync test-helpers
dvdplm 23add8a
Sort out import for secret-store
dvdplm 3cb1e90
Sort out more imports
dvdplm 4288cd3
Fix easy todos
dvdplm 4487e84
cleanup
dvdplm 8995858
Move SnapshotClient and SnapshotWriter to their proper places
dvdplm caa2d2d
cleanup
dvdplm 145d77c
Cleanup
dvdplm c60a43f
Merge branch 'master' into dp/chore/extract-snapshot-with-traits-in-t…
dvdplm d6e0574
fix merge issues
dvdplm e86c991
Update ethcore/snapshot/snapshot-tests/Cargo.toml
dvdplm 3717ecf
Sort out botched merge
dvdplm dcee086
Merge branch 'dp/chore/extract-snapshot-with-traits-in-the-right-plac…
dvdplm dff7adc
Ensure snapshot-tests run
dvdplm 3c2d649
Docs
dvdplm 78dac6a
Fix grumbles
dvdplm a21731c
Merge branch 'master' into dp/chore/extract-snapshot-with-traits-in-t…
dvdplm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| [package] | ||
| name = "snapshot-tests" | ||
| version = "0.1.0" | ||
| authors = ["Parity Technologies <admin@parity.io>"] | ||
| edition = "2018" | ||
|
|
||
| [dependencies] | ||
| accounts = { package = "ethcore-accounts", path = "../../../accounts" } | ||
| account-db = { path = "../../account-db" } | ||
| account-state = { path = "../../account-state" } | ||
| blockchain = { package = "ethcore-blockchain", path = "../../blockchain" } | ||
| bytes = { package = "parity-bytes", version = "0.1.0" } | ||
| client-traits = { path = "../../client-traits" } | ||
| common-types = { path = "../../types" } | ||
| engine = { path = "../../engine", features = ["test-helpers"] } | ||
| env_logger = "0.5" | ||
| ethcore = { path = "../..", features = ["test-helpers"] } | ||
| ethcore-db = { path = "../../db" } | ||
| ethcore-io = { path = "../../../util/io" } | ||
| ethereum-types = "0.6.0" | ||
| ethkey = { path = "../../../accounts/ethkey" } | ||
| ethtrie = { package = "patricia-trie-ethereum", path = "../../../util/patricia-trie-ethereum" } | ||
| hash-db = "0.15.0" | ||
| journaldb = { path = "../../../util/journaldb" } | ||
| keccak-hash = "0.2.0" | ||
| keccak-hasher = { path = "../../../util/keccak-hasher" } | ||
| kvdb = "0.1.0" | ||
| kvdb-rocksdb = { version = "0.1.3" } | ||
| log = "0.4.8" | ||
| parking_lot = "0.8.0" | ||
| rand = "0.6" | ||
| rand_xorshift = "0.1.1" | ||
| rlp = "0.4.2" | ||
| snappy = { package = "parity-snappy", version ="0.1.0" } | ||
| snapshot = { path = "../../snapshot", features = ["test-helpers"] } | ||
| spec = { path = "../../spec" } | ||
| tempdir = "0.3" | ||
| trie-db = "0.15.0" | ||
| trie-standardmap = "0.15.0" | ||
| ethabi = "8.0" | ||
| ethabi-contract = "8.0" | ||
| ethabi-derive = "8.0" | ||
| lazy_static = { version = "1.3" } | ||
| triehash = { package = "triehash-ethereum", version = "0.2", path = "../../../util/triehash-ethereum" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| // Copyright 2015-2019 Parity Technologies (UK) Ltd. | ||
| // This file is part of Parity Ethereum. | ||
|
|
||
| // Parity Ethereum is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
|
|
||
| // Parity Ethereum is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
|
|
||
| // You should have received a copy of the GNU General Public License | ||
| // along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| //! Tests for block RLP encoding | ||
|
|
||
| use snapshot::test_helpers::AbridgedBlock; | ||
|
|
||
| use bytes::Bytes; | ||
| use ethereum_types::{H256, U256, Address}; | ||
| use common_types::{ | ||
| transaction::{Action, Transaction}, | ||
| block::Block, | ||
| view, | ||
| views::BlockView, | ||
| }; | ||
|
|
||
| fn encode_block(b: &Block) -> Bytes { | ||
| b.rlp_bytes() | ||
| } | ||
|
|
||
| #[test] | ||
| fn empty_block_abridging() { | ||
| let b = Block::default(); | ||
| let receipts_root = b.header.receipts_root().clone(); | ||
| let encoded = encode_block(&b); | ||
|
|
||
| let abridged = AbridgedBlock::from_block_view(&view!(BlockView, &encoded)); | ||
| assert_eq!(abridged.to_block(H256::zero(), 0, receipts_root).unwrap(), b); | ||
| } | ||
|
|
||
| #[test] | ||
| #[should_panic] | ||
| fn wrong_number() { | ||
| let b = Block::default(); | ||
| let receipts_root = b.header.receipts_root().clone(); | ||
| let encoded = encode_block(&b); | ||
|
|
||
| let abridged = AbridgedBlock::from_block_view(&view!(BlockView, &encoded)); | ||
| assert_eq!(abridged.to_block(H256::zero(), 2, receipts_root).unwrap(), b); | ||
| } | ||
|
|
||
| #[test] | ||
| fn with_transactions() { | ||
| let mut b = Block::default(); | ||
|
|
||
| let t1 = Transaction { | ||
| action: Action::Create, | ||
| nonce: U256::from(42), | ||
| gas_price: U256::from(3000), | ||
| gas: U256::from(50_000), | ||
| value: U256::from(1), | ||
| data: b"Hello!".to_vec() | ||
| }.fake_sign(Address::from_low_u64_be(0x69)); | ||
|
|
||
| let t2 = Transaction { | ||
| action: Action::Create, | ||
| nonce: U256::from(88), | ||
| gas_price: U256::from(12345), | ||
| gas: U256::from(300000), | ||
| value: U256::from(1000000000), | ||
| data: "Eep!".into(), | ||
| }.fake_sign(Address::from_low_u64_be(0x55)); | ||
|
|
||
| b.transactions.push(t1.into()); | ||
| b.transactions.push(t2.into()); | ||
|
|
||
| let receipts_root = b.header.receipts_root().clone(); | ||
| b.header.set_transactions_root(triehash::ordered_trie_root( | ||
| b.transactions.iter().map(::rlp::encode) | ||
| )); | ||
|
|
||
| let encoded = encode_block(&b); | ||
|
|
||
| let abridged = AbridgedBlock::from_block_view(&view!(BlockView, &encoded[..])); | ||
| assert_eq!(abridged.to_block(H256::zero(), 0, receipts_root).unwrap(), b); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is unfortunate, but I didn't come up with something better