Skip to content

Commit

Permalink
Make the header timestamp respect time of generation (#220)
Browse files Browse the repository at this point in the history
# Description

This PR makes sure the header timestamp respects the time of generation.

Merging from Polygon Edge [PR
678](0xPolygon#678).

# Changes include

- [x] Bugfix (non-breaking change that solves an issue)
- [ ] Hotfix (change that solves an urgent issue, and requires immediate
attention)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (change that is not backwards-compatible and/or
changes current functionality)

# Checklist

- [x] I have assigned this PR to myself
- [x] I have added at least 1 reviewer
- [x] I have added the relevant labels
- [ ] I have updated the official documentation
- [ ] I have added sufficient documentation in code

## Testing

- [x] I have tested this code with the official test suite
- [ ] I have tested this code manually
  • Loading branch information
DarianShawn authored Oct 24, 2022
1 parent 23e72e9 commit a7eab44
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions consensus/ibft/ibft.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,7 @@ func (i *Ibft) buildBlock(snap *Snapshot, parent *types.Header) (*types.Block, e
}

// set the timestamp
parentTime := time.Unix(int64(parent.Timestamp), 0)
headerTime := parentTime.Add(i.blockTime)

if headerTime.Before(time.Now()) {
headerTime = time.Now()
}

header.Timestamp = uint64(headerTime.Unix())
header.Timestamp = uint64(time.Now().Unix())

// we need to include in the extra field the current set of validators
putIbftExtraValidators(header, snap.Set)
Expand Down

0 comments on commit a7eab44

Please sign in to comment.