Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ rustdoc-args = ["--document-private-items"]
[workspace.lints.clippy]
ref_option = "deny"
ref_option_ref = "deny"
cast_lossless = "deny"

[workspace]
members = ["interop-tests"]
Expand Down
2 changes: 1 addition & 1 deletion src/chain_sync/sync_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl SyncStatusReport {
let status = match stateless_mode {
true => NodeSyncStatus::Offline,
false => {
if time_diff < seconds_per_epoch as u64 * SYNCED_EPOCH_THRESHOLD {
if time_diff < u64::from(seconds_per_epoch) * SYNCED_EPOCH_THRESHOLD {
NodeSyncStatus::Synced
} else {
NodeSyncStatus::Syncing
Expand Down
2 changes: 1 addition & 1 deletion src/chain_sync/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl TipsetValidator<'_> {
.unwrap()
.as_secs();
let max_epoch =
((now - genesis_tipset.min_timestamp()) / block_delay as u64) + MAX_HEIGHT_DRIFT;
((now - genesis_tipset.min_timestamp()) / u64::from(block_delay)) + MAX_HEIGHT_DRIFT;
let too_far_ahead_in_time = self.0.epoch() as u64 > max_epoch;
if too_far_ahead_in_time {
Err(TipsetValidationError::EpochTooLarge)
Expand Down
2 changes: 1 addition & 1 deletion src/db/car/forest/index/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn ideal_slot_ix(hash: NonMaximalU64, num_buckets: NonZeroUsize) -> usize {

// break 0..=u64::MAX into 'buckets' chunks and map each chunk to 0..len.
// if buckets=2, 0..(u64::MAX/2) maps to 0, and (u64::MAX/2)..=u64::MAX maps to 1.
usize::try_from((hash.get() as u128 * num_buckets.get() as u128) >> 64).unwrap()
usize::try_from((u128::from(hash.get()) * num_buckets.get() as u128) >> 64).unwrap()
}

/// Reverse engineer hashes which will be mapped to `ideal`.
Expand Down
2 changes: 1 addition & 1 deletion src/db/car/forest/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl<R: ReadAt> ZstdSkipFramesEncodedDataReader<R> {
.read_u32_at::<LittleEndian>(offset + ZSTD_SKIPPABLE_FRAME_MAGIC_HEADER.len() as u64)
{
skip_frame_header_offsets.push(offset);
offset += ZSTD_SKIP_FRAME_LEN + data_len as u64;
offset += ZSTD_SKIP_FRAME_LEN + u64::from(data_len);
}
Ok(Self {
reader,
Expand Down
2 changes: 1 addition & 1 deletion src/db/car/plain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl<ReaderT: super::RandomAccessFileReader> PlainCar<ReaderT> {
.read()
.get(&k)
.map(|UncompressedBlockDataLocation { offset, length }| {
positioned_io::Cursor::new_pos(&self.reader, *offset).take(*length as u64)
positioned_io::Cursor::new_pos(&self.reader, *offset).take(u64::from(*length))
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/fil_cns/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ fn block_timestamp_checks(
// Timestamp checks
let block_delay = chain_config.block_delay_secs;
let nulls = header.epoch - (base_tipset.epoch() + 1);
let target_timestamp = base_tipset.min_timestamp() + block_delay as u64 * (nulls + 1) as u64;
let target_timestamp =
base_tipset.min_timestamp() + u64::from(block_delay) * (nulls + 1) as u64;
if target_timestamp != header.timestamp {
return Err(FilecoinConsensusError::UnequalBlockTimestamps(
header.timestamp,
Expand Down
2 changes: 1 addition & 1 deletion src/libp2p/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl ForestBehaviour {
.with_kademlia(config.kademlia)
.with_user_defined(config.bootstrap_peers.clone())
.await?
.target_peer_count(config.target_peer_count as u64)
.target_peer_count(u64::from(config.target_peer_count))
.finish()?;

let connection_limits = connection_limits::Behaviour::new(
Expand Down
6 changes: 3 additions & 3 deletions src/libp2p_bitswap/bitswap_pb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl MessageWrite for Wantlist {
fn get_size(&self) -> usize {
0
+ self.entries.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
+ if self.full == false { 0 } else { 1 + sizeof_varint(*(&self.full) as u64) }
+ if self.full == false { 0 } else { 1 + sizeof_varint(u64::from(*(&self.full))) }
}

fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
Expand Down Expand Up @@ -141,9 +141,9 @@ impl MessageWrite for Entry {
0
+ if self.block.is_empty() { 0 } else { 1 + sizeof_len((&self.block).len()) }
+ if self.priority == 0i32 { 0 } else { 1 + sizeof_varint(*(&self.priority) as u64) }
+ if self.cancel == false { 0 } else { 1 + sizeof_varint(*(&self.cancel) as u64) }
+ if self.cancel == false { 0 } else { 1 + sizeof_varint(u64::from(*(&self.cancel))) }
+ if self.wantType == bitswap_pb::mod_Message::mod_Wantlist::WantType::Block { 0 } else { 1 + sizeof_varint(*(&self.wantType) as u64) }
+ if self.sendDontHave == false { 0 } else { 1 + sizeof_varint(*(&self.sendDontHave) as u64) }
+ if self.sendDontHave == false { 0 } else { 1 + sizeof_varint(u64::from(*(&self.sendDontHave))) }
}

fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
Expand Down
2 changes: 1 addition & 1 deletion src/message_pool/block_prob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ fn test_winner_probability() {
}
}

let avg = sum / (n as f64);
let avg = sum / (f64::from(n));
assert!((avg - 5.0).abs() > 0.01, "Average too far off ");
}
2 changes: 1 addition & 1 deletion src/message_pool/msgpool/msg_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ where
let republished = mp.republished.clone();
let local_addrs = mp.local_addrs.clone();
let network_sender = Arc::new(mp.network_sender.clone());
let republish_interval = (10 * block_delay + chain_config.propagation_delay_secs) as u64;
let republish_interval = u64::from(10 * block_delay + chain_config.propagation_delay_secs);
// Reacts to republishing requests
services.spawn(async move {
let mut repub_trigger_rx = repub_trigger_rx.stream();
Expand Down
2 changes: 1 addition & 1 deletion src/networks/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ where
{
let network_version = self.chain_config.network_version(epoch);
let nv_gauge: Gauge = Default::default();
nv_gauge.set(u32::from(network_version) as _);
nv_gauge.set(i64::from(u32::from(network_version)));
let metric_encoder = encoder.encode_descriptor(
"network_version",
"Network version of the current chain head",
Expand Down
8 changes: 4 additions & 4 deletions src/networks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ impl ChainConfig {
.map(|dc| {
BeaconPoint::new(
dc.height,
DrandBeacon::new(genesis_ts, self.block_delay_secs as u64, dc.config),
DrandBeacon::new(genesis_ts, u64::from(self.block_delay_secs), dc.config),
)
})
.collect(),
Expand Down Expand Up @@ -629,7 +629,7 @@ pub fn calculate_expected_epoch(
genesis_timestamp: u64,
block_delay_secs: u32,
) -> i64 {
(now_timestamp.saturating_sub(genesis_timestamp) / block_delay_secs as u64) as i64
(now_timestamp.saturating_sub(genesis_timestamp) / u64::from(block_delay_secs)) as i64
}

#[cfg(test)]
Expand Down Expand Up @@ -735,7 +735,7 @@ mod tests {
assert_eq!(
0,
calculate_expected_epoch(
mainnet_genesis + mainnet_block_delay as u64 - 1,
mainnet_genesis + u64::from(mainnet_block_delay) - 1,
mainnet_genesis,
mainnet_block_delay
)
Expand All @@ -744,7 +744,7 @@ mod tests {
assert_eq!(
1,
calculate_expected_epoch(
mainnet_genesis + mainnet_block_delay as u64,
mainnet_genesis + u64::from(mainnet_block_delay),
mainnet_genesis,
mainnet_block_delay
)
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/auth_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl<S> Auth<S> {
Ok(false) => {
tracing::warn!("Unauthorized access attempt for method {method_name}");
Err(ErrorObject::borrowed(
http::StatusCode::UNAUTHORIZED.as_u16() as _,
i32::from(http::StatusCode::UNAUTHORIZED.as_u16()),
"Unauthorized",
None,
))
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/filter_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<S> Filtering<S> {
Ok(())
} else {
Err(ErrorObject::borrowed(
http::StatusCode::FORBIDDEN.as_u16() as _,
i32::from(http::StatusCode::FORBIDDEN.as_u16()),
"Forbidden",
None,
))
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/methods/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ async fn new_eth_tx_receipt<DB: Blockstore + Send + Sync + 'static>(
block_hash: tx.block_hash,
block_number: tx.block_number,
r#type: tx.r#type,
status: (msg_receipt.exit_code().is_success() as u64).into(),
status: u64::from(msg_receipt.exit_code().is_success()).into(),
gas_used: msg_receipt.gas_used().into(),
..EthTxReceipt::new()
};
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/methods/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn estimate_fee_cap<DB: Blockstore>(
(1.0 + (BASE_FEE_MAX_CHANGE_DENOM as f64).recip()).powf(max_queue_blks as f64);

let fee_in_future = parent_base_fee
* BigInt::from_f64(increase_factor * (1 << 8) as f64)
* BigInt::from_f64(increase_factor * f64::from(1_i32 << 8))
.context("failed to convert fee_in_future f64 to bigint")?;
let out = fee_in_future.div_floor(1 << 8).add(msg.gas_premium());
Ok(out)
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/methods/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ impl RpcMethod<3> for StateCompute {
msg: ctx.message.message().clone(),
msg_rct: Some(ctx.apply_ret.msg_receipt()),
error: ctx.apply_ret.failure_info().unwrap_or_default(),
duration: ctx.duration.as_nanos().clamp(0, u64::MAX as u128) as u64,
duration: ctx.duration.as_nanos().clamp(0, u128::from(u64::MAX)) as u64,
gas_cost: MessageGasCost::new(ctx.message.message(), ctx.apply_ret)?,
execution_trace: structured::parse_events(ctx.apply_ret.exec_trace())
.unwrap_or_default(),
Expand Down Expand Up @@ -2116,7 +2116,7 @@ impl RpcMethod<1> for StateGetBeaconEntry {
) -> Result<Self::Ok, ServerError> {
{
let genesis_timestamp = ctx.chain_store().genesis_block_header().timestamp as i64;
let block_delay = ctx.chain_config().block_delay_secs as i64;
let block_delay = i64::from(ctx.chain_config().block_delay_secs);
// Give it a 1s clock drift buffer
let epoch_timestamp = genesis_timestamp + block_delay * epoch + 1;
let now_timestamp = chrono::Utc::now().timestamp();
Expand Down Expand Up @@ -3081,7 +3081,7 @@ impl RpcMethod<0> for StateGetNetworkParams {

let params = NetworkParams {
network_name,
block_delay_secs: config.block_delay_secs as u64,
block_delay_secs: u64::from(config.block_delay_secs),
consensus_miner_min_power: policy.minimum_consensus_power.clone(),
pre_commit_challenge_delay: policy.pre_commit_challenge_delay,
fork_upgrade_params: ForkUpgradeParams::try_from(config)
Expand Down
2 changes: 1 addition & 1 deletion src/shim/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Gas {
impl GasDuration {
pub fn as_nanos(&self) -> u64 {
if let Some(duration) = self.0.get() {
duration.as_nanos().clamp(0, u64::MAX as u128) as u64
duration.as_nanos().clamp(0, u128::from(u64::MAX)) as u64
} else {
0
}
Expand Down
8 changes: 4 additions & 4 deletions src/state_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ where
msg_rct: Some(apply_ret.msg_receipt()),
msg_cid: msg.cid(),
error: apply_ret.failure_info().unwrap_or_default(),
duration: duration.as_nanos().clamp(0, u64::MAX as u128) as u64,
duration: duration.as_nanos().clamp(0, u128::from(u64::MAX)) as u64,
gas_cost: MessageGasCost::default(),
execution_trace: structured::parse_events(apply_ret.exec_trace()).unwrap_or_default(),
})
Expand Down Expand Up @@ -723,7 +723,7 @@ where
msg,
msg_rct: Some(apply_ret.msg_receipt()),
error: apply_ret.failure_info().unwrap_or_default(),
duration: duration.as_nanos().clamp(0, u64::MAX as u128) as u64,
duration: duration.as_nanos().clamp(0, u128::from(u64::MAX)) as u64,
gas_cost: MessageGasCost::default(),
execution_trace: structured::parse_events(apply_ret.exec_trace())
.unwrap_or_default(),
Expand Down Expand Up @@ -830,7 +830,7 @@ where
msg: ctx.message.message().clone(),
msg_rct: Some(ctx.apply_ret.msg_receipt()),
error: ctx.apply_ret.failure_info().unwrap_or_default(),
duration: ctx.duration.as_nanos().clamp(0, u64::MAX as u128) as u64,
duration: ctx.duration.as_nanos().clamp(0, u128::from(u64::MAX)) as u64,
gas_cost: MessageGasCost::new(ctx.message.message(), ctx.apply_ret)?,
execution_trace: structured::parse_events(ctx.apply_ret.exec_trace())
.unwrap_or_default(),
Expand Down Expand Up @@ -1748,7 +1748,7 @@ where
msg: ctx.message.message().clone(),
msg_rct: Some(ctx.apply_ret.msg_receipt()),
error: ctx.apply_ret.failure_info().unwrap_or_default(),
duration: ctx.duration.as_nanos().clamp(0, u64::MAX as u128) as u64,
duration: ctx.duration.as_nanos().clamp(0, u128::from(u64::MAX)) as u64,
gas_cost: MessageGasCost::new(ctx.message.message(), ctx.apply_ret)?,
execution_trace: structured::parse_events(ctx.apply_ret.exec_trace())
.unwrap_or_default(),
Expand Down
14 changes: 7 additions & 7 deletions src/tool/subcommands/api_cmd/api_compare_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,22 +958,22 @@ fn state_tests_with_tipset<DB: Blockstore>(
RpcTest::identity(StateMarketDeals::request((tipset.key().into(),))?),
RpcTest::identity(StateSectorPreCommitInfo::request((
Default::default(), // invalid address
u16::MAX as _,
u64::from(u16::MAX),
tipset.key().into(),
))?)
.policy_on_rejected(PolicyOnRejected::Pass),
RpcTest::identity(StateSectorGetInfo::request((
Default::default(), // invalid address
u16::MAX as _, // invalid sector number
Default::default(), // invalid address
u64::from(u16::MAX), // invalid sector number
tipset.key().into(),
))?)
.policy_on_rejected(PolicyOnRejected::Pass),
RpcTest::identity(StateGetAllocationIdForPendingDeal::request((
u16::MAX as _, // Invalid deal id
u64::from(u16::MAX), // Invalid deal id
tipset.key().into(),
))?),
RpcTest::identity(StateGetAllocationForPendingDeal::request((
u16::MAX as _, // Invalid deal id
u64::from(u16::MAX), // Invalid deal id
tipset.key().into(),
))?),
RpcTest::identity(StateCompute::request((
Expand Down Expand Up @@ -1104,13 +1104,13 @@ fn state_tests_with_tipset<DB: Blockstore>(
RpcTest::identity(StateGetAllAllocations::request((tipset.key().into(),))?),
RpcTest::identity(StateSectorPreCommitInfo::request((
block.miner_address,
u16::MAX as _, // invalid sector number
u64::from(u16::MAX), // invalid sector number
tipset.key().into(),
))?)
.policy_on_rejected(PolicyOnRejected::PassWithIdenticalError),
RpcTest::identity(StateSectorGetInfo::request((
block.miner_address,
u16::MAX as _, // invalid sector number
u64::from(u16::MAX), // invalid sector number
tipset.key().into(),
))?)
.policy_on_rejected(PolicyOnRejected::PassWithIdenticalError),
Expand Down
6 changes: 3 additions & 3 deletions src/tool/subcommands/snapshot_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ async fn validate_ipld_links<DB>(ts: Tipset, db: &DB, epochs: u32) -> anyhow::Re
where
DB: Blockstore + Send + Sync,
{
let epoch_limit = ts.epoch() - epochs as i64;
let epoch_limit = ts.epoch() - i64::from(epochs);

let pb = validation_spinner("Checking IPLD integrity:").with_finish(
indicatif::ProgressFinish::AbandonWithMessage("❌ Invalid IPLD data!".into()),
Expand Down Expand Up @@ -412,7 +412,7 @@ where
// Fix off-by-1 bug: prevent validating more epochs than available in the snapshot.
// Without +1, specifying --check-stateroots=900 would validate 901 epochs,
// causing out-of-bounds errors when the snapshot contains only 900 recent state roots.
let last_epoch = ts.epoch() - epochs as i64 + 1;
let last_epoch = ts.epoch() - i64::from(epochs) + 1;

// Set proof parameter data dir before downloading proofs.
crate::utils::proofs_api::maybe_set_proofs_parameter_cache_dir_env(
Expand Down Expand Up @@ -574,7 +574,7 @@ mod structured {
"TotalCost": (chain_message.message().required_funds() - &apply_ret.refund()).into_lotus_json(),
},
"ExecutionTrace": structured::parse_events(apply_ret.exec_trace())?.into_lotus_json(),
"Duration": duration.as_nanos().clamp(0, u64::MAX as u128) as u64,
"Duration": duration.as_nanos().clamp(0, u128::from(u64::MAX)) as u64,
}))
}
}
Loading