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-0041: Forward Compatibility for PreCommit and ReplicaUpdate #395

Merged
merged 3 commits into from
Jul 12, 2022
Merged
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
114 changes: 114 additions & 0 deletions FIPS/fip-0041.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
fip: "0041"
title: Forward Compatibility for PreCommit and ReplicaUpdate
author: Jakub Sztandera (@Kubuxu)
discussions-to: https://github.com/filecoin-project/FIPs/discussions/380
status: Draft
type: Technical
category: Core
created: 2022-06-29
---

<!--You can leave these HTML comments in your merged FIP and delete the visible duplicate text guides, they will not appear and may be helpful to refer to if you edit it again. This is the suggested template for new FIPs. Note that a FIP number will be assigned by an editor. When opening a pull request to submit your FIP, please use an abbreviated title in the filename, `fip-draft_title_abbrev.md`. The title should be 44 characters or less.-->

## Simple Summary
<!--"If you can't explain it simply, you don't understand it well enough." Provide a simplified and layman-accessible explanation of the FIP.-->
Introduce new versions of PreCommitBatch and ProveReplicaUpdates methods such that future update is easier to perform.

## Abstract
<!--A short (~200 word) description of the technical issue being addressed.-->
In close future we expect a change in storage market mechanisms to recognise UnsealedSectorCID
as primary identifier of data. This would require PreCommitBatch and ProveReplicaUpdates to accept
UnsealedSectorCID. We propose adding variants of these methods capable of accepting UnsealedSectorCID today
for a more straightforward upgrade in the future.

## Change Motivation
<!--The motivation is critical for FIPs that want to change the Filecoin protocol. It should clearly explain why the existing protocol specification is inadequate to address the problem that the FIP solves. FIP submissions without sufficient motivation may be rejected outright.-->
When there is a necessary change in parameters of an actor's method exposed to users, the cleanest mechanism to execute such change is to add a new method and permissively continue to accept calls to the old method.
This mechanism increases implementation complexity as old code pathways have to continue functioning.
In this case, the motivating factors for the change are User Deployable Storage Markets and FVM Programmability. These two, by themselves, will be complex changes to built-in actors.
By introducing new method signatures before behavioural changes, the primary change can omit compatibility with old method signatures and thus reduce their complexity and work required.

## Specification
<!--The technical specification should describe the syntax and semantics of any new feature. The specification should be detailed enough to allow competing, interoperable implementations for any of the current Filecoin implementations. -->
Within Miner actor, introduce a new method number 28, called `PreCommitSectorBatch2` which is a copy of
`PreCommitSectorBatch` with following changes:
- remove of fields related to deprecated and non-functional CC upgrade.
- introduce a `unsealed_sector_cid` field, a tagged union of `Cid` and `None`.
`None` signifies a UnsealedSectorCID of sector containing just zeros (CC sector).
- verify that the UnsealedSectorCID is consistent with UnsealedSectorCID computed from DealIDs.

```diff
pub struct SectorPreCommitInfo {
pub seal_proof: RegisteredSealProof,
pub sector_number: SectorNumber,
pub sealed_cid: Cid,
pub seal_rand_epoch: ChainEpoch,
pub deal_ids: Vec<DealID>,
pub expiration: ChainEpoch,
- pub replace_capacity: bool,
- pub replace_sector_deadline: u64,
- pub replace_sector_partition: u64,
- pub replace_sector_number: SectorNumber,
+ pub unsealed_sector_cid: Option<Cid>,
}
```

Within Miner actor, introduce a new method number 29, called `ProveReplicaUpdates2` which is a copy of
`ProveReplicaUpdates` with following changes:
- introduce a `new_unsealed_cid` field of type Cid.
- verify that the UnsealedSectorCID is consistent with UnsealedSectorCID computed from DealIDs.

```diff
pub struct ReplicaUpdate2 {
pub sector_number: SectorNumber,
pub deadline: u64,
pub partition: u64,
pub new_sealed_cid: Cid,
+ pub new_unsealed_cid: Cid,
pub deals: Vec<DealID>,
pub update_proof_type: RegisteredUpdateProof,
#[serde(with = "serde_bytes")]
pub replica_proof: Vec<u8>,
}
```


## Design Rationale
<!--The rationale fleshes out the specification by describing what motivated the design and why particular design decisions were made. It should describe alternate designs that were considered and related work, e.g. how the feature is supported in other languages. The rationale may also provide evidence of consensus within the community, and should discuss important objections or concerns raised during discussion.-->
Tagged union type was selected from `PreCommitSectorBatch2` to save on storing repeated
UnsealedSectorCIDs for CC sectors containing zeros as there exist a function `ZeroUnsealedSectorCID(PoRepType)` capable of producing it.

`ProveReplicaUpdates2` uses an explicit UnsealedSectorCID as the ZeroUnsealedSectorCID
is expected to be rare for this function.


## Backwards Compatibility
<!--All FIPs that introduce backwards incompatibilities must include a section describing these incompatibilities and their severity. The FIP must explain how the author proposes to deal with these incompatibilities. FIP submissions without a sufficient backwards compatibility treatise may be rejected outright.-->
This change requires a network upgrade but otherwise is backwards compatible.
The older variants of newly introduced functions should be deprecated.

## Test Cases
<!--Test cases for an implementation are mandatory for FIPs that are affecting consensus changes. Other FIPs can choose to include links to test cases if applicable.-->
Test cases for an implementation are mandatory for FIPs that are affecting consensus changes. Other FIPs can choose to include links to test cases if applicable.

## Security Considerations
<!--All FIPs must contain a section that discusses the security implications/considerations relevant to the proposed change. Include information that might be important for security discussions, surfaces risks and can be used throughout the life cycle of the proposal. E.g. include security-relevant design decisions, concerns, important discussions, implementation-specific guidance and pitfalls, an outline of threats and risks and how they are being addressed. FIP submissions missing the "Security Considerations" section will be rejected. A FIP cannot proceed to status "Final" without a Security Considerations discussion deemed sufficient by the reviewers.-->
This FIP doesn't introduce significant functional changes which would have an effect on security.


## Incentive Considerations
<!--All FIPs must contain a section that discusses the incentive implications/considerations relative to the proposed change. Include information that might be important for incentive discussion. A discussion on how the proposed change will incentivize reliable and useful storage is required. FIP submissions missing the "Incentive Considerations" section will be rejected. An FIP cannot proceed to status "Final" without a Incentive Considerations discussion deemed sufficient by the reviewers.-->
This FIP doesn't introduce significant functional changes which would have an effect on incentive structure.

## Product Considerations
<!--All FIPs must contain a section that discusses the product implications/considerations relative to the proposed change. Include information that might be important for product discussion. A discussion on how the proposed change will enable better storage-related goods and services to be developed on Filecoin. FIP submissions missing the "Product Considerations" section will be rejected. An FIP cannot proceed to status "Final" without a Product Considerations discussion deemed sufficient by the reviewers.-->
This FIP doesn't introduce significant functional changes which would have an effect on product.

## Implementation
<!--The implementations must be completed before any core FIP is given status "Final", but it need not be completed before the FIP is accepted. While there is merit to the approach of reaching consensus on the specification and rationale before writing code, the principle of "rough consensus and running code" is still useful when it comes to resolving many discussions of API details.-->
This FIP is being worked on as part of the FIP-0034 implementation as both require similar changes
in the same part of the codebase.

## Copyright
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).