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

Commit

Permalink
Merge commit a0724ba (no conflict)
Browse files Browse the repository at this point in the history
Parent branch: origin/master
Forked at: 4da2926
  • Loading branch information
cecton committed Jul 21, 2020
2 parents adffa7e + a0724ba commit 944fd93
Show file tree
Hide file tree
Showing 86 changed files with 515 additions and 235 deletions.
61 changes: 5 additions & 56 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,15 @@ test-linux-stable: &test-linux
<<: *default-vars
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
RUST_BACKTRACE: 1
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
RUST_BACKTRACE: 1
WASM_BUILD_NO_COLOR: 1
except:
variables:
- $DEPLOY_TAG
script:
- WASM_BUILD_NO_COLOR=1 time cargo test --all --release --verbose --locked
# this job runs all tests in former runtime-benchmarks, frame-staking and wasmtime tests
- time cargo test --workspace --locked --release --verbose --features runtime-benchmarks --manifest-path bin/node/cli/Cargo.toml
- sccache -s

unleash-check:
Expand All @@ -240,24 +242,6 @@ unleash-check:
- cargo install cargo-unleash ${CARGO_UNLEASH_INSTALL_PARAMS}
- cargo unleash check ${CARGO_UNLEASH_PKG_DEF}

test-frame-staking:
# into one job
stage: test
<<: *docker-env
variables:
<<: *default-vars
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: -Cdebug-assertions=y
RUST_BACKTRACE: 1
except:
variables:
- $DEPLOY_TAG
script:
- cd frame/staking/
- WASM_BUILD_NO_COLOR=1 time cargo test --release --verbose --no-default-features --features "std"
- sccache -s

test-frame-examples-compile-to-wasm:
# into one job
stage: test
Expand All @@ -278,41 +262,6 @@ test-frame-examples-compile-to-wasm:
- cargo +nightly build --target=wasm32-unknown-unknown --no-default-features
- sccache -s

test-wasmtime:
stage: test
<<: *docker-env
variables:
<<: *default-vars
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: -Cdebug-assertions=y
RUST_BACKTRACE: 1
except:
variables:
- $DEPLOY_TAG
script:
- cd client/executor
- WASM_BUILD_NO_COLOR=1 time cargo test --release --verbose --features wasmtime
- sccache -s

test-runtime-benchmarks:
# into one job
stage: test
<<: *docker-env
variables:
<<: *default-vars
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: -Cdebug-assertions=y
RUST_BACKTRACE: 1
except:
variables:
- $DEPLOY_TAG
script:
- cd bin/node/cli
- WASM_BUILD_NO_COLOR=1 time cargo test --workspace --release --verbose --features runtime-benchmarks
- sccache -s

test-linux-stable-int:
<<: *test-linux
except:
Expand Down
12 changes: 6 additions & 6 deletions bin/node-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
// if the node isn't actively participating in consensus then it doesn't
// need a keystore, regardless of which protocol we use below.
let keystore = if role.is_authority() {
Some(keystore.clone() as sp_core::traits::BareCryptoStorePtr)
Some(keystore as sp_core::traits::BareCryptoStorePtr)
} else {
None
};
Expand All @@ -182,11 +182,11 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
let grandpa_config = sc_finality_grandpa::GrandpaParams {
config: grandpa_config,
link: grandpa_link,
network: network.clone(),
inherent_data_providers: inherent_data_providers.clone(),
network,
inherent_data_providers,
telemetry_on_connect: Some(telemetry_on_connect_sinks.on_connect_stream()),
voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(),
prometheus_registry: prometheus_registry.clone(),
prometheus_registry,
shared_voter_state: SharedVoterState::empty(),
};

Expand All @@ -200,7 +200,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
sc_finality_grandpa::setup_disabled_grandpa(
client,
&inherent_data_providers,
network.clone(),
network,
)?;
}

