Skip to content

Commit

Permalink
Merge remote-tracking branch 'osmosis/osmo/v0.37.4' into faddat/updat…
Browse files Browse the repository at this point in the history
…e-from-upstream
  • Loading branch information
faddat committed Feb 25, 2024
2 parents 3f935bf + 6e2a1c3 commit 75f9d4f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `[blocksync]` Avoid double-calling `types.BlockFromProto` for performance
reasons ([\#2016](https://github.com/cometbft/cometbft/pull/2016))
21 changes: 13 additions & 8 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
defaults:
actions:
backport:
assignees:
- "{{ author }}"

queue_rules:
- name: default
conditions:
- base=main
- label=S:automerge
- "#approved-reviews-by>=1"

pull_request_rules:
- name: Automerge to main
conditions:
- base=main
- "#approved-reviews-by>=1"
- base=osmo/v0.37.4
- label=S:automerge
actions:
queue:
method: squash
name: default
commit_message_template: |
{{ title }} (#{{ number }})
{{ body }}
- name: backport patches to v0.34.x branch
- name: backport patches to v23 branch
conditions:
- base=main
- label=S:backport-to-v0.34.x
- base=osmo/v0.37.4
- label=S:backport/v23
actions:
backport:
branches:
- v0.34.x
- osmo-v23/v0.37.4
7 changes: 3 additions & 4 deletions blocksync/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ func ValidateMsg(pb proto.Message) error {
return errors.New("negative Height")
}
case *bcproto.BlockResponse:
_, err := types.BlockFromProto(msg.Block)
if err != nil {
return err
}
// Avoid double-calling `types.BlockFromProto` for performance reasons.
// See https://github.com/cometbft/cometbft/issues/1964
return nil
case *bcproto.NoBlockResponse:
if msg.Height < 0 {
return errors.New("negative Height")
Expand Down
5 changes: 3 additions & 2 deletions blocksync/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ func (bcR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
case *bcproto.BlockResponse:
bi, err := types.BlockFromProto(msg.Block)
if err != nil {
bcR.Logger.Error("Block content is invalid", "err", err)
bcR.Logger.Error("Peer sent us invalid block", "peer", e.Src, "msg", e.Message, "err", err)
bcR.Switch.StopPeerForError(e.Src, err)
return
}
bcR.pool.AddBlock(e.Src.ID(), bi, msg.Block.Size())
Expand Down Expand Up @@ -419,7 +420,7 @@ FOR_LOOP:

// TODO: same thing for app - but we would need a way to
// get the hash without persisting the state
state, _, err = bcR.blockExec.ApplyBlock(state, firstID, first)
state, err = bcR.blockExec.ApplyVerifiedBlock(state, firstID, first)
if err != nil {
// TODO This is bad, are we zombie?
panic(fmt.Sprintf("Failed to process committed block (%d:%X): %v", first.Height, first.Hash(), err))
Expand Down
5 changes: 1 addition & 4 deletions mempool/nop_mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,4 @@ func (*NopMempoolReactor) ReceiveEnvelope(p2p.Envelope) {}
// SetSwitch does nothing.
func (*NopMempoolReactor) SetSwitch(*p2p.Switch) {}

// AppHashErrorsCh always returns nil.
func (r *NopMempoolReactor) AppHashErrorsCh() chan p2p.AppHashError {
return nil
}
func (*NopMempoolReactor) AppHashErrorsCh() chan p2p.AppHashError { return nil }
12 changes: 12 additions & 0 deletions state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ func (blockExec *BlockExecutor) ValidateBlock(state State, block *types.Block) e
return blockExec.evpool.CheckEvidence(block.Evidence.Evidence)
}

// ApplyVerifiedBlock does the same as `ApplyBlock`, but skips verification.
func (blockExec *BlockExecutor) ApplyVerifiedBlock(
state State, blockID types.BlockID, block *types.Block,
) (State, error) {
newState, _, err := blockExec.applyBlock(state, blockID, block)
return newState, err
}

// ApplyBlock validates the block against the state, executes it against the app,
// fires the relevant events, commits the app, and saves the new state and responses.
// It returns the new state and the block height to retain (pruning older blocks).
Expand All @@ -193,6 +201,10 @@ func (blockExec *BlockExecutor) ApplyBlock(
return state, 0, ErrInvalidBlock(err)
}

return blockExec.applyBlock(state, blockID, block)
}

func (blockExec *BlockExecutor) applyBlock(state State, blockID types.BlockID, block *types.Block) (State, int64, error) {
startTime := time.Now().UnixNano()
abciResponses, err := execBlockOnProxyApp(
blockExec.logger, blockExec.proxyApp, block, blockExec.store, state.InitialHeight,
Expand Down

0 comments on commit 75f9d4f

Please sign in to comment.