Unverified Commit c4ee9d46 authored by Shawn Tabrizi's avatar Shawn Tabrizi Committed by GitHub
Browse files

cargo +nightly fmt (#3540)

* cargo +nightly fmt

* add cargo-fmt check to ci

* update ci

* fmt

* fmt

* skip macro

* ignore bridges
parent 4debdcd8
Pipeline #150496 canceled with stages
in 5 minutes and 22 seconds
......@@ -101,6 +101,14 @@ check-line-width:
- ./scripts/gitlab/check_line_width.sh
allow_failure: true
cargo-fmt:
stage: test
<<: *kubernetes-env
<<: *rules-pr-only
script:
- cargo +nightly fmt --all -- --check
allow_failure: true
test-deterministic-wasm:
stage: test
<<: *rules-test
......@@ -172,7 +180,7 @@ spellcheck:
- cargo spellcheck --version
# compare with the commit parent to the PR, given it's from a default branch
- git fetch origin +${CI_DEFAULT_BRANCH}:${CI_DEFAULT_BRANCH}
- time cargo spellcheck check -vvv --cfg=scripts/gitlab/spellcheck.toml --checkers hunspell --code 1
- time cargo spellcheck check -vvv --cfg=scripts/gitlab/spellcheck.toml --checkers hunspell --code 1
-r $(git diff --name-only ${CI_COMMIT_SHA} $(git merge-base ${CI_COMMIT_SHA} ${CI_DEFAULT_BRANCH}))
allow_failure: true
......
......@@ -397,7 +397,7 @@ mod tests {
#![allow(clippy::from_over_into)]
use super::*;
use frame_support::{parameter_types, weights::Weight, dispatch::GetDispatchInfo};
use frame_support::{dispatch::GetDispatchInfo, parameter_types, weights::Weight};
use frame_system::{EventRecord, Phase};
use sp_core::H256;
use sp_runtime::{
......@@ -603,7 +603,10 @@ mod tests {
let call_weight = call.get_dispatch_info().weight;
let mut message = prepare_root_message(call);
message.weight = 7;
assert!(call_weight != 7, "needed for test to actually trigger a weight mismatch");
assert!(
call_weight != 7,
"needed for test to actually trigger a weight mismatch"
);
System::set_block_number(1);
let result = Dispatch::dispatch(SOURCE_CHAIN_ID, TARGET_CHAIN_ID, id, Ok(message), |_, _| unreachable!());
......
......@@ -24,12 +24,15 @@ pub fn start_client(chain_spec: String, log_level: String) -> Result<Client, JsV
start_inner(chain_spec, log_level).map_err(|err| JsValue::from_str(&err.to_string()))
}
fn start_inner(chain_spec: String, log_directives: String) -> Result<Client, Box<dyn std::error::Error>> {
fn start_inner(
chain_spec: String,
log_directives: String,
) -> Result<Client, Box<dyn std::error::Error>> {
set_console_error_panic_hook();
init_logging(&log_directives)?;
let chain_spec =
service::PolkadotChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec()).map_err(|e| format!("{:?}", e))?;
let chain_spec = service::PolkadotChainSpec::from_json_bytes(chain_spec.as_bytes().to_vec())
.map_err(|e| format!("{:?}", e))?;
let config = browser_configuration(chain_spec)?;
info!("Polkadot browser node");
......@@ -40,7 +43,8 @@ fn start_inner(chain_spec: String, log_directives: String) -> Result<Client, Box
info!("👤 Role: {}", config.display_role());
// Create the service. This is the most heavy initialization step.
let (task_manager, rpc_handlers) = service::build_light(config).map_err(|e| format!("{:?}", e))?;
let (task_manager, rpc_handlers) =
service::build_light(config).map_err(|e| format!("{:?}", e))?;
Ok(browser_utils::start_client(task_manager, rpc_handlers))
}
......@@ -51,10 +51,7 @@ pub enum Subcommand {
PvfExecuteWorker(ValidationWorkerCommand),
/// The custom benchmark subcommand benchmarking runtime pallets.
#[structopt(
name = "benchmark",
about = "Benchmark runtime pallets."
)]
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
/// Try some command against runtime state.
......
......@@ -14,11 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use log::info;
use service::{IdentifyVariant, self};
use sc_cli::{SubstrateCli, RuntimeVersion, Role};
use crate::cli::{Cli, Subcommand};
use futures::future::TryFutureExt;
use log::info;
use sc_cli::{Role, RuntimeVersion, SubstrateCli};
use service::{self, IdentifyVariant};
#[derive(thiserror::Error, Debug)]
pub enum Error {
......@@ -51,28 +51,45 @@ fn get_exec_name() -> Option<String> {
}
impl SubstrateCli for Cli {
fn impl_name() -> String { "Parity Polkadot".into() }
fn impl_name() -> String {
"Parity Polkadot".into()
}
fn impl_version() -> String { env!("SUBSTRATE_CLI_IMPL_VERSION").into() }
fn impl_version() -> String {
env!("SUBSTRATE_CLI_IMPL_VERSION").into()
}
fn description() -> String { env!("CARGO_PKG_DESCRIPTION").into() }
fn description() -> String {
env!("CARGO_PKG_DESCRIPTION").into()
}
fn author() -> String { env!("CARGO_PKG_AUTHORS").into() }
fn author() -> String {
env!("CARGO_PKG_AUTHORS").into()
}
fn support_url() -> String { "https://github.com/paritytech/polkadot/issues/new".into() }
fn support_url() -> String {
"https://github.com/paritytech/polkadot/issues/new".into()
}
fn copyright_start_year() -> i32 { 2017 }
fn copyright_start_year() -> i32 {
2017
}
fn executable_name() -> String { "polkadot".into() }
fn executable_name() -> String {
"polkadot".into()
}
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
let id = if id == "" {
let n = get_exec_name().unwrap_or_default();
["polkadot", "kusama", "westend", "rococo"].iter()
["polkadot", "kusama", "westend", "rococo"]
.iter()
.cloned()
.find(|&chain| n.starts_with(chain))
.unwrap_or("polkadot")
} else { id };
} else {
id
};
Ok(match id {
"kusama" => Box::new(service::chain_spec::kusama_config()?),
#[cfg(feature = "kusama-native")]
......@@ -119,7 +136,8 @@ impl SubstrateCli for Cli {
path => {
let path = std::path::PathBuf::from(path);
let chain_spec = Box::new(service::PolkadotChainSpec::from_json_file(path.clone())?) as Box<dyn service::ChainSpec>;
let chain_spec = Box::new(service::PolkadotChainSpec::from_json_file(path.clone())?)
as Box<dyn service::ChainSpec>;
// When `force_*` is given or the file name starts with the name of one of the known chains,
// we use the chain spec for the specific chain.
......@@ -152,7 +170,11 @@ impl SubstrateCli for Cli {
return &service::rococo_runtime::VERSION
}
#[cfg(not(all(feature = "rococo-native", feature = "westend-native", feature = "kusama-native")))]
#[cfg(not(all(
feature = "rococo-native",
feature = "westend-native",
feature = "kusama-native"
)))]
let _ = spec;
&service::polkadot_runtime::VERSION
......@@ -193,8 +215,7 @@ pub fn run_node(cli: Cli, overseer_gen: impl service::OverseerGen) -> Result<()>
}
fn run_node_inner(cli: Cli, overseer_gen: impl service::OverseerGen) -> Result<()> {
let runner = cli.create_runner(&cli.run.base)
.map_err(Error::from)?;
let runner = cli.create_runner(&cli.run.base).map_err(Error::from)?;
let chain_spec = &runner.config().chain_spec;
set_default_ss58_version(chain_spec);
......@@ -220,7 +241,9 @@ fn run_node_inner(cli: Cli, overseer_gen: impl service::OverseerGen) -> Result<(
match role {
#[cfg(feature = "browser")]
Role::Light => service::build_light(config).map(|(task_manager, _)| task_manager).map_err(Into::into),
Role::Light => service::build_light(config)
.map(|(task_manager, _)| task_manager)
.map_err(Into::into),
#[cfg(not(feature = "browser"))]
Role::Light => Err(Error::Other("Light client not enabled".into())),
_ => service::build_full(
......@@ -231,7 +254,9 @@ fn run_node_inner(cli: Cli, overseer_gen: impl service::OverseerGen) -> Result<(
jaeger_agent,
None,
overseer_gen,
).map(|full| full.task_manager).map_err(Into::into)
)
.map(|full| full.task_manager)
.map_err(Into::into),
}
})
}
......@@ -244,19 +269,17 @@ pub fn run() -> Result<()> {
None => run_node_inner(cli, service::RealOverseerGen),
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
Ok(runner.sync_run(|config| {
cmd.run(config.chain_spec, config.network)
})?)
Ok(runner.sync_run(|config| cmd.run(config.chain_spec, config.network))?)
},
Some(Subcommand::CheckBlock(cmd)) => {
let runner = cli.create_runner(cmd)
.map_err(Error::SubstrateCli)?;
let runner = cli.create_runner(cmd).map_err(Error::SubstrateCli)?;
let chain_spec = &runner.config().chain_spec;
set_default_ss58_version(chain_spec);
runner.async_run(|mut config| {
let (client, _, import_queue, task_manager) = service::new_chain_ops(&mut config, None)?;
let (client, _, import_queue, task_manager) =
service::new_chain_ops(&mut config, None)?;
Ok((cmd.run(client, import_queue).map_err(Error::SubstrateCli), task_manager))
})
},
......@@ -267,8 +290,8 @@ pub fn run() -> Result<()> {
set_default_ss58_version(chain_spec);
Ok(runner.async_run(|mut config| {
let (client, _, _, task_manager) = service::new_chain_ops(&mut config, None)
.map_err(Error::PolkadotService)?;
let (client, _, _, task_manager) =
service::new_chain_ops(&mut config, None).map_err(Error::PolkadotService)?;
Ok((cmd.run(client, config.database).map_err(Error::SubstrateCli), task_manager))
})?)
},
......@@ -290,7 +313,8 @@ pub fn run() -> Result<()> {
set_default_ss58_version(chain_spec);
Ok(runner.async_run(|mut config| {
let (client, _, import_queue, task_manager) = service::new_chain_ops(&mut config, None)?;
let (client, _, import_queue, task_manager) =
service::new_chain_ops(&mut config, None)?;
Ok((cmd.run(client, import_queue).map_err(Error::SubstrateCli), task_manager))
})?)
},
......@@ -316,9 +340,10 @@ pub fn run() -> Result<()> {
#[cfg(any(target_os = "android", feature = "browser"))]
{
return Err(
sc_cli::Error::Input("PVF preparation workers are not supported under this platform".into()).into()
);
return Err(sc_cli::Error::Input(
"PVF preparation workers are not supported under this platform".into(),
)
.into())
}
#[cfg(not(any(target_os = "android", feature = "browser")))]
......@@ -334,9 +359,10 @@ pub fn run() -> Result<()> {
#[cfg(any(target_os = "android", feature = "browser"))]
{
return Err(
sc_cli::Error::Input("PVF execution workers are not supported under this platform".into()).into()
);
return Err(sc_cli::Error::Input(
"PVF execution workers are not supported under this platform".into(),
)
.into())
}
#[cfg(not(any(target_os = "android", feature = "browser")))]
......@@ -383,45 +409,51 @@ pub fn run() -> Result<()> {
use sc_service::TaskManager;
let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry);
let task_manager = TaskManager::new(
runner.config().task_executor.clone(),
*registry,
).map_err(|e| Error::SubstrateService(sc_service::Error::Prometheus(e)))?;
let task_manager =
TaskManager::new(runner.config().task_executor.clone(), *registry)
.map_err(|e| Error::SubstrateService(sc_service::Error::Prometheus(e)))?;
ensure_dev(chain_spec).map_err(Error::Other)?;
#[cfg(feature = "kusama-native")]
if chain_spec.is_kusama() {
return runner.async_run(|config| {
Ok((cmd.run::<
service::kusama_runtime::Block,
service::KusamaExecutor,
>(config).map_err(Error::SubstrateCli), task_manager))
Ok((
cmd.run::<service::kusama_runtime::Block, service::KusamaExecutor>(config)
.map_err(Error::SubstrateCli),
task_manager,
))
})
}
#[cfg(feature = "westend-native")]
if chain_spec.is_westend() {
return runner.async_run(|config| {
Ok((cmd.run::<
service::westend_runtime::Block,
service::WestendExecutor,
>(config).map_err(Error::SubstrateCli), task_manager))
Ok((
cmd.run::<service::westend_runtime::Block, service::WestendExecutor>(
config,
)
.map_err(Error::SubstrateCli),
task_manager,
))
})
}
// else we assume it is polkadot.
runner.async_run(|config| {
Ok((cmd.run::<
service::polkadot_runtime::Block,
service::PolkadotExecutor,
>(config).map_err(Error::SubstrateCli), task_manager))
Ok((
cmd.run::<service::polkadot_runtime::Block, service::PolkadotExecutor>(config)
.map_err(Error::SubstrateCli),
task_manager,
))
})
},
#[cfg(not(feature = "try-runtime"))]
Some(Subcommand::TryRuntime) => {
Err(Error::Other("TryRuntime wasn't enabled when building the node. \
You can enable it with `--features try-runtime`.".into()).into())
},
Some(Subcommand::TryRuntime) => Err(Error::Other(
"TryRuntime wasn't enabled when building the node. \
You can enable it with `--features try-runtime`."
.into(),
)
.into()),
}?;
Ok(())
}
......@@ -26,9 +26,7 @@ mod cli;
mod command;
pub use service::{
self,
ProvideRuntimeApi, CoreApi, IdentifyVariant,
Block, RuntimeApiCollection, TFullClient,
self, Block, CoreApi, IdentifyVariant, ProvideRuntimeApi, RuntimeApiCollection, TFullClient,
};
#[cfg(feature = "malus")]
......
......@@ -20,10 +20,14 @@
//!
//! These core Polkadot types are used by the relay chain and the Parachains.
use sp_runtime::{generic, MultiSignature, traits::{Verify, IdentifyAccount}};
use parity_scale_codec::{Encode, Decode};
use parity_scale_codec::{Decode, Encode};
#[cfg(feature = "std")]
use parity_util_mem::MallocSizeOf;
use sp_runtime::{
generic,
traits::{IdentifyAccount, Verify},
MultiSignature,
};
pub use sp_runtime::traits::{BlakeTwo256, Hash as HashT};
......@@ -64,7 +68,7 @@ pub type Hash = sp_core::H256;
#[cfg_attr(feature = "std", derive(MallocSizeOf))]
pub struct CandidateHash(pub Hash);
#[cfg(feature="std")]
#[cfg(feature = "std")]
impl std::fmt::Display for CandidateHash {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
......
......@@ -24,15 +24,17 @@
//! f is the maximum number of faulty validators in the system.
//! The data is coded so any f+1 chunks can be used to reconstruct the full data.
use parity_scale_codec::{Encode, Decode};
use polkadot_primitives::v0::{self, Hash as H256, BlakeTwo256, HashT};
use parity_scale_codec::{Decode, Encode};
use polkadot_node_primitives::AvailableData;
use polkadot_primitives::v0::{self, BlakeTwo256, Hash as H256, HashT};
use sp_core::Blake2Hasher;
use trie::{EMPTY_PREFIX, MemoryDB, Trie, TrieMut, trie_types::{TrieDBMut, TrieDB}};
use thiserror::Error;
use trie::{
trie_types::{TrieDB, TrieDBMut},
MemoryDB, Trie, TrieMut, EMPTY_PREFIX,
};
use novelpoly::WrappedShard;
use novelpoly::CodeParams;
use novelpoly::{CodeParams, WrappedShard};
// we are limited to the field order of GF(2^16), which is 65536
const MAX_VALIDATORS: usize = novelpoly::f2e16::FIELD_SIZE;
......@@ -63,7 +65,7 @@ pub enum Error {
UnevenLength,
/// Chunk index out of bounds.
#[error("Chunk is out of bounds: {chunk_index} not included in 0..{n_validators}")]
ChunkIndexOutOfBounds{ chunk_index: usize, n_validators: usize },
ChunkIndexOutOfBounds { chunk_index: usize, n_validators: usize },
/// Bad payload in reconstructed bytes.
#[error("Reconstructed payload invalid")]
BadPayload,
......@@ -83,8 +85,12 @@ pub enum Error {
/// Obtain a threshold of chunks that should be enough to recover the data.
pub const fn recovery_threshold(n_validators: usize) -> Result<usize, Error> {
if n_validators > MAX_VALIDATORS { return Err(Error::TooManyValidators) }
if n_validators <= 1 { return Err(Error::NotEnoughValidators) }
if n_validators > MAX_VALIDATORS {
return Err(Error::TooManyValidators)
}
if n_validators <= 1 {
return Err(Error::NotEnoughValidators)
}
let needed = n_validators.saturating_sub(1) / 3;
Ok(needed + 1)
......@@ -97,51 +103,47 @@ fn code_params(n_validators: usize) -> Result<CodeParams, Error> {
let k_wanted = recovery_threshold(n_wanted)?;
if n_wanted > MAX_VALIDATORS as usize {
return Err(Error::TooManyValidators);
return Err(Error::TooManyValidators)
}
CodeParams::derive_parameters(n_wanted, k_wanted)
.map_err(|e| {
match e {
novelpoly::Error::WantedShardCountTooHigh(_) => Error::TooManyValidators,
novelpoly::Error::WantedShardCountTooLow(_) => Error::NotEnoughValidators,
_ => Error::UnknownCodeParam,
}
})
CodeParams::derive_parameters(n_wanted, k_wanted).map_err(|e| match e {
novelpoly::Error::WantedShardCountTooHigh(_) => Error::TooManyValidators,
novelpoly::Error::WantedShardCountTooLow(_) => Error::NotEnoughValidators,
_ => Error::UnknownCodeParam,
})
}
/// Obtain erasure-coded chunks for v0 `AvailableData`, one for each validator.
///
/// Works only up to 65536 validators, and `n_validators` must be non-zero.
pub fn obtain_chunks_v0(n_validators: usize, data: &v0::AvailableData)
-> Result<Vec<Vec<u8>>, Error>
{
pub fn obtain_chunks_v0(
n_validators: usize,
data: &v0::AvailableData,
) -> Result<Vec<Vec<u8>>, Error> {
obtain_chunks(n_validators, data)
}
/// Obtain erasure-coded chunks for v1 `AvailableData`, one for each validator.
///
/// Works only up to 65536 validators, and `n_validators` must be non-zero.
pub fn obtain_chunks_v1(n_validators: usize, data: &AvailableData)
-> Result<Vec<Vec<u8>>, Error>
{
pub fn obtain_chunks_v1(n_validators: usize, data: &AvailableData) -> Result<Vec<Vec<u8>>, Error> {
obtain_chunks(n_validators, data)
}
/// Obtain erasure-coded chunks, one for each validator.
///
/// Works only up to 65536 validators, and `n_validators` must be non-zero.
fn obtain_chunks<T: Encode>(n_validators: usize, data: &T)
-> Result<Vec<Vec<u8>>, Error>
{
fn obtain_chunks<T: Encode>(n_validators: usize, data: &T) -> Result<Vec<Vec<u8>>, Error> {
let params = code_params(n_validators)?;
let encoded = data.encode();
if encoded.is_empty() {
return Err(Error::BadPayload);
return Err(Error::BadPayload)
}
let shards = params.make_encoder().encode::<WrappedShard>(&encoded[..])
let shards = params
.make_encoder()
.encode::<WrappedShard>(&encoded[..])
.expect("Payload non-empty, shard sizes are uniform, and validator numbers checked; qed");
Ok(shards.into_iter().map(|w: WrappedShard| w.into_inner()).collect())
......@@ -154,9 +156,9 @@ fn obtain_chunks<T: Encode>(n_validators: usize, data: &T)
/// are provided, recovery is not possible.
///
/// Works only up to 65536 validators, and `n_validators` must be non-zero.
pub fn reconstruct_v0<'a, I: 'a>(n_validators: usize, chunks: I)
-> Result<v0::AvailableData, Error>
where I: IntoIterator<Item=(&'a [u8], usize)>
pub fn reconstruct_v0<'a, I: 'a>(n_validators: usize, chunks: I) -> Result<v0::AvailableData, Error>
where
I: IntoIterator<Item = (&'a [u8], usize)>,
{
reconstruct(n_validators, chunks)
}
......@@ -168,9 +170,9 @@ pub fn reconstruct_v0<'a, I: 'a>(n_validators: usize, chunks: I)
/// are provided, recovery is not possible.
///
/// Works only up to 65536 validators, and `n_validators` must be non-zero.
pub fn reconstruct_v1<'a, I: 'a>(n_validators: usize, chunks: I)
-> Result<AvailableData, Error>
where I: IntoIterator<Item=(&'a [u8], usize)>
pub fn reconstruct_v1<'a, I: 'a>(n_validators: usize, chunks: I) -> Result<AvailableData, Error>
where
I: IntoIterator<Item = (&'a [u8], usize)>,
{
reconstruct(n_validators, chunks)
}
......@@ -183,42 +185,43 @@ pub fn reconstruct_v1<'a, I: 'a>(n_validators: usize, chunks: I)
///
/// Works only up to 65536 validators, and `n_validators` must be non-zero.
fn reconstruct<'a, I: 'a, T: Decode>(n_validators: usize, chunks: I) -> Result<T, Error>
where I: IntoIterator<Item=(&'a [u8], usize)>
where
I: IntoIterator<Item = (&'a [u8], usize)>,
{
let params = code_params(n_validators)?;
let mut received_shards: Vec<Option<WrappedShard>> = vec![None; n_validators];
let mut shard_len = None;
for (chunk_data, chunk_idx) in chunks.into_iter().take(n_validators) {
if chunk_idx >= n_validators {
return Err(Error::ChunkIndexOutOfBounds{ chunk_index: chunk_idx, n_validators });
return Err(Error::ChunkIndexOutOfBounds { chunk_index: chunk_idx, n_validators })
}
let shard_len = shard_len.get_or_insert_with(|| chunk_data.len());
if *shard_len % 2 != 0 {
return Err(Error::UnevenLength);
return Err(Error::UnevenLength)
}
if *shard_len != chunk_data.len() || *shard_len == 0 {
return Err(Error::NonUniformChunks);
return Err(Error::NonUniformChunks)
}
received_shards[chunk_idx] = Some(WrappedShard::new(chunk_data.to_vec()));
}
let res = params.make_encoder().reconstruct(received_shards);
let payload_bytes= match res {
let payload_bytes = match res {
Err(e) => match e {
novelpoly::Error::NeedMoreShards { .. } => return Err(Error::NotEnoughChunks),
novelpoly::Error::ParamterMustBePowerOf2 { .. } => return Err(Error::UnevenLength),
novelpoly::Error::WantedShardCountTooHigh(_) => return Err(Error::TooManyValidators),
novelpoly::Error::WantedShardCountTooLow(_) => return Err(Error::NotEnoughValidators),
novelpoly::Error::PayloadSizeIsZero { .. } => return Err(Error::BadPayload),
novelpoly::Error::InconsistentShardLengths { .. } => return Err(Error::NonUniformChunks),
novelpoly::Error::InconsistentShardLengths { .. } =>
return Err(Error::NonUniformChunks),
_ => return Err(Error::UnknownReconstruction),
}
},
Ok(payload_bytes) => payload_bytes,
};
......@@ -236,7 +239,9 @@ pub struct Branches<'a, I> {
impl<'a, I: AsRef<[u8]>> Branches<'a, I> {
/// Get the trie root.
pub fn root(&self) -> H256 { self.root.clone() }
pub fn root(&self) -> H256 {
self.root.clone()
}
}
impl<'a, I: AsRef<[u8]>> Iterator for Branches<'a, I> {
......@@ -249,19 +254,18 @@ impl<'a, I: AsRef<[u8]>> Iterator for Branches<'a, I> {
.expect("`Branches` is only created with a valid memorydb that contains all nodes for the trie with given root; qed");
let mut recorder = Recorder::new();
let res = (self.current_pos as u32).using_encoded(|s|
trie.get_with(s, &mut recorder)
);
let res = (self.current_pos as u32).using_encoded(|s| trie.get_with(s, &mut recorder));
match res.expect("all nodes in trie present; qed") {
Some(_) => {
let nodes = recorder.drain().into_iter().map(|r| r.data).collect();
let chunk = self.chunks.get(self.current_pos)
.expect("there is a one-to-one mapping of chunks to valid merkle branches; qed");