Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
bet
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed Jun 1, 2024
1 parent e74ef39 commit dc20c63
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cosmos/runtime/miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,20 @@ func (m *Miner) submitPayloadForBuilding(ctx context.Context) error {
// to clock skew / rounding to commit two blocks in succession with the same
// unix time. This will prevent the block from being built.
prevBlockTs := uint64(0)
if finalBlock := m.bc.CurrentFinalBlock(); finalBlock != nil {
prevBlockTs = finalBlock.Time
if finalBlock := m.bc.GetBlockByNumber(uint64(sCtx.BlockHeight()) - 1); finalBlock != nil {
prevBlockTs = finalBlock.Time()
} else {
// If we fail to find the previous block, we minimum of the current time
// and the next block time, time.Now() is always increasing, so eventually
// time.Now() > sCtx.BlockTime() + 1.
prevBlockTs = min(uint64(time.Now().Unix()), uint64(sCtx.BlockTime().Unix())+1)
}

// Ensure that the block time is always increasing.
if prevBlockTs <= uint64(sCtx.BlockTime().Unix()) {
prevBlockTs = uint64(sCtx.BlockTime().Unix())
}

ts := max(uint64(sCtx.BlockTime().Unix()), prevBlockTs+1)

// Build Payload.
Expand Down

0 comments on commit dc20c63

Please sign in to comment.