Skip to content

Commit

Permalink
Merge branch 'chore/rust1.81' into ci-update-and-refactor-all-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
aeweda committed Sep 23, 2024
2 parents 903ea11 + 81590f4 commit edcf8e9
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 23 deletions.
1 change: 1 addition & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export CLIPPY_LINTS := '-D warnings
-D clippy::checked-conversions
-A clippy::upper-case-acronyms
-A clippy::uninlined-format-args
-A renamed_and_removed_lints
'

# run clippy
Expand Down
6 changes: 2 additions & 4 deletions bridges/centralized-ethereum/src/actors/eth_poller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,11 @@ impl EthPoller {
None,
)
.await
.map_err(|err| {
.inspect_err(|err| {
log::error!(
"Fail to read getNextQueryId from contract: {:?}",
err.to_string()
);

err
)
});

let last_dr_id = dr_database_addr.send(GetLastDrId).await;
Expand Down
2 changes: 1 addition & 1 deletion data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ num_enum = "0.4.2"
num-traits = "0.2.15"
ordered-float = "3.0"
partial_struct = { path = "../partial_struct" }
protobuf = { version = "2.23.0", features = ["with-serde"] }
protobuf = { version = "2.28.0", features = ["with-serde"] }
protobuf-convert = "0.1.1"
rand = "0.8.5"
serde = { version = "1.0.104", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion node/src/actors/chain_manager/mining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ impl ChainManager {
log::info!(
"{} Created Tally for Data Request {} with result: {}\n{}",
Yellow.bold().paint("[Data Request]"),
Yellow.bold().paint(&dr_pointer.to_string()),
Yellow.bold().paint(dr_pointer.to_string()),
Yellow
.bold()
.paint(format!("{}", &tally_result.into_inner())),
Expand Down
4 changes: 2 additions & 2 deletions node/src/actors/epoch_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ impl EpochManager {
.and_then(|config, act, ctx| {
let checkpoint_zero_timestamp_v2 =
config.consensus_constants.checkpoint_zero_timestamp
+ get_protocol_version_activation_epoch(ProtocolVersion::V2_0) as i64
* config.consensus_constants.checkpoints_period as i64;
+ i64::from(get_protocol_version_activation_epoch(ProtocolVersion::V2_0))
* i64::from(config.consensus_constants.checkpoints_period);
act.set_checkpoint_zero_and_period(
config.consensus_constants.checkpoint_zero_timestamp,
config.consensus_constants.checkpoints_period,
Expand Down
4 changes: 2 additions & 2 deletions node/src/actors/sessions_manager/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ impl Actor for SessionsManager {
let checkpoint_zero_timestamp =
config.consensus_constants.checkpoint_zero_timestamp;
let checkpoint_zero_timestamp_v2 = checkpoint_zero_timestamp
+ get_protocol_version_activation_epoch(ProtocolVersion::V2_0) as i64
* checkpoints_period as i64;
+ i64::from(get_protocol_version_activation_epoch(ProtocolVersion::V2_0))
* i64::from(checkpoints_period);
let checkpoints_period_v2 = get_protocol_version_period(ProtocolVersion::V2_0);
let epoch_constants = EpochConstants {
checkpoint_zero_timestamp,
Expand Down
5 changes: 1 addition & 4 deletions node/src/config_mngr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ impl actix::Handler<Load> for ConfigManager {

fn handle(&mut self, Load(source): Load, _ctx: &mut Self::Context) -> Self::Result {
self.load_config(&source)
.map(|r| {
log::info!("Loaded new configuration from source: {:?}", source);
r
})
.inspect(|_| log::info!("Loaded new configuration from source: {:?}", source))
.map_err(|e| {
log::error!(
"Failed to load new configuration from source: {:?}, error: {}",
Expand Down
4 changes: 2 additions & 2 deletions rad/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,11 @@ pub async fn run_paranoid_retrieval(
/// There are 4 cases in which this function will fail with `InconsistentSource`:
///
/// 1. All the transports failed or no transports are configured at all (in theory, this condition
/// should be unreachable).
/// should be unreachable).
/// 2. The retrieval failed on some of the used transports.
/// 3. The values that we got from different transports cannot be aggregated together.
/// 4. The result of applying the aggregation on the data coming from the different transports
/// reached a level of consensus that is lower than the configured paranoid threshold.
/// reached a level of consensus that is lower than the configured paranoid threshold.
fn evaluate_paranoid_retrieval(
data: Vec<Result<RadonReport<RadonTypes>>>,
aggregate: RADAggregate,
Expand Down
13 changes: 8 additions & 5 deletions validations/src/eligibility/current.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,24 +232,27 @@ where
// Requirement no. 3 from the WIP:
// "the big-endian value of the VRF output is less than
// `max_rounds * own_power / (round * threshold_power + max_power * (max_rounds - round))`"
let dividend = Power::from(WITNESSING_MAX_ROUNDS as u64)
let dividend = Power::from(u64::from(WITNESSING_MAX_ROUNDS))
* Power::from((u64::BITS - u64::from(power).leading_zeros()).into());
let divisor = (round as u32)
let divisor = u32::from(round)
.saturating_mul(u64::BITS - u64::from(threshold_power).leading_zeros())
.saturating_add(
(u64::BITS - u64::from(max_power).leading_zeros())
.saturating_mul(WITNESSING_MAX_ROUNDS - round as u32),
.saturating_mul(WITNESSING_MAX_ROUNDS - u32::from(round)),
);
let (target_hash, probability) = if divisor == 0 {
(Hash::with_first_u32(u32::MAX), 1_f64)
} else {
let hash = Hash::with_first_u32(
(((u64::MAX / Power::from(divisor as u64)).saturating_mul(u64::from(dividend)))
(((u64::MAX / Power::from(u64::from(divisor)))
.saturating_mul(u64::from(dividend)))
>> 32)
.try_into()
.unwrap(),
);
let probability = u64::from(dividend) as f64 / divisor as f64;

#[allow(clippy::cast_precision_loss, clippy::cast_lossless)]
let probability: f64 = u64::from(dividend) as f64 / divisor as f64;

(hash, probability)
};
Expand Down
4 changes: 2 additions & 2 deletions wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ pub fn run(conf: Config) -> Result<(), Error> {
let checkpoints_period = conf.consensus_constants.checkpoints_period;
let checkpoint_zero_timestamp = conf.consensus_constants.checkpoint_zero_timestamp;
let checkpoint_zero_timestamp_v2 = checkpoint_zero_timestamp
+ get_protocol_version_activation_epoch(ProtocolVersion::V2_0) as i64
* checkpoints_period as i64;
+ i64::from(get_protocol_version_activation_epoch(ProtocolVersion::V2_0))
* i64::from(checkpoints_period);
let checkpoints_period_v2 = get_protocol_version_period(ProtocolVersion::V2_0);
let epoch_constants = EpochConstants {
checkpoint_zero_timestamp,
Expand Down

0 comments on commit edcf8e9

Please sign in to comment.