From 7b22a8189e8ff82f83757c559ed57fcd97adb099 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Tue, 3 Dec 2024 14:38:08 +1100 Subject: [PATCH] fix lint errors --- .../evm/src/interpreter/instructions/call.rs | 2 +- actors/evm/src/interpreter/instructions/ext.rs | 8 ++++---- actors/evm/src/interpreter/precompiles/evm.rs | 6 +++--- actors/evm/src/interpreter/precompiles/mod.rs | 18 +++++++++--------- actors/init/tests/init_actor_test.rs | 4 ++-- actors/market/src/testing.rs | 2 +- actors/market/tests/harness.rs | 2 +- .../tests/publish_storage_deals_failures.rs | 2 +- actors/miner/tests/sector_map_test.rs | 2 +- actors/miner/tests/sector_number_allocation.rs | 2 +- actors/paych/src/types.rs | 2 +- runtime/Cargo.toml | 2 ++ runtime/src/runtime/fvm.rs | 4 ++-- runtime/src/runtime/mod.rs | 1 + vm_api/src/lib.rs | 1 + 15 files changed, 31 insertions(+), 27 deletions(-) diff --git a/actors/evm/src/interpreter/instructions/call.rs b/actors/evm/src/interpreter/instructions/call.rs index 553532e6b..37a501f42 100644 --- a/actors/evm/src/interpreter/instructions/call.rs +++ b/actors/evm/src/interpreter/instructions/call.rs @@ -291,7 +291,7 @@ pub fn call_generic( // this is how the EVM behaves. ContractType::Account | ContractType::NotFound => Ok(None), // If we're calling a "native" actor, always revert. - ContractType::Native(_) => { + ContractType::Native => { log::info!("attempted to delegatecall a native actor at {dst:?}"); Err(None) } diff --git a/actors/evm/src/interpreter/instructions/ext.rs b/actors/evm/src/interpreter/instructions/ext.rs index bd036c0eb..c89edf095 100644 --- a/actors/evm/src/interpreter/instructions/ext.rs +++ b/actors/evm/src/interpreter/instructions/ext.rs @@ -29,7 +29,7 @@ pub fn extcodesize( ContractType::EVM(addr) => { get_evm_bytecode(system, &addr).map(|bytecode| bytecode.len())? } - ContractType::Native(_) => 1, + ContractType::Native => 1, // account, not found, and precompiles are 0 size _ => 0, }; @@ -45,7 +45,7 @@ pub fn extcodehash( let addr = match get_contract_type(system.rt, &addr.into()) { ContractType::EVM(a) => a, // _Technically_ since we have native "bytecode" set as 0xfe this is valid, though we cant differentiate between different native actors. - ContractType::Native(_) => return Ok(BytecodeHash::NATIVE_ACTOR.into()), + ContractType::Native => return Ok(BytecodeHash::NATIVE_ACTOR.into()), // Precompiles "exist" and therefore aren't empty (although spec-wise they can be either 0 or keccak("") ). ContractType::Precompile => return Ok(BytecodeHash::EMPTY.into()), // NOTE: There may be accounts that in EVM would be considered "empty" (as defined in EIP-161) and give 0, but we will instead return keccak(""). @@ -94,7 +94,7 @@ pub enum ContractType { Precompile, /// EVM ID Address and the CID of the actor (not the bytecode) EVM(Address), - Native(Cid), + Native, Account, NotFound, } @@ -115,7 +115,7 @@ pub fn get_contract_type(rt: &RT, addr: &EthAddress) -> ContractTyp Some(Type::Account | Type::Placeholder | Type::EthAccount) => ContractType::Account, Some(Type::EVM) => ContractType::EVM(Address::new_id(id)), // remaining builtin actors are native - _ => ContractType::Native(cid), + _ => ContractType::Native, }) .unwrap_or(ContractType::NotFound) } diff --git a/actors/evm/src/interpreter/precompiles/evm.rs b/actors/evm/src/interpreter/precompiles/evm.rs index c38d9f1e3..b79445ebd 100644 --- a/actors/evm/src/interpreter/precompiles/evm.rs +++ b/actors/evm/src/interpreter/precompiles/evm.rs @@ -490,7 +490,7 @@ mod tests { let res = ec_add(&mut system, &input, PrecompileContext::default()); assert!(matches!( res, - Err(PrecompileError::EcErr(substrate_bn::CurveError::NotMember)) + Err(PrecompileError::EcErr) )); } @@ -595,7 +595,7 @@ mod tests { let res = ec_mul(&mut system, &input, PrecompileContext::default()); assert!(matches!( res, - Err(PrecompileError::EcErr(substrate_bn::CurveError::NotMember)) + Err(PrecompileError::EcErr) )); let input = hex::decode( @@ -680,7 +680,7 @@ mod tests { let res = ec_pairing(&mut system, &input, PrecompileContext::default()); assert!(matches!( res, - Err(PrecompileError::EcErr(substrate_bn::CurveError::NotMember)) + Err(PrecompileError::EcErr) )); // invalid input length let input = hex::decode( diff --git a/actors/evm/src/interpreter/precompiles/mod.rs b/actors/evm/src/interpreter/precompiles/mod.rs index 74625fc0f..d7aef8f8a 100644 --- a/actors/evm/src/interpreter/precompiles/mod.rs +++ b/actors/evm/src/interpreter/precompiles/mod.rs @@ -114,18 +114,18 @@ impl Precompiles { #[derive(Debug)] pub enum PrecompileError { // EVM precompile errors - EcErr(CurveError), + EcErr, IncorrectInputSize, // FVM precompile errors InvalidInput, CallForbidden, TransferFailed, - VMError(ActorError), + VMError, } impl From for PrecompileError { - fn from(e: ActorError) -> Self { - Self::VMError(e) + fn from(_: ActorError) -> Self { + Self::VMError } } impl From for PrecompileError { @@ -141,20 +141,20 @@ impl From for PrecompileError { } impl From for PrecompileError { - fn from(src: FieldError) -> Self { - PrecompileError::EcErr(src.into()) + fn from(_: FieldError) -> Self { + PrecompileError::EcErr } } impl From for PrecompileError { - fn from(src: CurveError) -> Self { - PrecompileError::EcErr(src) + fn from(_: CurveError) -> Self { + PrecompileError::EcErr } } impl From for PrecompileError { fn from(_: GroupError) -> Self { - PrecompileError::EcErr(CurveError::NotMember) + PrecompileError::EcErr } } diff --git a/actors/init/tests/init_actor_test.rs b/actors/init/tests/init_actor_test.rs index c6d123101..5bd26e75e 100644 --- a/actors/init/tests/init_actor_test.rs +++ b/actors/init/tests/init_actor_test.rs @@ -435,7 +435,7 @@ fn construct_and_verify(rt: &MockRuntime) { check_state(rt); } -fn exec_and_verify( +fn exec_and_verify( rt: &MockRuntime, code_id: Cid, params: &S, @@ -455,7 +455,7 @@ where ret.and_then(|v| v.unwrap().deserialize().map_err(|e| e.into())) } -fn exec4_and_verify( +fn exec4_and_verify( rt: &MockRuntime, namespace: ActorID, subaddr: &[u8], diff --git a/actors/market/src/testing.rs b/actors/market/src/testing.rs index aaf874d9f..ea22738d5 100644 --- a/actors/market/src/testing.rs +++ b/actors/market/src/testing.rs @@ -167,7 +167,7 @@ pub fn check_state_invariants( let deal_id: u64 = u64::decode_var(key.0.as_slice()).unwrap().0; acc.require( - proposal_stats.get(&deal_id).is_some(), + proposal_stats.contains_key(&deal_id), format!("pending deal allocation {} not found in proposals", deal_id), ); diff --git a/actors/market/tests/harness.rs b/actors/market/tests/harness.rs index f30313168..d1fc3f5f2 100644 --- a/actors/market/tests/harness.rs +++ b/actors/market/tests/harness.rs @@ -767,7 +767,7 @@ pub fn publish_deals( if deal.verified_deal { // Expect query for the client's datacap balance, just once per client. let client_id = deal.client.id().unwrap(); - if client_verified_deals.get(&client_id).is_none() { + if client_verified_deals.contains_key(&client_id) { rt.expect_send_simple( DATACAP_TOKEN_ACTOR_ADDR, ext::datacap::BALANCE_OF_METHOD, diff --git a/actors/market/tests/publish_storage_deals_failures.rs b/actors/market/tests/publish_storage_deals_failures.rs index 898fc0252..89b9d862f 100644 --- a/actors/market/tests/publish_storage_deals_failures.rs +++ b/actors/market/tests/publish_storage_deals_failures.rs @@ -392,7 +392,7 @@ fn fail_when_deals_have_different_providers() { .deserialize() .unwrap(); - let valid: Vec = psd_ret.valid_deals.bounded_iter(std::u64::MAX).unwrap().collect(); + let valid: Vec = psd_ret.valid_deals.bounded_iter(u64::MAX).unwrap().collect(); assert_eq!(vec![0], valid); rt.verify(); diff --git a/actors/miner/tests/sector_map_test.rs b/actors/miner/tests/sector_map_test.rs index 8f0e42870..823411915 100644 --- a/actors/miner/tests/sector_map_test.rs +++ b/actors/miner/tests/sector_map_test.rs @@ -55,7 +55,7 @@ fn create_deadline_sector_map( } fn create_bitfield_sequence(start: u64, end: u64) -> BitField { - let ranges = vec![Range { start, end }]; + let ranges = [Range { start, end }]; let ranges = Ranges::new(ranges.iter().cloned()); BitField::from_ranges(ranges) } diff --git a/actors/miner/tests/sector_number_allocation.rs b/actors/miner/tests/sector_number_allocation.rs index f892f74f7..fc07ade1f 100644 --- a/actors/miner/tests/sector_number_allocation.rs +++ b/actors/miner/tests/sector_number_allocation.rs @@ -89,7 +89,7 @@ mod sector_number_allocation { // Allocate widely-spaced numbers to consume the run-length encoded bytes quickly, // until the limit is reached. let mut limit_reached = false; - for i in 0..std::u64::MAX { + for i in 0..u64::MAX { let (number, _) = (i + 1).overflowing_shl(50); let res = h.allocate_sector_numbers(&[number]); if res.is_err() { diff --git a/actors/paych/src/types.rs b/actors/paych/src/types.rs index 06ef530c4..1fcc7949e 100644 --- a/actors/paych/src/types.rs +++ b/actors/paych/src/types.rs @@ -13,7 +13,7 @@ use fvm_shared::MethodNum; use super::Merge; /// Maximum number of lanes in a channel -pub const MAX_LANE: u64 = std::i64::MAX as u64; +pub const MAX_LANE: u64 = i64::MAX as u64; pub const SETTLE_DELAY: ChainEpoch = EPOCHS_IN_HOUR * 12; diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 265aa940c..b828ce5f8 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -86,6 +86,8 @@ short-precommit = [] min-power-2k = [] # Lower the minimum power requirement to 2g min-power-2g = [] +# Lower the minimum power requirement to 32g +min-power-32g = [] # no collateral for deals (for testing) no-provider-deal-collateral = [] diff --git a/runtime/src/runtime/fvm.rs b/runtime/src/runtime/fvm.rs index d4bc5562e..a2e2af4a1 100644 --- a/runtime/src/runtime/fvm.rs +++ b/runtime/src/runtime/fvm.rs @@ -573,8 +573,8 @@ where /// 2. Obtains the method number for the invocation. /// 3. Creates an FVM runtime shim. /// 4. Invokes the target method. -/// 5a. In case of error, aborts the execution with the emitted exit code, or -/// 5b. In case of success, stores the return data as a block and returns the latter. +/// 5. (a) In case of error, aborts the execution with the emitted exit code, or +/// 5. (b) In case of success, stores the return data as a block and returns the latter. pub fn trampoline(params: u32) -> u32 { init_logging(C::name()); diff --git a/runtime/src/runtime/mod.rs b/runtime/src/runtime/mod.rs index 34bc5f2e5..64e1b0a43 100644 --- a/runtime/src/runtime/mod.rs +++ b/runtime/src/runtime/mod.rs @@ -227,6 +227,7 @@ pub trait Runtime: Primitives + RuntimePolicy { /// The circulating supply is the sum of: /// - rewards emitted by the reward actor, /// - funds vested from lock-ups in the genesis state, + /// /// less the sum of: /// - funds burnt, /// - pledge collateral locked in storage miner actors (recorded in the storage power actor) diff --git a/vm_api/src/lib.rs b/vm_api/src/lib.rs index 1b9f833e6..c9e9973f0 100644 --- a/vm_api/src/lib.rs +++ b/vm_api/src/lib.rs @@ -190,6 +190,7 @@ pub trait Primitives { /// - first header is of the same or lower epoch as the second /// - at least one of the headers appears in the current chain at or after epoch `earliest` /// - the headers provide evidence of a fault (see the spec for the different fault types). + /// /// The parameters are all serialized block headers. The third "extra" parameter is consulted only for /// the "parent grinding fault", in which case it must be the sibling of h1 (same parent tipset) and one of the /// blocks in the parent of h2 (i.e. h2's grandparent).