Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
DSharifi committed Jan 17, 2025
1 parent 6cb3bdc commit 9daf907
Show file tree
Hide file tree
Showing 34 changed files with 37 additions and 276 deletions.
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ members = [
"rs/rust_canisters/load_simulator",
"rs/rust_canisters/memory_test",
"rs/rust_canisters/on_wire",
"rs/rust_canisters/pmap",
"rs/rust_canisters/proxy_canister",
"rs/rust_canisters/response_payload_test",
"rs/rust_canisters/stable_reader",
Expand Down
6 changes: 5 additions & 1 deletion packages/pocket-ic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,8 @@ To download the binary, please visit https://github.com/dfinity/pocketic."
cmd.stderr(std::process::Stdio::null());
}
}
cmd.spawn()
let process = cmd
.spawn()
.unwrap_or_else(|_| panic!("Failed to start PocketIC binary ({:?})", bin_path));

loop {
Expand All @@ -1652,6 +1653,9 @@ To download the binary, please visit https://github.com/dfinity/pocketic."
}
std::thread::sleep(Duration::from_millis(20));
}

process.kill();
process.wait().unwrap();
}

#[derive(Error, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion rs/artifact_pool/src/rocksdb_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ fn deserialize_consensus_artifact(

impl PoolSection<ValidatedConsensusArtifact> for PersistentHeightIndexedPool<ConsensusMessage> {
fn contains(&self, msg_id: &ConsensusMessageId) -> bool {
self.lookup_key(msg_id).map_or(false, |key| {
self.lookup_key(msg_id).is_some_and(|key| {
let info = info_for_msg_id(msg_id);
let cf_handle = check_not_none_uw!(self.db.cf_handle(info.name));
check_ok_uw!(self.db.get_pinned_cf(cf_handle, &key)).is_some()
Expand Down
2 changes: 0 additions & 2 deletions rs/canister_sandbox/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::task::{Context, Poll};

/// Pieces for a very simple bidirectional RPC using an underlying
/// duplex stream channel.
/// Describe RPC error -- can be either related to transport (i.e.
/// failure to transport or parse a message) or to server (i.e. server
/// responded, but gave us a message indicating an error).
Expand Down Expand Up @@ -276,7 +275,6 @@ impl<Message> MessageSink<Message> for ReplyManager<Message> {

/// An RPC result that is immediately "ready" (i.e. pass a value to
/// a caller such that it does not need to wait).
pub struct ReadyResult<Value> {
value: Mutex<RPCResult<Value>>,
}
Expand Down
1 change: 0 additions & 1 deletion rs/consensus/src/consensus/malicious_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ fn maliciously_notarize_all(notary: &Notary, pool: &PoolReader<'_>) -> Vec<Notar

/// Generate finalization shares for each notarized block in the validated
/// pool.
fn maliciously_finalize_all(
finalizer: &Finalizer,
pool: &PoolReader<'_>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
///
/// System API Calls Complexity Module
///
/// The Fixed System API Overhead (in Instructions)
///
/// The cost of the System API calls is proportional to the work the call performs.
Expand Down
6 changes: 2 additions & 4 deletions rs/execution_environment/src/canister_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ impl CanisterManager {
return false;
}
};
module.memories.first().map_or(false, |m| m.memory64)
module.memories.first().is_some_and(|m| m.memory64)
}

/// Installs code to a canister.
Expand Down Expand Up @@ -2190,9 +2190,7 @@ impl CanisterManager {
.certified_data
.clone_from(snapshot.certified_data());

let is_wasm64_execution = new_execution_state
.as_ref()
.map_or(false, |es| es.is_wasm64);
let is_wasm64_execution = new_execution_state.as_ref().is_some_and(|es| es.is_wasm64);

let mut new_canister =
CanisterState::new(system_state, new_execution_state, scheduler_state);
Expand Down
2 changes: 1 addition & 1 deletion rs/execution_environment/src/execution/replicated_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn execute_replicated_query(
let is_wasm64_execution = canister
.execution_state
.as_ref()
.map_or(false, |es| es.is_wasm64);
.is_some_and(|es| es.is_wasm64);

let prepaid_execution_cycles = match round.cycles_account_manager.prepay_execution_cycles(
&mut canister.system_state,
Expand Down
3 changes: 1 addition & 2 deletions rs/execution_environment/src/execution/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ const RESERVED_CLEANUP_INSTRUCTIONS_IN_PERCENT: u64 = 5;
/// ▼
/// [end]
///```
/// Contains fields of `ResponseHelper` that are necessary for resuming the
/// response execution.
#[derive(Debug)]
Expand Down Expand Up @@ -575,7 +574,7 @@ impl ResponseHelper {
.canister
.execution_state
.as_ref()
.map_or(false, |es| es.is_wasm64);
.is_some_and(|es| es.is_wasm64);

round.cycles_account_manager.refund_unused_execution_cycles(
&mut self.canister.system_state,
Expand Down
6 changes: 3 additions & 3 deletions rs/execution_environment/src/execution/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn execute_update(
let is_wasm64_execution = canister
.execution_state
.as_ref()
.map_or(false, |es| es.is_wasm64);
.is_some_and(|es| es.is_wasm64);

let prepaid_execution_cycles = match round
.cycles_account_manager
Expand Down Expand Up @@ -268,7 +268,7 @@ fn finish_err(
let is_wasm64_execution = canister
.execution_state
.as_ref()
.map_or(false, |es| es.is_wasm64);
.is_some_and(|es| es.is_wasm64);

let instruction_limit = original.execution_parameters.instruction_limits.message();
round.cycles_account_manager.refund_unused_execution_cycles(
Expand Down Expand Up @@ -537,7 +537,7 @@ impl UpdateHelper {
.canister
.execution_state
.as_ref()
.map_or(false, |es| es.is_wasm64);
.is_some_and(|es| es.is_wasm64);

round.cycles_account_manager.refund_unused_execution_cycles(
&mut self.canister.system_state,
Expand Down
2 changes: 1 addition & 1 deletion rs/execution_environment/src/execution/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ fn determine_main_memory_handling(
let old_state_uses_orthogonal_persistence = || {
old_state
.as_ref()
.map_or(false, expects_enhanced_orthogonal_persistence)
.is_some_and(expects_enhanced_orthogonal_persistence)
};
let new_state_uses_classical_persistence = || {
new_state_candidate.is_ok()
Expand Down
4 changes: 2 additions & 2 deletions rs/execution_environment/src/hypervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,11 @@ impl Hypervisor {
if let Err(err) = &mut result.wasm_result {
let can_view = match &system_state.log_visibility {
LogVisibilityV2::Controllers => {
caller.map_or(false, |c| system_state.controllers.contains(&c))
caller.is_some_and(|c| system_state.controllers.contains(&c))
}
LogVisibilityV2::Public => true,
LogVisibilityV2::AllowedViewers(allowed) => {
caller.map_or(false, |c| allowed.get().contains(&c))
caller.is_some_and(|c| allowed.get().contains(&c))
}
};
if !can_view {
Expand Down
9 changes: 4 additions & 5 deletions rs/execution_environment/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ impl SchedulerRoundLimits {

////////////////////////////////////////////////////////////////////////
/// Scheduler Implementation
pub(crate) struct SchedulerImpl {
config: SchedulerConfig,
own_subnet_id: SubnetId,
Expand Down Expand Up @@ -222,7 +221,7 @@ impl SchedulerImpl {
state = new_state;
ongoing_long_install_code |= state
.canister_state(canister_id)
.map_or(false, |canister| canister.has_paused_install_code());
.is_some_and(|canister| canister.has_paused_install_code());

let round_instructions_executed =
as_num_instructions(instructions_before - round_limits.instructions);
Expand Down Expand Up @@ -1658,7 +1657,7 @@ impl Scheduler for SchedulerImpl {

////////////////////////////////////////////////////////////////////////
/// Filtered Canisters
///
/// This struct represents a collection of canister IDs.
struct FilteredCanisters {
/// Active canisters during the execution of the inner round.
Expand Down Expand Up @@ -1823,7 +1822,7 @@ fn execute_canisters_on_thread(
&mut round_limits,
subnet_size,
);
if instructions_used.map_or(false, |instructions| instructions.get() > 0) {
if instructions_used.is_some_and( |instructions| instructions.get() > 0) {
// We only want to count the canister as executed if it used instructions.
executed_canister_ids.insert(new_canister.canister_id());
}
Expand Down Expand Up @@ -2324,7 +2323,7 @@ fn is_next_method_chosen(
.system_state
.task_queue
.front()
.map_or(false, |task| task.is_hook())
.is_some_and( |task| task.is_hook())
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion rs/execution_environment/tests/hypervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7587,7 +7587,7 @@ fn declaring_too_many_tables_fails() {
fn use_wasm_memory_and_reply(bytes: u64) -> Vec<u8> {
wasm()
.stable64_grow(
(bytes + WASM_PAGE_SIZE_IN_BYTES as u64 - 1) / WASM_PAGE_SIZE_IN_BYTES as u64,
bytes.div_ceil(WASM_PAGE_SIZE_IN_BYTES as u64),
)
.stable64_read(0, bytes)
.blob_length()
Expand Down
2 changes: 1 addition & 1 deletion rs/messaging/tests/queue_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl SubnetPairProxy {
do_until_or_panic(MAX_TICKS, |_| {
let exit_condition = self
.local_output_queue_snapshot()
.map_or(false, |q| q.len() >= min_num_messages);
.is_some_and(|q| q.len() >= min_num_messages);
if !exit_condition {
self.local_env.tick();
}
Expand Down
14 changes: 6 additions & 8 deletions rs/nns/governance/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ impl Proposal {
fn allowed_when_resources_are_low(&self) -> bool {
self.action
.as_ref()
.map_or(false, |a| a.allowed_when_resources_are_low())
.is_some_and(|a| a.allowed_when_resources_are_low())
}

fn omit_large_fields(self) -> Self {
Expand Down Expand Up @@ -1177,7 +1177,7 @@ impl ProposalData {
pub fn is_manage_neuron(&self) -> bool {
self.proposal
.as_ref()
.map_or(false, Proposal::is_manage_neuron)
.is_some_and(Proposal::is_manage_neuron)
}

pub fn reward_status(
Expand Down Expand Up @@ -1938,6 +1938,10 @@ fn spawn_in_canister_env(future: impl Future<Output = ()> + Sized + 'static) {
}
}

fn error_string_to_governance_error(error: String) -> GovernanceError {
GovernanceError::new_with_message(ErrorType::InvalidProposal, error)
}

impl Governance {
/// Creates a new Governance instance with uninitialized fields. The canister should only have
/// such state before the state is recovered from the stable memory in post_upgrade or
Expand Down Expand Up @@ -5308,12 +5312,6 @@ impl Governance {
}

fn validate_proposal(&self, proposal: &Proposal) -> Result<Action, GovernanceError> {
impl From<String> for GovernanceError {
fn from(message: String) -> Self {
Self::new_with_message(ErrorType::InvalidProposal, message)
}
}

if proposal.topic() == Topic::Unspecified {
Err(format!("Topic not specified. proposal: {:#?}", proposal))?;
}
Expand Down
1 change: 0 additions & 1 deletion rs/nns/governance/src/known_neuron_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use ic_stable_structures::{Memory, StableBTreeMap, Storable};
/// Note that the index only cares about the uniqueness of the names, not the ids -
/// the caller should make sure the name-id is removed from the index when a neuron
/// is removed or its name is changed.

pub struct KnownNeuronIndex<M: Memory> {
known_neuron_name_to_id: StableBTreeMap<KnownNeuronName, NeuronId, M>,
}
Expand Down
2 changes: 1 addition & 1 deletion rs/registry/admin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5962,7 +5962,7 @@ struct GovernanceCanisterClient(NnsCanisterClient);
struct RootCanisterClient(NnsCanisterClient);

fn is_mainnet(url: &Url) -> bool {
url.domain().map_or(false, |domain| {
url.domain().is_some_and(|domain| {
IC_DOMAINS
.iter()
.any(|&ic_domain| domain.contains(ic_domain))
Expand Down
1 change: 0 additions & 1 deletion rs/rosetta-api/icp/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use std::convert::{TryFrom, TryInto};

/// This module converts from ledger_canister data structures to Rosetta data
/// structures

pub fn to_rosetta_core_transaction(
transaction_index: BlockIndex,
transaction: Transaction,
Expand Down
2 changes: 1 addition & 1 deletion rs/rosetta-api/icp/tests/integration_tests/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ fn matches_blockchain_is_empty_error(error: &rosetta_core::miscellaneous::Error)
.as_ref()
.unwrap()
.get("error_message")
.map_or(false, |e| {
.is_some_and( |e| {
e == "Blockchain is empty" || e == "Block not found: 0" || e == "RosettaBlocks was activated and there are no RosettaBlocks in the database yet. The synch is ongoing, please wait until the first RosettaBlock is written to the database."
})
}
Expand Down
55 changes: 0 additions & 55 deletions rs/rust_canisters/pmap/BUILD.bazel

This file was deleted.

Loading

0 comments on commit 9daf907

Please sign in to comment.