Expand All @@ -221,7 +221,7 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {

let pool_api = sc_transaction_pool::LightChainApi::new(
builder.client().clone(),
fetcher.clone(),
fetcher,
);
let pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
builder.config().transaction_pool.clone(),
Expand Down
1 change: 0 additions & 1 deletion bin/node/bench/src/tempdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ impl Clone for TempDatabase {
.map(|f_result|
f_result.expect("failed to read file in seed db")
.path()
.clone()
).collect();
fs_extra::copy_items(
&self_db_files,
Expand Down
6 changes: 3 additions & 3 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ pub fn new_full_base(
// if the node isn't actively participating in consensus then it doesn't
// need a keystore, regardless of which protocol we use below.
let keystore = if role.is_authority() {
Some(keystore.clone() as BareCryptoStorePtr)
Some(keystore as BareCryptoStorePtr)
} else {
None
};
Expand Down Expand Up @@ -302,7 +302,7 @@ pub fn new_full_base(
inherent_data_providers: inherent_data_providers.clone(),
telemetry_on_connect: Some(telemetry_on_connect_sinks.on_connect_stream()),
voting_rule: grandpa::VotingRulesBuilder::default().build(),
prometheus_registry: prometheus_registry.clone(),
prometheus_registry,
shared_voter_state,
};

Expand Down Expand Up @@ -403,7 +403,7 @@ pub fn new_light_base(config: Configuration) -> Result<(
babe_block_import,
None,
Some(Box::new(finality_proof_import)),
client.clone(),
client,
select_chain,
inherent_data_providers.clone(),
spawn_task_handle,
Expand Down
1 change: 0 additions & 1 deletion bin/node/testing/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ impl Clone for BenchDb {
.map(|f_result|
f_result.expect("failed to read file in seed db")
.path()
.clone()
).collect();
fs_extra::copy_items(
&seed_db_files,
Expand Down
2 changes: 1 addition & 1 deletion bin/utils/chain-spec-builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn generate_chain_spec(
Default::default(),
);

chain_spec.as_json(false).map_err(|err| err.to_string())
chain_spec.as_json(false).map_err(|err| err)
}

fn generate_authority_keys_and_store(
Expand Down
6 changes: 3 additions & 3 deletions client/api/src/in_mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<Block: BlockT + Clone> Clone for Blockchain<Block> {
fn clone(&self) -> Self {
let storage = Arc::new(RwLock::new(self.storage.read().clone()));
Blockchain {
storage: storage.clone(),
storage,
}
}
}
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<Block: BlockT> Blockchain<Block> {
aux: HashMap::new(),
}));
Blockchain {
storage: storage.clone(),
storage,
}
}

Expand Down Expand Up @@ -346,7 +346,7 @@ impl<Block: BlockT> HeaderMetadata<Block> for Blockchain<Block> {

fn header_metadata(&self, hash: Block::Hash) -> Result<CachedHeaderMetadata<Block>, Self::Error> {
self.header(BlockId::hash(hash))?.map(|header| CachedHeaderMetadata::from(&header))
.ok_or(sp_blockchain::Error::UnknownBlock(format!("header not found: {}", hash)))
.ok_or_else(|| sp_blockchain::Error::UnknownBlock(format!("header not found: {}", hash)))
}

fn insert_header_metadata(&self, _hash: Block::Hash, _metadata: CachedHeaderMetadata<Block>) {
Expand Down
16 changes: 8 additions & 8 deletions client/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub trait CliConfiguration: Sized {
fn database_cache_size(&self) -> Result<Option<usize>> {
Ok(self.database_params()
.map(|x| x.database_cache_size())
.unwrap_or(Default::default()))
.unwrap_or_default())
}

/// Get the database backend variant.
Expand Down Expand Up @@ -195,7 +195,7 @@ pub trait CliConfiguration: Sized {
fn state_cache_size(&self) -> Result<usize> {
Ok(self.import_params()
.map(|x| x.state_cache_size())
.unwrap_or(Default::default()))
.unwrap_or_default())
}

/// Get the state cache child ratio (if any).
Expand All @@ -212,7 +212,7 @@ pub trait CliConfiguration: Sized {
fn pruning(&self, unsafe_pruning: bool, role: &Role) -> Result<PruningMode> {
self.pruning_params()
.map(|x| x.pruning(unsafe_pruning, role))
.unwrap_or(Ok(Default::default()))
.unwrap_or_else(|| Ok(Default::default()))
}

/// Get the chain ID (string).
Expand All @@ -236,7 +236,7 @@ pub trait CliConfiguration: Sized {
fn wasm_method(&self) -> Result<WasmExecutionMethod> {
Ok(self.import_params()
.map(|x| x.wasm_method())
.unwrap_or(Default::default()))
.unwrap_or_default())
}

/// Get the execution strategies.
Expand All @@ -251,7 +251,7 @@ pub trait CliConfiguration: Sized {
Ok(self
.import_params()
.map(|x| x.execution_strategies(is_dev, is_validator))
.unwrap_or(Default::default()))
.unwrap_or_default())
}

/// Get the RPC HTTP address (`None` if disabled).
Expand Down Expand Up @@ -365,7 +365,7 @@ pub trait CliConfiguration: Sized {
fn tracing_targets(&self) -> Result<Option<String>> {
Ok(self.import_params()
.map(|x| x.tracing_targets())
.unwrap_or(Default::default()))
.unwrap_or_else(|| Default::default()))
}

/// Get the TracingReceiver value from the current object
Expand All @@ -375,7 +375,7 @@ pub trait CliConfiguration: Sized {
fn tracing_receiver(&self) -> Result<TracingReceiver> {
Ok(self.import_params()
.map(|x| x.tracing_receiver())
.unwrap_or(Default::default()))
.unwrap_or_default())
}

/// Get the node key from the current object
Expand All @@ -385,7 +385,7 @@ pub trait CliConfiguration: Sized {
fn node_key(&self, net_config_dir: &PathBuf) -> Result<NodeKeyConfig> {
self.node_key_params()
.map(|x| x.node_key(net_config_dir))
.unwrap_or(Ok(Default::default()))
.unwrap_or_else(|| Ok(Default::default()))
}

/// Get maximum runtime instances
Expand Down
2 changes: 1 addition & 1 deletion client/cli/src/params/import_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl ImportParams {
default
};

exec.execution.unwrap_or(strat.unwrap_or(default)).into()
exec.execution.unwrap_or_else(|| strat.unwrap_or(default)).into()
};

let default_execution_import_block = if is_validator {
Expand Down
2 changes: 1 addition & 1 deletion client/cli/src/params/keystore_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl KeystoreParams {
let path = self
.keystore_path
.clone()
.unwrap_or(base_path.join(DEFAULT_KEYSTORE_CONFIG_PATH));
.unwrap_or_else(|| base_path.join(DEFAULT_KEYSTORE_CONFIG_PATH));

Ok(KeystoreConfig::Path { path, password })
}
Expand Down
4 changes: 2 additions & 2 deletions client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub fn start_aura<B, C, SC, E, I, P, SO, CAW, Error>(
CAW: CanAuthorWith<B> + Send,
{
let worker = AuraWorker {
client: client.clone(),
client,
block_import: Arc::new(Mutex::new(block_import)),
env,
keystore,
Expand Down Expand Up @@ -839,7 +839,7 @@ pub fn import_queue<B, I, C, P, S>(
initialize_authorities_cache(&*client)?;

let verifier = AuraVerifier {
client: client.clone(),
client,
inherent_data_providers,
phantom: PhantomData,
};
Expand Down
2 changes: 1 addition & 1 deletion client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ impl<Block: BlockT> HeaderMetadata<Block> for BlockchainDb<Block> {
header_metadata.clone(),
);
header_metadata
}).ok_or(ClientError::UnknownBlock(format!("header not found in db: {}", hash)))
}).ok_or_else(|| ClientError::UnknownBlock(format!("header not found in db: {}", hash)))
}, Ok)
}

Expand Down
2 changes: 1 addition & 1 deletion client/db/src/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl<Block: BlockT> HeaderMetadata<Block> for LightStorage<Block> {
header_metadata.clone(),
);
header_metadata
}).ok_or(ClientError::UnknownBlock(format!("header not found in db: {}", hash)))
}).ok_or_else(|| ClientError::UnknownBlock(format!("header not found in db: {}", hash)))
}, Ok)
}

