Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine multiple hardforks into one #1039

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@
}

//Hardfork to remove the rotation of validator list on stake update
if ctx.BlockHeight() < helper.GetValidatorSetRotationStopHeight() {
if ctx.BlockHeight() < helper.GetAalborgHardForkHeight() {

Check warning on line 602 in app/app.go

View check run for this annotation

Codecov / codecov/patch

app/app.go#L602

Added line #L602 was not covered by tests
// increment proposer priority
currentValidatorSet.IncrementProposerPriority(1)
}
Expand Down
2 changes: 1 addition & 1 deletion auth/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func NewAnteHandler(
}()

//Check whether the chain has reached the hard fork length to execute milestone msgs
if ctx.BlockHeight() <= helper.GetMilestoneHardForkHeight() && stdTx.Msg.Type() == checkpointTypes.EventTypeMilestone {
if ctx.BlockHeight() < helper.GetAalborgHardForkHeight() && stdTx.Msg.Type() == checkpointTypes.EventTypeMilestone {
return newCtx, sdk.ErrUnknownRequest("Milestone msgs proposed before the hardfork").Result(), true
}

Expand Down
3 changes: 2 additions & 1 deletion auth/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ func (suite *AnteTestSuite) TestMilestoneHardFork() {
// checkpoint msg
msg := TestMilestoneMsg{*sdkAuth.NewTestMsg(addr1)}

ctx = ctx.WithBlockHeight(int64(0))
//Setting block height to -1 t0 check for the hard fork
ctx = ctx.WithBlockHeight(int64(-1))
// test good tx from one signer
tx = types.NewTestTx(ctx, sdk.Msg(&msg), priv1, acc1.GetAccountNumber(), uint64(0))
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnknownRequest)
Expand Down
8 changes: 4 additions & 4 deletions bridge/setu/processor/milestone.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func (mp *MilestoneProcessor) startPolling(ctx context.Context, milestoneLength
// 3. if so, propose milestone to heimdall.
func (mp *MilestoneProcessor) checkAndPropose(milestoneLength uint64) (err error) {
//Milestone proposing mechanism will work only after specific block height
if util.GetBlockHeight(mp.cliCtx) < helper.GetMilestoneHardForkHeight() {
mp.Logger.Debug("Block height Less than fork height", "current block height", util.GetBlockHeight(mp.cliCtx), "milestone hard fork height", helper.GetMilestoneHardForkHeight())
if util.GetBlockHeight(mp.cliCtx) < helper.GetAalborgHardForkHeight() {
mp.Logger.Debug("Block height Less than fork height", "current block height", util.GetBlockHeight(mp.cliCtx), "milestone hard fork height", helper.GetAalborgHardForkHeight())
return nil
}

Expand Down Expand Up @@ -225,8 +225,8 @@ func (mp *MilestoneProcessor) startPollingMilestoneTimeout(ctx context.Context,
// 3. if so, propose milestone to heimdall.
func (mp *MilestoneProcessor) checkAndProposeMilestoneTimeout() (err error) {
//Milestone proposing mechanism will work only after specific block height
if util.GetBlockHeight(mp.cliCtx) < helper.GetMilestoneHardForkHeight() {
mp.Logger.Debug("Block height Less than fork height", "current block height", util.GetBlockHeight(mp.cliCtx), "milestone hard fork height", helper.GetMilestoneHardForkHeight())
if util.GetBlockHeight(mp.cliCtx) < helper.GetAalborgHardForkHeight() {
mp.Logger.Debug("Block height Less than fork height", "current block height", util.GetBlockHeight(mp.cliCtx), "milestone hard fork height", helper.GetAalborgHardForkHeight())
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion checkpoint/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func handleMsgCheckpointNoAck(ctx sdk.Context, msg types.MsgCheckpointNoAck, k K
}

//Hardfork to check the validaty of the NoAckProposer
if ctx.BlockHeight() >= helper.GetNoAckProposerCheckHeight() {
if ctx.BlockHeight() >= helper.GetAalborgHardForkHeight() {
timeDiff := currentTime.Sub(lastCheckpointTime)

//count value is calculated based on the time passed since the last checkpoint
Expand Down
6 changes: 0 additions & 6 deletions checkpoint/side_milestone_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ func SideHandleMsgMilestone(ctx sdk.Context, k Keeper, msg types.MsgMilestone, c
// logger
logger := k.Logger(ctx)

//Check whether the chain has reached the hard fork length
if ctx.BlockHeight() < helper.GetMilestoneHardForkHeight() {
VAIBHAVJINDAL3012 marked this conversation as resolved.
Show resolved Hide resolved
logger.Error("Network hasn't reached the", "Hard forked height", helper.GetMilestoneHardForkHeight())
return common.ErrorSideTx(k.Codespace(), common.CodeInvalidBlockInput)
}

//Get the milestone count
count := k.GetMilestoneCount(ctx)
lastMilestone, err := k.GetLastMilestone(ctx)
Expand Down
21 changes: 0 additions & 21 deletions checkpoint/side_milestone_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,6 @@ func (suite *SideHandlerTestSuite) TestSideHandleMsgMilestone() {

borChainId := "1234"

suite.Run("Failure-Before Hard Fork", func() {
VAIBHAVJINDAL3012 marked this conversation as resolved.
Show resolved Hide resolved

// create milestone msg
msgMilestone := types.NewMsgMilestoneBlock(
milestone.Proposer,
milestone.StartBlock,
milestone.EndBlock,
milestone.Hash,
borChainId,
milestone.MilestoneID,
)

ctxNew := ctx.WithBlockHeight(-1) //Setting height as -1 just to check for the hard fork.

// send milestone to handler
result := suite.sideHandler(ctxNew, msgMilestone)
require.NotEqual(t, uint32(sdk.CodeOK), result.Code, "Side tx handler should Fail")
require.Equal(t, uint32(common.CodeInvalidBlockInput), result.Code)

})

suite.Run("Success", func() {
suite.contractCaller = mocks.IContractCaller{}

Expand Down
37 changes: 8 additions & 29 deletions helper/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,10 @@ var GenesisDoc tmTypes.GenesisDoc
var newSelectionAlgoHeight int64 = 0

var spanOverrideHeight int64 = 0
var noAckProposerCheckHeight int64 = 0

var milestoneHardForkHeight int64 = 0

var milestoneBorBlockHeight uint64 = 0

var validatorSetRotationStopHeight int64 = 0
var aalborgHeight int64 = 0

var newHexToStringAlgoHeight int64 = 0

Expand Down Expand Up @@ -397,27 +394,18 @@ func InitHeimdallConfigWith(homeDir string, heimdallConfigFileFromFLag string) {
case MainChain:
newSelectionAlgoHeight = 375300
spanOverrideHeight = 8664000
newHexToStringAlgoHeight = 9266260
noAckProposerCheckHeight = 50000000
milestoneHardForkHeight = 50
milestoneBorBlockHeight = 1000 //Fixme:Change the value
validatorSetRotationStopHeight = 50000000 //Change this value
newHexToStringAlgoHeight = 9266260
aalborgHeight = 1000000000 //NOTE:IT IS NOT CONFIRMED,WILL CHANGE THIS VALUE IN FUTURE
case MumbaiChain:
newSelectionAlgoHeight = 282500
spanOverrideHeight = 10205000
newHexToStringAlgoHeight = 12048023
noAckProposerCheckHeight = 50000000
milestoneHardForkHeight = 50
milestoneBorBlockHeight = 1000 //Fixme:Change the value
validatorSetRotationStopHeight = 50000000 //Change this value
aalborgHeight = 18035772
default:
newSelectionAlgoHeight = 0
spanOverrideHeight = 0
newHexToStringAlgoHeight = 0
noAckProposerCheckHeight = 50000000
milestoneHardForkHeight = 50
milestoneBorBlockHeight = 1000 //Fixme:Change the value
validatorSetRotationStopHeight = 50000000 //Change this value
aalborgHeight = 0
}
}

Expand Down Expand Up @@ -537,25 +525,16 @@ func GetSpanOverrideHeight() int64 {
return spanOverrideHeight
}

// GetNoAckProposerCheckHeight returns noAckProposerCheckHeight
func GetNoAckProposerCheckHeight() int64 {
return noAckProposerCheckHeight
}
// GetMilestoneHardForkHeight returns milestoneHardForkHeight
func GetMilestoneHardForkHeight() int64 {
return milestoneHardForkHeight
// GetAalborgHardForkHeight returns AalborgHardForkHeight
func GetAalborgHardForkHeight() int64 {
return aalborgHeight
}

// GetMilestoneBorBlockHeight returns milestoneBorBlockHeight
func GetMilestoneBorBlockHeight() uint64 {
return milestoneBorBlockHeight
}

// GetValidatorSetRotationStopHeight returns validatorSetRotationStopHeight
func GetValidatorSetRotationStopHeight() int64 {
return validatorSetRotationStopHeight
}

// GetNewHexToStringAlgoHeight returns newHexToStringAlgoHeight
func GetNewHexToStringAlgoHeight() int64 {
return newHexToStringAlgoHeight
Expand Down
2 changes: 1 addition & 1 deletion staking/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func (k *Keeper) UpdateValidatorSetInStore(ctx sdk.Context, newValidatorSet hmTy

//Hard fork changes for milestone
//When there is any update in checkpoint validator set, we assign it to milestone validator set too.
if ctx.BlockHeight() >= helper.GetMilestoneHardForkHeight() {
if ctx.BlockHeight() >= helper.GetAalborgHardForkHeight() {
store.Set(CurrentMilestoneValidatorSetKey, bz)
}

Expand Down