Introduce gas prices for aggregate verifications
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
2b93bcde72
commit
cb59daf3c1
@ -161,7 +161,34 @@ var prices = map[abi.ChainEpoch]Pricelist{
|
||||
hashingBase: 31355,
|
||||
computeUnsealedSectorCidBase: 98647,
|
||||
verifySealBase: 2000, // TODO gas, it VerifySeal syscall is not used
|
||||
verifyAggregateSealBase: 400_000_000, // TODO (~40ms, I think)
|
||||
|
||||
verifyAggregateSealPer: map[abi.RegisteredSealProof]int64{
|
||||
abi.RegisteredSealProof_StackedDrg32GiBV1_1: 449900,
|
||||
abi.RegisteredSealProof_StackedDrg64GiBV1_1: 359272,
|
||||
},
|
||||
verifyAggregateSealSteps: map[abi.RegisteredSealProof]stepCost{
|
||||
abi.RegisteredSealProof_StackedDrg32GiBV1_1: {
|
||||
{4, 103994170},
|
||||
{7, 112356810},
|
||||
{13, 122912610},
|
||||
{26, 137559930},
|
||||
{52, 162039100},
|
||||
{103, 210960780},
|
||||
{205, 318351180},
|
||||
{410, 528274980},
|
||||
},
|
||||
abi.RegisteredSealProof_StackedDrg64GiBV1_1: {
|
||||
{4, 102581240},
|
||||
{7, 110803030},
|
||||
{13, 120803700},
|
||||
{26, 134642130},
|
||||
{52, 157357890},
|
||||
{103, 203017690},
|
||||
{205, 304253590},
|
||||
{410, 509880640},
|
||||
},
|
||||
},
|
||||
|
||||
verifyPostLookup: map[abi.RegisteredPoStProof]scalingCost{
|
||||
abi.RegisteredPoStProof_StackedDrgWindow512MiBV1: {
|
||||
flat: 117680921,
|
||||
|
@ -18,6 +18,28 @@ type scalingCost struct {
|
||||
scale int64
|
||||
}
|
||||
|
||||
type stepCost []step
|
||||
|
||||
type step struct {
|
||||
start int64
|
||||
cost int64
|
||||
}
|
||||
|
||||
func (sc stepCost) Lookup(x int64) int64 {
|
||||
i := 0
|
||||
for ; i < len(sc); i++ {
|
||||
if sc[i].start > x {
|
||||
break
|
||||
}
|
||||
}
|
||||
i-- // look at previous item
|
||||
if i < 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
return sc[i].cost
|
||||
}
|
||||
|
||||
type pricelistV0 struct {
|
||||
computeGasMulti int64
|
||||
storageGasMulti int64
|
||||
@ -93,6 +115,9 @@ type pricelistV0 struct {
|
||||
computeUnsealedSectorCidBase int64
|
||||
verifySealBase int64
|
||||
verifyAggregateSealBase int64
|
||||
verifyAggregateSealPer map[abi.RegisteredSealProof]int64
|
||||
verifyAggregateSealSteps map[abi.RegisteredSealProof]stepCost
|
||||
|
||||
verifyPostLookup map[abi.RegisteredPoStProof]scalingCost
|
||||
verifyPostDiscount bool
|
||||
verifyConsensusFault int64
|
||||
@ -189,8 +214,18 @@ func (pl *pricelistV0) OnVerifySeal(info proof2.SealVerifyInfo) GasCharge {
|
||||
|
||||
// OnVerifyAggregateSeals
|
||||
func (pl *pricelistV0) OnVerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) GasCharge {
|
||||
// TODO: this needs more cost tunning
|
||||
return newGasCharge("OnVerifyAggregateSeals", pl.verifyAggregateSealBase, 0)
|
||||
proofType := aggregate.SealProof
|
||||
perProof, ok := pl.verifyAggregateSealPer[proofType]
|
||||
if !ok {
|
||||
perProof = pl.verifyAggregateSealPer[abi.RegisteredSealProof_StackedDrg32GiBV1_1]
|
||||
}
|
||||
|
||||
step, ok := pl.verifyAggregateSealSteps[proofType]
|
||||
if !ok {
|
||||
step = pl.verifyAggregateSealSteps[abi.RegisteredSealProof_StackedDrg32GiBV1_1]
|
||||
}
|
||||
num := int64(len(aggregate.Infos))
|
||||
return newGasCharge("OnVerifyAggregateSeals", perProof*num+step.Lookup(num), 0)
|
||||
}
|
||||
|
||||
// OnVerifyPost
|
||||
|
32
chain/vm/gas_v0_test.go
Normal file
32
chain/vm/gas_v0_test.go
Normal file
@ -0,0 +1,32 @@
|
||||
package vm
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestStepGasCost(t *testing.T) {
|
||||
s := stepCost{
|
||||
{4, 103994170},
|
||||
{7, 112356810},
|
||||
{13, 122912610},
|
||||
{26, 137559930},
|
||||
{52, 162039100},
|
||||
{103, 210960780},
|
||||
{205, 318351180},
|
||||
{410, 528274980},
|
||||
}
|
||||
|
||||
assert.EqualValues(t, 0, s.Lookup(0))
|
||||
assert.EqualValues(t, 0, s.Lookup(3))
|
||||
assert.EqualValues(t, 103994170, s.Lookup(4))
|
||||
assert.EqualValues(t, 103994170, s.Lookup(6))
|
||||
assert.EqualValues(t, 112356810, s.Lookup(7))
|
||||
assert.EqualValues(t, 210960780, s.Lookup(103))
|
||||
assert.EqualValues(t, 210960780, s.Lookup(204))
|
||||
assert.EqualValues(t, 318351180, s.Lookup(205))
|
||||
assert.EqualValues(t, 318351180, s.Lookup(409))
|
||||
assert.EqualValues(t, 528274980, s.Lookup(410))
|
||||
assert.EqualValues(t, 528274980, s.Lookup(10000000000))
|
||||
}
|
Loading…
Reference in New Issue
Block a user