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
Comment thread send.go Outdated
Comment thread send.go
Comment thread dbft.go Outdated
@Turalchik
Turalchik force-pushed the extend-prepare-request branch from 087c01c to 945ab02 Compare August 12, 2026 17:37
Comment thread context.go Outdated
Comment thread context.go Outdated
Comment thread context.go Outdated
Comment thread dbft.go
Comment thread send.go Outdated
@Turalchik
Turalchik force-pushed the extend-prepare-request branch from 945ab02 to 514cc36 Compare August 13, 2026 10:25
Signed-off-by: Tural Devrishev <tural@nspcc.ru>
@Turalchik
Turalchik force-pushed the extend-prepare-request branch from 514cc36 to 8ecec1c Compare August 19, 2026 16:36

@AnnaShaleva AnnaShaleva 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.

Let's align dbft code wrt nspcc-dev/neo-go@ff4eb10. No decoding optimisation is required. Both old (master) and new (feature) behaviour should be preserved, the behaviour switch (something like a configurable callback or an additional parameter to (DBFT).Start or (DBFT).Reset) should be exposed to the external user to enable the extension starting from some point without dBFT shutdown.

dbft.WithCurrentBlockHash[crypto.Uint256](currentBlockHash),
dbft.WithGetValidators[crypto.Uint256](getValidators),
dbft.WithVerifyPrepareRequest[crypto.Uint256](verifyPayload),
dbft.WithUnpackTransactions[crypto.Uint256](UnpackTransactions),

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.

Since we decided to drop the decoding optimisation, let's remove this callback.

for i, tx := range ctx.TransactionsOrdered {
txHashes[i] = tx.Hash()
}
block := NewBlock(ctx.Timestamp, ctx.BlockIndex, ctx.PrevHash, ctx.Nonce, txHashes)

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.

We need a context-level switch (something like boolean field will suit). Depending on this switch we'll use either hashes (the old behaviour) or transactions (the new behaviour) to construct prepare request (and block). This switch should be activated on the caller's side (i.e. by NeoGo at Huyao hardfork) at the runtime without consensus service interruption.

Comment thread context.go
// Transactions is a map containing actual transactions for the current block.
Transactions map[H]Transaction[H]

TransactionsOrdered []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.

Here we should maintain both TransactionHashes and Transactions fields. The first one should be used for pre-Huyao behaviour, the second one should be used for post-Huyao behaviour.

The similar logic should be applied to other places where the old code is replaced by the new approach.

Comment thread dbft.go
d.sendPrepareResponse()
d.checkPrepare()
}
panic("dbft: addTransaction must not be called, PrepareRequest transactions are always attached in full")

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, panic only if the behaviour switch is on. Otherwise the old behaviour should be kept.

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