Skip to content

Commit

Permalink
Problem: performance is not optimal when blocklist is empty (#1658)
Browse files Browse the repository at this point in the history
* Problem: performance is not optimal when blocklist is empty

* Update CHANGELOG.md

Signed-off-by: yihuang <[email protected]>

---------

Signed-off-by: yihuang <[email protected]>
  • Loading branch information
yihuang authored Oct 23, 2024
1 parent 572aae7 commit 8a698f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* [#1648](https://github.com/crypto-org-chain/cronos/pull/1648) Add abort OE in PrepareProposal.
* (testground)[#1651](https://github.com/crypto-org-chain/cronos/pull/1651) Benchmark use cosmos broadcast rpc.
* (testground)[#1650](https://github.com/crypto-org-chain/cronos/pull/1650) Benchmark support batch mode.
* [#1658](https://github.com/crypto-org-chain/cronos/pull/1658) Optimize when block-list is empty.

*Oct 14, 2024*

Expand Down
10 changes: 10 additions & 0 deletions app/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ func (h *ProposalHandler) SetBlockList(blob []byte) error {
}

func (h *ProposalHandler) ValidateTransaction(tx sdk.Tx) error {
if len(h.blocklist) == 0 {
// fast path, accept all txs
return nil
}

sigTx, ok := tx.(signing.SigVerifiableTx)
if !ok {
return fmt.Errorf("tx of type %T does not implement SigVerifiableTx", tx)
Expand All @@ -147,6 +152,11 @@ func (h *ProposalHandler) ValidateTransaction(tx sdk.Tx) error {

func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler {
return func(ctx sdk.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) {
if len(h.blocklist) == 0 {
// fast path, accept all txs
return &abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil
}

for _, txBz := range req.Txs {
memTx, err := h.TxDecoder(txBz)
if err != nil {
Expand Down

0 comments on commit 8a698f4

Please sign in to comment.