From 8b735e7f398017376af523102ceccd292fc0dceb Mon Sep 17 00:00:00 2001 From: Eric Tu Date: Wed, 21 Apr 2021 09:17:46 -0400 Subject: [PATCH] remove check for empty_params --- vm/actor/src/builtin/account/mod.rs | 3 +-- vm/actor/src/builtin/cron/mod.rs | 3 +-- vm/actor/src/builtin/market/mod.rs | 4 +--- vm/actor/src/builtin/miner/mod.rs | 9 +++------ vm/actor/src/builtin/paych/mod.rs | 7 +------ vm/actor/src/builtin/power/mod.rs | 7 ++----- vm/actor/src/builtin/reward/mod.rs | 5 +---- vm/actor/src/builtin/system/mod.rs | 5 ++--- vm/actor/src/lib.rs | 10 ---------- 9 files changed, 12 insertions(+), 41 deletions(-) diff --git a/vm/actor/src/builtin/account/mod.rs b/vm/actor/src/builtin/account/mod.rs index 1d37ca6d7c1e..bfa243e785ee 100644 --- a/vm/actor/src/builtin/account/mod.rs +++ b/vm/actor/src/builtin/account/mod.rs @@ -4,7 +4,7 @@ mod state; pub use self::state::State; -use crate::{builtin::singletons::SYSTEM_ACTOR_ADDR, check_empty_params}; +use crate::builtin::singletons::SYSTEM_ACTOR_ADDR; use address::{Address, Protocol}; use ipld_blockstore::BlockStore; use num_derive::FromPrimitive; @@ -71,7 +71,6 @@ impl ActorCode for Actor { Ok(Serialized::default()) } Some(Method::PubkeyAddress) => { - check_empty_params(params)?; let addr = Self::pubkey_address(rt)?; Ok(Serialized::serialize(addr)?) } diff --git a/vm/actor/src/builtin/cron/mod.rs b/vm/actor/src/builtin/cron/mod.rs index 31395c10a5ab..3439e010f319 100644 --- a/vm/actor/src/builtin/cron/mod.rs +++ b/vm/actor/src/builtin/cron/mod.rs @@ -4,7 +4,7 @@ mod state; pub use self::state::{Entry, State}; -use crate::{check_empty_params, SYSTEM_ACTOR_ADDR}; +use crate::SYSTEM_ACTOR_ADDR; use encoding::tuple::*; use ipld_blockstore::BlockStore; use num_derive::FromPrimitive; @@ -87,7 +87,6 @@ impl ActorCode for Actor { Ok(Serialized::default()) } Some(Method::EpochTick) => { - check_empty_params(params)?; Self::epoch_tick(rt)?; Ok(Serialized::default()) } diff --git a/vm/actor/src/builtin/market/mod.rs b/vm/actor/src/builtin/market/mod.rs index 63a4cb539a67..abf97920b0d1 100644 --- a/vm/actor/src/builtin/market/mod.rs +++ b/vm/actor/src/builtin/market/mod.rs @@ -11,7 +11,7 @@ use self::policy::*; pub use self::state::*; pub use self::types::*; use crate::{ - check_empty_params, power, request_miner_control_addrs, reward, + power, request_miner_control_addrs, reward, verifreg::{Method as VerifregMethod, RestoreBytesParams, UseBytesParams}, ActorDowncast, DealID, BURNT_FUNDS_ACTOR_ADDR, CALLER_TYPES_SIGNABLE, CRON_ACTOR_ADDR, MINER_ACTOR_CODE_ID, REWARD_ACTOR_ADDR, STORAGE_POWER_ACTOR_ADDR, SYSTEM_ACTOR_ADDR, @@ -1355,7 +1355,6 @@ impl ActorCode for Actor { { match FromPrimitive::from_u64(method) { Some(Method::Constructor) => { - check_empty_params(params)?; Self::constructor(rt)?; Ok(Serialized::default()) } @@ -1388,7 +1387,6 @@ impl ActorCode for Actor { Ok(Serialized::serialize(res)?) } Some(Method::CronTick) => { - check_empty_params(params)?; Self::cron_tick(rt)?; Ok(Serialized::default()) } diff --git a/vm/actor/src/builtin/miner/mod.rs b/vm/actor/src/builtin/miner/mod.rs index a7dc80b039d7..13459e7638d5 100644 --- a/vm/actor/src/builtin/miner/mod.rs +++ b/vm/actor/src/builtin/miner/mod.rs @@ -40,9 +40,9 @@ use crate::{ power::MAX_MINER_PROVE_COMMITS_PER_EPOCH, }; use crate::{ - check_empty_params, is_principal, smooth::FilterEstimate, ACCOUNT_ACTOR_CODE_ID, - BURNT_FUNDS_ACTOR_ADDR, CALLER_TYPES_SIGNABLE, INIT_ACTOR_ADDR, REWARD_ACTOR_ADDR, - STORAGE_MARKET_ACTOR_ADDR, STORAGE_POWER_ACTOR_ADDR, + is_principal, smooth::FilterEstimate, ACCOUNT_ACTOR_CODE_ID, BURNT_FUNDS_ACTOR_ADDR, + CALLER_TYPES_SIGNABLE, INIT_ACTOR_ADDR, REWARD_ACTOR_ADDR, STORAGE_MARKET_ACTOR_ADDR, + STORAGE_POWER_ACTOR_ADDR, }; use crate::{ market::{ @@ -4058,7 +4058,6 @@ impl ActorCode for Actor { Ok(Serialized::default()) } Some(Method::ControlAddresses) => { - check_empty_params(params)?; let res = Self::control_addresses(rt)?; Ok(Serialized::serialize(&res)?) } @@ -4135,12 +4134,10 @@ impl ActorCode for Actor { Ok(Serialized::default()) } Some(Method::ConfirmUpdateWorkerKey) => { - check_empty_params(params)?; Self::confirm_update_worker_key(rt)?; Ok(Serialized::default()) } Some(Method::RepayDebt) => { - check_empty_params(params)?; Self::repay_debt(rt)?; Ok(Serialized::default()) } diff --git a/vm/actor/src/builtin/paych/mod.rs b/vm/actor/src/builtin/paych/mod.rs index 1f815b6e4aa0..9adcac326b79 100644 --- a/vm/actor/src/builtin/paych/mod.rs +++ b/vm/actor/src/builtin/paych/mod.rs @@ -6,10 +6,7 @@ mod types; pub use self::state::{LaneState, Merge, State}; pub use self::types::*; -use crate::{ - check_empty_params, resolve_to_id_addr, ActorDowncast, ACCOUNT_ACTOR_CODE_ID, - INIT_ACTOR_CODE_ID, -}; +use crate::{resolve_to_id_addr, ActorDowncast, ACCOUNT_ACTOR_CODE_ID, INIT_ACTOR_CODE_ID}; use address::Address; use ipld_amt::Amt; use ipld_blockstore::BlockStore; @@ -372,12 +369,10 @@ impl ActorCode for Actor { Ok(Serialized::default()) } Some(Method::Settle) => { - check_empty_params(params)?; Self::settle(rt)?; Ok(Serialized::default()) } Some(Method::Collect) => { - check_empty_params(params)?; Self::collect(rt)?; Ok(Serialized::default()) } diff --git a/vm/actor/src/builtin/power/mod.rs b/vm/actor/src/builtin/power/mod.rs index 0704d54e2381..e224bfc87295 100644 --- a/vm/actor/src/builtin/power/mod.rs +++ b/vm/actor/src/builtin/power/mod.rs @@ -10,8 +10,8 @@ pub use self::state::*; pub use self::types::*; use crate::miner::MinerConstructorParams; use crate::{ - check_empty_params, init, miner, ActorDowncast, Multimap, CALLER_TYPES_SIGNABLE, - CRON_ACTOR_ADDR, INIT_ACTOR_ADDR, MINER_ACTOR_CODE_ID, REWARD_ACTOR_ADDR, SYSTEM_ACTOR_ADDR, + init, miner, ActorDowncast, Multimap, CALLER_TYPES_SIGNABLE, CRON_ACTOR_ADDR, INIT_ACTOR_ADDR, + MINER_ACTOR_CODE_ID, REWARD_ACTOR_ADDR, SYSTEM_ACTOR_ADDR, }; use crate::{make_map_with_root_and_bitwidth, reward::Method as RewardMethod}; use address::Address; @@ -621,7 +621,6 @@ impl ActorCode for Actor { { match FromPrimitive::from_u64(method) { Some(Method::Constructor) => { - check_empty_params(params)?; Self::constructor(rt)?; Ok(Serialized::default()) } @@ -638,7 +637,6 @@ impl ActorCode for Actor { Ok(Serialized::default()) } Some(Method::OnEpochTickEnd) => { - check_empty_params(params)?; Self::on_epoch_tick_end(rt)?; Ok(Serialized::default()) } @@ -652,7 +650,6 @@ impl ActorCode for Actor { Ok(Serialized::default()) } Some(Method::CurrentTotalPower) => { - check_empty_params(params)?; let res = Self::current_total_power(rt)?; Ok(Serialized::serialize(res)?) } diff --git a/vm/actor/src/builtin/reward/mod.rs b/vm/actor/src/builtin/reward/mod.rs index 01e7f070d6a2..897da76a82fd 100644 --- a/vm/actor/src/builtin/reward/mod.rs +++ b/vm/actor/src/builtin/reward/mod.rs @@ -10,9 +10,7 @@ pub use self::logic::*; pub use self::state::{Reward, State, VestingFunction}; pub use self::types::*; use crate::network::EXPECTED_LEADERS_PER_EPOCH; -use crate::{ - check_empty_params, miner, BURNT_FUNDS_ACTOR_ADDR, STORAGE_POWER_ACTOR_ADDR, SYSTEM_ACTOR_ADDR, -}; +use crate::{miner, BURNT_FUNDS_ACTOR_ADDR, STORAGE_POWER_ACTOR_ADDR, SYSTEM_ACTOR_ADDR}; use fil_types::StoragePower; use ipld_blockstore::BlockStore; use log::{error, warn}; @@ -261,7 +259,6 @@ impl ActorCode for Actor { Ok(Serialized::default()) } Some(Method::ThisEpochReward) => { - check_empty_params(params)?; let res = Self::this_epoch_reward(rt)?; Ok(Serialized::serialize(&res)?) } diff --git a/vm/actor/src/builtin/system/mod.rs b/vm/actor/src/builtin/system/mod.rs index 7403e1522b61..96359649290e 100644 --- a/vm/actor/src/builtin/system/mod.rs +++ b/vm/actor/src/builtin/system/mod.rs @@ -1,7 +1,7 @@ // Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT -use crate::{check_empty_params, SYSTEM_ACTOR_ADDR}; +use crate::SYSTEM_ACTOR_ADDR; use encoding::Cbor; use ipld_blockstore::BlockStore; @@ -46,7 +46,7 @@ impl ActorCode for Actor { fn invoke_method( rt: &mut RT, method: MethodNum, - params: &Serialized, + _params: &Serialized, ) -> Result where BS: BlockStore, @@ -54,7 +54,6 @@ impl ActorCode for Actor { { match FromPrimitive::from_u64(method) { Some(Method::Constructor) => { - check_empty_params(params)?; Self::constructor(rt)?; Ok(Serialized::default()) } diff --git a/vm/actor/src/lib.rs b/vm/actor/src/lib.rs index 4465e7229117..c2013972abcd 100644 --- a/vm/actor/src/lib.rs +++ b/vm/actor/src/lib.rs @@ -33,16 +33,6 @@ pub type Map<'bs, BS, V> = Hamt<'bs, BS, V, BytesKey>; /// Deal weight pub type DealWeight = BigInt; -/// Used when invocation requires parameters to be an empty array of bytes -pub fn check_empty_params(params: &Serialized) -> Result<(), ActorError> { - if !params.is_empty() { - Err(actor_error!(ErrSerialization; - "params expected to be empty, was: {}", base64::encode(params.bytes()))) - } else { - Ok(()) - } -} - /// Create a hamt with a custom bitwidth. #[inline] pub fn make_empty_map(store: &'_ BS, bitwidth: u32) -> Map<'_, BS, V>