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: add DDO-friendly StateMinerInitialPledgeForSector #6406

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/submodule/chain/chaininfo_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ func (cia *chainInfoAPI) StateGetNetworkParams(ctx context.Context) (*types.Netw
UpgradeDragonHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeDragonHeight,
UpgradePhoenixHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradePhoenixHeight,
UpgradeWaffleHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeWaffleHeight,
UpgradeTuktukHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeTuktukHeight,
},
Eip155ChainID: cfg.NetworkParams.Eip155ChainID,
}
Expand Down
265 changes: 180 additions & 85 deletions app/submodule/chain/miner_api.go

Large diffs are not rendered by default.

49 changes: 31 additions & 18 deletions venus-shared/api/chain/v0/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,35 @@ type IMinerState interface {
// StateGetClaim returns the claim for a given address and claim ID.
StateGetClaim(ctx context.Context, providerAddr address.Address, claimID types.ClaimId, tsk types.TipSetKey) (*types.Claim, error) //perm:read
// StateGetClaims returns the all the claims for a given provider.
StateGetClaims(ctx context.Context, providerAddr address.Address, tsk types.TipSetKey) (map[types.ClaimId]types.Claim, error) //perm:read
StateMinerPreCommitDepositForPower(ctx context.Context, maddr address.Address, pci types.SectorPreCommitInfo, tsk types.TipSetKey) (big.Int, error) //perm:read
StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci types.SectorPreCommitInfo, tsk types.TipSetKey) (big.Int, error) //perm:read
StateVMCirculatingSupplyInternal(ctx context.Context, tsk types.TipSetKey) (types.CirculatingSupply, error) //perm:read
StateCirculatingSupply(ctx context.Context, tsk types.TipSetKey) (abi.TokenAmount, error) //perm:read
StateMarketDeals(ctx context.Context, tsk types.TipSetKey) (map[string]*types.MarketDeal, error) //perm:read
StateMinerActiveSectors(ctx context.Context, maddr address.Address, tsk types.TipSetKey) ([]*lminer.SectorOnChainInfo, error) //perm:read
StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) //perm:read
StateListMiners(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error) //perm:read
StateListActors(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error) //perm:read
StateMinerPower(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*types.MinerPower, error) //perm:read
StateMinerAvailableBalance(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (big.Int, error) //perm:read
StateSectorExpiration(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk types.TipSetKey) (*lminer.SectorExpiration, error) //perm:read
StateChangedActors(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error) //perm:read
StateMinerSectorCount(ctx context.Context, addr address.Address, tsk types.TipSetKey) (types.MinerSectors, error) //perm:read
StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (types.MarketBalance, error) //perm:read
StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (types.DealCollateralBounds, error) //perm:read
StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error) //perm:read
StateGetClaims(ctx context.Context, providerAddr address.Address, tsk types.TipSetKey) (map[types.ClaimId]types.Claim, error) //perm:read
StateMinerPreCommitDepositForPower(ctx context.Context, maddr address.Address, pci types.SectorPreCommitInfo, tsk types.TipSetKey) (big.Int, error) //perm:read
// StateMinerInitialPledgeCollateral attempts to calculate the initial pledge collateral based on a SectorPreCommitInfo.
// This method uses the DealIDs field in SectorPreCommitInfo to determine the amount of verified
// deal space in the sector in order to perform a QAP calculation. Since network version 22 and
// the introduction of DDO, the DealIDs field can no longer be used to reliably determine verified
// deal space; therefore, this method is deprecated. Use StateMinerInitialPledgeForSector instead
// and pass in the verified deal space directly.
//
// Deprecated: Use StateMinerInitialPledgeForSector instead.
StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci types.SectorPreCommitInfo, tsk types.TipSetKey) (big.Int, 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 (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
StateVMCirculatingSupplyInternal(ctx context.Context, tsk types.TipSetKey) (types.CirculatingSupply, error) //perm:read
StateCirculatingSupply(ctx context.Context, tsk types.TipSetKey) (abi.TokenAmount, error) //perm:read
StateMarketDeals(ctx context.Context, tsk types.TipSetKey) (map[string]*types.MarketDeal, error) //perm:read
StateMinerActiveSectors(ctx context.Context, maddr address.Address, tsk types.TipSetKey) ([]*lminer.SectorOnChainInfo, error) //perm:read
StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) //perm:read
StateListMiners(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error) //perm:read
StateListActors(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error) //perm:read
StateMinerPower(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*types.MinerPower, error) //perm:read
StateMinerAvailableBalance(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (big.Int, error) //perm:read
StateSectorExpiration(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk types.TipSetKey) (*lminer.SectorExpiration, error) //perm:read
StateChangedActors(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error) //perm:read
StateMinerSectorCount(ctx context.Context, addr address.Address, tsk types.TipSetKey) (types.MinerSectors, error) //perm:read
StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (types.MarketBalance, error) //perm:read
StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (types.DealCollateralBounds, error) //perm:read
StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error) //perm:read
}
46 changes: 42 additions & 4 deletions venus-shared/api/chain/v0/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "
* [StateMinerFaults](#stateminerfaults)
* [StateMinerInfo](#stateminerinfo)
* [StateMinerInitialPledgeCollateral](#stateminerinitialpledgecollateral)
* [StateMinerInitialPledgeForSector](#stateminerinitialpledgeforsector)
* [StateMinerPartitions](#stateminerpartitions)
* [StateMinerPower](#stateminerpower)
* [StateMinerPreCommitDepositForPower](#stateminerprecommitdepositforpower)
Expand Down Expand Up @@ -1222,7 +1223,7 @@ Perms: read
Inputs:
```json
[
23
24
]
```

Expand All @@ -1237,7 +1238,7 @@ Perms: read
Inputs:
```json
[
23
24
]
```

Expand Down Expand Up @@ -1662,7 +1663,8 @@ Response:
"UpgradeWatermelonHeight": 10101,
"UpgradeDragonHeight": 10101,
"UpgradePhoenixHeight": 10101,
"UpgradeWaffleHeight": 10101
"UpgradeWaffleHeight": 10101,
"UpgradeTuktukHeight": 10101
},
"Eip155ChainID": 123
}
Expand Down Expand Up @@ -1780,7 +1782,7 @@ Inputs:
]
```

Response: `23`
Response: `24`

### StateReplay

Expand Down Expand Up @@ -3795,6 +3797,14 @@ Response:
```

### StateMinerInitialPledgeCollateral
StateMinerInitialPledgeCollateral attempts to calculate the initial pledge collateral based on a SectorPreCommitInfo.
This method uses the DealIDs field in SectorPreCommitInfo to determine the amount of verified
deal space in the sector in order to perform a QAP calculation. Since network version 22 and
the introduction of DDO, the DealIDs field can no longer be used to reliably determine verified
deal space; therefore, this method is deprecated. Use StateMinerInitialPledgeForSector instead
and pass in the verified deal space directly.

Deprecated: Use StateMinerInitialPledgeForSector instead.


Perms: read
Expand Down Expand Up @@ -3831,6 +3841,34 @@ Inputs:

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 (total power, total pledge and current rewards) at the
given tipset.


Perms: read

Inputs:
```json
[
10101,
34359738368,
42,
[
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
{
"/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve"
}
]
]
```

Response: `"0"`

### StateMinerPartitions


Expand Down
15 changes: 15 additions & 0 deletions venus-shared/api/chain/v0/mock/mock_fullnode.go

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

Loading
Loading