Skip to content

Commit c107c2c

Browse files
committed
clippy
1 parent f5b295c commit c107c2c

File tree

10 files changed

+150
-10
lines changed

10 files changed

+150
-10
lines changed

common/cosmwasm-smart-contracts/mixnet-contract/src/key_rotation.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ pub struct KeyRotationState {
2222
impl KeyRotationState {
2323
pub fn key_rotation_id(&self, current_epoch_id: EpochId) -> KeyRotationId {
2424
let diff = current_epoch_id.saturating_sub(self.initial_epoch_id);
25-
let full_rots = diff / self.validity_epochs;
26-
full_rots
25+
diff / self.validity_epochs
2726
}
2827

2928
pub fn next_rotation_starting_epoch_id(&self, current_epoch_id: EpochId) -> EpochId {

common/http-api-client/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,9 @@ impl Client {
444444
Client {
445445
base_url: new_url,
446446
reqwest_client: self.reqwest_client.clone(),
447+
448+
#[cfg(target_arch = "wasm32")]
449+
request_timeout: self.request_timeout,
447450
}
448451
}
449452

common/nymsphinx/params/src/packet_version.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use thiserror::Error;
1010
// - packet_version (starting with v1.1.0)
1111
// - packet_size indicator
1212
// - packet_type
13-
// - sphinx key rotation (starting with v1.11.0)
14-
const TODO: &str = "update the ^ version number when this PR is almost ready";
13+
// - sphinx key rotation (starting with v1.12.0/v1.13.0 - either Cheddar or Dolcelatte release)
14+
1515
// it also just so happens that the only valid values for packet_size indicator include values 1-6
1616
// therefore if we receive byte `7` (or larger than that) we'll know we received a versioned packet,
1717
// otherwise we should treat it as legacy

contracts/mixnet/schema/nym-mixnet-contract.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3440,6 +3440,34 @@
34403440
}
34413441
},
34423442
"additionalProperties": false
3443+
},
3444+
{
3445+
"description": "Gets the current state config of the key rotation (i.e. starting epoch id and validity duration)",
3446+
"type": "object",
3447+
"required": [
3448+
"get_key_rotation_state"
3449+
],
3450+
"properties": {
3451+
"get_key_rotation_state": {
3452+
"type": "object",
3453+
"additionalProperties": false
3454+
}
3455+
},
3456+
"additionalProperties": false
3457+
},
3458+
{
3459+
"description": "Gets the current key rotation id",
3460+
"type": "object",
3461+
"required": [
3462+
"get_key_rotation_id"
3463+
],
3464+
"properties": {
3465+
"get_key_rotation_id": {
3466+
"type": "object",
3467+
"additionalProperties": false
3468+
}
3469+
},
3470+
"additionalProperties": false
34433471
}
34443472
],
34453473
"definitions": {
@@ -5116,6 +5144,46 @@
51165144
}
51175145
}
51185146
},
5147+
"get_key_rotation_id": {
5148+
"$schema": "http://json-schema.org/draft-07/schema#",
5149+
"title": "KeyRotationIdResponse",
5150+
"type": "object",
5151+
"required": [
5152+
"rotation_id"
5153+
],
5154+
"properties": {
5155+
"rotation_id": {
5156+
"type": "integer",
5157+
"format": "uint32",
5158+
"minimum": 0.0
5159+
}
5160+
},
5161+
"additionalProperties": false
5162+
},
5163+
"get_key_rotation_state": {
5164+
"$schema": "http://json-schema.org/draft-07/schema#",
5165+
"title": "KeyRotationState",
5166+
"type": "object",
5167+
"required": [
5168+
"initial_epoch_id",
5169+
"validity_epochs"
5170+
],
5171+
"properties": {
5172+
"initial_epoch_id": {
5173+
"description": "Records the initial epoch_id when the key rotation has been introduced (0 for fresh contracts). It is used for determining when rotation is meant to advance.",
5174+
"type": "integer",
5175+
"format": "uint32",
5176+
"minimum": 0.0
5177+
},
5178+
"validity_epochs": {
5179+
"description": "Defines how long each key rotation is valid for (in terms of epochs)",
5180+
"type": "integer",
5181+
"format": "uint32",
5182+
"minimum": 0.0
5183+
}
5184+
},
5185+
"additionalProperties": false
5186+
},
51195187
"get_mix_node_bonds": {
51205188
"$schema": "http://json-schema.org/draft-07/schema#",
51215189
"title": "PagedMixnodeBondsResponse",

contracts/mixnet/schema/raw/query.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,34 @@
14861486
}
14871487
},
14881488
"additionalProperties": false
1489+
},
1490+
{
1491+
"description": "Gets the current state config of the key rotation (i.e. starting epoch id and validity duration)",
1492+
"type": "object",
1493+
"required": [
1494+
"get_key_rotation_state"
1495+
],
1496+
"properties": {
1497+
"get_key_rotation_state": {
1498+
"type": "object",
1499+
"additionalProperties": false
1500+
}
1501+
},
1502+
"additionalProperties": false
1503+
},
1504+
{
1505+
"description": "Gets the current key rotation id",
1506+
"type": "object",
1507+
"required": [
1508+
"get_key_rotation_id"
1509+
],
1510+
"properties": {
1511+
"get_key_rotation_id": {
1512+
"type": "object",
1513+
"additionalProperties": false
1514+
}
1515+
},
1516+
"additionalProperties": false
14891517
}
14901518
],
14911519
"definitions": {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "KeyRotationIdResponse",
4+
"type": "object",
5+
"required": [
6+
"rotation_id"
7+
],
8+
"properties": {
9+
"rotation_id": {
10+
"type": "integer",
11+
"format": "uint32",
12+
"minimum": 0.0
13+
}
14+
},
15+
"additionalProperties": false
16+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "KeyRotationState",
4+
"type": "object",
5+
"required": [
6+
"initial_epoch_id",
7+
"validity_epochs"
8+
],
9+
"properties": {
10+
"initial_epoch_id": {
11+
"description": "Records the initial epoch_id when the key rotation has been introduced (0 for fresh contracts). It is used for determining when rotation is meant to advance.",
12+
"type": "integer",
13+
"format": "uint32",
14+
"minimum": 0.0
15+
},
16+
"validity_epochs": {
17+
"description": "Defines how long each key rotation is valid for (in terms of epochs)",
18+
"type": "integer",
19+
"format": "uint32",
20+
"minimum": 0.0
21+
}
22+
},
23+
"additionalProperties": false
24+
}

