-
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
[FIP-0034]Switch to Constant PCD, add CommD to PreCommit state #484
Conversation
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 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.
actors/miner/src/types.rs
Outdated
/// Information stored on-chain for a pre-committed sector. | ||
#[derive(Debug, PartialEq, Clone, Serialize_tuple, Deserialize_tuple)] | ||
pub struct SectorPreCommitOnChainInfo2 { |
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.
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.
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 left the old state affecting types as they are because I don't know what is the migration flow for FVM.
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.
If we are sure that they are not needed, I can remove them and run a refactor.
I've moved deal weights to activation, added some docs, and removed the usage of From/Into for the PreCommitParams wrapping. |
I also added the ReplicaUpdate changes. |
|
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.
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.
actors/miner/src/lib.rs
Outdated
deal_ids: spci.deal_ids, | ||
expiration: spci.expiration, | ||
|
||
unsealed_cid: CommDState::Unknown, |
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.
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."
c212c3f
to
807ca55
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.
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.
Looking now, mostly at tests |
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.
Got hung up on the code change, tests tomorrow
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'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
(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). |
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.
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); |
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.
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)); |
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.
It looks like these tests started running out of tokens, why would the changes in this PR introduce a different amount of tokens sent?
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.
We initially create a Miner with a CC sector so it needs more money for a larger PCD.
actors/miner/tests/util.rs
Outdated
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()); |
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.
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 |
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.
nit: "// Deprecated: "
@@ -161,44 +133,6 @@ mod miner_actor_test_commitment { | |||
h.check_state(&rt); | |||
} | |||
|
|||
#[test] | |||
fn deal_space_exceeds_sector_space() { |
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.
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); |
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 these two types are now different and this comment should be removed
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]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Signed-off-by: Jakub Sztandera <[email protected]>
Implements FIP-0034. Closes #421.