Skip to content

Commit

Permalink
Revert "timestamp ahead two days latest"
Browse files Browse the repository at this point in the history
This reverts commit 9c58691.
  • Loading branch information
andicrypt committed Aug 14, 2024
1 parent 9c58691 commit 889b0b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 31 deletions.
29 changes: 6 additions & 23 deletions consensus/consortium/v2/consortium.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ const (
assemblingFinalityVoteDuration = 1 * time.Second
MaxValidatorCandidates = 64 // Maximum number of validator candidates.
dayInSeconds = uint64(86400)

// enable rep10 logic at 14pm tuesday, which virtually correspond to 7am thursday
TWO_DAY_IN_SECONDS = uint64(86400 + 17*60*60)
)

// Consortium delegated proof-of-stake protocol constants.
Expand Down Expand Up @@ -515,9 +512,9 @@ func (c *Consortium) verifyCascadingFields(chain consensus.ChainHeaderReader, he
if err != nil {
return err
}
// if err = c.verifyHeaderTime(header, parent, snap); err != nil {
// return err
// }
if err = c.verifyHeaderTime(header, parent, snap); err != nil {
return err
}

// All basic checks passed, verify the seal and return
return c.verifySeal(chain, header, parents, snap)
Expand Down Expand Up @@ -991,11 +988,7 @@ func (c *Consortium) Prepare(chain consensus.ChainHeaderReader, header *types.He
return consensus.ErrUnknownAncestor
}

if c.chainConfig.ShadowForkBlock.Cmp(header.Number) == 0 {
header.Time = c.computeHeaderTime(header, parent, snap) + TWO_DAY_IN_SECONDS
} else {
header.Time = c.computeHeaderTime(header, parent, snap)
}
header.Time = c.computeHeaderTime(header, parent, snap)
return nil
}

Expand Down Expand Up @@ -1369,12 +1362,7 @@ func (c *Consortium) Seal(chain consensus.ChainHeaderReader, block *types.Block,

// Sweet, the protocol permits us to sign the block, wait for our time
// After the Buba hardfork, the delay is included in header time already
var delay time.Duration
if c.chainConfig.IsShadow(header.Number) {
delay = time.Until(time.Unix(int64(header.Time-TWO_DAY_IN_SECONDS), 0))
} else {
delay = time.Until(time.Unix(int64(header.Time), 0))
}
delay := time.Until(time.Unix(int64(header.Time), 0))
if !c.chainConfig.IsBuba(block.Number()) {
if header.Difficulty.Cmp(diffInTurn) != 0 {
// It's not our turn explicitly to sign, delay it a bit
Expand Down Expand Up @@ -1404,12 +1392,7 @@ func (c *Consortium) Seal(chain consensus.ChainHeaderReader, block *types.Block,
copy(header.Extra[len(header.Extra)-consortiumCommon.ExtraSeal:], sig)
}

if c.chainConfig.IsShadow(header.Number) {
delay = time.Until(time.Unix(int64(header.Time-TWO_DAY_IN_SECONDS), 0))
} else {
delay = time.Until(time.Unix(int64(header.Time), 0))
}

delay = time.Until(time.Unix(int64(header.Time), 0))
select {
case <-stop:
return
Expand Down
2 changes: 1 addition & 1 deletion core/vm/consortium_precompiled_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func (c *consortiumVerifyHeaders) unpack(smcAbi abi.ABI, v interface{}, input []
}

func (c *consortiumVerifyHeaders) getSigner(header types.BlockHeader) (common.Address, error) {
if header.Number == nil || (!c.evm.chainConfig.IsShadow(header.Number) && header.Timestamp > uint64(time.Now().Unix())) || len(header.ExtraData) < crypto.SignatureLength {
if header.Number == nil || header.Timestamp > uint64(time.Now().Unix()) || len(header.ExtraData) < crypto.SignatureLength {
return common.Address{}, errors.New("invalid header")
}
signature := header.ExtraData[len(header.ExtraData)-crypto.SignatureLength:]
Expand Down
8 changes: 1 addition & 7 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/consortium"
v2 "github.com/ethereum/go-ethereum/consensus/consortium/v2"
"github.com/ethereum/go-ethereum/consensus/misc"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
Expand Down Expand Up @@ -908,12 +907,7 @@ func (w *worker) commitTransactions(txs *types.TransactionsByPriceAndNonce, coin
// block with transactions to be produced and abort the
// empty block producer.
if w.chainConfig.IsBuba(w.current.header.Number) {
var duration time.Duration
if w.chainConfig.IsShadow(w.current.header.Number) {
duration = time.Until(time.Unix(int64(w.current.header.Time - v2.TWO_DAY_IN_SECONDS), 0)) - w.config.BlockProduceLeftOver
} else {
duration = time.Until(time.Unix(int64(w.current.header.Time), 0)) - w.config.BlockProduceLeftOver
}
duration := time.Until(time.Unix(int64(w.current.header.Time), 0)) - w.config.BlockProduceLeftOver
timer = time.NewTimer(duration)
}

Expand Down

0 comments on commit 889b0b8

Please sign in to comment.