-
Notifications
You must be signed in to change notification settings - Fork 83
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
Land Builtin actors API MVP into next #850
Conversation
13a9860
to
8b4cae8
Compare
e825d3a
to
a0e4d75
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## next #850 +/- ##
===========================================
- Coverage 87.10% 74.54% -12.56%
===========================================
Files 126 127 +1
Lines 23278 25940 +2662
===========================================
- Hits 20276 19338 -938
- Misses 3002 6602 +3600
|
a0e4d75
to
3ec10ab
Compare
Rebased. |
3ec10ab
to
52fe937
Compare
750eb93
to
708794d
Compare
Rebased |
406ec0e
to
6f2b62b
Compare
1a434b4
to
2404990
Compare
Rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I either reviewed or authored all of this when it first landed in integration/builtin-api
, so my review here was fairly cursory.
After landing, we should figure out if the EVM actors should also have restrict_internal_api
on invoke.
format!("failed to load deal state {}", id) | ||
})?; | ||
Ok(found.cloned()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @anorth, will pick it up.
impl Cbor for GetAvailableBalanceReturn {} | ||
|
||
#[derive(Serialize_tuple, Deserialize_tuple)] | ||
pub struct GetVestingFundsReturn { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want #[serde(transparent)]
here too? Also for GetPeerIDReturn and GetMultiaddrsReturn.
I suggest fixing with a PR to the source branch here, then propagating to next
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack for PeerID/Multiaddrs.
I don't see logic for complexity of the single embedded object being a deciding factor about whether to wrap it in a tuple or not, tho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, the logic is entirely about consistency with existing types (cf. ComputeDataCommitmentReturn).
rt.verify(); | ||
|
||
// Ok to call exported method number | ||
rt.expect_validate_caller_any(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks redundant with 113 and on now that we made that part of the test use the exported method
@@ -469,51 +485,51 @@ impl ActorCode for Actor { | |||
let ret = Self::destroy(rt, cbor::deserialize_params(params)?)?; | |||
serialize(&ret, "destroy result") | |||
} | |||
Some(Method::Name) => { | |||
Some(Method::Name) | Some(Method::NameExported) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we keeping the non-exported method numbers active?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a policy decision that built-in actors only call other built-in actors through their internal method numbers? If that's the case, I think it makes sense for uniformity, as otherwise we would see calls to exported and internal method sprinkled over this codebase. However, it might be a usability nit for explorers and other tooling to have two method numbers associated with the same exact behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Deal message must have a From field identical to the provider of all the deals. | ||
// This allows us to retain and verify only the client's signature in each deal proposal itself. | ||
rt.validate_immediate_caller_type(CALLER_TYPES_SIGNABLE.iter())?; | ||
rt.validate_immediate_caller_accept_any()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double checking here: the implicit assumption with exposing this is that miner control addresses will be contracts because the caller is constrained to be a miner control address. I want to make sure we are communicating this requirement well because it might be unexpected for users who want to use the storage market. It's possible this is too confusing and we might want to keep PSD from being exported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, i think you're right, and the suggestion to externalize this information is well-taken. This method now can be called by non-builtin actors, but those actors must still be control addresses.
* Export Datacap Actor methods * Export Init Actor methods * Export Market Actor methods * Export Miner Actor methods * Export Multisig Actor methods * Export Verifreg Actor methods * Address review
* Power actor: Add exported getters for raw power * FRC-XXXX is FRC-0042 * Power actor: network_raw_power: Return this_epoch_raw_byte_power * Power actor: miner_raw_power: Return whether above consensus min power * Power actor: types: serialize one-element structs transparently * Address review * Miner actor: Add exported getters for info and monies (#811) * Miner actor: Add exported getters for info and monies * Tweak comment * Miner actor: Replace GetWorker and GetControls with IsControllingAddress * Miner actor: Add exported GetAvailableBalance * Miner actor: Add exported GetVestingFunds * Miner actor: Remove exported monies getters * Miner actor: types: serialize one-element structs transparently * Address review * Address review
Co-authored-by: zenground0 <[email protected]>
* Market actor: GetDealTermExported: Return (start_epoch, duration) * Market actor: Export getter for deal total price
…#824) * Paych actor: Drop account req, use AuthenticateMessage to verify sigs * Address review * Address review
* Miner: Export ChangeWorkerAddress * Miner: Export ChangePeerID * Miner: Export WithdrawBalance * Miner: Export ChangeMultiaddrs * Miner: Export ConfirmUpdateWorkerKey * Miner: Export RepayDebt * Miner: Export ChangeOwnerAddress * Miner: Add exported getters for PeerID & multiaddrs * Miner: Refactor: Rename ConfirmUpdateWorkerKey to ConfirmChangeWorkerAddress
* Power: Export CreateMiner * Power Actor: Export MinerCount and MinerConsensusCount * Update actors/power/src/lib.rs Co-authored-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]>
* Verifreg: Rename AddVerifierClientParams to AddVerifiedClientParams * Verifreg: Export AddVerifiedClient and GetClaims
2404990
to
d0097ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't get to all.
@@ -469,51 +485,51 @@ impl ActorCode for Actor { | |||
let ret = Self::destroy(rt, cbor::deserialize_params(params)?)?; | |||
serialize(&ret, "destroy result") | |||
} | |||
Some(Method::Name) => { | |||
Some(Method::Name) | Some(Method::NameExported) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a policy decision that built-in actors only call other built-in actors through their internal method numbers? If that's the case, I think it makes sense for uniformity, as otherwise we would see calls to exported and internal method sprinkled over this codebase. However, it might be a usability nit for explorers and other tooling to have two method numbers associated with the same exact behaviour.
match FromPrimitive::from_u64(method) { | ||
Some(Method::Constructor) => { | ||
Self::constructor(rt, cbor::deserialize_params(params)?)?; | ||
Ok(RawBytes::default()) | ||
} | ||
Some(Method::Exec) => { | ||
Some(Method::Exec) | Some(Method::ExecExported) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arajasek this is going to require changes in JSON-RPC and CLIs in Lotus. Are we tracking those?
#[test] | ||
fn change_owner_address_restricted_correctly() { | ||
let (h, mut rt) = setup(); | ||
|
||
let params = &RawBytes::serialize(NEW_ADDRESS).unwrap(); | ||
rt.set_caller(make_identity_cid(b"1234"), h.owner); | ||
|
||
// fail to call the unexported method | ||
|
||
expect_abort_contains_message( | ||
ExitCode::USR_FORBIDDEN, | ||
"must be built-in", | ||
rt.call::<Actor>(Method::ChangeOwnerAddress as u64, params), | ||
); | ||
|
||
// can call the exported method | ||
|
||
rt.expect_validate_caller_addr(vec![h.owner]); | ||
rt.call::<Actor>(Method::ChangeOwnerAddressExported as u64, params).unwrap(); | ||
|
||
rt.verify(); | ||
|
||
let info = h.get_info(&rt); | ||
assert_eq!(h.owner, info.owner); | ||
assert_eq!(NEW_ADDRESS, info.pending_owner_address.unwrap()); | ||
|
||
// new owner can also call the exported method | ||
|
||
rt.expect_validate_caller_addr(vec![NEW_ADDRESS]); | ||
rt.set_caller(make_identity_cid(b"1234"), NEW_ADDRESS); | ||
rt.call::<Actor>(Method::ChangeOwnerAddressExported as u64, params).unwrap(); | ||
|
||
rt.verify(); | ||
let info = h.get_info(&rt); | ||
assert_eq!(NEW_ADDRESS, info.owner); | ||
assert_eq!(NEW_ADDRESS, info.beneficiary); | ||
assert!(info.pending_owner_address.is_none()); | ||
|
||
h.check_state(&rt); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be some common boilerplate to these tests. Would recommend factoring that out.
The integration/builtin-api will stay, but will remain on top of
master