Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove check for empty_params #1079

Merged
merged 2 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions vm/actor/src/builtin/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)?)
}
Expand Down
3 changes: 1 addition & 2 deletions vm/actor/src/builtin/cron/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
}
Expand Down
4 changes: 1 addition & 3 deletions vm/actor/src/builtin/market/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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())
}
Expand Down Expand Up @@ -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())
}
Expand Down
9 changes: 3 additions & 6 deletions vm/actor/src/builtin/miner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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)?)
}
Expand Down Expand Up @@ -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())
}
Expand Down
7 changes: 1 addition & 6 deletions vm/actor/src/builtin/paych/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
}
Expand Down
7 changes: 2 additions & 5 deletions vm/actor/src/builtin/power/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
}
Expand All @@ -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())
}
Expand All @@ -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)?)
}
Expand Down
5 changes: 1 addition & 4 deletions vm/actor/src/builtin/reward/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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)?)
}
Expand Down
5 changes: 2 additions & 3 deletions vm/actor/src/builtin/system/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -46,15 +46,14 @@ impl ActorCode for Actor {
fn invoke_method<BS, RT>(
rt: &mut RT,
method: MethodNum,
params: &Serialized,
_params: &Serialized,
) -> Result<Serialized, ActorError>
where
BS: BlockStore,
RT: Runtime<BS>,
{
match FromPrimitive::from_u64(method) {
Some(Method::Constructor) => {
check_empty_params(params)?;
Self::constructor(rt)?;
Ok(Serialized::default())
}
Expand Down
10 changes: 0 additions & 10 deletions vm/actor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BS, V>(store: &'_ BS, bitwidth: u32) -> Map<'_, BS, V>
Expand Down