Expand Down
4 changes: 2 additions & 2 deletions client/db/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ pub fn insert_hash_to_key_mapping<N: TryInto<u32>, H: AsRef<[u8]> + Clone>(
) -> sp_blockchain::Result<()> {
transaction.set_from_vec(
key_lookup_col,
hash.clone().as_ref(),
number_and_hash_to_lookup_key(number, hash)?,
hash.as_ref(),
number_and_hash_to_lookup_key(number, hash.clone())?,
);
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion client/executor/runtime-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ fn execute_sandboxed(
Memory::new() can't return a Error qed"
),
};
env_builder.add_memory("env", "memory", memory.clone());
env_builder.add_memory("env", "memory", memory);
env_builder
};

Expand Down
2 changes: 1 addition & 1 deletion client/executor/src/native_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl<D: NativeExecutionDispatch + 'static> CodeExecutor for NativeExecutor<D> {
let res = with_externalities_safe(&mut **ext, move || (call)())
.and_then(|r| r
.map(NativeOrEncoded::Native)
.map_err(|s| Error::ApiError(s.to_string()))
.map_err(|s| Error::ApiError(s))
);

Ok(res)
Expand Down
1 change: 0 additions & 1 deletion client/executor/wasmi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ impl<'a> Sandbox for FunctionExecutor<'a> {
table.get(dispatch_thunk_id)
.map_err(|_| "dispatch_thunk_idx is out of the table bounds")?
.ok_or_else(|| "dispatch_thunk_idx points on an empty table entry")?
.clone()
};

let guest_env = match sandbox::GuestEnvironment::decode(&self.sandbox_store, raw_env_def) {
Expand Down
4 changes: 2 additions & 2 deletions client/finality-grandpa/src/communication/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,8 @@ impl<Block: BlockT> Sink<Message<Block>> for OutgoingMessages<Block>
keystore.local_id().clone(),
self.round,
self.set_id,
).ok_or(
Error::Signing(format!(
).ok_or_else(
|| Error::Signing(format!(
"Failed to sign GRANDPA vote for round {} targetting {:?}", self.round, target_hash
))
)?;
Expand Down
2 changes: 1 addition & 1 deletion client/keystore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl BareCryptoStore for Store {
.fold(Vec::new(), |mut v, k| {
v.push(CryptoTypePublicPair(sr25519::CRYPTO_ID, k.clone()));
v.push(CryptoTypePublicPair(ed25519::CRYPTO_ID, k.clone()));
v.push(CryptoTypePublicPair(ecdsa::CRYPTO_ID, k.clone()));
v.push(CryptoTypePublicPair(ecdsa::CRYPTO_ID, k));
v
}))
}
Expand Down
2 changes: 1 addition & 1 deletion client/network-gossip/src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl<B: BlockT> ConsensusGossip<B> {

let validator = self.validator.clone();
let mut context = NetworkContext { gossip: self, network };
validator.new_peer(&mut context, &who, role.clone());
validator.new_peer(&mut context, &who, role);
}

fn register_message_hashed(
Expand Down
Loading

0 comments on commit 944fd93

Please sign in to comment.