Skip to content

Commit 5c7dba2

Browse files
committed
chore: fix clippy and fmt
1 parent 289adf5 commit 5c7dba2

File tree

5 files changed

+64
-76
lines changed

5 files changed

+64
-76
lines changed

core/src/validator.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! The `validator` module hosts all the validator microservices.
22
33
pub use solana_perf::report_target_features;
4-
use solana_runtime::bank::pyth_accumulator;
54
use {
65
crate::{
76
accounts_hash_verifier::AccountsHashVerifier,
@@ -75,7 +74,7 @@ use {
7574
accounts_db::{AccountShrinkThreshold, AccountsDbConfig},
7675
accounts_index::AccountSecondaryIndexes,
7776
accounts_update_notifier_interface::AccountsUpdateNotifier,
78-
bank::Bank,
77+
bank::{pyth_accumulator, Bank},
7978
bank_forks::BankForks,
8079
commitment::BlockCommitmentCache,
8180
cost_model::CostModel,

runtime/src/bank/pyth_accumulator.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use {
22
super::Bank,
33
crate::accounts_index::{ScanConfig, ScanError},
4-
byteorder::LittleEndian,
5-
byteorder::ReadBytesExt,
4+
byteorder::{LittleEndian, ReadBytesExt},
65
log::*,
76
pyth_oracle::validator::AggregationError,
87
pythnet_sdk::{
@@ -124,7 +123,7 @@ pub fn get_accumulator_keys() -> Vec<(
124123
]
125124
}
126125

127-
pub fn update_v1<'a>(
126+
pub fn update_v1(
128127
bank: &Bank,
129128
v2_messages: &[Vec<u8>],
130129
use_message_buffers: bool,
@@ -166,7 +165,7 @@ pub fn update_v1<'a>(
166165
let mut header_begin = header_len;
167166
let mut inputs = Vec::new();
168167
let mut cur_end_offsets_idx: usize = 0;
169-
while let Some(end) = cursor.read_u16::<LittleEndian>().ok() {
168+
while let Ok(end) = cursor.read_u16::<LittleEndian>() {
170169
if end == 0 || cur_end_offsets_idx == (u8::MAX as usize) {
171170
break;
172171
}

runtime/src/bank/pyth_accumulator_tests.rs

Lines changed: 57 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
1-
use crate::{
2-
bank::{
3-
pyth_accumulator::{get_accumulator_keys, ACCUMULATOR_RING_SIZE, ORACLE_PID},
4-
Bank,
1+
use {
2+
crate::{
3+
bank::{
4+
pyth_accumulator::{get_accumulator_keys, ACCUMULATOR_RING_SIZE, ORACLE_PID},
5+
Bank,
6+
},
7+
genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo},
58
},
6-
genesis_utils::{create_genesis_config_with_leader, GenesisConfigInfo},
7-
};
8-
use byteorder::ByteOrder;
9-
use byteorder::{LittleEndian, ReadBytesExt};
10-
use itertools::Itertools;
11-
use pyth_oracle::PythOracleSerialize;
12-
use pyth_oracle::{solana_program::account_info::AccountInfo, PriceAccountFlags};
13-
use pyth_oracle::{PriceAccount, PythAccount};
14-
use pythnet_sdk::{
15-
accumulators::{merkle::MerkleAccumulator, Accumulator},
16-
hashers::{keccak256_160::Keccak160, Hasher},
17-
wormhole::{AccumulatorSequenceTracker, MessageData, PostedMessageUnreliableData},
18-
ACCUMULATOR_EMITTER_ADDRESS,
19-
};
20-
use solana_sdk::{
21-
account::{AccountSharedData, ReadableAccount, WritableAccount},
22-
borsh::{BorshDeserialize, BorshSerialize},
23-
clock::Epoch,
24-
epoch_schedule::EpochSchedule,
25-
feature::{self, Feature},
26-
feature_set,
27-
hash::hashv,
28-
pubkey::Pubkey,
29-
signature::keypair_from_seed,
30-
signer::Signer,
9+
byteorder::{ByteOrder, LittleEndian, ReadBytesExt},
10+
itertools::Itertools,
11+
pyth_oracle::{
12+
solana_program::account_info::AccountInfo, PriceAccount, PriceAccountFlags, PythAccount,
13+
PythOracleSerialize,
14+
},
15+
pythnet_sdk::{
16+
accumulators::{merkle::MerkleAccumulator, Accumulator},
17+
hashers::{keccak256_160::Keccak160, Hasher},
18+
wormhole::{AccumulatorSequenceTracker, MessageData, PostedMessageUnreliableData},
19+
ACCUMULATOR_EMITTER_ADDRESS,
20+
},
21+
solana_sdk::{
22+
account::{AccountSharedData, ReadableAccount, WritableAccount},
23+
borsh::{BorshDeserialize, BorshSerialize},
24+
clock::Epoch,
25+
epoch_schedule::EpochSchedule,
26+
feature::{self, Feature},
27+
feature_set,
28+
hash::hashv,
29+
pubkey::Pubkey,
30+
signature::keypair_from_seed,
31+
signer::Signer,
32+
},
33+
std::{io::Read, mem::size_of, sync::Arc},
3134
};
32-
use std::{io::Read, mem::size_of, sync::Arc};
3335

3436
// Create Message Account Bytes
3537
//
@@ -60,7 +62,7 @@ fn get_acc_sequence_tracker(bank: &Bank) -> AccumulatorSequenceTracker {
6062
pythnet_sdk::pythnet::ACCUMULATOR_SEQUENCE_ADDR,
6163
))
6264
.unwrap();
63-
AccumulatorSequenceTracker::try_from_slice(&mut account.data()).unwrap()
65+
AccumulatorSequenceTracker::try_from_slice(account.data()).unwrap()
6466
}
6567

6668
fn get_wormhole_message_account(bank: &Bank, ring_index: u32) -> AccountSharedData {
@@ -137,7 +139,7 @@ fn test_update_accumulator_sysvar() {
137139
false,
138140
true,
139141
&mut 0,
140-
&mut price_feed_account.data_mut(),
142+
price_feed_account.data_mut(),
141143
&ORACLE_PID.to_bytes().into(),
142144
false,
143145
Epoch::default(),
@@ -167,11 +169,9 @@ fn test_update_accumulator_sysvar() {
167169
let wormhole_message_account = bank
168170
.get_account(&wormhole_message_pubkey)
169171
.unwrap_or_default();
170-
assert_eq!(
171-
bank.feature_set
172-
.is_active(&feature_set::enable_accumulator_sysvar::id()),
173-
false
174-
);
172+
assert!(!bank
173+
.feature_set
174+
.is_active(&feature_set::enable_accumulator_sysvar::id()));
175175
assert_eq!(wormhole_message_account.data().len(), 0);
176176

177177
// Enable Accumulator Feature (42 = random lamport balance, and the meaning of the universe).
@@ -186,11 +186,9 @@ fn test_update_accumulator_sysvar() {
186186
}
187187

188188
// Feature should now be enabled on the new bank as the epoch has changed.
189-
assert_eq!(
190-
bank.feature_set
191-
.is_active(&feature_set::enable_accumulator_sysvar::id()),
192-
true
193-
);
189+
assert!(!bank
190+
.feature_set
191+
.is_active(&feature_set::enable_accumulator_sysvar::id()));
194192

195193
// The current sequence value will be used in the message when the bank advances, so we snapshot
196194
// it here before advancing the slot so we can assert the correct sequence is present in the message.
@@ -306,7 +304,7 @@ fn test_update_accumulator_sysvar() {
306304
let message_1 = vec![2u8; 127];
307305
let message_2 = vec![3u8; 254];
308306

309-
let updated_messages = vec![message_1.clone(), message_2.clone(), message_0.clone()];
307+
let updated_messages = vec![message_1, message_2, message_0];
310308

311309
let updated_message_buffer_bytes = create_message_buffer_bytes(updated_messages.clone());
312310
price_message_account.set_data(updated_message_buffer_bytes);
@@ -426,7 +424,7 @@ fn test_update_accumulator_end_of_block() {
426424
false,
427425
true,
428426
&mut 0,
429-
&mut price_feed_account.data_mut(),
427+
price_feed_account.data_mut(),
430428
&ORACLE_PID.to_bytes().into(),
431429
false,
432430
Epoch::default(),
@@ -453,16 +451,12 @@ fn test_update_accumulator_end_of_block() {
453451
// still [].
454452
bank = new_from_parent(&Arc::new(bank));
455453

456-
assert_eq!(
457-
bank.feature_set
458-
.is_active(&feature_set::enable_accumulator_sysvar::id()),
459-
false
460-
);
461-
assert_eq!(
462-
bank.feature_set
463-
.is_active(&feature_set::move_accumulator_to_end_of_block::id()),
464-
false
465-
);
454+
assert!(!bank
455+
.feature_set
456+
.is_active(&feature_set::enable_accumulator_sysvar::id()));
457+
assert!(!bank
458+
.feature_set
459+
.is_active(&feature_set::move_accumulator_to_end_of_block::id()));
466460

467461
let wormhole_message_account = bank
468462
.get_account(&wormhole_message_pubkey)
@@ -488,16 +482,12 @@ fn test_update_accumulator_end_of_block() {
488482
}
489483

490484
// Features should now be enabled on the new bank as the epoch has changed.
491-
assert_eq!(
492-
bank.feature_set
493-
.is_active(&feature_set::enable_accumulator_sysvar::id()),
494-
true
495-
);
496-
assert_eq!(
497-
bank.feature_set
498-
.is_active(&feature_set::move_accumulator_to_end_of_block::id()),
499-
true
500-
);
485+
assert!(bank
486+
.feature_set
487+
.is_active(&feature_set::enable_accumulator_sysvar::id()));
488+
assert!(bank
489+
.feature_set
490+
.is_active(&feature_set::move_accumulator_to_end_of_block::id()));
501491

502492
// The current sequence value will be used in the message when the bank advances, so we snapshot
503493
// it here before freezing the bank so we can assert the correct sequence is present in the message.
@@ -614,7 +604,7 @@ fn test_update_accumulator_end_of_block() {
614604
let message_1 = vec![2u8; 127];
615605
let message_2 = vec![3u8; 254];
616606

617-
let updated_messages = vec![message_1.clone(), message_2.clone(), message_0.clone()];
607+
let updated_messages = vec![message_1, message_2, message_0];
618608

619609
let updated_message_buffer_bytes = create_message_buffer_bytes(updated_messages.clone());
620610
price_message_account.set_data(updated_message_buffer_bytes);
@@ -783,8 +773,7 @@ fn test_accumulator_v2(generate_buffers: [bool; 4]) {
783773

784774
let messages = prices_with_messages
785775
.iter()
786-
.map(|(_, messages)| messages)
787-
.flatten()
776+
.flat_map(|(_, messages)| messages)
788777
.map(|message| &message[..])
789778
.sorted_unstable()
790779
.dedup()
@@ -803,7 +792,7 @@ fn test_accumulator_v2(generate_buffers: [bool; 4]) {
803792
PostedMessageUnreliableData::deserialize(&mut wormhole_message_account.data()).unwrap();
804793

805794
// Create MerkleAccumulator by hand to verify that the Wormhole message
806-
// contents are correctg.
795+
// contents are correct.
807796
let expected_accumulator =
808797
MerkleAccumulator::<Keccak160>::from_set(messages.iter().copied()).unwrap();
809798

runtime/src/genesis_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub fn activate_all_features(genesis_config: &mut GenesisConfig) {
204204
/// Based on v1.10.24 state at pythnet launch.
205205
pub fn activate_pythnet_genesis_features(genesis_config: &mut GenesisConfig) {
206206
// Activate all features at genesis in development mode
207-
for (feature_id, _) in &*solana_sdk::feature_set::PYTHNET_GENESIS_FEATURES {
207+
for feature_id in solana_sdk::feature_set::PYTHNET_GENESIS_FEATURES.keys() {
208208
genesis_config.accounts.insert(
209209
*feature_id,
210210
Account::from(feature::create_account(

transaction-status/src/option_serializer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ impl<T> OptionSerializer<T> {
2828
}
2929

3030
pub fn as_ref(&self) -> OptionSerializer<&T> {
31-
#[allow(clippy::needless_match)] // The nightly clippy used by CI is incorrect here
31+
#[allow(unknown_lints, clippy::needless_match)]
32+
// The nightly clippy used by CI is incorrect here
3233
match self {
3334
OptionSerializer::Some(item) => OptionSerializer::Some(item),
3435
OptionSerializer::None => OptionSerializer::None,

0 commit comments

Comments
 (0)