Skip to content

Commit 986fa2c

Browse files
committed
lint
1 parent b3dcc04 commit 986fa2c

File tree

21 files changed

+83
-84
lines changed

21 files changed

+83
-84
lines changed

core/bin/external_node/src/node_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ impl ExternalNodeBuilder {
587587

588588
pub fn build(mut self, mut components: Vec<Component>) -> anyhow::Result<ZkStackService> {
589589
// Add "base" layers
590-
let l1_chain_id = self.config.required.l1_chain_id.clone();
590+
let l1_chain_id = self.config.required.l1_chain_id;
591591
self = self
592592
.add_sigint_handler_layer()?
593593
.add_healthcheck_layer()?

core/bin/zksync_server/src/node_builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ impl MainNodeBuilder {
689689

690690
/// Builds the node with the genesis initialization task only.
691691
pub fn only_genesis(mut self) -> anyhow::Result<ZkStackService> {
692-
let l1_chain_id = self.genesis_config.l1_chain_id.clone();
692+
let l1_chain_id = self.genesis_config.l1_chain_id;
693693
self = self
694694
.add_pools_layer()?
695695
.add_object_store_layer()?
@@ -702,7 +702,7 @@ impl MainNodeBuilder {
702702
}
703703

704704
pub fn only_l1_recovery(mut self) -> anyhow::Result<ZkStackService> {
705-
let l1_chain_id = self.genesis_config.l1_chain_id.clone();
705+
let l1_chain_id = self.genesis_config.l1_chain_id;
706706
self = self
707707
.add_pools_layer()?
708708
.add_object_store_layer()?
@@ -717,7 +717,7 @@ impl MainNodeBuilder {
717717
/// Builds the node with the specified components.
718718
pub fn build(mut self, mut components: Vec<Component>) -> anyhow::Result<ZkStackService> {
719719
// Add "base" layers (resources and helper tasks).
720-
let l1_chain_id = self.genesis_config.l1_chain_id.clone();
720+
let l1_chain_id = self.genesis_config.l1_chain_id;
721721
self = self
722722
.add_sigint_handler_layer()?
723723
.add_pools_layer()?

core/lib/multivm/src/versions/testonly/l1_messenger.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ pub(crate) fn test_rollup_da_output_hash_match<VM: TestedVm>() {
9999

100100
// Firstly, deploy tx. It should publish the bytecode of the "test contract"
101101
let counter_bytecode = TestContract::counter().bytecode;
102-
let tx = account
103-
.get_deploy_tx(&counter_bytecode, None, TxType::L2)
104-
.tx;
102+
let tx = account.get_deploy_tx(counter_bytecode, None, TxType::L2).tx;
105103
// We do not use compression here, to have the bytecode published in full.
106104
let (_, result) = vm
107105
.vm

core/node/eth_watch/src/tests/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ async fn test_batch_root_processor_from_genesis() {
480480
.await
481481
.unwrap()
482482
.unwrap();
483-
let proof1 = hex::encode(&bincode::serialize(&proof1).unwrap());
483+
let proof1 = hex::encode(bincode::serialize(&proof1).unwrap());
484484
assert_eq!(proof1, "000000000600000000000000420000000000000030783030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303042000000000000003078303030303030303030303030303030303030303030303030303030303030303530303030303030303030303030303030303030303030303030303030303030334200000000000000307830303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030316639420000000000000030783031303230303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303042000000000000003078303932343932386331333737613663663234633339633264343666386562396466323365383131623236646333353237653534383339366664346531373362314200000000000000307833373561356266393039636230323134336533363935636136353865303634316537333961613539306630303034646261393335373263343463646239643264");
485485

486486
sl_client.set_last_finalized_block_number(11).await;
@@ -492,7 +492,7 @@ async fn test_batch_root_processor_from_genesis() {
492492
.await
493493
.unwrap()
494494
.unwrap();
495-
let proof2 = hex::encode(&bincode::serialize(&proof2).unwrap());
495+
let proof2 = hex::encode(bincode::serialize(&proof2).unwrap());
496496
assert_eq!(proof2, "0100000007000000000000004200000000000000307830303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303031420000000000000030783130613265663736653730396433313862343539626534396631653864376630326437313230663262353031626330616664646439333566316138313363363742000000000000003078303030303030303030303030303030303030303030303030303030303030303930303030303030303030303030303030303030303030303030303030303030334200000000000000307830303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030316639420000000000000030783031303230303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303042000000000000003078303932343932386331333737613663663234633339633264343666386562396466323365383131623236646333353237653534383339366664346531373362314200000000000000307861333738613230636132376237616533303731643162643763326164613030343639616263353765343239646436663438613833303932646237303539613138");
497497

498498
let proof3 = connection
@@ -501,7 +501,7 @@ async fn test_batch_root_processor_from_genesis() {
501501
.await
502502
.unwrap()
503503
.unwrap();
504-
let proof3 = hex::encode(&bincode::serialize(&proof3).unwrap());
504+
let proof3 = hex::encode(bincode::serialize(&proof3).unwrap());
505505
assert_eq!(proof3, "02000000080000000000000042000000000000003078303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030324200000000000000307834363730306234643430616335633335616632633232646461323738376139316562353637623036633932346138666238616539613035623230633038633231420000000000000030786530633333333066363734623662326435373866393538613164626436366631363464303638623062623561396662303737656361303133393736666461366642000000000000003078303030303030303030303030303030303030303030303030303030303030306230303030303030303030303030303030303030303030303030303030303030334200000000000000307830303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030316639420000000000000030783031303230303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303042000000000000003078303932343932386331333737613663663234633339633264343666386562396466323365383131623236646333353237653534383339366664346531373362314200000000000000307833373561356266393039636230323134336533363935636136353865303634316537333961613539306630303034646261393335373263343463646239643264");
506506
}
507507

@@ -567,7 +567,7 @@ async fn test_batch_root_processor_restart() {
567567
.await
568568
.unwrap()
569569
.unwrap();
570-
let proof = hex::encode(&bincode::serialize(&proof).unwrap());
570+
let proof = hex::encode(bincode::serialize(&proof).unwrap());
571571
assert_eq!(proof, "02000000080000000000000042000000000000003078303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030324200000000000000307834363730306234643430616335633335616632633232646461323738376139316562353637623036633932346138666238616539613035623230633038633231420000000000000030786530633333333066363734623662326435373866393538613164626436366631363464303638623062623561396662303737656361303133393736666461366642000000000000003078303030303030303030303030303030303030303030303030303030303030306230303030303030303030303030303030303030303030303030303030303030334200000000000000307830303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030316639420000000000000030783031303230303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303042000000000000003078303932343932386331333737613663663234633339633264343666386562396466323365383131623236646333353237653534383339366664346531373362314200000000000000307833373561356266393039636230323134336533363935636136353865303634316537333961613539306630303034646261393335373263343463646239643264");
572572

573573
let proof = connection
@@ -576,7 +576,7 @@ async fn test_batch_root_processor_restart() {
576576
.await
577577
.unwrap()
578578
.unwrap();
579-
let proof = hex::encode(&bincode::serialize(&proof).unwrap());
579+
let proof = hex::encode(bincode::serialize(&proof).unwrap());
580580
assert_eq!(proof, "02000000080000000000000042000000000000003078303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030334200000000000000307837623765373735373139343639366666393634616233353837393131373362636337663735356132656161393334653935373061636533393139383435313265420000000000000030786530633333333066363734623662326435373866393538613164626436366631363464303638623062623561396662303737656361303133393736666461366642000000000000003078303030303030303030303030303030303030303030303030303030303030306430303030303030303030303030303030303030303030303030303030303030334200000000000000307830303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030316639420000000000000030783031303230303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303042000000000000003078303932343932386331333737613663663234633339633264343666386562396466323365383131623236646333353237653534383339366664346531373362314200000000000000307835353063313735316338653764626166633839303939326634353532333636663064643565623665343362653535353936386264616338633732656466316261");
581581

582582
let proof = connection
@@ -585,7 +585,7 @@ async fn test_batch_root_processor_restart() {
585585
.await
586586
.unwrap()
587587
.unwrap();
588-
let proof = hex::encode(&bincode::serialize(&proof).unwrap());
588+
let proof = hex::encode(bincode::serialize(&proof).unwrap());
589589
assert_eq!(proof, "030000000900000000000000420000000000000030783030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303442000000000000003078303235663065363031353230366661626364326263613930316432633438396536336263356564346231356266356330633963363066396531363735383564614200000000000000307863633463343165646230633230333133343862323932623736386539626163316565386339326330396566386133323737633265636534303963313264383661420000000000000030783533656463316635616437396335393939626435373864666331333566396335316562643766616661343538356236346637316431356232646365316237323842000000000000003078303030303030303030303030303030303030303030303030303030303030306530303030303030303030303030303030303030303030303030303030303030334200000000000000307830303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030316639420000000000000030783031303230303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303042000000000000003078303932343932386331333737613663663234633339633264343666386562396466323365383131623236646333353237653534383339366664346531373362314200000000000000307833373561356266393039636230323134336533363935636136353865303634316537333961613539306630303034646261393335373263343463646239643264");
590590

591591
let proof = connection
@@ -594,7 +594,7 @@ async fn test_batch_root_processor_restart() {
594594
.await
595595
.unwrap()
596596
.unwrap();
597-
let proof = hex::encode(&bincode::serialize(&proof).unwrap());
597+
let proof = hex::encode(bincode::serialize(&proof).unwrap());
598598
assert_eq!(proof, "030000000900000000000000420000000000000030783030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303542000000000000003078323465653435363834376535373364313635613832333634306632303834383139636331613865333433316562633635633865363064333435343266313637324200000000000000307863633463343165646230633230333133343862323932623736386539626163316565386339326330396566386133323737633265636534303963313264383661420000000000000030783533656463316635616437396335393939626435373864666331333566396335316562643766616661343538356236346637316431356232646365316237323842000000000000003078303030303030303030303030303030303030303030303030303030303030306530303030303030303030303030303030303030303030303030303030303030334200000000000000307830303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030316639420000000000000030783031303230303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303042000000000000003078303932343932386331333737613663663234633339633264343666386562396466323365383131623236646333353237653534383339366664346531373362314200000000000000307833373561356266393039636230323134336533363935636136353865303634316537333961613539306630303034646261393335373263343463646239643264");
599599
}
600600

core/node/l1_recovery/src/l1_fetcher/constants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use zksync_utils::env::Workspace;
55
use zksync_web3_decl::client::{Client, DynClient, L1};
66

77
use crate::{
8-
l1_fetcher::l1_fetcher::{
8+
l1_fetcher::fetcher::{
99
L1Fetcher, L1FetcherConfig, ProtocolVersioning, ProtocolVersioning::AllVersions,
1010
},
1111
BlobClient, BlobHttpClient,
@@ -73,7 +73,7 @@ pub fn sepolia_diamond_proxy_addr() -> &'static str {
7373

7474
#[allow(unused)] // only used in tests
7575
pub fn sepolia_l1_client() -> Box<DynClient<L1>> {
76-
let url = SensitiveUrl::from_str(&"https://ethereum-sepolia-rpc.publicnode.com").unwrap();
76+
let url = SensitiveUrl::from_str("https://ethereum-sepolia-rpc.publicnode.com").unwrap();
7777
let eth_client = Client::http(url)
7878
.unwrap()
7979
.with_allowed_requests_per_second(NonZero::new(10).unwrap())

core/node/l1_recovery/src/l1_fetcher/l1_fetcher.rs renamed to core/node/l1_recovery/src/l1_fetcher/fetcher.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -288,17 +288,13 @@ impl L1Fetcher {
288288
.unwrap();
289289
let default_aa_bytecode_hash: H256 =
290290
CallFunctionArgs::new("getL2DefaultAccountBytecodeHash", ())
291-
.with_block(BlockId::Number(BlockNumber::Number(U64::from(
292-
block_to_check,
293-
))))
291+
.with_block(BlockId::Number(BlockNumber::Number(block_to_check)))
294292
.for_contract(self.config.diamond_proxy_addr, &Self::hyperchain_contract())
295293
.call(&self.eth_client)
296294
.await
297295
.unwrap();
298296
let packed_protocol_version: U256 = CallFunctionArgs::new("getProtocolVersion", ())
299-
.with_block(BlockId::Number(BlockNumber::Number(U64::from(
300-
block_to_check,
301-
))))
297+
.with_block(BlockId::Number(BlockNumber::Number(block_to_check)))
302298
.for_contract(self.config.diamond_proxy_addr, &Self::hyperchain_contract())
303299
.call(&self.eth_client)
304300
.await
@@ -539,9 +535,9 @@ impl L1Fetcher {
539535

540536
let first_unprocessed_priority_id: U256 =
541537
CallFunctionArgs::new("getFirstUnprocessedPriorityTx", ())
542-
.with_block(BlockId::Number(BlockNumber::Number(U64::from(
538+
.with_block(BlockId::Number(BlockNumber::Number(
543539
block_just_after_execute_tx_eth_block,
544-
))))
540+
)))
545541
.for_contract(self.config.diamond_proxy_addr, &Self::hyperchain_contract())
546542
.call(&self.eth_client)
547543
.await
@@ -559,10 +555,12 @@ impl L1Fetcher {
559555
RollupEventsFilter::PriorityOpId(first_unprocessed_priority_id - 1),
560556
)
561557
.await
562-
.expect(&format!(
563-
"Unable to find priority tx with id {}",
564-
first_unprocessed_priority_id - 1
565-
));
558+
.unwrap_or_else(|| {
559+
panic!(
560+
"Unable to find priority tx with id {}",
561+
first_unprocessed_priority_id - 1
562+
)
563+
});
566564
L1Tx::try_from(log).unwrap()
567565
}
568566

@@ -638,7 +636,7 @@ impl L1Fetcher {
638636
.unwrap();
639637
let blocks = L1Fetcher::process_tx_data(
640638
&functions,
641-
&blob_client,
639+
blob_client,
642640
tx,
643641
&self.config.versioning,
644642
)
@@ -679,11 +677,13 @@ impl L1Fetcher {
679677
.push(priority_tx.common_data.onchain_data());
680678
for factory_dep in &priority_tx.execute.factory_deps {
681679
let hashed = BytecodeHash::for_bytecode(factory_dep).value();
682-
if factory_deps_hashes.contains_key(&hashed) {
683-
continue;
684-
} else {
685-
factory_deps_hashes.insert(hashed, ());
680+
if let std::collections::hash_map::Entry::Vacant(e) =
681+
factory_deps_hashes.entry(hashed)
682+
{
683+
e.insert(());
686684
block.factory_deps.push(factory_dep.clone());
685+
} else {
686+
continue;
687687
}
688688
}
689689
last_processed_priority_tx += 1;
@@ -710,7 +710,7 @@ impl L1Fetcher {
710710
}
711711
current_block = filter_to_block + 1;
712712
}
713-
return result;
713+
result
714714
}
715715

716716
async fn process_tx_data(
@@ -720,31 +720,31 @@ impl L1Fetcher {
720720
protocol_versioning: &ProtocolVersioning,
721721
) -> Result<Vec<CommitBlock>, ParseError> {
722722
let block_number = tx.block_number.unwrap().as_u64();
723-
loop {
724-
match parse_calldata(
725-
protocol_versioning,
726-
block_number,
727-
&commit_functions,
728-
&tx.input.0,
729-
&blob_client,
730-
)
731-
.await
732-
{
733-
Ok(blks) => break Ok(blks),
734-
Err(e) => {
735-
match e.clone() {
736-
ParseError::BlobStorageError(err) => {
737-
tracing::error!("Blob storage error {err}");
738-
}
739-
ParseError::BlobFormatError(data, inner) => {
740-
tracing::error!("Cannot parse {}: {}", data, inner);
741-
}
742-
_ => {
743-
tracing::error!("Failed to parse calldata: {e}, encountered on block: {block_number}");
744-
}
723+
match parse_calldata(
724+
protocol_versioning,
725+
block_number,
726+
commit_functions,
727+
&tx.input.0,
728+
blob_client,
729+
)
730+
.await
731+
{
732+
Ok(blks) => Ok(blks),
733+
Err(e) => {
734+
match e.clone() {
735+
ParseError::BlobStorageError(err) => {
736+
tracing::error!("Blob storage error {err}");
737+
}
738+
ParseError::BlobFormatError(data, inner) => {
739+
tracing::error!("Cannot parse {}: {}", data, inner);
740+
}
741+
_ => {
742+
tracing::error!(
743+
"Failed to parse calldata: {e}, encountered on block: {block_number}"
744+
);
745745
}
746-
return Err(e);
747746
}
747+
return Err(e);
748748
}
749749
}
750750
}
@@ -817,7 +817,7 @@ pub async fn parse_last_committed_l1_batch(
817817

818818
let _new_blocks_data = parsed_input.pop().unwrap();
819819
let stored_block_info = parsed_input.pop().unwrap();
820-
return Ok(StoredBatchInfo::from_token(stored_block_info).unwrap());
820+
Ok(StoredBatchInfo::from_token(stored_block_info).unwrap())
821821
}
822822

823823
pub async fn parse_calldata(
@@ -936,7 +936,7 @@ mod tests {
936936
sepolia_blob_client, sepolia_initial_state_path, sepolia_l1_client,
937937
sepolia_l1_fetcher, sepolia_versioning,
938938
},
939-
l1_fetcher::L1Fetcher,
939+
fetcher::L1Fetcher,
940940
},
941941
processor::{snapshot::StateCompressor, tree::TreeProcessor},
942942
};

core/node/l1_recovery/src/l1_fetcher/main_node_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl SnapshotsApplierMainNodeClient for L1RecoveryOnlineMainNodeClient {
5959
.rpc_context("get_block_details")
6060
.with_arg("batch", &l1_batch_number)
6161
.await?
62-
.expect(&format!("Unable to find {l1_batch_number:?} batch"))
62+
.unwrap_or_else(|| panic!("Unable to find {l1_batch_number:?} batch"))
6363
.1;
6464
Ok(Some(SnapshotHeader {
6565
version: SnapshotVersion::Version1.into(),

0 commit comments

Comments
 (0)