add state check assert routine

This commit is contained in:
alex.sharov 2021-08-28 15:02:02 +07:00
parent 3d5b89c4b9
commit adaa3bb2ff

View File

@ -1782,7 +1782,7 @@ func BroadcastLoop(ctx context.Context, db kv.RwDB, coreDB kv.RoDB, p *TxPool, s
if ASSERT {
go func() {
if err := p.forceCheckState(ctx, db, coreDB); err != nil {
log.Error("restore from db", "err", err)
log.Error("forceCheckState", "err", err)
}
}()
}
@ -1866,6 +1866,12 @@ func (p *TxPool) forceCheckState(ctx context.Context, db, coreDB kv.RoDB) error
if err != nil {
return err
}
if v2 == nil {
// for now skip this case because we do create
// account with 0 nonce and 0 balance for unknown senders (because
// they may become known in near future)
return nil
}
if !bytes.Equal(v, v2) {
return fmt.Errorf("state check failed: key=%x, local value=%x, remote value=%x\n", k, v, v2)
}