Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Update parity-codec/-derive to 3.1 #1900

Merged
merged 2 commits into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update parity-codec/-derive to 3.1
  • Loading branch information
bkchr committed Feb 28, 2019
commit b93f76897e2ca288259475abdefe5f71b30b63c4
199 changes: 100 additions & 99 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions core/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ trie = { package = "substrate-trie", path = "../trie", optional = true }
substrate-telemetry = { path = "../telemetry", optional = true }
hash-db = { version = "0.11", optional = true }
kvdb = { git = "https://github.com/paritytech/parity-common", optional = true, rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" }
parity-codec = { version = "3.0", default-features = false }
parity-codec-derive = { version = "3.0", default-features = false }
parity-codec = { version = "3.1", default-features = false }
parity-codec-derive = { version = "3.1", default-features = false }
primitives = { package = "substrate-primitives", path = "../primitives", default-features = false }
runtime-primitives = { package = "sr-primitives", path = "../sr-primitives", default-features = false }
runtime-version = { package = "sr-version", path = "../sr-version", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions core/client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ primitives = { package = "substrate-primitives", path = "../../primitives" }
runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" }
client = { package = "substrate-client", path = "../../client" }
state-machine = { package = "substrate-state-machine", path = "../../state-machine" }
parity-codec = "3.0"
parity-codec-derive = "3.0"
parity-codec = "3.1"
parity-codec-derive = "3.1"
executor = { package = "substrate-executor", path = "../../executor" }
state_db = { package = "substrate-state-db", path = "../../state-db" }
trie = { package = "substrate-trie", path = "../../trie" }
Expand Down
2 changes: 1 addition & 1 deletion core/consensus/aura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "Aura consensus algorithm for substrate"
edition = "2018"

[dependencies]
parity-codec = "3.0"
parity-codec = "3.1"
client = { package = "substrate-client", path = "../../client" }
primitives = { package = "substrate-primitives", path = "../../primitives" }
runtime_support = { package = "srml-support", path = "../../../srml/support" }
Expand Down
4 changes: 2 additions & 2 deletions core/consensus/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ futures = "0.1"
runtime_version = { package = "sr-version", path = "../../sr-version" }
runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" }
tokio = "0.1.7"
parity-codec = "3.0"
parity-codec-derive = "3.0"
parity-codec = "3.1"
parity-codec-derive = "3.1"

[dev-dependencies]
test_client = { package = "substrate-test-client", path = "../../test-client" }
2 changes: 1 addition & 1 deletion core/consensus/rhd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"
[dependencies]
futures = "0.1.17"
codec = { package = "parity-codec", version = "3.0" }
parity-codec-derive = { version = "3.0" }
parity-codec-derive = { version = "3.1" }
primitives = { package = "substrate-primitives", path = "../../primitives" }
consensus = { package = "substrate-consensus-common", path = "../common" }
client = { package = "substrate-client", path = "../../client" }
Expand Down
2 changes: 1 addition & 1 deletion core/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"

[dependencies]
error-chain = "0.12"
parity-codec = "3.0"
parity-codec = "3.1"
runtime_io = { package = "sr-io", path = "../sr-io" }
primitives = { package = "substrate-primitives", path = "../primitives" }
trie = { package = "substrate-trie", path = "../trie" }
Expand Down
4 changes: 2 additions & 2 deletions core/finality-grandpa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ log = "0.4"
parking_lot = "0.7.1"
tokio = "0.1.7"
rand = "0.6"
parity-codec = "3.0"
parity-codec-derive = "3.0"
parity-codec = "3.1"
parity-codec-derive = "3.1"
runtime_primitives = { package = "sr-primitives", path = "../sr-primitives" }
consensus_common = { package = "substrate-consensus-common", path = "../consensus/common" }
substrate-primitives = { path = "../primitives" }
Expand Down
4 changes: 2 additions & 2 deletions core/finality-grandpa/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2018"
[dependencies]
client = { package = "substrate-client", path = "../../client", default-features = false }
substrate-primitives = { path = "../../primitives", default-features = false }
parity-codec = { version = "3.0", default-features = false }
parity-codec-derive = { version = "3.0", default-features = false }
parity-codec = { version = "3.1", default-features = false }
parity-codec-derive = { version = "3.1", default-features = false }
sr-primitives = { path = "../../sr-primitives", default-features = false }
rstd = { package = "sr-std", path = "../../sr-std", default-features = false }

Expand Down
4 changes: 2 additions & 2 deletions core/inherents/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2018"
[dependencies]
parking_lot = { version = "0.7", optional = true }
rstd = { package = "sr-std", path = "../sr-std", default-features = false }
parity-codec = { version = "3.0", default-features = false }
parity-codec-derive = { version = "3.0", default-features = false }
parity-codec = { version = "3.1", default-features = false }
parity-codec-derive = { version = "3.1", default-features = false }
runtime_primitives = { package = "sr-primitives", path = "../sr-primitives", default-features = false }

[features]
Expand Down
4 changes: 2 additions & 2 deletions core/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ primitives = { package = "substrate-primitives", path = "../../core/primitives"
consensus = { package = "substrate-consensus-common", path = "../../core/consensus/common" }
client = { package = "substrate-client", path = "../../core/client" }
runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives" }
parity-codec = "3.0"
parity-codec-derive = "3.0"
parity-codec = "3.1"
parity-codec-derive = "3.1"
network_libp2p = { package = "substrate-network-libp2p", path = "../../core/network-libp2p" }
tokio = "0.1.11"
keyring = { package = "substrate-keyring", path = "../../core/keyring", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions core/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ edition = "2018"

[dependencies]
rstd = { package = "sr-std", path = "../sr-std", default-features = false }
parity-codec = { version = "3.0", default-features = false }
parity-codec-derive = { version = "3.0", default-features = false }
parity-codec = { version = "3.1", default-features = false }
parity-codec-derive = { version = "3.1", default-features = false }
rustc-hex = { version = "2.0", default-features = false }
serde = { version = "1.0", default-features = false }
serde_derive = { version = "1.0", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion core/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jsonrpc-pubsub = "10.0.1"
jsonrpc-derive = "10.0.2"
log = "0.4"
parking_lot = "0.7.1"
parity-codec = "3.0"
parity-codec = "3.1"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion core/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ consensus_common = { package = "substrate-consensus-common", path = "../../core/
network = { package = "substrate-network", path = "../../core/network" }
client = { package = "substrate-client", path = "../../core/client" }
client_db = { package = "substrate-client-db", path = "../../core/client/db" }
parity-codec = "3.0"
parity-codec = "3.1"
substrate-executor = { path = "../../core/executor" }
transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" }
rpc = { package = "substrate-rpc-servers", path = "../../core/rpc-servers" }
Expand Down
2 changes: 1 addition & 1 deletion core/sr-io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rustc_version = "0.2"
[dependencies]
rstd = { package = "sr-std", path = "../sr-std", default-features = false }
primitives = { package = "substrate-primitives", path = "../primitives", default-features = false }
parity-codec = { version = "3.0", default-features = false }
parity-codec = { version = "3.1", default-features = false }
hash-db = { version = "0.11", default-features = false }
libsecp256k1 = { version = "0.2.1", optional = true }
tiny-keccak = { version = "1.4.2", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions core/sr-primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ num-traits = { version = "0.2", default-features = false }
integer-sqrt = { version = "0.1.2" }
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
parity-codec = { version = "3.0", default-features = false }
parity-codec-derive = { version = "3.0", default-features = false }
parity-codec = { version = "3.1", default-features = false }
parity-codec-derive = { version = "3.1", default-features = false }
substrate-primitives = { path = "../primitives", default-features = false }
rstd = { package = "sr-std", path = "../sr-std", default-features = false }
runtime_io = { package = "sr-io", path = "../sr-io", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions core/sr-version/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ edition = "2018"
impl-serde = { version = "0.1", optional = true }
serde = { version = "1.0", default-features = false }
serde_derive = { version = "1.0", optional = true }
parity-codec = { version = "3.0", default-features = false }
parity-codec-derive = { version = "3.0", default-features = false }
parity-codec = { version = "3.1", default-features = false }
parity-codec-derive = { version = "3.1", default-features = false }
rstd = { package = "sr-std", path = "../sr-std", default-features = false }
runtime_primitives = { package = "sr-primitives", path = "../sr-primitives", default-features = false }

Expand Down
4 changes: 2 additions & 2 deletions core/state-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ edition = "2018"
parking_lot = "0.7.1"
log = "0.4"
primitives = { package = "substrate-primitives", path = "../../core/primitives" }
parity-codec = "3.0"
parity-codec-derive = "3.0"
parity-codec = "3.1"
parity-codec-derive = "3.1"

[dev-dependencies]
env_logger = "0.6"
2 changes: 1 addition & 1 deletion core/state-machine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ trie-root = "0.11"
trie = { package = "substrate-trie", path = "../trie" }
primitives = { package = "substrate-primitives", path = "../primitives" }
panic-handler = { package = "substrate-panic-handler", path = "../panic-handler" }
parity-codec = "3.0"
parity-codec = "3.1"
2 changes: 1 addition & 1 deletion core/test-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"
client = { package = "substrate-client", path = "../client" }
client-db = { package = "substrate-client-db", path = "../client/db", features = ["test-helpers"] }
futures = { version = "0.1.17" }
parity-codec = "3.0"
parity-codec = "3.1"
executor = { package = "substrate-executor", path = "../executor" }
consensus = { package = "substrate-consensus-common", path = "../consensus/common" }
keyring = { package = "substrate-keyring", path = "../../core/keyring" }
Expand Down
4 changes: 2 additions & 2 deletions core/test-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ log = { version = "0.4", optional = true }
hex-literal = { version = "0.1.0", optional = true }
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
parity-codec = { version = "3.0", default-features = false }
parity-codec-derive = { version = "3.0", default-features = false }
parity-codec = { version = "3.1", default-features = false }
parity-codec-derive = { version = "3.1", default-features = false }
keyring = { package = "substrate-keyring", path = "../keyring", optional = true }
substrate-client = { path = "../client", default-features = false }
primitives = { package = "substrate-primitives", path = "../primitives", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion core/transaction-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"
error-chain = "0.12"
futures = "0.1"
log = "0.4"
parity-codec = "3.0"
parity-codec = "3.1"
parking_lot = "0.7.1"
sr-primitives = { path = "../sr-primitives" }
client = { package = "substrate-client", path = "../client" }
Expand Down
2 changes: 1 addition & 1 deletion core/transaction-pool/graph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ sr-primitives = { path = "../../sr-primitives" }

[dev-dependencies]
assert_matches = "1.1"
parity-codec = "3.0"
parity-codec = "3.1"
test_runtime = { package = "substrate-test-runtime", path = "../../test-runtime" }
4 changes: 2 additions & 2 deletions core/util/fork-tree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

[dependencies]
parity-codec = "3.0"
parity-codec-derive = "3.0"
parity-codec = "3.1"
parity-codec-derive = "3.1"
94 changes: 51 additions & 43 deletions core/util/fork-tree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,58 +349,66 @@ impl<H, N, V> ForkTree<H, N, V> where
}
}

#[derive(Clone, Debug, Decode, Encode)]
#[cfg_attr(test, derive(PartialEq))]
struct Node<H, N, V> {
hash: H,
number: N,
data: V,
children: Vec<Node<H, N, V>>,
}
// Workaround for: https://github.com/rust-lang/rust/issues/34537
mod node_implementation {
use super::*;

#[derive(Clone, Debug, Decode, Encode)]
#[cfg_attr(test, derive(PartialEq))]
pub struct Node<H, N, V> {
pub hash: H,
pub number: N,
pub data: V,
pub children: Vec<Node<H, N, V>>,
}

impl<H: PartialEq, N: Ord, V> Node<H, N, V> {
fn import<F, E: std::error::Error>(
&mut self,
mut hash: H,
mut number: N,
mut data: V,
is_descendent_of: &F,
) -> Result<Option<(H, N, V)>, Error<E>>
where E: fmt::Debug,
F: Fn(&H, &H) -> Result<bool, E>,
{
if self.hash == hash {
return Err(Error::Duplicate);
};
impl<H: PartialEq, N: Ord, V> Node<H, N, V> {
pub fn import<F, E: std::error::Error>(
&mut self,
mut hash: H,
mut number: N,
mut data: V,
is_descendent_of: &F,
) -> Result<Option<(H, N, V)>, Error<E>>
where E: fmt::Debug,
F: Fn(&H, &H) -> Result<bool, E>,
{
if self.hash == hash {
return Err(Error::Duplicate);
};

if number <= self.number { return Ok(Some((hash, number, data))); }
if number <= self.number { return Ok(Some((hash, number, data))); }

for node in self.children.iter_mut() {
match node.import(hash, number, data, is_descendent_of)? {
Some((h, n, d)) => {
hash = h;
number = n;
data = d;
},
None => return Ok(None),
for node in self.children.iter_mut() {
match node.import(hash, number, data, is_descendent_of)? {
Some((h, n, d)) => {
hash = h;
number = n;
data = d;
},
None => return Ok(None),
}
}
}

if is_descendent_of(&self.hash, &hash)? {
self.children.push(Node {
data,
hash: hash,
number: number,
children: Vec::new(),
});

Ok(None)
} else {
Ok(Some((hash, number, data)))
if is_descendent_of(&self.hash, &hash)? {
self.children.push(Node {
data,
hash: hash,
number: number,
children: Vec::new(),
});

Ok(None)
} else {
Ok(Some((hash, number, data)))
}
}
}
}

// Workaround for: https://github.com/rust-lang/rust/issues/34537
use node_implementation::Node;

struct ForkTreeIterator<'a, H, N, V> {
stack: Vec<&'a Node<H, N, V>>,
}
Expand Down
2 changes: 1 addition & 1 deletion node-template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exit-future = "0.1"
parking_lot = "0.7.1"
hex-literal = "0.1"
slog = "^2"
parity-codec = "3.0"
parity-codec = "3.1"
trie-root = "0.11.0"
sr-io = { path = "../core/sr-io" }
substrate-cli = { path = "../core/cli" }
Expand Down
4 changes: 2 additions & 2 deletions node-template/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ edition = "2018"
serde = { version = "1.0", default-features = false }
serde_derive = { version = "1.0", optional = true }
safe-mix = { version = "1.0", default-features = false }
parity-codec = { version = "3.0", default-features = false }
parity-codec-derive = { version = "3.0", default-features = false }
parity-codec = { version = "3.1", default-features = false }
parity-codec-derive = { version = "3.1", default-features = false }
rstd = { package = "sr-std", path = "../../core/sr-std", default_features = false }
runtime-io = { package = "sr-io", path = "../../core/sr-io", default_features = false }
version = { package = "sr-version", path = "../../core/sr-version", default_features = false }
Expand Down
2 changes: 1 addition & 1 deletion node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tokio = "0.1.7"
futures = "0.1"
exit-future = "0.1"
cli = { package = "substrate-cli", path = "../../core/cli" }
parity-codec = { version = "3.0" }
parity-codec = { version = "3.1" }
slog = "^2"
sr-io = { path = "../../core/sr-io" }
client = { package = "substrate-client", path = "../../core/client" }
Expand Down
2 changes: 1 addition & 1 deletion node/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"

[dependencies]
trie-root = "0.11"
parity-codec = "3.0"
parity-codec = "3.1"
runtime_io = { package = "sr-io", path = "../../core/sr-io" }
state_machine = { package = "substrate-state-machine", path = "../../core/state-machine" }
substrate-executor = { path = "../../core/executor" }
Expand Down
4 changes: 2 additions & 2 deletions node/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2018"
[dependencies]
serde = { version = "1.0", default-features = false }
serde_derive = { version = "1.0", optional = true }
parity-codec = { version = "3.0", default-features = false }
parity-codec-derive = { version = "3.0", default-features = false }
parity-codec = { version = "3.1", default-features = false }
parity-codec-derive = { version = "3.1", default-features = false }
primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false }
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2018"
[dependencies]
integer-sqrt = { version = "0.1.2" }
safe-mix = { version = "1.0", default-features = false }
parity-codec-derive = { version = "3.0" }
parity-codec = { version = "3.0", default-features = false }
parity-codec-derive = { version = "3.1" }
parity-codec = { version = "3.1", default-features = false }
substrate-primitives = { path = "../../core/primitives", default-features = false }
client = { package = "substrate-client", path = "../../core/client", default-features = false }
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
Expand Down
Loading