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 19, 2024
1 parent 955ea3e commit c55777c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 91 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
## New features

* 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.
* [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.
* feat: 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)

## 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 @@ -419,7 +419,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
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.

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

0 comments on commit c55777c

Please sign in to comment.