Remove drand on miner side, MinerGetBaseInfo provides the same info

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-05-27 20:24:26 +02:00
parent 6986204657
commit 4604b60fb1
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA
5 changed files with 11 additions and 30 deletions

View File

@ -106,7 +106,8 @@ func (db *DrandBeacon) Entry(ctx context.Context, round uint64) <-chan beacon.Re
} }
go func() { go func() {
log.Infow("fetching randomness", "round", round) start := time.Now()
log.Infow("start fetching randomness", "round", round)
resp, err := db.client.Get(ctx, round) resp, err := db.client.Get(ctx, round)
var br beacon.Response var br beacon.Response
@ -116,7 +117,7 @@ func (db *DrandBeacon) Entry(ctx context.Context, round uint64) <-chan beacon.Re
br.Entry.Round = resp.Round() br.Entry.Round = resp.Round()
br.Entry.Data = resp.Signature() br.Entry.Data = resp.Signature()
} }
log.Infow("done fetching randomness", "round", round, "took", time.Since(start))
out <- br out <- br
close(out) close(out)
}() }()

View File

@ -37,7 +37,6 @@ import (
lapi "github.com/filecoin-project/lotus/api" lapi "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/beacon/drand"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli" lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/genesis" "github.com/filecoin-project/lotus/genesis"
@ -446,17 +445,7 @@ func storageMinerInit(ctx context.Context, cctx *cli.Context, api lapi.FullNode,
return err return err
} }
gen, err := api.ChainGetGenesis(ctx) m := miner.NewMiner(api, epp, a)
if err != nil {
return err
}
beacon, err := drand.NewDrandBeacon(gen.Blocks()[0].Timestamp, build.BlockDelay)
if err != nil {
return err
}
m := miner.NewMiner(api, epp, beacon, a)
{ {
if err := m.Start(ctx); err != nil { if err := m.Start(ctx); err != nil {
return xerrors.Errorf("failed to start up genesis miner: %w", err) return xerrors.Errorf("failed to start up genesis miner: %w", err)

View File

@ -15,7 +15,6 @@ import (
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/beacon"
"github.com/filecoin-project/lotus/chain/gen" "github.com/filecoin-project/lotus/chain/gen"
"github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
@ -31,7 +30,7 @@ var log = logging.Logger("miner")
// returns a callback reporting whether we mined a blocks in this round // returns a callback reporting whether we mined a blocks in this round
type waitFunc func(ctx context.Context, baseTime uint64) (func(bool), error) type waitFunc func(ctx context.Context, baseTime uint64) (func(bool), error)
func NewMiner(api api.FullNode, epp gen.WinningPoStProver, beacon beacon.RandomBeacon, addr address.Address) *Miner { func NewMiner(api api.FullNode, epp gen.WinningPoStProver, addr address.Address) *Miner {
arc, err := lru.NewARC(10000) arc, err := lru.NewARC(10000)
if err != nil { if err != nil {
panic(err) panic(err)
@ -40,7 +39,6 @@ func NewMiner(api api.FullNode, epp gen.WinningPoStProver, beacon beacon.RandomB
return &Miner{ return &Miner{
api: api, api: api,
epp: epp, epp: epp,
beacon: beacon,
address: addr, address: addr,
waitFunc: func(ctx context.Context, baseTime uint64) (func(bool), error) { waitFunc: func(ctx context.Context, baseTime uint64) (func(bool), error) {
// Wait around for half the block time in case other parents come in // Wait around for half the block time in case other parents come in
@ -56,8 +54,7 @@ func NewMiner(api api.FullNode, epp gen.WinningPoStProver, beacon beacon.RandomB
type Miner struct { type Miner struct {
api api.FullNode api api.FullNode
epp gen.WinningPoStProver epp gen.WinningPoStProver
beacon beacon.RandomBeacon
lk sync.Mutex lk sync.Mutex
address address.Address address address.Address
@ -267,12 +264,8 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg,
beaconPrev := mbi.PrevBeaconEntry beaconPrev := mbi.PrevBeaconEntry
bvals, err := beacon.BeaconEntriesForBlock(ctx, m.beacon, round, beaconPrev)
if err != nil {
return nil, xerrors.Errorf("get beacon entries failed: %w", err)
}
tDrand := time.Now() tDrand := time.Now()
bvals := mbi.BeaconEntries
hasPower, err := m.hasPower(ctx, m.address, base.TipSet) hasPower, err := m.hasPower(ctx, m.address, base.TipSet)
if err != nil { if err != nil {

View File

@ -5,20 +5,18 @@ import (
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/beacon"
"github.com/filecoin-project/lotus/chain/gen" "github.com/filecoin-project/lotus/chain/gen"
lru "github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
) )
func NewTestMiner(nextCh <-chan func(bool), addr address.Address) func(api.FullNode, gen.WinningPoStProver, beacon.RandomBeacon) *Miner { func NewTestMiner(nextCh <-chan func(bool), addr address.Address) func(api.FullNode, gen.WinningPoStProver) *Miner {
return func(api api.FullNode, epp gen.WinningPoStProver, b beacon.RandomBeacon) *Miner { return func(api api.FullNode, epp gen.WinningPoStProver) *Miner {
arc, err := lru.NewARC(10000) arc, err := lru.NewARC(10000)
if err != nil { if err != nil {
panic(err) panic(err)
} }
m := &Miner{ m := &Miner{
beacon: b,
api: api, api: api,
waitFunc: chanWaiter(nextCh), waitFunc: chanWaiter(nextCh),
epp: epp, epp: epp,

View File

@ -263,13 +263,13 @@ func StagingGraphsync(mctx helpers.MetricsCtx, lc fx.Lifecycle, ibs dtypes.Stagi
return gs return gs
} }
func SetupBlockProducer(lc fx.Lifecycle, ds dtypes.MetadataDS, api lapi.FullNode, epp gen.WinningPoStProver, beacon beacon.RandomBeacon) (*miner.Miner, error) { func SetupBlockProducer(lc fx.Lifecycle, ds dtypes.MetadataDS, api lapi.FullNode, epp gen.WinningPoStProver) (*miner.Miner, error) {
minerAddr, err := minerAddrFromDS(ds) minerAddr, err := minerAddrFromDS(ds)
if err != nil { if err != nil {
return nil, err return nil, err
} }
m := miner.NewMiner(api, epp, beacon, minerAddr) m := miner.NewMiner(api, epp, minerAddr)
lc.Append(fx.Hook{ lc.Append(fx.Hook{
OnStart: func(ctx context.Context) error { OnStart: func(ctx context.Context) error {