Skip to content

*: attach full transactions to PrepareRequest - #160

Open
Turalchik wants to merge 1 commit into
masterfrom
extend-prepare-request
Open

*: attach full transactions to PrepareRequest#160
Turalchik wants to merge 1 commit into
masterfrom
extend-prepare-request

Conversation

@Turalchik

Copy link
Copy Markdown

Extend PrepareRequest with Transactions(). NewPrepareRequest now also receives the full transaction bodies, and processMissingTx takes them as an argument, so a backup can pull a missing transaction straight from the request instead of a network request that may go unanswered. See nspcc-dev/neo-go#4325.

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 39.28571% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.83%. Comparing base (01db3a4) to head (514cc36).

Files with missing lines Patch % Lines
internal/consensus/consensus.go 0.00% 5 Missing ⚠️
internal/consensus/constructors.go 0.00% 4 Missing ⚠️
internal/consensus/prepare_request.go 40.00% 3 Missing ⚠️
internal/consensus/recovery_message.go 0.00% 3 Missing ⚠️
dbft.go 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #160      +/-   ##
==========================================
- Coverage   57.65%   54.83%   -2.83%     
==========================================
  Files          33       33              
  Lines        1913     1882      -31     
==========================================
- Hits         1103     1032      -71     
- Misses        717      754      +37     
- Partials       93       96       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

Comment thread dbft.go Outdated
}

func (d *DBFT[H]) processMissingTx() {
func (d *DBFT[H]) processMissingTx(attached []Transaction[H]) {

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.

Revert changes of this method. Panic if this method is called. There's no missing transactions in the new scheme.

Comment thread send.go Outdated
Comment on lines +24 to +27
txx := make([]Transaction[H], len(c.TransactionHashes))
for i, h := range c.TransactionHashes {
txx[i] = c.Transactions[h]
}

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.

Use only c.Transactions to construct txx, don't use c.TransactionHashes. In the new scheme c.TransactionHashes is always empty (and will be removed in future).

Comment thread send.go
@@ -187,7 +192,7 @@ func (d *DBFT[H]) sendRecoveryRequest() {
// If we're here, something is wrong, we either missing some messages or
// transactions or both, so re-request missing transactions here too.
if d.RequestSentOrReceived() && !d.hasAllTransactions() {

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.

Adjust hasAllTransactions -- it should always return true respectively from c.TransactinoHashes.

Comment thread dbft.go Outdated

d.Logger.Info("received PrepareRequest", zap.Uint16("validator", msg.ValidatorIndex()), zap.Int("tx", len(d.TransactionHashes)))
d.processMissingTx()
d.processMissingTx(p.Transactions())

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.

Don't call d.processMissingTx at all. There's no missing tx.

@Turalchik
Turalchik force-pushed the extend-prepare-request branch from 087c01c to 945ab02 Compare August 12, 2026 17:37
Comment thread context.go Outdated
@@ -62,6 +63,8 @@ type Context[H Hash] struct {
// Transactions is a map containing actual transactions for the current block.
Transactions map[H]Transaction[H]

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.

Unused field, remove.

Comment thread context.go Outdated
// we don't skip a call to Block.SetTransactions since it may be used as a
// signal to the user's code to finalize the block.
c.block.SetTransactions(txx)
c.block.SetTransactions(slices.Clone(c.TransactionsOrdered))

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.

Why do you need Clone here? Affects performance, no real profit.

Comment thread context.go Outdated
}

c.preBlock.SetTransactions(txx)
c.preBlock.SetTransactions(slices.Clone(c.TransactionsOrdered))

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.

Ditto.

Comment thread dbft.go
Comment thread send.go Outdated
if d.RequestSentOrReceived() && !d.hasAllTransactions() {
d.processMissingTx()
}
// If we're here, something is wrong, we're missing some messages.

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.

Revert this change.

Signed-off-by: Tural Devrishev <tural@nspcc.ru>
@Turalchik
Turalchik force-pushed the extend-prepare-request branch from 945ab02 to 514cc36 Compare August 13, 2026 10:25
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.

2 participants