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

Use Option<IpldBlock> for all message params #913

Merged
merged 8 commits into from
Dec 16, 2022
Merged

Conversation

arajasek
Copy link
Contributor

@arajasek arajasek commented Dec 5, 2022

#758 (the "params" half)

This is a mostly-manual overhaul of the system to use Option for message params, as driven by filecoin-project/ref-fvm#1199. As part of it, we start using the macros introduced in #947 for the dispatch table for all actors.

Other changes:

  • The ReceiverHooks of the account & multisig actors now explicitly receive UniversalReceiverParams, where previously they accepted anything. They will fail if called with input that isn't validly serialized UniversalReceiverParams (though the value of the UniversalReceiverParams itself doesn't matter)
  • Methods that take no input previously succeeded no matter what was passed to them. They now explicitly require "no input". The exception is Send.

@arajasek arajasek force-pushed the asr/ipld-block-master branch 4 times, most recently from 906b9ee to 9f57d96 Compare December 8, 2022 00:42
@arajasek arajasek marked this pull request as ready for review December 8, 2022 01:45
@arajasek
Copy link
Contributor Author

arajasek commented Dec 8, 2022

This is now ready for review. The GH dependencies will be dropped when the FVM PR lands, but I'd like confidence that this is the right direction before landing work in the FVM.

Copy link
Member

@anorth anorth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on, but this PR is too large to review. It's doing too many things at once, unnecessarily. I gotta put my foot down somewhere, and I'm doing it here. Please engage me on Slack or similar for discussion about why large PRs are very costly.

I've looked at about a third of this. It looks directionally fine. I can review more of it on a second pass.

A bunch of things that are not just what this PR title says should be broken out to separate PRs, to land ahead of this one.

  • Removing use of Cbor trait
  • Upgrading frc46_token with all changes except this IpldBlock change
  • Fancy but complex macros to reduce dispatch boilerplate
  • Changing send to use IpldBlock too

actors/account/tests/account_actor_test.rs Outdated Show resolved Hide resolved
@@ -71,14 +72,14 @@ pub struct Actor;

