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

[FIP-0034]Switch to Constant PCD, add CommD to PreCommit state #484

Merged
merged 20 commits into from
Aug 4, 2022

Conversation

Kubuxu
Copy link
Contributor

@Kubuxu Kubuxu commented Jun 20, 2022

Implements FIP-0034. Closes #421.

@Kubuxu Kubuxu force-pushed the feat/stable-pcd branch from b4366da to 302f46b Compare June 22, 2022 15:46
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.

I realise we forgot to address the design for ProveReplicaUpdate in the FIP and you ran into it here. However I think we can do it better, and retain the design described in the FIP of dropping the deal weights from VerifyDealsForActivation and the PreCommitOnChainInfo.

Thinking about interactions with the market ideally, for the pre/prove commit flow I think we want:

  • A call from pre-commit that validates deals and computes CommD (but not weight)
  • A call from prove-commit that activates the deals and returns weight

The ideal for replica update would be a single call that does both of the above. However, simply making those same two calls in order would achieve the same. Batching the activation would be a further improvement.

The existing code in prove_replica_update is not very well factored, and makes those two calls in the opposite order. But the deal weight could still be moved to the activation call, as the FIP describes.

My sense is that you attempted to minimise the complexity of the change from the status quo. I suggest instead that we should strive to minimise the complexity of the end result code, which will be the subject of future changes.

On a style/structure note, the flows with SectorPreCommitInfoInner etc are quite complex. I think they emerge from attempting to get each of the entry point methods to converge on a single implementation, which then has to deal with tri-state CommD. An alternative would be to factor that inner implementation into smaller methods and then orchestrate those smaller methods from the entry points. This should move the handling for zero/unknown CommD into only the entry points where it's possible. I think having some code in those entry points would be fine if it's just straight line sequencing of smaller methods, plus the CommD handling specific to each one.

/// Information stored on-chain for a pre-committed sector.
#[derive(Debug, PartialEq, Clone, Serialize_tuple, Deserialize_tuple)]
pub struct SectorPreCommitOnChainInfo2 {
Copy link
Member

Choose a reason for hiding this comment

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

We should be able to change the existing type rather than create a new one. I understand the old one should be un-used in the new code. We'll need both only in migration code.

I'm guessing you ran into the unfortunate re-use of SectorPreCommitInfo as both state type and the exported parameter type. We should fix this by redefining PreCommitSectorParams to be a copy of the state type rather than identified with 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.

I left the old state affecting types as they are because I don't know what is the migration flow for FVM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we are sure that they are not needed, I can remove them and run a refactor.

@Kubuxu
Copy link
Contributor Author

Kubuxu commented Jun 28, 2022

I've moved deal weights to activation, added some docs, and removed the usage of From/Into for the PreCommitParams wrapping.

@Kubuxu
Copy link
Contributor Author

Kubuxu commented Jun 28, 2022

I also added the ReplicaUpdate changes.

@Kubuxu
Copy link
Contributor Author

Kubuxu commented Jun 29, 2022

  • dropping out the v2 entry point
  • tristate for ReplicaUpdate
  • ComputeCommD delete

@Kubuxu Kubuxu closed this Jun 29, 2022
@Kubuxu Kubuxu reopened this Jun 29, 2022
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.

Looking good, much cleaner. I didn't review the tests in depth. After those few items we discussed and the tests passing, let's also ask Zen to review.

deal_ids: spci.deal_ids,
expiration: spci.expiration,

unsealed_cid: CommDState::Unknown,
Copy link
Member

Choose a reason for hiding this comment

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

Add explanatory comment.
"This entry point computes the unsealed CID from deals vial the market. A future one will accept it directly as a parameter."

@anorth anorth self-requested a review June 30, 2022 00:01
@Kubuxu Kubuxu force-pushed the feat/stable-pcd branch 3 times, most recently from c212c3f to 807ca55 Compare July 6, 2022 18:45
@Kubuxu Kubuxu marked this pull request as ready for review July 6, 2022 18:55
@Kubuxu Kubuxu force-pushed the feat/stable-pcd branch from 91f224f to 6f76bae Compare July 6, 2022 19:49
@Kubuxu Kubuxu requested a review from anorth July 11, 2022 12:52
@Kubuxu Kubuxu changed the title Initial work for Stable PCD FIP Switch to Constant PCD, drop CommD out of PreCommit state, add future compatibility for CommD passing Jul 11, 2022
@Kubuxu Kubuxu force-pushed the feat/stable-pcd branch from fab7eec to fe2785b Compare July 11, 2022 14:26
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, I gather this is now ready from your POV. I need to allocate a half hour for a final thorough review, but this is great.

Are we going to drop out the new v2 APIs from this PR so we can land it independently of the forward compatibility FIP process?

Let's now request @ZenGround0 review. In particular I would appreciate your focus on the tests, which I have not examined in as much depth as the main change.

@anorth anorth requested review from anorth and ZenGround0 July 12, 2022 02:45
@ZenGround0
Copy link
Contributor

Looking now, mostly at tests

Copy link
Contributor

@ZenGround0 ZenGround0 left a comment

Choose a reason for hiding this comment

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

Got hung up on the code change, tests tomorrow

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.

I've reviewed again, looks great. Minor things before we merge:

