Merge pull request #2637 from filecoin-project/gas/tag-verify-post

Use scaling VerifyPost cost
This commit is contained in:
Aayush Rajasekaran 2020-07-28 21:22:23 -04:00 committed by GitHub
commit 5e485a085a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 7 deletions

View File

@ -111,8 +111,22 @@ var prices = map[abi.ChainEpoch]Pricelist{
hashingBase: 110685,
computeUnsealedSectorCidBase: 431890,
verifySealBase: 2000, // TODO gas , it VerifySeal syscall is not used
verifyPostBase: 2621447835,
verifyConsensusFault: 495422,
verifyPostLookup: map[abi.RegisteredPoStProof]scalingCost{
abi.RegisteredPoStProof_StackedDrgWindow512MiBV1: {
flat: 106102820,
scale: 10238878,
},
abi.RegisteredPoStProof_StackedDrgWindow32GiBV1: {
flat: 1165718059,
scale: 166657,
},
abi.RegisteredPoStProof_StackedDrgWindow64GiBV1: {
// TODO, for now the same as 32GiB
flat: 1165718059,
scale: 166657,
},
},
verifyConsensusFault: 495422,
},
}

View File

@ -9,6 +9,11 @@ import (
"github.com/filecoin-project/specs-actors/actors/crypto"
)
type scalingCost struct {
flat int64
scale int64
}
type pricelistV0 struct {
///////////////////////////////////////////////////////////////////////////
// System operations
@ -81,7 +86,7 @@ type pricelistV0 struct {
computeUnsealedSectorCidBase int64
verifySealBase int64
verifyPostBase int64
verifyPostLookup map[abi.RegisteredPoStProof]scalingCost
verifyConsensusFault int64
}
@ -176,7 +181,27 @@ func (pl *pricelistV0) OnVerifySeal(info abi.SealVerifyInfo) GasCharge {
// OnVerifyPost
func (pl *pricelistV0) OnVerifyPost(info abi.WindowPoStVerifyInfo) GasCharge {
return newGasCharge("OnVerifyPost", pl.verifyPostBase, 0).WithExtra(len(info.ChallengedSectors))
sectorSize := "unknown"
var proofType abi.RegisteredPoStProof
if len(info.Proofs) != 0 {
proofType = info.Proofs[0].PoStProof
ss, err := info.Proofs[0].PoStProof.SectorSize()
if err == nil {
sectorSize = ss.ShortString()
}
}
cost, ok := pl.verifyPostLookup[proofType]
if !ok {
cost = pl.verifyPostLookup[abi.RegisteredPoStProof_StackedDrgWindow512MiBV1]
}
return newGasCharge("OnVerifyPost", cost.flat+int64(len(info.ChallengedSectors))*cost.scale, 0).
WithExtra(map[string]interface{}{
"type": sectorSize,
"size": len(info.ChallengedSectors),
})
}
// OnVerifyConsensusFault

View File

@ -410,6 +410,13 @@ func tallyGasCharges(charges map[string]*stats, et types.ExecutionTrace) {
continue
}
tt := float64(gc.TimeTaken.Nanoseconds())
if name == "OnVerifyPost" && tt > 2e9 {
log.Warnf("Skipping abnormally long OnVerifyPost: %fs", tt/1e9)
// discard initial very long OnVerifyPost
continue
}
eType, eSize := getExtras(gc.Extra)
if name == "OnIpldGet" {
next := &types.GasTrace{}
if i+1 < len(et.GasCharges) {
@ -417,14 +424,18 @@ func tallyGasCharges(charges map[string]*stats, et types.ExecutionTrace) {
}
if next.Name != "OnIpldGetEnd" {
log.Warn("OnIpldGet without OnIpldGetEnd")
} else {
_, size := getExtras(next.Extra)
eSize = size
}
tt += float64(next.TimeTaken.Nanoseconds())
}
eType, eSize := getExtras(gc.Extra)
if eType != nil {
name += "-" + *eType
}
compGas := gc.VirtualComputeGas
compGas := gc.ComputeGas
if compGas == 0 {
compGas = gc.VirtualComputeGas
}
if compGas == 0 {
compGas = 1
}