dont allow submitting blocks more than a second in the future

This commit is contained in:
whyrusleeping 2019-12-15 16:43:32 -08:00
parent dad3b1cb26
commit 159117e720
2 changed files with 2 additions and 2 deletions

View File

@ -31,7 +31,7 @@ const PaymentChannelClosingDelay = 6 * 60 * 60 / BlockDelay // six hours
// Consensus / Network // Consensus / Network
// Seconds // Seconds
const AllowableClockDrift = BlockDelay * 2 const AllowableClockDrift = 1
// Epochs // Epochs
const ForkLengthThreshold = Finality const ForkLengthThreshold = Finality

View File

@ -480,7 +480,7 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
} }
if h.Timestamp > uint64(time.Now().Unix()+build.AllowableClockDrift) { if h.Timestamp > uint64(time.Now().Unix()+build.AllowableClockDrift) {
return xerrors.Errorf("block was from the future") return xerrors.Errorf("block was from the future: %w", ErrTemporal)
} }
if h.Timestamp > uint64(time.Now().Unix()) { if h.Timestamp > uint64(time.Now().Unix()) {
log.Warn("Got block from the future, but within threshold", h.Timestamp, time.Now().Unix()) log.Warn("Got block from the future, but within threshold", h.Timestamp, time.Now().Unix())