diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cb61975f3..16b888c968 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/api/api_full.go b/api/api_full.go index 44a30a888e..08e360e3ef 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -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 diff --git a/build/openrpc/full.json b/build/openrpc/full.json index 80b33e7de0..3507b360d4 100644 --- a/build/openrpc/full.json +++ b/build/openrpc/full.json @@ -20997,7 +20997,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": [ { diff --git a/chain/actors/builtin/verifreg/actor.go.template b/chain/actors/builtin/verifreg/actor.go.template index bbda9be124..75c99f2aae 100644 --- a/chain/actors/builtin/verifreg/actor.go.template +++ b/chain/actors/builtin/verifreg/actor.go.template @@ -21,15 +21,7 @@ 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 ( @@ -37,41 +29,6 @@ var ( 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 { @@ -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 +) + diff --git a/chain/actors/builtin/verifreg/verifreg.go b/chain/actors/builtin/verifreg/verifreg.go index 36c9aad137..02d8aa116f 100644 --- a/chain/actors/builtin/verifreg/verifreg.go +++ b/chain/actors/builtin/verifreg/verifreg.go @@ -8,7 +8,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" actorstypes "github.com/filecoin-project/go-state-types/actors" builtin15 "github.com/filecoin-project/go-state-types/builtin" - verifregtypes13 "github.com/filecoin-project/go-state-types/builtin/v14/verifreg" + verifregtypes12 "github.com/filecoin-project/go-state-types/builtin/v12/verifreg" verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg" "github.com/filecoin-project/go-state-types/cbor" "github.com/filecoin-project/go-state-types/manifest" @@ -25,54 +25,11 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) -const ( - NoAllocationID = verifregtypes.NoAllocationID - MaximumVerifiedAllocationExpiration = verifregtypes.MaximumVerifiedAllocationExpiration - MinimumVerifiedAllocationTerm = verifregtypes.MinimumVerifiedAllocationTerm - MaximumVerifiedAllocationTerm = verifregtypes.MaximumVerifiedAllocationTerm - MinimumVerifiedAllocationSize = verifregtypes13.MinimumVerifiedAllocationSize -) - var ( Address = builtin15.VerifiedRegistryActorAddr Methods = builtin15.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 { @@ -230,3 +187,22 @@ func AllCodes() []cid.Cid { (&state15{}).Code(), } } + +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 +) diff --git a/documentation/en/api-v1-unstable-methods.md b/documentation/en/api-v1-unstable-methods.md index 6009b19ef7..ede8aa58c0 100644 --- a/documentation/en/api-v1-unstable-methods.md +++ b/documentation/en/api-v1-unstable-methods.md @@ -7152,7 +7152,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 diff --git a/itests/sector_miner_collateral_test.go b/itests/sector_miner_collateral_test.go index 7bb84c2ce1..a4df47dbd1 100644 --- a/itests/sector_miner_collateral_test.go +++ b/itests/sector_miner_collateral_test.go @@ -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