contracts/mixnet/src/rewards/transactions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ pub(crate) fn try_update_rewarding_params(
313313
}
314314
}
315315

316+
#[allow(clippy::panic)]
317+
#[allow(clippy::unreachable)]
316318
#[cfg(test)]
317319
pub mod tests {
318320
use super::*;

nym-node/src/node/key_rotation/controller.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ impl KeyRotationController {
198198
{
199199
// mutex poisoning - we have to exit
200200
self.shutdown_token.cancel();
201-
return;
202201
}
203202

204203
// no need to send the information explicitly to nym-apis, as they're scheduled to refresh
@@ -217,7 +216,6 @@ impl KeyRotationController {
217216
{
218217
// mutex poisoning - we have to exit
219218
self.shutdown_token.cancel();
220-
return;
221219
}
222220
}
223221

@@ -229,7 +227,6 @@ impl KeyRotationController {
229227
if self.replay_protection_manager.purge_secondary().is_err() {
230228
// mutex poisoning - we have to exit
231229
self.shutdown_token.cancel();
232-
return;
233230
}
234231
}
235232

nym-node/src/node/replay_protection/bloomfilter.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,18 +238,21 @@ impl ReplayProtectionBloomfilters {
238238
}
239239
}
240240

241+
// map from particular rotation id to vector of results, based on the order of requests received
242+
type BatchCheckResult = HashMap<u32, Vec<bool>>;
243+
241244
impl ReplayProtectionBloomfilters {
242245
pub(crate) fn batch_try_check_and_set(
243246
&self,
244247
reply_tags: &HashMap<u32, Vec<&[u8; REPLAY_TAG_SIZE]>>,
245-
) -> Option<Result<HashMap<u32, Vec<bool>>, PoisonError<()>>> {
248+
) -> Option<Result<BatchCheckResult, PoisonError<()>>> {
246249
let mut guard = match self.inner.try_lock() {
247250
Ok(guard) => guard,
248251
Err(TryLockError::Poisoned(_)) => return Some(Err(PoisonError::new(()))),
249252
Err(TryLockError::WouldBlock) => return None,
250253
};
251254

252-
Some(Ok(guard.batch_check_and_set(&reply_tags)))
255+
Some(Ok(guard.batch_check_and_set(reply_tags)))
253256
}
254257

255258
pub(crate) fn batch_check_and_set(
@@ -260,7 +263,7 @@ impl ReplayProtectionBloomfilters {
260263
return Err(PoisonError::new(()));
261264
};
262265

263-
Ok(guard.batch_check_and_set(&reply_tags))
266+
Ok(guard.batch_check_and_set(reply_tags))
264267
}
265268
}
266269

0 commit comments

Comments
 (0)