  • Resolve duplication of compute_data_commitment (prefer by deleting the method, but otherwise by extracting duplicate code)
  • Remove the FIP-0041 entry points for now. When we put them back in a new PR we need to test them too

@Kubuxu Kubuxu force-pushed the feat/stable-pcd branch from 7aa4018 to 2bfd393 Compare July 18, 2022 17:52
@Kubuxu Kubuxu requested a review from anorth July 18, 2022 19:07
@jennijuju jennijuju changed the title Switch to Constant PCD, drop CommD out of PreCommit state, add future compatibility for CommD passing [FIP-0034]Switch to Constant PCD, drop CommD out of PreCommit state, add future compatibility for CommD passing Jul 19, 2022
@jennijuju
Copy link
Member

(note this FIP has been in discussion since Feb, 2022 and has moved to last call on July 13th (until July 27th), so far, there is no objection & concern about accepting this FIP. This FIP is also being considered to be finalized in nv17 actively. Therefore, if @filecoin-project/actors-maintainers approves this PR, it maybe optimistically merged into master. We will make changes if FIP status changes accordingly(i.e.: if rejected or won't be finalized in nv17, we will revert the PR).

Copy link
Contributor

@ZenGround0 ZenGround0 left a comment

Choose a reason for hiding this comment

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

The only thing I haven't fully looked over since last review are miner lib.rs and compact commd. I will get to these tomorrow if you haven't merged yet. But assuming logic hasn't changed much and @anorth approves then this LGTM.

@@ -33,15 +38,21 @@ fn verify_deal_and_get_deal_weight_for_unverified_deal_proposal() {
generate_and_publish_deal(&mut rt, CLIENT_ADDR, &MINER_ADDRESSES, START_EPOCH, END_EPOCH);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: here and elsewhere "verify_and_activate_deal_and..."

@@ -165,15 +165,15 @@ fn prove_replica_update_multi_dline() {
let store = &MemoryBlockstore::new();
let policy = Policy::default();
let mut v = VM::new_with_singletons(store);
let addrs = create_accounts(&v, 1, TokenAmount::from(100_000e18 as i128));
let addrs = create_accounts(&v, 1, TokenAmount::from(1_000_000e18 as i128));
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like these tests started running out of tokens, why would the changes in this PR introduce a different amount of tokens sent?

Copy link
Contributor Author

@Kubuxu Kubuxu Jul 27, 2022

Choose a reason for hiding this comment

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

We initially create a Miner with a CC sector so it needs more money for a larger PCD.

if conf.sector_weights.len() > i {
sector_weights.push(conf.sector_weights[i].clone());
if conf.sector_deal_data.len() > i {
sector_weights.push(conf.sector_deal_data[i].clone());
Copy link
Contributor

Choose a reason for hiding this comment

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

Change the name to match the new return value

pub expiration: ChainEpoch,
/// Whether to replace a "committed capacity" no-deal sector (requires non-empty DealIDs)
pub replace_capacity: bool,
/// The committed capacity sector to replace, and its deadline/partition location
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "// Deprecated: "

@@ -161,44 +133,6 @@ mod miner_actor_test_commitment {
h.check_state(&rt);
}

#[test]
fn deal_space_exceeds_sector_space() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Potentially worth introducing this in proveCommitAggregate test. Or ConfirmSectorProofsValid though that seems a bit too annoying to be worth it.


assert_eq!(sector_nos[i], precommits[i].info.sector_number);
assert_eq!(sectors[i], precommits[i].info);
//assert_eq!(sectors[i], precommits[i].info);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these two types are now different and this comment should be removed

Jakub Sztandera added 19 commits August 4, 2022 16:20
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
@Kubuxu Kubuxu enabled auto-merge (squash) August 4, 2022 14:21
@Kubuxu Kubuxu changed the title [FIP-0034]Switch to Constant PCD, drop CommD out of PreCommit state, add future compatibility for CommD passing [FIP-0034]Switch to Constant PCD, add CommD to PreCommit state Aug 4, 2022
@Kubuxu Kubuxu merged commit ac3d3e8 into master Aug 4, 2022
@Kubuxu Kubuxu deleted the feat/stable-pcd branch August 4, 2022 14:47
@Kubuxu Kubuxu restored the feat/stable-pcd branch August 4, 2022 16:37
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.

Implement FIP-0034: Fixed pre-commit deposit
4 participants