Skip to content

Commit

Permalink
feat(bpos): instead RevertToPOWV1Height with new change view height
Browse files Browse the repository at this point in the history
  • Loading branch information
RainFallsSilent committed Jun 29, 2023
1 parent 1346d98 commit 366fc47
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
17 changes: 6 additions & 11 deletions common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ func GetDefaultParams() *Configuration {
MaxInactiveRoundsOfRandomNode: 36 * 8,
RevertToPOWNoBlockTime: 12 * 3600,
StopConfirmBlockTime: 11 * 3600,
RevertToPOWV1Height: math.MaxUint32, // todo complete me
RevertToPOWNoBlockTimeV1: 2 * 3600, // todo complete me
StopConfirmBlockTimeV1: 6600, // todo complete me
ChangeViewV1Height: math.MaxUint32, // todo complete me
Expand Down Expand Up @@ -364,10 +363,9 @@ func (p *Configuration) TestNet() *Configuration {
p.MaxReservedCustomIDLength = 255
p.DPoSConfiguration.RevertToPOWNoBlockTime = 12 * 3600
p.DPoSConfiguration.StopConfirmBlockTime = 11 * 3600
p.DPoSConfiguration.RevertToPOWV1Height = math.MaxUint32 // todo complete me
p.DPoSConfiguration.RevertToPOWNoBlockTimeV1 = 2 * 3600 // todo complete me
p.DPoSConfiguration.StopConfirmBlockTimeV1 = 6600 // todo complete me
p.DPoSConfiguration.ChangeViewV1Height = math.MaxUint32 // todo complete me
p.DPoSConfiguration.RevertToPOWNoBlockTimeV1 = 2 * 3600 // todo complete me
p.DPoSConfiguration.StopConfirmBlockTimeV1 = 6600 // todo complete me
p.DPoSConfiguration.ChangeViewV1Height = math.MaxUint32 // todo complete me
p.DPoSConfiguration.RevertToPOWStartHeight = 815060
p.HalvingRewardHeight = 877880 //767000 + 154 * 720
p.HalvingRewardInterval = 1051200 //4 * 365 * 720
Expand Down Expand Up @@ -492,10 +490,9 @@ func (p *Configuration) RegNet() *Configuration {
p.MaxReservedCustomIDLength = 255
p.DPoSConfiguration.RevertToPOWNoBlockTime = 12 * 3600
p.DPoSConfiguration.StopConfirmBlockTime = 11 * 3600
p.DPoSConfiguration.RevertToPOWV1Height = math.MaxUint32 // todo complete me
p.DPoSConfiguration.RevertToPOWNoBlockTimeV1 = 2 * 3600 // todo complete me
p.DPoSConfiguration.StopConfirmBlockTimeV1 = 6600 // todo complete me
p.DPoSConfiguration.ChangeViewV1Height = math.MaxUint32 // todo complete me
p.DPoSConfiguration.RevertToPOWNoBlockTimeV1 = 2 * 3600 // todo complete me
p.DPoSConfiguration.StopConfirmBlockTimeV1 = 6600 // todo complete me
p.DPoSConfiguration.ChangeViewV1Height = math.MaxUint32 // todo complete me
p.DPoSConfiguration.RevertToPOWStartHeight = 706240
p.HalvingRewardHeight = 801240 //690360 + 154 * 720
p.HalvingRewardInterval = 1051200 //4 * 365 * 720
Expand Down Expand Up @@ -733,8 +730,6 @@ type DPoSConfiguration struct {
RevertToPOWNoBlockTime int64 `screw:"--reverttopownoblocktime" usage:"defines how long time does it take to revert to POW mode"`
// StopConfirmBlockTime defines how long time dose it take before stop confirm block.
StopConfirmBlockTime int64 `screw:"--stopconfirmblocktime" usage:"defines how long time does it take to stop confirm block"`
// RevertToPOWV1Height defines how the height of POW mode of version 1.0
RevertToPOWV1Height uint32 `screw:"--reverttopowv1height" usage:"defines how the height of POW mode of version 1.0"`
// RevertToPOWInterval defines how long time does it take to revert to POW mode.
RevertToPOWNoBlockTimeV1 int64 `screw:"--reverttopownoblocktimev1" usage:"defines how long time does it take to revert to POW mode"`
// StopConfirmBlockTime defines how long time dose it take before stop confirm block.
Expand Down
2 changes: 1 addition & 1 deletion core/transaction/reverttopowtransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (t *RevertToPOWTransaction) SpecialContextCheck() (result elaerr.ELAError,
lastBlockTime := int64(t.parameters.BlockChain.BestChain.Timestamp)

var noBlockTime int64
if t.parameters.BlockHeight < t.parameters.Config.DPoSConfiguration.RevertToPOWV1Height {
if t.parameters.BlockHeight < t.parameters.Config.DPoSConfiguration.ChangeViewV1Height {
noBlockTime = t.parameters.Config.DPoSConfiguration.RevertToPOWNoBlockTime
} else {
noBlockTime = t.parameters.Config.DPoSConfiguration.RevertToPOWNoBlockTimeV1
Expand Down
2 changes: 1 addition & 1 deletion dpos/arbitrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (a *Arbitrator) OnBlockReceived(b *types.Block, confirmed bool) {
localTimestamp := a.cfg.Chain.TimeSource.AdjustedTime().Unix()

var stopConfirmTime int64
if b.Height < a.cfg.ChainParams.DPoSConfiguration.RevertToPOWV1Height {
if b.Height < a.cfg.ChainParams.DPoSConfiguration.ChangeViewV1Height {
stopConfirmTime = a.cfg.ChainParams.DPoSConfiguration.StopConfirmBlockTime
} else {
stopConfirmTime = a.cfg.ChainParams.DPoSConfiguration.StopConfirmBlockTime
Expand Down
2 changes: 1 addition & 1 deletion pow/revertlistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (pow *Service) ListenForRevert() {
lastBlockTimestamp := int64(pow.arbiters.GetLastBlockTimestamp())
localTimestamp := pow.chain.TimeSource.AdjustedTime().Unix()
var noBlockTime int64
if currentHeight < pow.chainParams.DPoSConfiguration.RevertToPOWV1Height {
if currentHeight < pow.chainParams.DPoSConfiguration.ChangeViewV1Height {
noBlockTime = pow.chainParams.DPoSConfiguration.RevertToPOWNoBlockTime
} else {
noBlockTime = pow.chainParams.DPoSConfiguration.RevertToPOWNoBlockTimeV1
Expand Down

0 comments on commit 366fc47

Please sign in to comment.