-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
feat(server/v2/cometbft): Implement necessary handlers and helpers for vote extensions #22830
Changes from 7 commits
adebbc0
1c54265
79efd34
8944e10
ed2e353
aaff4f5
fc20251
741cdeb
ee42697
97ec24b
0a13d59
0807cb3
7db5e2a
6ee24df
ad2801e
28beb94
f620313
ca5d8f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ func NewDefaultProposalHandler[T transaction.Tx](mp mempool.Mempool[T]) *Default | |
} | ||
|
||
func (h *DefaultProposalHandler[T]) PrepareHandler() PrepareHandler[T] { | ||
return func(ctx context.Context, app AppManager[T], codec transaction.Codec[T], req *abci.PrepareProposalRequest) ([]T, error) { | ||
return func(ctx context.Context, app AppManager[T], codec transaction.Codec[T], req *abci.PrepareProposalRequest, chainID string) ([]T, error) { | ||
var maxBlockGas uint64 | ||
|
||
res, err := app.Query(ctx, 0, &consensustypes.QueryParamsRequest{}) | ||
|
@@ -98,7 +98,7 @@ func (h *DefaultProposalHandler[T]) PrepareHandler() PrepareHandler[T] { | |
} | ||
|
||
func (h *DefaultProposalHandler[T]) ProcessHandler() ProcessHandler[T] { | ||
return func(ctx context.Context, app AppManager[T], codec transaction.Codec[T], req *abci.ProcessProposalRequest) error { | ||
return func(ctx context.Context, app AppManager[T], codec transaction.Codec[T], req *abci.ProcessProposalRequest, chainID string) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Remove unused chainID parameter from ProcessHandler The
🔗 Analysis chainVerify the usage of chainID parameter Similar to PrepareHandler, the 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for chainID usage in process proposal handlers
rg -A 5 "chainID.*ProcessProposal"
Length of output: 36 Script: #!/bin/bash
# Let's search for the ProcessHandler function implementation and check chainID usage
ast-grep --pattern 'func ProcessHandler[T any]($$$) func($$$) error {
$$$
}'
# Also search for any chainID usage in the file
rg -A 5 "chainID" server/v2/cometbft/handlers/defaults.go
Length of output: 1064 |
||
// If the mempool is nil we simply return ACCEPT, | ||
// because PrepareProposal may have included txs that could fail verification. | ||
_, isNoOp := h.mempool.(mempool.NoOpMempool[T]) | ||
|
@@ -174,15 +174,15 @@ func decodeTxs[T transaction.Tx](codec transaction.Codec[T], txsBz [][]byte) []T | |
// NoOpPrepareProposal defines a no-op PrepareProposal handler. It will always | ||
// return the transactions sent by the client's request. | ||
func NoOpPrepareProposal[T transaction.Tx]() PrepareHandler[T] { | ||
return func(ctx context.Context, app AppManager[T], codec transaction.Codec[T], req *abci.PrepareProposalRequest) ([]T, error) { | ||
return func(ctx context.Context, app AppManager[T], codec transaction.Codec[T], req *abci.PrepareProposalRequest, chainID string) ([]T, error) { | ||
return decodeTxs(codec, req.Txs), nil | ||
} | ||
} | ||
|
||
// NoOpProcessProposal defines a no-op ProcessProposal Handler. It will always | ||
// return ACCEPT. | ||
func NoOpProcessProposal[T transaction.Tx]() ProcessHandler[T] { | ||
return func(context.Context, AppManager[T], transaction.Codec[T], *abci.ProcessProposalRequest) error { | ||
return func(context.Context, AppManager[T], transaction.Codec[T], *abci.ProcessProposalRequest, string) error { | ||
return nil | ||
} | ||
} | ||
|
@@ -197,7 +197,7 @@ func NoOpExtendVote() ExtendVoteHandler { | |
|
||
// NoOpVerifyVoteExtensionHandler defines a no-op VerifyVoteExtension handler. It | ||
// will always return an ACCEPT status with no error. | ||
func NoOpVerifyVoteExtensionHandler() VerifyVoteExtensionhandler { | ||
func NoOpVerifyVoteExtensionHandler() VerifyVoteExtensionHandler { | ||
return func(context.Context, store.ReaderMap, *abci.VerifyVoteExtensionRequest) (*abci.VerifyVoteExtensionResponse, error) { | ||
return &abci.VerifyVoteExtensionResponse{Status: abci.VERIFY_VOTE_EXTENSION_STATUS_ACCEPT}, nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add go docs here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should precise as well that the module preblocker are ran before any logic there.
Which makes me think, do you think we should always run pre blocker before their logic?
What if we give them a callback to call preblocker themselves if needed.
Like
And then above we do smth like
Not sure if needed however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this, adding it