From aaf812bfef47399259dc5ad1e8570e31028fa409 Mon Sep 17 00:00:00 2001 From: HuangYi Date: Wed, 23 Oct 2024 11:37:13 +0800 Subject: [PATCH 1/2] Problem: performance is not optimal when blocklist is empty --- CHANGELOG.md | 1 + app/proposal.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d36264fde..99ca97d4c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. +* [#]() Optimize when block-list is empty. *Oct 14, 2024* diff --git a/app/proposal.go b/app/proposal.go index 8a755941c5..3e4465b084 100644 --- a/app/proposal.go +++ b/app/proposal.go @@ -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) @@ -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 { From 1a2bfb495dc350d72c8f3876af1cc6bec841c658 Mon Sep 17 00:00:00 2001 From: yihuang Date: Wed, 23 Oct 2024 12:17:36 +0800 Subject: [PATCH 2/2] Update CHANGELOG.md Signed-off-by: yihuang --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99ca97d4c7..b8da07261a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +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. -* [#]() Optimize when block-list is empty. +* [#1658](https://github.com/crypto-org-chain/cronos/pull/1658) Optimize when block-list is empty. *Oct 14, 2024*