Skip to content

Rejects empty transactions in the example kvstore#9823

Merged
lasarojc merged 5 commits intomainfrom
lasarojc/code/reject_empty_transactions
Dec 6, 2022
Merged

Rejects empty transactions in the example kvstore#9823
lasarojc merged 5 commits intomainfrom
lasarojc/code/reject_empty_transactions

Conversation

@lasarojc
Copy link
Contributor

@lasarojc lasarojc commented Dec 2, 2022

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

  • Tests written/updated, or no tests needed
  • CHANGELOG_PENDING.md updated, or no changelog entry needed
  • Updated relevant documentation (docs/) and code comments, or no
    documentation updates needed

@lasarojc lasarojc self-assigned this Dec 2, 2022
@lasarojc lasarojc added the S:backport-to-v0.37.x Tell mergify to backport the PR to v0.37.x label Dec 2, 2022
@lasarojc lasarojc marked this pull request as ready for review December 2, 2022 19:49
@lasarojc lasarojc requested a review from ebuchman as a code owner December 2, 2022 19:49
@lasarojc lasarojc requested a review from a team December 2, 2022 19:49
@lasarojc lasarojc requested a review from adizere as a code owner December 2, 2022 19:49
@lasarojc lasarojc requested a review from sergio-mena December 4, 2022 12:16
Copy link
Contributor

@sergio-mena sergio-mena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lasarojc for this

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 ")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Request "

??

Co-authored-by: Sergio Mena <sergio@informal.systems>
@lasarojc lasarojc merged commit 49502da into main Dec 6, 2022
@lasarojc lasarojc deleted the lasarojc/code/reject_empty_transactions branch December 6, 2022 13:00
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S:backport-to-v0.37.x Tell mergify to backport the PR to v0.37.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants