Skip to content

Remove invalid transactions from PrepareRequest payload - #984

Merged
superboyiii merged 4 commits into
neo-project:master-n3from
erikzhang:remove-invalid-tx
Jan 27, 2026
Merged

superboyiii merged 4 commits into
neo-project:master-n3from
erikzhang:remove-invalid-tx

Conversation

@erikzhang

Copy link
Copy Markdown
Member

If the policy configurations among consensus nodes are inconsistent (e.g., MaxBlockSize or MaxBlockSystemFee), it may lead to some invalid transactions being persistently retained in some consensus nodes, preventing block creation. A mechanism is needed to ensure that when a transaction is identified as invalid by more than F consensus nodes, all consensus nodes will refrain from including that transaction in the PrepareRequest payload.

@github-actions github-actions Bot added the N3 label Jan 23, 2026
@coveralls

coveralls commented Jan 23, 2026 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 21316142171

Details

  • 3 of 36 (8.33%) changed or added relevant lines in 5 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.07%) to 38.907%

Changes Missing Coverage Covered Lines Changed/Added Lines %
plugins/DBFTPlugin/Consensus/ConsensusContext.MakePayload.cs 0 4 0.0%
plugins/DBFTPlugin/Consensus/ConsensusService.cs 1 9 11.11%
plugins/DBFTPlugin/Consensus/ConsensusService.OnMessage.cs 0 9 0.0%
plugins/DBFTPlugin/Messages/ChangeView.cs 1 13 7.69%
Files with Coverage Reduction New Missed Lines %
plugins/DBFTPlugin/Messages/ChangeView.cs 1 24.24%
Totals Coverage Status
Change from base Build 21311977432: -0.07%
Covered Lines: 7079
Relevant Lines: 16868

💛 - Coveralls

@roman-khimov roman-khimov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. Consistent policy configuration can be achieved via Policy contract.
  2. Node disputes are to be resolved via CV, some other node will propose something acceptable. Bad primaries are to de-elected.
  3. Nodes directly telling other nodes what's right or wrong doesn't seem reliable, we need BFT number of them following the protocol, that's it.

@shargon

shargon commented Jan 23, 2026

Copy link
Copy Markdown
Member
  1. Consistent policy configuration can be achieved via Policy contract.
  2. Node disputes are to be resolved via CV, some other node will propose something acceptable. Bad primaries are to de-elected.
  3. Nodes directly telling other nodes what's right or wrong doesn't seem reliable, we need BFT number of them following the protocol, that's it.

But currently they will change view forever and de-election is not something automatically, require vote changing

@roman-khimov

Copy link
Copy Markdown
Contributor

But currently they will change view forever

Why? Node A proposes "bad" tx T, CV happens, node B proposes another set of transactions without T, everyone agrees (no policy conflict), block produced.

@erikzhang

Copy link
Copy Markdown
Member Author

If the transaction is still in the memory pool, A will submit this transaction in each round.

@roman-khimov

Copy link
Copy Markdown
Contributor

If the transaction is still in the memory pool, A will submit this transaction in each round.

Yes. And it's not a problem to me. This (incorrect Primary) can be discovered quickly and either configuration will be fixed or node will be voted out. Otherwise policies are for Policy contract, it has (almost) all the mechanisms for that.

@erikzhang

Copy link
Copy Markdown
Member Author

I would not call it "incorrect." The policy for each node may differ and may not necessarily be correct or incorrect. Therefore, we need a mechanism to intersect the policy of each node when more than F nodes are inconsistent, in order to enhance the stability of the consensus protocol.

@roman-khimov

Copy link
Copy Markdown
Contributor

The policy for each node may differ and may not necessarily be correct or incorrect.

As long as BFT number of nodes agree we're OK. If we're to imagine each node doing local policing of any kind we're in trouble and this PR can't fix it. A node can have a policy of always using 42 as block nonce and rejecting any other proposals for example.

we need a mechanism to intersect the policy

The mechanism for that is CV. Just like in any other case where agreement can't be reach for the current proposal (or proposal is missing).

@vncoelho vncoelho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is related to neo-project/neo#4333

It is needed

// Iterate transaction until reach the size or maximum system fee
foreach (Transaction tx in txs)
{
if (InvalidTransactions.TryGetValue(tx.Hash, out var hashset))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add some comment

// Verify if there is, at least, one honest node that consider this TX as invalid. If so, skip it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

One is not enough; at least more than F are needed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That means one honest

@vncoelho vncoelho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants