Skip to content

Commit 6495d8a

Browse files
authored
chore: fix clippy issues (#1049)
1 parent 8a110d3 commit 6495d8a

7 files changed

Lines changed: 118 additions & 99 deletions

File tree

packages/proof-api/modules/cosmos-to-eth/src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -391,21 +391,6 @@ impl ProofApiService for CosmosToEthProofApiModuleService {
391391
}
392392
}
393393

394-
#[cfg(test)]
395-
mod tests {
396-
use alloy::providers::{Provider, RootProvider};
397-
398-
#[tokio::test]
399-
async fn https_provider_can_fetch_chain_id() {
400-
let provider: RootProvider = RootProvider::builder()
401-
.connect("https://ethereum-rpc.publicnode.com")
402-
.await
403-
.expect("connect to HTTPS Ethereum RPC endpoint");
404-
405-
assert_eq!(provider.get_chain_id().await.unwrap(), 1);
406-
}
407-
}
408-
409394
#[tonic::async_trait]
410395
impl ProofApiModule for CosmosToEthProofApiModule {
411396
fn name(&self) -> &'static str {
@@ -477,3 +462,18 @@ impl CosmosToEthTxBuilder {
477462
matches!(self, Self::Attested(_))
478463
}
479464
}
465+
466+
#[cfg(test)]
467+
mod tests {
468+
use alloy::providers::{Provider, RootProvider};
469+
470+
#[tokio::test]
471+
async fn https_provider_can_fetch_chain_id() {
472+
let provider: RootProvider = RootProvider::builder()
473+
.connect("https://ethereum-rpc.publicnode.com")
474+
.await
475+
.expect("connect to HTTPS Ethereum RPC endpoint");
476+
477+
assert_eq!(provider.get_chain_id().await.unwrap(), 1);
478+
}
479+
}

packages/proof-api/modules/eth-to-cosmos/src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -272,21 +272,6 @@ impl ProofApiService for EthToCosmosProofApiModuleService {
272272
}
273273
}
274274

275-
#[cfg(test)]
276-
mod tests {
277-
use alloy::providers::{Provider, RootProvider};
278-
279-
#[tokio::test]
280-
async fn https_provider_can_fetch_chain_id() {
281-
let provider: RootProvider = RootProvider::builder()
282-
.connect("https://ethereum-rpc.publicnode.com")
283-
.await
284-
.expect("connect to HTTPS Ethereum RPC endpoint");
285-
286-
assert_eq!(provider.get_chain_id().await.unwrap(), 1);
287-
}
288-
}
289-
290275
#[tonic::async_trait]
291276
impl ProofApiModule for EthToCosmosProofApiModule {
292277
fn name(&self) -> &'static str {
@@ -365,3 +350,18 @@ impl EthToCosmosTxBuilder {
365350
matches!(self, Self::Attested(_))
366351
}
367352
}
353+
354+
#[cfg(test)]
355+
mod tests {
356+
use alloy::providers::{Provider, RootProvider};
357+
358+
#[tokio::test]
359+
async fn https_provider_can_fetch_chain_id() {
360+
let provider: RootProvider = RootProvider::builder()
361+
.connect("https://ethereum-rpc.publicnode.com")
362+
.await
363+
.expect("connect to HTTPS Ethereum RPC endpoint");
364+
365+
assert_eq!(provider.get_chain_id().await.unwrap(), 1);
366+
}
367+
}

packages/proof-api/modules/eth-to-eth/src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -275,21 +275,6 @@ impl ProofApiService for EthToEthProofApiModuleService {
275275
}
276276
}
277277

278-
#[cfg(test)]
279-
mod tests {
280-
use alloy::providers::{Provider, RootProvider};
281-
282-
#[tokio::test]
283-
async fn https_provider_can_fetch_chain_id() {
284-
let provider: RootProvider = RootProvider::builder()
285-
.connect("https://ethereum-rpc.publicnode.com")
286-
.await
287-
.expect("connect to HTTPS Ethereum RPC endpoint");
288-
289-
assert_eq!(provider.get_chain_id().await.unwrap(), 1);
290-
}
291-
}
292-
293278
#[tonic::async_trait]
294279
impl ProofApiModule for EthToEthProofApiModule {
295280
fn name(&self) -> &'static str {
@@ -335,3 +320,18 @@ impl EthToEthTxBuilder {
335320
}
336321
}
337322
}
323+
324+
#[cfg(test)]
325+
mod tests {
326+
use alloy::providers::{Provider, RootProvider};
327+
328+
#[tokio::test]
329+
async fn https_provider_can_fetch_chain_id() {
330+
let provider: RootProvider = RootProvider::builder()
331+
.connect("https://ethereum-rpc.publicnode.com")
332+
.await
333+
.expect("connect to HTTPS Ethereum RPC endpoint");
334+
335+
assert_eq!(provider.get_chain_id().await.unwrap(), 1);
336+
}
337+
}

packages/proof-api/modules/eth-to-solana/src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,6 @@ impl ProofApiService for EthToSolanaProofApiModuleService {
292292
}
293293
}
294294

295-
#[cfg(test)]
296-
mod tests {
297-
use alloy::providers::{Provider, RootProvider};
298-
299-
#[tokio::test]
300-
async fn https_provider_can_fetch_chain_id() {
301-
let provider: RootProvider = RootProvider::builder()
302-
.connect("https://ethereum-rpc.publicnode.com")
303-
.await
304-
.expect("connect to HTTPS Ethereum RPC endpoint");
305-
306-
assert_eq!(provider.get_chain_id().await.unwrap(), 1);
307-
}
308-
}
309-
310295
#[tonic::async_trait]
311296
impl ProofApiModule for EthToSolanaProofApiModule {
312297
fn name(&self) -> &'static str {
@@ -375,3 +360,18 @@ impl EthToSolanaTxBuilder {
375360
}
376361
}
377362
}
363+
364+
#[cfg(test)]
365+
mod tests {
366+
use alloy::providers::{Provider, RootProvider};
367+
368+
#[tokio::test]
369+
async fn https_provider_can_fetch_chain_id() {
370+
let provider: RootProvider = RootProvider::builder()
371+
.connect("https://ethereum-rpc.publicnode.com")
372+
.await
373+
.expect("connect to HTTPS Ethereum RPC endpoint");
374+
375+
assert_eq!(provider.get_chain_id().await.unwrap(), 1);
376+
}
377+
}

packages/proof-api/modules/solana-to-eth/src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -250,21 +250,6 @@ impl ProofApiService for SolanaToEthProofApiModuleService {
250250
}
251251
}
252252

253-
#[cfg(test)]
254-
mod tests {
255-
use alloy::providers::{Provider, RootProvider};
256-
257-
#[tokio::test]
258-
async fn https_provider_can_fetch_chain_id() {
259-
let provider: RootProvider = RootProvider::builder()
260-
.connect("https://ethereum-rpc.publicnode.com")
261-
.await
262-
.expect("connect to HTTPS Ethereum RPC endpoint");
263-
264-
assert_eq!(provider.get_chain_id().await.unwrap(), 1);
265-
}
266-
}
267-
268253
#[tonic::async_trait]
269254
impl ProofApiModule for SolanaToEthProofApiModule {
270255
fn name(&self) -> &'static str {
@@ -300,3 +285,18 @@ impl SolanaToEthTxBuilder {
300285
}
301286
}
302287
}
288+
289+
#[cfg(test)]
290+
mod tests {
291+
use alloy::providers::{Provider, RootProvider};
292+
293+
#[tokio::test]
294+
async fn https_provider_can_fetch_chain_id() {
295+
let provider: RootProvider = RootProvider::builder()
296+
.connect("https://ethereum-rpc.publicnode.com")
297+
.await
298+
.expect("connect to HTTPS Ethereum RPC endpoint");
299+
300+
assert_eq!(provider.get_chain_id().await.unwrap(), 1);
301+
}
302+
}

programs/operator/src/runners/fixtures/misbehaviour.rs

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Runner for generating `misbehaviour` fixtures
22
33
use crate::{
4-
cli::command::{fixtures::MisbehaviourCmd, OutputPath},
4+
cli::command::{fixtures::MisbehaviourCmd, OutputPath, SP1ELFPaths},
55
runners::genesis::SP1ICS07TendermintGenesis,
66
};
77
use alloy::sol_types::SolValue;
@@ -41,20 +41,19 @@ struct SP1ICS07SubmitMisbehaviourFixture {
4141
submit_msg: Vec<u8>,
4242
}
4343

44+
struct SP1Programs {
45+
update_client: UpdateClientProgram,
46+
membership: MembershipProgram,
47+
misbehaviour: MisbehaviourProgram,
48+
uc_and_membership: UpdateClientAndMembershipProgram,
49+
}
50+
4451
/// Writes the proof data for misbehaviour to the given fixture path.
4552
#[allow(clippy::missing_errors_doc, clippy::missing_panics_doc)]
4653
pub async fn run(args: MisbehaviourCmd) -> anyhow::Result<()> {
4754
let misbehaviour: RawMisbehaviour =
4855
serde_json::from_slice(&std::fs::read(args.misbehaviour_json_path)?)?;
49-
50-
let update_client_elf = std::fs::read(args.elf_paths.update_client_path)?;
51-
let membership_elf = std::fs::read(args.elf_paths.membership_path)?;
52-
let misbehaviour_elf = std::fs::read(args.elf_paths.misbehaviour_path)?;
53-
let uc_and_membership_elf = std::fs::read(args.elf_paths.uc_and_membership_path)?;
54-
let update_client_program = UpdateClientProgram::new(update_client_elf);
55-
let membership_program = MembershipProgram::new(membership_elf);
56-
let misbehaviour_program = MisbehaviourProgram::new(misbehaviour_elf);
57-
let uc_and_membership_program = UpdateClientAndMembershipProgram::new(uc_and_membership_elf);
56+
let programs = load_sp1_programs(args.elf_paths)?;
5857

5958
let tm_rpc_client = HttpClient::from_env();
6059
let sp1_prover = if args.sp1.private_cluster {
@@ -93,28 +92,28 @@ pub async fn run(args: MisbehaviourCmd) -> anyhow::Result<()> {
9392
args.trust_options.trusting_period,
9493
args.trust_options.trust_level,
9594
args.sp1.proof_type,
96-
&update_client_program,
97-
&membership_program,
98-
&uc_and_membership_program,
99-
&misbehaviour_program,
95+
&programs.update_client,
96+
&programs.membership,
97+
&programs.uc_and_membership,
98+
&programs.misbehaviour,
10099
)
101100
.await?;
102101
let genesis_2 = SP1ICS07TendermintGenesis::from_env(
103102
&trusted_light_block_2,
104103
args.trust_options.trusting_period,
105104
args.trust_options.trust_level,
106105
args.sp1.proof_type,
107-
&update_client_program,
108-
&membership_program,
109-
&uc_and_membership_program,
110-
&misbehaviour_program,
106+
&programs.update_client,
107+
&programs.membership,
108+
&programs.uc_and_membership,
109+
&programs.misbehaviour,
111110
)
112111
.await?;
113112
let trusted_consensus_state_1 = ConsensusState::abi_decode(&genesis_1.trusted_consensus_state)?;
114113
let trusted_consensus_state_2 = ConsensusState::abi_decode(&genesis_2.trusted_consensus_state)?;
115114
let trusted_client_state_2 = ClientState::abi_decode(&genesis_2.trusted_client_state)?;
116115
let verify_misbehaviour_prover =
117-
SP1ICS07TendermintProver::new(args.sp1.proof_type, &sp1_prover, &misbehaviour_program)
116+
SP1ICS07TendermintProver::new(args.sp1.proof_type, &sp1_prover, &programs.misbehaviour)
118117
.await;
119118
let now_since_unix = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH)?;
120119
let proof_data = verify_misbehaviour_prover
@@ -143,12 +142,32 @@ pub async fn run(args: MisbehaviourCmd) -> anyhow::Result<()> {
143142
submit_msg: submit_msg.abi_encode(),
144143
};
145144

146-
match args.output_path {
145+
write_fixture(args.output_path, &fixture)?;
146+
147+
Ok(())
148+
}
149+
150+
fn load_sp1_programs(elf_paths: SP1ELFPaths) -> anyhow::Result<SP1Programs> {
151+
Ok(SP1Programs {
152+
update_client: UpdateClientProgram::new(std::fs::read(elf_paths.update_client_path)?),
153+
membership: MembershipProgram::new(std::fs::read(elf_paths.membership_path)?),
154+
misbehaviour: MisbehaviourProgram::new(std::fs::read(elf_paths.misbehaviour_path)?),
155+
uc_and_membership: UpdateClientAndMembershipProgram::new(std::fs::read(
156+
elf_paths.uc_and_membership_path,
157+
)?),
158+
})
159+
}
160+
161+
fn write_fixture(
162+
output_path: OutputPath,
163+
fixture: &SP1ICS07SubmitMisbehaviourFixture,
164+
) -> anyhow::Result<()> {
165+
match output_path {
147166
OutputPath::File(path) => {
148-
std::fs::write(PathBuf::from(path), serde_json::to_string_pretty(&fixture)?)?;
167+
std::fs::write(PathBuf::from(path), serde_json::to_string_pretty(fixture)?)?;
149168
}
150169
OutputPath::Stdout => {
151-
println!("{}", serde_json::to_string_pretty(&fixture)?);
170+
println!("{}", serde_json::to_string_pretty(fixture)?);
152171
}
153172
}
154173

programs/solana/programs/ics07-tendermint/src/instructions/pre_verify_signatures.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fn verify_ed25519_from_sysvar(
138138
}
139139

140140
#[inline]
141-
fn load_offsets(data: &[u8]) -> Offsets {
141+
const fn load_offsets(data: &[u8]) -> Offsets {
142142
Offsets {
143143
signature: u16::from_le_bytes([data[2], data[3]]) as usize,
144144
pubkey: u16::from_le_bytes([data[6], data[7]]) as usize,
@@ -155,7 +155,7 @@ struct Offsets {
155155
/// Returns `true` only when all three `*_instruction_index` fields equal
156156
/// `u16::MAX`, meaning the Ed25519 precompile reads signature, pubkey, and
157157
/// message from its own instruction data (not from another instruction).
158-
fn all_instruction_indices_inline(data: &[u8]) -> bool {
158+
const fn all_instruction_indices_inline(data: &[u8]) -> bool {
159159
let sig_ix = u16::from_le_bytes([
160160
data[ED25519_SIGNATURE_IX_INDEX_OFFSET],
161161
data[ED25519_SIGNATURE_IX_INDEX_OFFSET + 1],

0 commit comments

Comments
 (0)