Skip to content

Multisig: Do not export any functionality #967

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

Merged
merged 1 commit into from
Dec 19, 2022
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
37 changes: 10 additions & 27 deletions actors/multisig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ pub enum Method {
ChangeNumApprovalsThreshold = 8,
LockBalance = 9,
// Method numbers derived from FRC-0042 standards
ProposeExported = frc42_dispatch::method_hash!("Propose"),
ApproveExported = frc42_dispatch::method_hash!("Approve"),
CancelExported = frc42_dispatch::method_hash!("Cancel"),
AddSignerExported = frc42_dispatch::method_hash!("AddSigner"),
RemoveSignerExported = frc42_dispatch::method_hash!("RemoveSigner"),
SwapSignerExported = frc42_dispatch::method_hash!("SwapSigner"),
ChangeNumApprovalsThresholdExported =
frc42_dispatch::method_hash!("ChangeNumApprovalsThreshold"),
LockBalanceExported = frc42_dispatch::method_hash!("LockBalance"),
UniversalReceiverHook = frc42_dispatch::method_hash!("Receive"),
}

Expand Down Expand Up @@ -562,23 +553,15 @@ pub fn compute_proposal_hash(txn: &Transaction, sys: &dyn Primitives) -> anyhow:
impl ActorCode for Actor {
type Methods = Method;
actor_dispatch! {
Constructor => constructor,
Propose => propose,
ProposeExported => propose,
Approve => approve,
ApproveExported => approve,
Cancel => cancel,
CancelExported => cancel,
AddSigner => add_signer,
AddSignerExported => add_signer,
RemoveSigner => remove_signer,
RemoveSignerExported => remove_signer,
SwapSigner => swap_signer,
SwapSignerExported => swap_signer,
ChangeNumApprovalsThreshold => change_num_approvals_threshold,
ChangeNumApprovalsThresholdExported => change_num_approvals_threshold,
Constructor => constructor,
Propose => propose,
Approve => approve,
Cancel => cancel,
AddSigner => add_signer,
RemoveSigner => remove_signer,
SwapSigner => swap_signer,
ChangeNumApprovalsThreshold => change_num_approvals_threshold,
LockBalance => lock_balance,
LockBalanceExported => lock_balance,
UniversalReceiverHook => universal_receiver_hook,
}
UniversalReceiverHook => universal_receiver_hook,
}
}
50 changes: 3 additions & 47 deletions actors/multisig/tests/multisig_actor_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use fil_actor_multisig::testing::check_state_invariants;
use fil_actor_multisig::{
compute_proposal_hash, Actor as MultisigActor, ConstructorParams, Method, ProposeParams,
ProposeReturn, State, Transaction, TxnID, TxnIDParams, SIGNERS_MAX,
compute_proposal_hash, Actor as MultisigActor, ConstructorParams, Method, ProposeReturn, State,
Transaction, TxnID, TxnIDParams, SIGNERS_MAX,
};
use fil_actors_runtime::cbor::serialize;
use fil_actors_runtime::runtime::Runtime;
Expand Down Expand Up @@ -123,7 +123,7 @@ mod constructor_tests {
RawBytes::default(),
rt.call::<MultisigActor>(
Method::Constructor as u64,
IpldBlock::serialize_cbor(&params).unwrap()
IpldBlock::serialize_cbor(&params).unwrap(),
)
.unwrap()
);
Expand Down Expand Up @@ -748,50 +748,6 @@ fn test_fail_propose_from_non_signer() {
check_state(&rt);
}

#[test]
fn test_propose_restricted_correctly() {
let msig = Address::new_id(1000);
let mut rt = construct_runtime(msig);
let h = util::ActorHarness::new();

let anne = Address::new_id(101);
// We will treat Bob as having code CID b"102"
let bob = Address::new_id(102);
let chuck = Address::new_id(103);
let no_unlock_duration = 0;
let start_epoch = 0;
let signers = vec![anne, bob];

let send_value = TokenAmount::from_atto(10u8);
h.construct_and_verify(&mut rt, 2, no_unlock_duration, start_epoch, signers);

// set caller to not-builtin
rt.set_caller(make_identity_cid(b"102"), Address::new_id(102));
let propose_params = IpldBlock::serialize_cbor(&ProposeParams {
to: chuck,
value: send_value,
method: METHOD_SEND,
params: RawBytes::default(),
})
.unwrap();

// cannot call the unexported method num

expect_abort_contains_message(
ExitCode::USR_FORBIDDEN,
"must be built-in",
rt.call::<MultisigActor>(Method::Propose as u64, propose_params.clone()),
);

rt.verify();

// can call the exported method num
rt.expect_validate_caller_any();
rt.call::<MultisigActor>(Method::ProposeExported as u64, propose_params).unwrap();

rt.verify();
}

// AddSigner
#[test]
fn test_add_signer() {
Expand Down