self review: some cleanup
This commit is contained in:
parent
59d9c681ad
commit
422e25c8e6
@ -54,9 +54,6 @@ func GetParams(storage bool, tests bool) error {
|
|||||||
ft := &fetch{}
|
ft := &fetch{}
|
||||||
|
|
||||||
for name, info := range params {
|
for name, info := range params {
|
||||||
if info.SectorSize != 1024 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if !(SupportedSectorSize(info.SectorSize) || (tests && info.SectorSize == 1<<10)) {
|
if !(SupportedSectorSize(info.SectorSize) || (tests && info.SectorSize == 1<<10)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,6 @@ type ChainGen struct {
|
|||||||
|
|
||||||
eppProvs map[address.Address]ElectionPoStProver
|
eppProvs map[address.Address]ElectionPoStProver
|
||||||
Miners []address.Address
|
Miners []address.Address
|
||||||
mworkers []address.Address
|
|
||||||
receivers []address.Address
|
receivers []address.Address
|
||||||
banker address.Address
|
banker address.Address
|
||||||
bankerNonce uint64
|
bankerNonce uint64
|
||||||
@ -125,8 +124,6 @@ func NewGenerator() (*ChainGen, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this is really weird, we have to guess the miner addresses that
|
|
||||||
// will be created in order to preseal data for them
|
|
||||||
maddr1, err := address.NewFromString("t0300")
|
maddr1, err := address.NewFromString("t0300")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -214,7 +211,6 @@ func NewGenerator() (*ChainGen, error) {
|
|||||||
|
|
||||||
Miners: minercfg.MinerAddrs,
|
Miners: minercfg.MinerAddrs,
|
||||||
eppProvs: mgen,
|
eppProvs: mgen,
|
||||||
//mworkers: minercfg.Workers,
|
|
||||||
banker: banker,
|
banker: banker,
|
||||||
receivers: receievers,
|
receivers: receievers,
|
||||||
|
|
||||||
@ -256,7 +252,6 @@ func (cg *ChainGen) nextBlockProof(ctx context.Context, pts *types.TipSet, m add
|
|||||||
return nil, nil, xerrors.Errorf("get miner worker: %w", err)
|
return nil, nil, xerrors.Errorf("get miner worker: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Warnf("compute VRF ROUND: %d %s %s", round, m, worker)
|
|
||||||
vrfout, err := ComputeVRF(ctx, cg.w.Sign, worker, m, DSepTicket, lastTicket.VRFProof)
|
vrfout, err := ComputeVRF(ctx, cg.w.Sign, worker, m, DSepTicket, lastTicket.VRFProof)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("compute VRF: %w", err)
|
return nil, nil, xerrors.Errorf("compute VRF: %w", err)
|
||||||
@ -308,7 +303,6 @@ func (cg *ChainGen) NextTipSetFromMiners(base *types.TipSet, miners []address.Ad
|
|||||||
}
|
}
|
||||||
|
|
||||||
if proof != nil {
|
if proof != nil {
|
||||||
log.Warn("making block, ticket: ", t.VRFProof)
|
|
||||||
fblk, err := cg.makeBlock(base, m, proof, t, uint64(round), msgs)
|
fblk, err := cg.makeBlock(base, m, proof, t, uint64(round), msgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("making a block for next tipset failed: %w", err)
|
return nil, xerrors.Errorf("making a block for next tipset failed: %w", err)
|
||||||
@ -510,7 +504,6 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round int64, miner add
|
|||||||
sectors := sectorbuilder.NewSortedPublicSectorInfo(sinfos)
|
sectors := sectorbuilder.NewSortedPublicSectorInfo(sinfos)
|
||||||
|
|
||||||
hvrf := sha256.Sum256(vrfout)
|
hvrf := sha256.Sum256(vrfout)
|
||||||
log.Info("Replicas: ", sectors)
|
|
||||||
candidates, err := epp.GenerateCandidates(ctx, sectors, hvrf[:])
|
candidates, err := epp.GenerateCandidates(ctx, sectors, hvrf[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil, xerrors.Errorf("failed to generate electionPoSt candidates: %w", err)
|
return false, nil, xerrors.Errorf("failed to generate electionPoSt candidates: %w", err)
|
||||||
|
@ -620,7 +620,6 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
|
|||||||
err := gen.VerifyVRF(ctx, waddr, h.Miner, gen.DSepTicket, vrfBase, h.Ticket.VRFProof)
|
err := gen.VerifyVRF(ctx, waddr, h.Miner, gen.DSepTicket, vrfBase, h.Ticket.VRFProof)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("BAD TICKET: %d %x %x %s %s %x", h.Height, h.Ticket.VRFProof, vrfBase, waddr, h.Miner, baseTs.MinTicket().VRFProof)
|
|
||||||
return xerrors.Errorf("validating block tickets failed: %w", err)
|
return xerrors.Errorf("validating block tickets failed: %w", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
const PoStReservedWorkers = 1
|
const PoStReservedWorkers = 1
|
||||||
const PoRepProofPartitions = 2
|
const PoRepProofPartitions = 2
|
||||||
|
|
||||||
var LastSectorIdKey = datastore.NewKey("/sectorbuilder/last")
|
var lastSectorIdKey = datastore.NewKey("/sectorbuilder/last")
|
||||||
|
|
||||||
var log = logging.Logger("sectorbuilder")
|
var log = logging.Logger("sectorbuilder")
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ func New(cfg *Config, ds dtypes.MetadataDS) (*SectorBuilder, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var lastUsedID uint64
|
var lastUsedID uint64
|
||||||
b, err := ds.Get(LastSectorIdKey)
|
b, err := ds.Get(lastSectorIdKey)
|
||||||
switch err {
|
switch err {
|
||||||
case nil:
|
case nil:
|
||||||
i, err := strconv.ParseInt(string(b), 10, 64)
|
i, err := strconv.ParseInt(string(b), 10, 64)
|
||||||
@ -101,7 +101,6 @@ func New(cfg *Config, ds dtypes.MetadataDS) (*SectorBuilder, error) {
|
|||||||
default:
|
default:
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.Warn("STARTING UP SECTOR BULIDER, LAST ID: ", lastUsedID)
|
|
||||||
|
|
||||||
sb := &SectorBuilder{
|
sb := &SectorBuilder{
|
||||||
ds: ds,
|
ds: ds,
|
||||||
@ -148,7 +147,7 @@ func (sb *SectorBuilder) AcquireSectorId() (uint64, error) {
|
|||||||
sb.lastID++
|
sb.lastID++
|
||||||
id := sb.lastID
|
id := sb.lastID
|
||||||
|
|
||||||
err := sb.ds.Put(LastSectorIdKey, []byte(fmt.Sprint(id)))
|
err := sb.ds.Put(lastSectorIdKey, []byte(fmt.Sprint(id)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@ -267,14 +266,6 @@ func (sb *SectorBuilder) SealCommit(sectorID uint64, ticket SealTicket, seed Sea
|
|||||||
return proof, nil
|
return proof, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func (sb *SectorBuilder) GeneratePoSt(sectorInfo SortedSectorInfo, challengeSeed [CommLen]byte, faults []uint64) ([]byte, error) {
|
|
||||||
// Wait, this is a blocking method with no way of interrupting it?
|
|
||||||
// does it checkpoint itself?
|
|
||||||
return sectorbuilder.GeneratePoSt(sb.handle, sectorInfo, challengeSeed, faults)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
func (sb *SectorBuilder) SectorSize() uint64 {
|
func (sb *SectorBuilder) SectorSize() uint64 {
|
||||||
return sb.ssize
|
return sb.ssize
|
||||||
}
|
}
|
||||||
@ -292,8 +283,6 @@ func (sb *SectorBuilder) ComputeElectionPoSt(sectorInfo SortedPublicSectorInfo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
proverID := addressToProverID(sb.Miner)
|
proverID := addressToProverID(sb.Miner)
|
||||||
log.Info("GENERATING ELECTION POST")
|
|
||||||
defer log.Info("DONE GENERATING ELECTION POST")
|
|
||||||
|
|
||||||
return sectorbuilder.GeneratePoSt(sb.ssize, proverID, privsects, cseed, winners)
|
return sectorbuilder.GeneratePoSt(sb.ssize, proverID, privsects, cseed, winners)
|
||||||
}
|
}
|
||||||
@ -441,12 +430,12 @@ func (sb *SectorBuilder) ImportFrom(osb *SectorBuilder) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
val, err := osb.ds.Get(LastSectorIdKey)
|
val, err := osb.ds.Get(lastSectorIdKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := sb.ds.Put(LastSectorIdKey, val); err != nil {
|
if err := sb.ds.Put(lastSectorIdKey, val); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,6 @@ func (m *Miner) Unregister(ctx context.Context, addr address.Address) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Miner) mine(ctx context.Context) {
|
func (m *Miner) mine(ctx context.Context) {
|
||||||
log.Warn("Starting mining!!")
|
|
||||||
ctx, span := trace.StartSpan(ctx, "/mine")
|
ctx, span := trace.StartSpan(ctx, "/mine")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user