Skip to content

Conversation

@masih
Copy link
Collaborator

@masih masih commented Aug 8, 2025

Compared to the original Tendermint, Sei-Tendermint expands the proposal structure to include a number of additional fields. Update the basic validation logic to take into account additional fields when validating proposals.

Add validation to both direct message handling and ambient gossip handling to avoid propagation of an invalid proposal.

Expand tests to cover the additional execution paths at unit and reactor integration level.

@masih masih marked this pull request as draft August 8, 2025 09:57
@masih masih force-pushed the masih/gossip-validation branch from 1db7c27 to b710371 Compare August 8, 2025 09:58
@codecov
Copy link

codecov bot commented Aug 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.23%. Comparing base (c6c5a8f) to head (bc2e6ae).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #292      +/-   ##
==========================================
+ Coverage   56.94%   57.23%   +0.28%     
==========================================
  Files         254      254              
  Lines       33815    33815              
==========================================
+ Hits        19257    19353      +96     
+ Misses      13017    12926      -91     
+ Partials     1541     1536       -5     

see 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@masih
Copy link
Collaborator Author

masih commented Aug 8, 2025

Hmm test (15) flaked at first but the rerun succeeded. Is that expected?

Compared to the original Tendermint, Sei-Tendermint expands the proposal
structure to include a number of additional fields. Update the basic
validation logic to take into account additional fields when validating
proposals.

Add validation to both direct message handling and ambient gossip
handling to avoid propagation of an invalid proposal.

Expand tests to cover the additional execution paths at unit and reactor
integration level.
@masih masih force-pushed the masih/gossip-validation branch from b710371 to d12a535 Compare August 8, 2025 10:35
@masih
Copy link
Collaborator Author

masih commented Aug 8, 2025

test (15) flaked again and passed on 3rd attempt. Before I investigate this further, I would love input from the current maintainers on whether this test is genuinely flaky or it is likely caused by changes introduced in this PR please.

@masih masih marked this pull request as ready for review August 8, 2025 11:13
masih added 7 commits August 8, 2025 15:09
The contextual assumption across the codebase is remote messages get
validated once at transport. Then the rest of the internal
implementation implicitly assumes/or selectively does not check for
validity.

To reduce code churn revert tests that asserted close-to-logic validity
check.
CryptoAddress must have a fixed size. Assert the size in Proposal basic
validation.
A couple of error handling seem to be missing in proposal instantiation
from proto.
By the time we call validation basic it may be too late, in that the
decoding process may have allocated many keys unnecessarily.

Check earlier on that the list of keys does not reach max.

Also assert that each transaction key length meets the expected value.
Some of the *FromProto functions were not validating the constructed
wrapper. Consistently validate all.
}{
{"success", vote, true, true},
{"fail vote validate basic", &Vote{}, true, false},
{"fail vote validate basic", &Vote{}, false, false},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@codchen Can I ask why this test was specifically asserting that an invalid vote is construct-able from Proto?

I have changed the assertion to reject it (now that all *FromProto functions consistently call validation), and would love your eyes on it please! Thanks

# Conflicts:
#	types/proposal_test.go
// included in a proposal. The limit is determined such that the proposal should
// hit the gas limit before ever reaching the max transaction keys in order to
// cap the maximum.
const maxTxKeysPerProposal = 1_000
Copy link
Contributor

Choose a reason for hiding this comment

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

it may make sense to pull this from config, but then set the default to 1000? we may need that for load testing depending on how we configure the size of the blocks.

Copy link
Collaborator Author

@masih masih Sep 8, 2025

Choose a reason for hiding this comment

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

Are you envisioning a load test that exercises some malicious behaviour? If not, I think we will hit the maximum message size before we hit this limit. i.e. the rationale for this constant is to avoid specific attack vectors that a well behaving user should never hit.

Do you think it is possible to fit this many transactions and not hit the max message size?

Copy link
Contributor

@yzang2019 yzang2019 Sep 8, 2025

Choose a reason for hiding this comment

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

I think our max block size is pretty large and the txs are usually very tiny, we are pretty likely to hit this limit before hitting the size limit

Copy link
Contributor

Choose a reason for hiding this comment

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

think this should be safe for production, but just not sure if LT would need to bump it or not, and most likely we need because we want to optimize throughput by packing as many txs in a block as possible for parallel exectuion

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you both. I have made this overridable via environment variable SEI_TENDERMINT_MAX_TX_KEYS_PER_PROPOSAL.

I chose env var instead of config because this constant is used in package level functions and places deep in protobuf decentralisation, where no other "tendermint config" is present.

Considering the use of override, which is load test, I think this is a reasonable path of least resistance forward.

Please let me know if there is anything that I might have missed.

Make max tx keys per proposals overridable via env var
`SEI_TENDERMINT_MAX_TX_KEYS_PER_PROPOSAL`.
@github-actions
Copy link

github-actions bot commented Oct 1, 2025

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedOct 1, 2025, 2:05 PM

@masih masih merged commit 020476e into main Oct 2, 2025
27 checks passed
@masih masih deleted the masih/gossip-validation branch October 2, 2025 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants