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

feat/2841 - compute collateral as a function of sector size + track collateral as actor balance + collateral check before adding new commitments #2865

Merged
merged 8 commits into from
May 31, 2019

Conversation

laser
Copy link
Contributor

@laser laser commented May 31, 2019

Makes incremental progress towards #2530.

Fixes #2841.

Why does this PR exist?

The spec demonstrates that a miner's collateral is its balance, and the collateral which is has locked up for sectors which it is actively proving must be tracked via the ActiveCollateral field. This field's value must be incremented when a sector is committed, and commitments should be rejected if the miner doesn't have enough collateral to cover a new commitment.

The spec also demonstrates that per-sector collateral is a function of sector size. We believe that this will change soon (see Pledge Collateral Design Doc (Baseline (Pro-rata) Construction)), but this moves the codebase in the right direction.

What's in this PR?

@laser laser changed the title [WIP - DO NOT MERGE] Feat/2530 active collateral commit sector feat/2841 - compute collateral as a function of sector size May 31, 2019
@laser laser requested review from acruikshank and ZenGround0 May 31, 2019 17:13
@laser laser changed the title feat/2841 - compute collateral as a function of sector size feat/2841 - compute collateral as a function of sector size + track collateral as actor balance + collateral check before adding new commitments May 31, 2019
Copy link
Contributor

@acruikshank acruikshank left a comment

Choose a reason for hiding this comment

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

I have concerns about adding a constructor for miner actors that takes a balance. Other than that, this PR looks solid.

func NewActor() *actor.Actor {
return actor.NewActor(types.MinerActorCodeCid, types.NewZeroAttoFIL())
// NewActor returns a new miner actor with the provided balance.
func NewActor(balance *types.AttoFIL) *actor.Actor {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a little sketchy. This only gets used in tests an genesis, but it suggests you can create a miner actor in a state transition with a non-zero balance. This would be really bad, since it would be generating FIL from nowhere. For clarity's sake, I'd rather you not add balance to the constructor and set it manually after the actor is constructed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For clarity's sake, I'd rather you not add balance to the constructor and set it manually after the actor is constructed.

OK. This change is easy to roll back. I introduced it to be consistent with the account actor-creation constructor. Do you think that the same logic applies to the account actor?

// given size.
func CollateralForSector(sectorSize *types.BytesAmount) *types.AttoFIL {
// TODO: Replace this function with the baseline pro-rata construction.
// https://github.com/filecoin-project/go-filecoin/issues/2866
Copy link
Contributor

Choose a reason for hiding this comment

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

🙏

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.

LGTM. It's worth checking the wiki and potentially making an update explaining that there is a minimum collateral during the miner setup workflow (though it might not affect anything if users run with the default FIL values).

@laser laser force-pushed the feat/2530-active-collateral-commit-sector branch from 3857b6d to 147933b Compare May 31, 2019 21:50
@laser laser merged commit 98723ef into master May 31, 2019
@laser laser deleted the feat/2530-active-collateral-commit-sector branch May 31, 2019 22:03
@laser
Copy link
Contributor Author

laser commented May 31, 2019

@ZenGround0

It's worth checking the wiki and potentially making an update explaining that there is a minimum collateral during the miner setup workflow (though it might not affect anything if users run with the default FIL values).

Sounds good. I'm about to delete the pledge concept from the storage miner (and corresponding miner create command). I'll update the wiki to reflect both changes simultaneously.

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.

The network computes collateral as a function of sector size
3 participants