Skip to content

Commit

Permalink
chore(miner): tweaks to pledge api from feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Sep 25, 2024
1 parent 24e81ea commit f7244dd
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 333 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Add `EthSendRawTransactionUntrusted` RPC method to be used for the gateway when accepting `EthSendRawTransaction` and `eth_sendRawTransaction`. Applies a tighter limit on the number of messages in the queue from a single sender and applies additional restrictions on nonce increments. ([filecoin-project/lotus#12431](https://github.com/filecoin-project/lotus/pull/12431))
* [Checkpoint TipSets finalized by F3](https://github.com/filecoin-project/lotus/pull/12460): Once a decision is made by F3, the TipSet is check-pointed in `ChainStore`. As part of this change, any missing TipSets are asynchronously synced as required by the `ChainStore` checkpointing mechanism.
* Add an environment variable, `F3_INITIAL_POWERTABLE_CID` to allow specifying the initial power table used by F3 ([filecoin-project/lotus#12502](https://github.com/filecoin-project/lotus/pull/12502)). This may be used to help a lotus node re-sync the F3 chain when syncing from a snapshot after the F3 upgrade epoch. The precise CID to use here won't be known until the F3 is officially "live".
* Added `StateMinerInitialPledgeForSector` RPC method and deprecated existing `StateMinerInitialPledgeCollateral` method. Since ProveCommitSectors3 and ProveReplicaUpdates3, sector onboarding no longer includes an explicit notion of "deals", and precommit messages no longer contain deal information. This makes the existing `StateMinerInitialPledgeCollateral` unable to properly calculate pledge requirements with only the precommit. `StateMinerInitialPledgeForSector` is a new simplified calculator that simply takes duration, sector size, and verified size and estimates pledge based on current network conditions. ([filecoin-project/lotus#12384](https://github.com/filecoin-project/lotus/pull/12384)
* Added `StateMinerInitialPledgeForSector` RPC method and deprecated existing `StateMinerInitialPledgeCollateral` method. Since ProveCommitSectors3 and ProveReplicaUpdates3, sector onboarding no longer includes an explicit notion of "deals", and precommit messages no longer contain deal information. This makes the existing `StateMinerInitialPledgeCollateral` unable to properly calculate pledge requirements with only the precommit. `StateMinerInitialPledgeForSector` is a new simplified calculator that simply takes duration, sector size, and verified size and estimates pledge based on current network conditions. Please note that the `StateMinerInitialPledgeCollateral` method will be removed entirely in the next non-patch release. ([filecoin-project/lotus#12384](https://github.com/filecoin-project/lotus/pull/12384)

## Improvements

Expand Down
3 changes: 2 additions & 1 deletion api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ type FullNode interface {
StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) //perm:read
// StateMinerInitialPledgeForSector returns the initial pledge collateral for a given sector
// duration, size, and combined size of any verified pieces within the sector. This calculation
// depends on current network conditions at the given tipset.
// depends on current network conditions (total power, total pledge and current rewards) at the
// given tipset.
StateMinerInitialPledgeForSector(ctx context.Context, sectorDuration abi.ChainEpoch, sectorSize abi.SectorSize, verifiedSize uint64, tsk types.TipSetKey) (types.BigInt, error) //perm:read
// StateMinerAvailableBalance returns the portion of a miner's balance that can be withdrawn or spent
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) //perm:read
Expand Down
2 changes: 1 addition & 1 deletion build/openrpc/full.json
Original file line number Diff line number Diff line change
Expand Up @@ -21225,7 +21225,7 @@
{
"name": "Filecoin.StateMinerInitialPledgeForSector",
"description": "```go\nfunc (s *FullNodeStruct) StateMinerInitialPledgeForSector(p0 context.Context, p1 abi.ChainEpoch, p2 abi.SectorSize, p3 uint64, p4 types.TipSetKey) (types.BigInt, error) {\n\tif s.Internal.StateMinerInitialPledgeForSector == nil {\n\t\treturn *new(types.BigInt), ErrNotSupported\n\t}\n\treturn s.Internal.StateMinerInitialPledgeForSector(p0, p1, p2, p3, p4)\n}\n```",
"summary": "StateMinerInitialPledgeForSector returns the initial pledge collateral for a given sector\nduration, size, and combined size of any verified pieces within the sector. This calculation\ndepends on current network conditions at the given tipset.\n",
"summary": "StateMinerInitialPledgeForSector returns the initial pledge collateral for a given sector\nduration, size, and combined size of any verified pieces within the sector. This calculation\ndepends on current network conditions (total power, total pledge and current rewards) at the\ngiven tipset.\n",
"paramStructure": "by-position",
"params": [
{
Expand Down
65 changes: 21 additions & 44 deletions chain/actors/builtin/verifreg/actor.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,57 +21,14 @@ import (
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
verifregtypes13 "github.com/filecoin-project/go-state-types/builtin/v14/verifreg"
)

const (
NoAllocationID = verifregtypes.NoAllocationID
MaximumVerifiedAllocationExpiration = verifregtypes.MaximumVerifiedAllocationExpiration
MinimumVerifiedAllocationTerm = verifregtypes.MinimumVerifiedAllocationTerm
MaximumVerifiedAllocationTerm = verifregtypes.MaximumVerifiedAllocationTerm
MinimumVerifiedAllocationSize = verifregtypes13.MinimumVerifiedAllocationSize
verifregtypes12 "github.com/filecoin-project/go-state-types/builtin/v12/verifreg"
)

var (
Address = builtin{{.latestVersion}}.VerifiedRegistryActorAddr
Methods = builtin{{.latestVersion}}.MethodsVerifiedRegistry
)

type (
RemoveDataCapProposal = verifregtypes.RemoveDataCapProposal
RemoveDataCapRequest = verifregtypes.RemoveDataCapRequest
AddVerifierParams = verifregtypes.AddVerifierParams
AddVerifiedClientParams = verifregtypes.AddVerifiedClientParams
UseBytesParams = verifregtypes.UseBytesParams
RestoreBytesParams = verifregtypes.RestoreBytesParams
RemoveDataCapParams = verifregtypes.RemoveDataCapParams
RemoveDataCapReturn = verifregtypes.RemoveDataCapReturn
RemoveExpiredAllocationsParams = verifregtypes.RemoveExpiredAllocationsParams
RemoveExpiredAllocationsReturn = verifregtypes.RemoveExpiredAllocationsReturn
BatchReturn = verifregtypes.BatchReturn
AllocationId = verifregtypes.AllocationId
ClaimId = verifregtypes.ClaimId
ClaimAllocationsParams = verifregtypes.ClaimAllocationsParams
SectorAllocationClaims = verifregtypes13.SectorAllocationClaims
AllocationClaim = verifregtypes13.AllocationClaim
ClaimAllocationsReturn = verifregtypes.ClaimAllocationsReturn
GetClaimsParams = verifregtypes.GetClaimsParams
GetClaimsReturn = verifregtypes.GetClaimsReturn
Claim = verifregtypes.Claim
Allocation = verifregtypes.Allocation
UniversalReceiverParams = verifregtypes.UniversalReceiverParams
ReceiverType = verifregtypes.ReceiverType
AllocationsResponse = verifregtypes.AllocationsResponse
ExtendClaimTermsParams = verifregtypes.ExtendClaimTermsParams
ClaimTerm = verifregtypes.ClaimTerm
ExtendClaimTermsReturn = verifregtypes.ExtendClaimTermsReturn
RemoveExpiredClaimsParams = verifregtypes.RemoveExpiredClaimsParams
RemoveExpiredClaimsReturn = verifregtypes.RemoveExpiredClaimsReturn
AllocationRequest = verifregtypes.AllocationRequest
ClaimExtensionRequest = verifregtypes.ClaimExtensionRequest
AllocationRequests = verifregtypes.AllocationRequests
)

func Load(store adt.Store, act *types.Actor) (State, error) {
if name, av, ok := actors.GetActorMetaByCode(act.Code); ok {
if name != manifest.VerifregKey {
Expand Down Expand Up @@ -139,3 +96,23 @@ func AllCodes() []cid.Cid {
{{- end}}
}
}

type (
Allocation = verifregtypes.Allocation
AllocationId = verifregtypes.AllocationId
Claim = verifregtypes.Claim
ClaimId = verifregtypes.ClaimId
AllocationRequest = verifregtypes12.AllocationRequest
AllocationRequests = verifregtypes12.AllocationRequests
RemoveExpiredAllocationsParams = verifregtypes12.RemoveExpiredAllocationsParams
AddVerifierParams = verifregtypes12.AddVerifierParams
AddVerifiedClientParams = verifregtypes12.AddVerifiedClientParams
)

const (
NoAllocationID = verifregtypes.NoAllocationID
MinimumVerifiedAllocationTerm = verifregtypes12.MinimumVerifiedAllocationTerm
MaximumVerifiedAllocationTerm = verifregtypes12.MaximumVerifiedAllocationTerm
MaximumVerifiedAllocationExpiration = verifregtypes12.MaximumVerifiedAllocationExpiration
)

64 changes: 20 additions & 44 deletions chain/actors/builtin/verifreg/verifreg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion documentation/en/api-v1-unstable-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -7211,7 +7211,8 @@ Response: `"0"`
### StateMinerInitialPledgeForSector
StateMinerInitialPledgeForSector returns the initial pledge collateral for a given sector
duration, size, and combined size of any verified pieces within the sector. This calculation
depends on current network conditions at the given tipset.
depends on current network conditions (total power, total pledge and current rewards) at the
given tipset.


Perms: read
Expand Down
2 changes: 1 addition & 1 deletion itests/sector_miner_collateral_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ func TestPledgeCalculations(t *testing.T) {
require.NoError(t, err)
require.Equal(t, exitcode.Ok, r.Receipt.ExitCode)

tsk := r.TipSet // we're going to perform all pledge calculations at this tipset so we have consistent power outputs
tsk := r.TipSet // we're going to perform all pledge calculations at this tipset so we have consistent power, pledge, reward outputs

verifyPledge := func(sectorNumber abi.SectorNumber, verifiedSize uint64) big.Int {
// Compare deprecated pledge calculation that uses PreCommit with Deal information with the
Expand Down
Loading

0 comments on commit f7244dd

Please sign in to comment.