Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Implemented PreCommitSectorBatch method (FIP-0008) #1407

Merged
merged 2 commits into from
May 14, 2021

Conversation

anorth
Copy link
Member

@anorth anorth commented May 11, 2021

Implements a new PreCommitSectorBatch method, as specified by FIP-0008 (discussion)

The non-batched PreCommitSector method remains, but should be considered deprecated. The implementation delegates internally to the batched method. This consumes less gas than before this change (due to removal of redundant checks in the batched method) but is slightly less efficient at runtime than a strictly-optimized singleton method could be. I expect it to be removed in the future.

@anorth anorth force-pushed the anorth/batchprecommit branch 2 times, most recently from c6835d3 to 9292fec Compare May 13, 2021 06:17
@anorth anorth marked this pull request as ready for review May 13, 2021 06:19
@anorth anorth requested a review from ZenGround0 May 13, 2021 06:20
…8 (discussion)

The non-batched PreCommitSector method remains, but should be considered deprecated.
The implementation delegates internally to the batched method.
This consumes less gas than before this change (due to removal of redundant checks in
the batched method) but is slightly less efficient at runtime than a strictly-optimized
singleton method could be. I expect it to be removed in the future.
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.

Still need to look at tests but LGTM so far

@@ -647,60 +648,97 @@ func (a Actor) DisputeWindowedPoSt(rt Runtime, params *DisputeWindowedPoStParams
//}
type PreCommitSectorParams = miner0.SectorPreCommitInfo
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: v5 (along with every other version so far) has been redefining its own SectorPreCommitInfo and generating cbor (un)marshalling code for it. We should pick one strategy either relying only on miner0 for serialization and removing v5.SectorPreCommitInfo from gen.go or using miner5.SectorPreCommitInfo here. I slightly prefer the second option.

Copy link
Member Author

@anorth anorth May 14, 2021

Choose a reason for hiding this comment

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

Actually, every version has aliased this PreCommitSectorParams onto miner0.SectorPreCommitInfo, e.g. in v4. This is necessary to preserve type-compatibility in Lotus without extra effort. But then yes redefining a version used in state.

I would redefine the params object inline rather than reference the v5 state type, to decouple them. But either would require abstraction and version-switching in Lotus, which we currently avoid. PreCommitSectorParams is the ugly special case here where a state object (which we usually redefine) was used as a parameter type.

I opened a discussion in Filecoin slack about how we might consider aliasing the state types too in the future.

actors/builtin/miner/miner_actor.go Outdated Show resolved Hide resolved
if params.SealRandEpoch < challengeEarliest {
rt.Abortf(exitcode.ErrIllegalArgument, "seal challenge epoch %v too old, must be after %v", params.SealRandEpoch, challengeEarliest)
}
if !CanPreCommitSealProof(precommit.SealProof, nv) {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: because the actors major version is incrementing this might be a good time to simplify CanPreCommtiSealProof to only allow v1_1 seal proofs and not take in network version information

Copy link
Member Author

@anorth anorth May 14, 2021

Choose a reason for hiding this comment

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

Agreed, I will follow up with that. #1414

actors/builtin/miner/miner_actor.go Show resolved Hide resolved
actors/builtin/miner/miner_actor.go Show resolved Hide resolved
actors/builtin/miner/miner_test.go Show resolved Hide resolved
actors/builtin/miner/miner_test.go Outdated Show resolved Hide resolved
actors/builtin/miner/miner_commitment_test.go Show resolved Hide resolved
actors/builtin/miner/miner_commitment_test.go Show resolved Hide resolved
@anorth anorth added this to the Network Hyperdrive milestone May 14, 2021
@anorth anorth closed this May 14, 2021
@anorth anorth reopened this May 14, 2021
@anorth anorth merged commit 418e07d into master May 14, 2021
@anorth anorth deleted the anorth/batchprecommit branch May 14, 2021 03:44
@anorth anorth mentioned this pull request May 14, 2021
10 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants