Rejects empty transactions in the example kvstore#9823
Merged
Conversation
sergio-mena
approved these changes
Dec 6, 2022
Contributor
sergio-mena
left a comment
There was a problem hiding this comment.
Thanks @lasarojc for this
abci/example/kvstore/kvstore_test.go
Outdated
| txs = append(txs, []byte("key=value"), []byte("key"), []byte(""), []byte("kee=value")) | ||
| reqPrepare := types.RequestPrepareProposal{Txs: txs, MaxTxBytes: 10 * 1024} | ||
| resPrepare := kvstore.PrepareProposal(reqPrepare) | ||
| require.Equal(t, len(reqPrepare.Txs), len(resPrepare.Txs)+1, "Request ") |
lasarojc
commented
Dec 6, 2022
Co-authored-by: Sergio Mena <sergio@informal.systems>
mergify bot
pushed a commit
that referenced
this pull request
Dec 6, 2022
* Rejects empty transactions in the example kvstore * Add code for rejected transaction; Add test for txn rejection; * Apply suggestions from code review Co-authored-by: Sergio Mena <sergio@informal.systems> (cherry picked from commit 49502da)
lasarojc
added a commit
that referenced
this pull request
Dec 6, 2022
* Rejects empty transactions in the example kvstore * Add code for rejected transaction; Add test for txn rejection; * Apply suggestions from code review Co-authored-by: Sergio Mena <sergio@informal.systems> (cherry picked from commit 49502da) Co-authored-by: Lasaro Camargos <lasaro@informal.systems>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the kvstore, empty transactions accepted in the mempool and in prepareProposal, but not in processProposal. Hence, if an empty transaction is submitted to the system, it might keep being put into proposal which will always be rejected, effectively halting the chain.
This PR prevents empty transactions from being added to the pool and in the proposals. The check in prepareProposal isn't actually needed, but serves as an example that transactions should be checked for validity both when entering the pool and when being added to a proposal.
PR checklist
CHANGELOG_PENDING.mdupdated, or no changelog entry neededdocs/) and code comments, or nodocumentation updates needed