Fix post seed height math
This commit is contained in:
parent
c40f89f2a9
commit
839597012d
@ -1,7 +1,7 @@
|
|||||||
package build
|
package build
|
||||||
|
|
||||||
// Seconds
|
// Seconds
|
||||||
const BlockDelay = 5
|
const BlockDelay = 3
|
||||||
|
|
||||||
// Seconds
|
// Seconds
|
||||||
const AllowableClockDrift = BlockDelay * 2
|
const AllowableClockDrift = BlockDelay * 2
|
||||||
|
@ -20,7 +20,7 @@ const ForkLengthThreshold = 20
|
|||||||
const RandomnessLookback = 20
|
const RandomnessLookback = 20
|
||||||
|
|
||||||
// Blocks
|
// Blocks
|
||||||
const ProvingPeriodDuration = 20
|
const ProvingPeriodDuration = 10
|
||||||
const PoSTChallangeTime = 10
|
const PoSTChallangeTime = 5
|
||||||
|
|
||||||
// TODO: Move other important consts here
|
// TODO: Move other important consts here
|
||||||
|
@ -2,6 +2,7 @@ package actors
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-lotus/build"
|
"github.com/filecoin-project/go-lotus/build"
|
||||||
@ -336,13 +337,16 @@ func (sma StorageMinerActor) SubmitPoSt(act *types.Actor, vmctx types.VMContext,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dbgRandH uint64
|
||||||
var seed [sectorbuilder.CommLen]byte
|
var seed [sectorbuilder.CommLen]byte
|
||||||
{
|
{
|
||||||
var rand []byte
|
var rand []byte
|
||||||
var err ActorError
|
var err ActorError
|
||||||
if !lateSubmission {
|
if !lateSubmission {
|
||||||
|
dbgRandH = self.ProvingPeriodEnd - build.PoSTChallangeTime
|
||||||
rand, err = vmctx.GetRandomness(self.ProvingPeriodEnd - build.PoSTChallangeTime)
|
rand, err = vmctx.GetRandomness(self.ProvingPeriodEnd - build.PoSTChallangeTime)
|
||||||
} else {
|
} else {
|
||||||
|
dbgRandH = nextProvingPeriodEnd - build.PoSTChallangeTime
|
||||||
rand, err = vmctx.GetRandomness(nextProvingPeriodEnd - build.PoSTChallangeTime)
|
rand, err = vmctx.GetRandomness(nextProvingPeriodEnd - build.PoSTChallangeTime)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -384,14 +388,17 @@ func (sma StorageMinerActor) SubmitPoSt(act *types.Actor, vmctx types.VMContext,
|
|||||||
|
|
||||||
faults := self.CurrentFaultSet.All()
|
faults := self.CurrentFaultSet.All()
|
||||||
|
|
||||||
|
log.Infof("VerifyPost; rh=%d r=%s pLen=%d", dbgRandH, base64.StdEncoding.EncodeToString(seed[:]), len(params.Proof))
|
||||||
if ok, lerr := sectorbuilder.VerifyPost(mi.SectorSize.Uint64(),
|
if ok, lerr := sectorbuilder.VerifyPost(mi.SectorSize.Uint64(),
|
||||||
sectorbuilder.NewSortedSectorInfo(sectorInfos), seed, params.Proof,
|
sectorbuilder.NewSortedSectorInfo(sectorInfos), seed, params.Proof,
|
||||||
faults); !ok || lerr != nil {
|
faults); !ok || lerr != nil {
|
||||||
if lerr != nil {
|
if lerr != nil {
|
||||||
// TODO: study PoST errors
|
// TODO: study PoST errors
|
||||||
|
log.Infof("Post Verify Error: %s", lerr)
|
||||||
return nil, aerrors.Absorb(lerr, 4, "PoST error")
|
return nil, aerrors.Absorb(lerr, 4, "PoST error")
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
|
log.Info("post verification FAILED")
|
||||||
return nil, aerrors.New(4, "PoST invalid")
|
return nil, aerrors.New(4, "PoST invalid")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ func (mp *MessagePool) addLocked(m *types.SignedMessage) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("mpooladd: %s", base64.StdEncoding.EncodeToString(data))
|
log.Infof("mpooladd: %s", base64.StdEncoding.EncodeToString(data))
|
||||||
|
|
||||||
if err := m.Signature.Verify(m.Message.From, data); err != nil {
|
if err := m.Signature.Verify(m.Message.From, data); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -722,6 +722,7 @@ func (cs *ChainStore) GetRandomness(ctx context.Context, pts *types.TipSet, tick
|
|||||||
mtb := nts.MinTicketBlock()
|
mtb := nts.MinTicketBlock()
|
||||||
if nv < len(mtb.Tickets) {
|
if nv < len(mtb.Tickets) {
|
||||||
t := mtb.Tickets[len(mtb.Tickets)-(1+nv)]
|
t := mtb.Tickets[len(mtb.Tickets)-(1+nv)]
|
||||||
|
log.Infof("Returning randomness: H:%d, t:%d, mtb:%s", nts.Height(), len(mtb.Tickets)-(1+nv), mtb.Cid())
|
||||||
return t.VDFResult, nil
|
return t.VDFResult, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +67,10 @@ func (vmc *VMContext) Message() *types.Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (vmc *VMContext) GetRandomness(height uint64) ([]byte, aerrors.ActorError) {
|
func (vmc *VMContext) GetRandomness(height uint64) ([]byte, aerrors.ActorError) {
|
||||||
relHeight := int(vmc.BlockHeight()) - int(height)
|
hts := vmc.vm.cs.GetHeaviestTipSet()
|
||||||
res, err := vmc.vm.cs.GetRandomness(vmc.ctx, vmc.vm.cs.GetHeaviestTipSet(), nil, relHeight)
|
|
||||||
|
relHeight := int(hts.Height() - height)
|
||||||
|
res, err := vmc.vm.cs.GetRandomness(vmc.ctx, hts, nil, relHeight)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, aerrors.Escalate(err, "could not get randomness")
|
return nil, aerrors.Escalate(err, "could not get randomness")
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package storage
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
logging "github.com/ipfs/go-log"
|
logging "github.com/ipfs/go-log"
|
||||||
@ -259,19 +260,19 @@ func (m *Miner) maybeDoPost(ctx context.Context, ts *types.TipSet) (<-chan error
|
|||||||
return nil, nil, xerrors.Errorf("failed to get proving set for miner: %w", err)
|
return nil, nil, xerrors.Errorf("failed to get proving set for miner: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
r, err := m.api.ChainGetRandomness(ctx, ts, nil, int(ts.Height()-ppe+build.ProvingPeriodDuration)) // TODO: review: check math
|
r, err := m.api.ChainGetRandomness(ctx, ts, nil, int(int64(ts.Height())-int64(ppe)+int64(build.PoSTChallangeTime))) // TODO: review: check math
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("failed to get chain randomness for post: %w", err)
|
return nil, nil, xerrors.Errorf("failed to get chain randomness for post: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceTs, err := m.api.ChainGetTipSetByHeight(ctx, ppe-build.ProvingPeriodDuration, ts)
|
sourceTs, err := m.api.ChainGetTipSetByHeight(ctx, ppe-build.PoSTChallangeTime, ts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("failed to get post start tipset: %w", err)
|
return nil, nil, xerrors.Errorf("failed to get post start tipset: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ret := make(chan error, 1)
|
ret := make(chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
log.Info("running PoSt computation")
|
log.Infof("running PoSt computation, rh=%d r=%s, ppe=%d, h=%d", ts.Height()-(ts.Height()-ppe+build.PoSTChallangeTime), base64.StdEncoding.EncodeToString(r), ppe, ts.Height())
|
||||||
var faults []uint64
|
var faults []uint64
|
||||||
proof, err := m.secst.RunPoSt(ctx, sset, r, faults)
|
proof, err := m.secst.RunPoSt(ctx, sset, r, faults)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -279,7 +280,7 @@ func (m *Miner) maybeDoPost(ctx context.Context, ts *types.TipSet) (<-chan error
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("submitting PoSt")
|
log.Infof("submitting PoSt pLen=%d", len(proof))
|
||||||
|
|
||||||
params := &actors.SubmitPoStParams{
|
params := &actors.SubmitPoStParams{
|
||||||
Proof: proof,
|
Proof: proof,
|
||||||
|
Loading…
Reference in New Issue
Block a user