Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Dec 4, 2024
1 parent ba7d8d5 commit 7b22a81
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion actors/evm/src/interpreter/instructions/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ pub fn call_generic<RT: Runtime>(
// 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)
}
Expand Down
8 changes: 4 additions & 4 deletions actors/evm/src/interpreter/instructions/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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("").
Expand Down Expand Up @@ -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,
}
Expand All @@ -115,7 +115,7 @@ pub fn get_contract_type<RT: Runtime>(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)
}
Expand Down
6 changes: 3 additions & 3 deletions actors/evm/src/interpreter/precompiles/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
));
}

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
18 changes: 9 additions & 9 deletions actors/evm/src/interpreter/precompiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@ impl<RT: Runtime> Precompiles<RT> {
#[derive(Debug)]
pub enum PrecompileError {
// EVM precompile errors
EcErr(CurveError),
EcErr,
IncorrectInputSize,
// FVM precompile errors
InvalidInput,
CallForbidden,
TransferFailed,
VMError(ActorError),
VMError,
}

impl From<ActorError> for PrecompileError {
fn from(e: ActorError) -> Self {
Self::VMError(e)
fn from(_: ActorError) -> Self {
Self::VMError
}
}
impl From<TryFromIntError> for PrecompileError {
Expand All @@ -141,20 +141,20 @@ impl From<OverflowError> for PrecompileError {
}

impl From<FieldError> for PrecompileError {
fn from(src: FieldError) -> Self {
PrecompileError::EcErr(src.into())
fn from(_: FieldError) -> Self {
PrecompileError::EcErr
}
}

impl From<CurveError> for PrecompileError {
fn from(src: CurveError) -> Self {
PrecompileError::EcErr(src)
fn from(_: CurveError) -> Self {
PrecompileError::EcErr
}
}

impl From<GroupError> for PrecompileError {
fn from(_: GroupError) -> Self {
PrecompileError::EcErr(CurveError::NotMember)
PrecompileError::EcErr
}
}

Expand Down
4 changes: 2 additions & 2 deletions actors/init/tests/init_actor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ fn construct_and_verify(rt: &MockRuntime) {
check_state(rt);
}

fn exec_and_verify<S: Serialize>(
fn exec_and_verify<S>(
rt: &MockRuntime,
code_id: Cid,
params: &S,
Expand All @@ -455,7 +455,7 @@ where
ret.and_then(|v| v.unwrap().deserialize().map_err(|e| e.into()))
}

fn exec4_and_verify<S: Serialize>(
fn exec4_and_verify<S>(
rt: &MockRuntime,
namespace: ActorID,
subaddr: &[u8],
Expand Down
2 changes: 1 addition & 1 deletion actors/market/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub fn check_state_invariants<BS: Blockstore>(
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),
);

Expand Down
2 changes: 1 addition & 1 deletion actors/market/tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion actors/market/tests/publish_storage_deals_failures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ fn fail_when_deals_have_different_providers() {
.deserialize()
.unwrap();

let valid: Vec<u64> = psd_ret.valid_deals.bounded_iter(std::u64::MAX).unwrap().collect();
let valid: Vec<u64> = psd_ret.valid_deals.bounded_iter(u64::MAX).unwrap().collect();
assert_eq!(vec![0], valid);

rt.verify();
Expand Down
2 changes: 1 addition & 1 deletion actors/miner/tests/sector_map_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion actors/miner/tests/sector_number_allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion actors/paych/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/runtime/fvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<C: ActorCode>(params: u32) -> u32 {
init_logging(C::name());

Expand Down
1 change: 1 addition & 0 deletions runtime/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions vm_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 7b22a81

Please sign in to comment.