[WIP] Fix ticket randomness

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Steven Allen 2020-09-02 10:44:17 -07:00 committed by Aayush Rajasekaran
parent 98a9042c07
commit 7a46c5ff31
4 changed files with 8 additions and 11 deletions

View File

@ -358,9 +358,7 @@ func (cg *ChainGen) nextBlockProof(ctx context.Context, pts *types.TipSet, m add
return nil, nil, nil, xerrors.Errorf("failed to cbor marshal address: %w", err)
}
if len(entries) == 0 {
buf.Write(pts.MinTicket().VRFProof)
}
buf.Write(pts.MinTicket().VRFProof)
ticketRand, err := store.DrawRandomness(rbase.Data, crypto.DomainSeparationTag_TicketProduction, round-build.TicketRandomnessLookback, buf.Bytes())
if err != nil {

View File

@ -891,10 +891,10 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) (er
return xerrors.Errorf("failed to marshal miner address to cbor: %w", err)
}
buf.Write(baseTs.MinTicket().VRFProof)
beaconBase := *prevBeacon
if len(h.BeaconEntries) == 0 {
buf.Write(baseTs.MinTicket().VRFProof)
} else {
if len(h.BeaconEntries) != 0 {
beaconBase = h.BeaconEntries[len(h.BeaconEntries)-1]
}

View File

@ -46,6 +46,7 @@ func init() {
return xerrors.Errorf("StateMinerWorker: %w", err)
}
// XXX: This can't be right
rand, err := api.ChainGetRandomnessFromTickets(ctx, head.Key(), crypto.DomainSeparationTag_TicketProduction, head.Height(), addr.Bytes())
if err != nil {
return xerrors.Errorf("failed to get randomness: %w", err)

View File

@ -362,7 +362,7 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg,
rbase = bvals[len(bvals)-1]
}
ticket, err := m.computeTicket(ctx, &rbase, base, len(bvals) > 0)
ticket, err := m.computeTicket(ctx, &rbase, base)
if err != nil {
return nil, xerrors.Errorf("scratching ticket failed: %w", err)
}
@ -432,7 +432,7 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg,
return b, nil
}
func (m *Miner) computeTicket(ctx context.Context, brand *types.BeaconEntry, base *MiningBase, haveNewEntries bool) (*types.Ticket, error) {
func (m *Miner) computeTicket(ctx context.Context, brand *types.BeaconEntry, base *MiningBase) (*types.Ticket, error) {
mi, err := m.api.StateMinerInfo(ctx, m.address, types.EmptyTSK)
if err != nil {
return nil, err
@ -447,9 +447,7 @@ func (m *Miner) computeTicket(ctx context.Context, brand *types.BeaconEntry, bas
return nil, xerrors.Errorf("failed to marshal address to cbor: %w", err)
}
if !haveNewEntries {
buf.Write(base.TipSet.MinTicket().VRFProof)
}
buf.Write(base.TipSet.MinTicket().VRFProof)
input, err := store.DrawRandomness(brand.Data, crypto.DomainSeparationTag_TicketProduction, base.TipSet.Height()+base.NullRounds+1-build.TicketRandomnessLookback, buf.Bytes())
if err != nil {