This helps for some reason

This commit is contained in:
Łukasz Magiera 2019-12-03 17:39:47 +01:00
parent 9ad4a00cda
commit 5810922441
2 changed files with 16 additions and 4 deletions

View File

@ -195,6 +195,7 @@ func (sm *StateManager) computeTipSetState(ctx context.Context, blks []*types.Bl
}
if applied[m.From] != m.Nonce {
log.Infof("skipping message from %s: nonce check failed: exp %d, was %d", m.From, applied[m.From], m.Nonce)
continue
}
applied[m.From]++

View File

@ -2,6 +2,7 @@ package miner
import (
"context"
"sort"
"sync"
"time"
@ -348,16 +349,26 @@ func (m *Miner) actorLookup(ctx context.Context, addr address.Address, ts *types
balance := act.Balance
curnonce := act.Nonce
sort.Slice(msgs, func(i, j int) bool { // TODO: is this actually needed?
return msgs[i].Message.Nonce < msgs[j].Message.Nonce
})
max := int64(-2)
for _, m := range msgs {
if m.Message.From == addr {
if m.Message.Nonce != curnonce {
return 0, nil, xerrors.Errorf("tipset messages had bad nonce: %s had nonce %d, expected %d", m.Cid, m.Message.Nonce, curnonce)
}
curnonce++
max = int64(m.Message.Nonce)
balance = types.BigSub(balance, m.Message.RequiredFunds())
}
}
max++ // next unapplied nonce
if max != -1 && uint64(max) != curnonce {
return 0, nil, xerrors.Errorf("tipset messages from %s have too low nonce %d, expected %d, h: %d", addr, max, curnonce, ts.Height())
}
return curnonce, &balance, nil
}