impl Actor {
/// Constructor for DataCap Actor
pub fn constructor(rt: &mut impl Runtime, governor: Address) -> Result<(), ActorError> {
pub fn constructor(rt: &mut impl Runtime, params: Address) -> Result<(), ActorError> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rename reduces clarity and doesn't seem necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I was hoping to have all methods uniformly take a single parameter named params (or no parameters at all), but I'm not fussed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think params is fine if we've wrapped in a transparent struct, so the struct member then has an informative name.

actors/datacap/src/testing.rs Outdated Show resolved Hide resolved
actors/datacap/src/testing.rs Outdated Show resolved Hide resolved
runtime/src/actor_error.rs Outdated Show resolved Hide resolved
runtime/src/dispatch.rs Outdated Show resolved Hide resolved
rust-toolchain Outdated Show resolved Hide resolved
@anorth
Copy link
Member

anorth commented Dec 11, 2022

A further suggestion to make this more manageable is to apply it to only one or two simple actors initially, while figuring out all the supporting code, then do the mechanical application to the rest at the end.

@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2022

Codecov Report

Merging #913 (d5d2212) into master (45c56ed) will increase coverage by 0.21%.
The diff coverage is 99.36%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #913      +/-   ##
==========================================
+ Coverage   88.84%   89.05%   +0.21%     
==========================================
  Files          92       92              
  Lines       19584    19320     -264     
==========================================
- Hits        17399    17206     -193     
+ Misses       2185     2114      -71     
Impacted Files Coverage Δ
actors/power/src/ext.rs 83.33% <ø> (ø)
runtime/src/actor_error.rs 81.05% <ø> (ø)
runtime/src/lib.rs 88.00% <ø> (ø)
test_vm/src/lib.rs 88.97% <93.75%> (-0.54%) ⬇️
actors/account/src/lib.rs 91.66% <100.00%> (+0.17%) ⬆️
actors/cron/src/lib.rs 94.11% <100.00%> (-2.44%) ⬇️
actors/datacap/src/lib.rs 77.82% <100.00%> (+1.26%) ⬆️
actors/init/src/lib.rs 97.87% <100.00%> (+1.57%) ⬆️
actors/market/src/lib.rs 89.74% <100.00%> (-0.26%) ⬇️
actors/miner/src/lib.rs 83.12% <100.00%> (-0.30%) ⬇️
... and 32 more

@jennijuju jennijuju linked an issue Dec 13, 2022 that may be closed by this pull request
@arajasek
Copy link
Contributor Author

Lowering to draft until pre-factors have landed and conflicts resolved

@arajasek arajasek marked this pull request as draft December 14, 2022 16:02
@arajasek arajasek force-pushed the asr/ipld-block-master branch 5 times, most recently from ad37e93 to f85ce31 Compare December 15, 2022 02:17
where
RT: Runtime,
{
// I'm trying to find a fixed template for these blocks so we can macro it.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now done!

@arajasek arajasek marked this pull request as ready for review December 15, 2022 02:31
@arajasek
Copy link
Contributor Author

Rebased.

actors/power/src/lib.rs Outdated Show resolved Hide resolved
actors/power/src/types.rs Show resolved Hide resolved
actors/reward/src/types.rs Outdated Show resolved Hide resolved
actors/verifreg/src/lib.rs Show resolved Hide resolved
runtime/src/runtime/fvm.rs Outdated Show resolved Hide resolved
actors/miner/src/lib.rs Show resolved Hide resolved
actors/miner/src/lib.rs Show resolved Hide resolved
Cargo.toml Outdated
@@ -53,6 +53,7 @@ members = [
"test_vm",
]

[patch.crates-io]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: revert

@@ -159,8 +161,14 @@ impl Actor {
}

if let Some(extra) = &sv.extra {
rt.send(&extra.actor, extra.method, extra.data.clone(), TokenAmount::zero())
.map_err(|e| e.wrap("spend voucher verification failed"))?;
// TODO: Is this the best way to handle this?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment isn't helpful. Please either explain the design issue, or remove.

@@ -68,12 +69,12 @@ pub struct Actor;

impl Actor {
/// Constructor for Registry Actor
pub fn constructor(rt: &mut impl Runtime, root_key: Address) -> Result<(), ActorError> {
pub fn constructor(rt: &mut impl Runtime, params: Address) -> Result<(), ActorError> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I don't think this rename is helpful

@@ -371,11 +372,7 @@ impl<'bs> VM<'bs> {

pub fn get_state<C: Cbor>(&self, addr: Address) -> Option<C> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-opening #700 until we remove use of Cbor here too

@@ -2168,3 +2188,60 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

[[package]]
name = "windows-sys"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is introducing windows stuff required for this PR? That's unexpected

actors/account/tests/account_actor_test.rs Show resolved Hide resolved
@@ -117,7 +128,7 @@ fn authenticate_message() {
plaintext: vec![],
result: Ok(()),
});
assert_eq!(RawBytes::default(), rt.call::<AccountActor>(3, &params).unwrap());
assert_eq!(RawBytes::default(), rt.call::<AccountActor>(3, params.clone()).unwrap());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have thought the None would carry over to the output of call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet -- returns will be a separate PR.

@@ -86,7 +87,7 @@ impl Actor {
}

/// Deposits the received value into the balance held in escrow.
fn add_balance(rt: &mut impl Runtime, provider_or_client: Address) -> Result<(), ActorError> {
fn add_balance(rt: &mut impl Runtime, params: Address) -> Result<(), ActorError> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Overall I'm not convinced standardizing params names is the best way. Not a super strong opinion though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the majority opinion, so I'm gonna revert

// TODO: when landing https://github.com/filecoin-project/builtin-actors/pull/518
// ExtendProofValidity
ExtendCommittmentLegacy,
// handle only legacy sectors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo, if you want this above a field it should be above the ExtendCommittmentLegacy field

@@ -289,7 +292,7 @@ impl Actor {

fn submit_porep_for_bulk_verify(
rt: &mut impl Runtime,
seal_info: SealVerifyInfo,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reiterating: I think it makes sense for methods to define param names that make sense in context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IPLD Block Abstraction
5 participants