Fix Weight issue

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-08-06 17:00:45 +02:00
parent e54a87f91b
commit a625943fc3
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA

View File

@ -199,8 +199,8 @@ func (syncer *Syncer) InformNewHead(from peer.ID, fts *store.FullTipSet) bool {
syncer.Bsync.AddPeer(from) syncer.Bsync.AddPeer(from)
bestPweight := syncer.store.GetHeaviestTipSet().Blocks()[0].ParentWeight bestPweight := syncer.store.GetHeaviestTipSet().ParentWeight()
targetWeight := fts.TipSet().Blocks()[0].ParentWeight targetWeight := fts.TipSet().ParentWeight()
if targetWeight.LessThan(bestPweight) { if targetWeight.LessThan(bestPweight) {
var miners []string var miners []string
for _, blk := range fts.TipSet().Blocks() { for _, blk := range fts.TipSet().Blocks() {
@ -671,8 +671,6 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) (er
return xerrors.Errorf("failed to get latest beacon entry: %w", err) return xerrors.Errorf("failed to get latest beacon entry: %w", err)
} }
//nulls := h.Height - (baseTs.Height() + 1)
// fast checks first // fast checks first
nulls := h.Height - (baseTs.Height() + 1) nulls := h.Height - (baseTs.Height() + 1)
if tgtTs := baseTs.MinTimestamp() + build.BlockDelaySecs*uint64(nulls+1); h.Timestamp != tgtTs { if tgtTs := baseTs.MinTimestamp() + build.BlockDelaySecs*uint64(nulls+1); h.Timestamp != tgtTs {
@ -700,6 +698,15 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) (er
} }
return nil return nil
}) })
pweight, err := syncer.store.Weight(ctx, baseTs)
if err != nil {
return xerrors.Errorf("getting parent weight: %w", err)
}
if types.BigCmp(pweight, b.Header.ParentWeight) != 0 {
return xerrors.Errorf("parrent weight different: %s (header) != %s (computed)",
b.Header.ParentWeight, pweight)
}
// Stuff that needs stateroot / worker address // Stuff that needs stateroot / worker address
stateroot, precp, err := syncer.sm.TipSetState(ctx, baseTs) stateroot, precp, err := syncer.sm.TipSetState(ctx, baseTs)
@ -994,7 +1001,6 @@ func (syncer *Syncer) checkBlockMessages(ctx context.Context, b *types.FullBlock
return xerrors.Errorf("failed to get actor: %w", err) return xerrors.Errorf("failed to get actor: %w", err)
} }
// redundant check
if !act.IsAccountActor() { if !act.IsAccountActor() {
return xerrors.New("Sender must be an account actor") return xerrors.New("Sender must be an account actor")
} }