-
Notifications
You must be signed in to change notification settings - Fork 226
Limit invalid tx size #1090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master-n3
Are you sure you want to change the base?
Limit invalid tx size #1090
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -221,10 +221,10 @@ private void OnChangeViewReceived(ExtensiblePayload payload, ChangeView message) | |
| foreach (UInt256 hash in message.RejectedHashes) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of the problems of this mechanism in general is that this set is completely disconnected from the proposal. Given that My suggestion is to revert #984. Another option could be filtering hashes through PrepareRequest set of hashes if it's received and ignoring it completely if it's not. |
||
| { | ||
| ECPoint pubkey = context.Validators[message.ValidatorIndex]; | ||
| if (context.InvalidTransactions.TryGetValue(hash, out var hashset)) | ||
| hashset.Add(pubkey); | ||
| if (context.InvalidTransactions.TryGet(hash, out var hashset)) | ||
| hashset.Value.Add(pubkey); | ||
| else | ||
| context.InvalidTransactions.Add(hash, [pubkey]); | ||
| context.InvalidTransactions.Add(new ConsensusContext.UnvalidTxCacheItem(hash, new HashSet<ECPoint> { pubkey })); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [bug] Every hash in Suggestion: Do not cache hashes that are not in the mempool and/or the current proposal (ignore |
||
| } | ||
| break; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -318,7 +318,7 @@ public void TestConsensusServiceRoutesConsensusMessagesIntoContextState() | |
| InvokeConsensusMethod(actor, "OnConsensusPayload", changeViewPayload); | ||
|
|
||
| Assert.AreSame(changeViewPayload, context.ChangeViewPayloads[2]); | ||
| CollectionAssert.Contains(context.InvalidTransactions[rejectedHash].ToArray(), context.Validators[2]); | ||
| CollectionAssert.Contains(context.InvalidTransactions[rejectedHash].Value.ToArray(), context.Validators[2]); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [suggestion] The only test update is Suggestion: Add a unit test that constructs |
||
|
|
||
| context.TransactionHashes = null; | ||
| var commit = new Commit | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit]
UnvalidTxCacheItemis a typo for Invalid. The record andInvalidCacheare also public nested types onConsensusContext, which leaks a cache implementation detail from a type that is already a large public surface.Suggestion: Rename to
InvalidTxCacheItem. Make both nested typesprivate(or file-scoped) if callers only needInvalidTransactionslookup/add/remove.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot fix it