Skip to content

Commit

Permalink
Problem: halt-height behavior is not deterministic
Browse files Browse the repository at this point in the history
Solution:
- make sure in state machine that we don't execute block beyond halt-height
  • Loading branch information
yihuang committed Jun 21, 2023
1 parent a827f42 commit eb767a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes

* [#16547](https://github.com/cosmos/cosmos-sdk/pull/16547) Ensure a transaction's gas limit cannot exceed the block gas limit.
* [#]() Make sure we don't execute blocks beyond the halt height.

### Improvements

Expand Down
14 changes: 14 additions & 0 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,20 @@ func (app *BaseApp) VerifyVoteExtension(req *abci.RequestVerifyVoteExtension) (r
func (app *BaseApp) FinalizeBlock(req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) {
var events []abci.Event

// don't execute blocks beyond the halt height
var halt bool
switch {
case app.haltHeight > 0 && uint64(req.Height) > app.haltHeight:
halt = true

case app.haltTime > 0 && req.Time.Unix() > int64(app.haltTime):
halt = true
}

if halt {
return nil, fmt.Errorf("halt per configuration height %d time %d", app.haltHeight, app.haltTime)
}

if err := app.validateFinalizeBlockHeight(req); err != nil {
return nil, err
}
Expand Down

0 comments on commit eb767a1

Please sign in to comment.