*: attach full transactions to PrepareRequest - #160
Conversation
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
| } | ||
|
|
||
| func (d *DBFT[H]) processMissingTx() { | ||
| func (d *DBFT[H]) processMissingTx(attached []Transaction[H]) { |
There was a problem hiding this comment.
Revert changes of this method. Panic if this method is called. There's no missing transactions in the new scheme.
| txx := make([]Transaction[H], len(c.TransactionHashes)) | ||
| for i, h := range c.TransactionHashes { | ||
| txx[i] = c.Transactions[h] | ||
| } |
There was a problem hiding this comment.
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).
| @@ -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() { | |||
There was a problem hiding this comment.
Adjust hasAllTransactions -- it should always return true respectively from c.TransactinoHashes.
|
|
||
| d.Logger.Info("received PrepareRequest", zap.Uint16("validator", msg.ValidatorIndex()), zap.Int("tx", len(d.TransactionHashes))) | ||
| d.processMissingTx() | ||
| d.processMissingTx(p.Transactions()) |
There was a problem hiding this comment.
Don't call d.processMissingTx at all. There's no missing tx.
087c01c to
945ab02
Compare
| @@ -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] | |||
| // 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)) |
There was a problem hiding this comment.
Why do you need Clone here? Affects performance, no real profit.
| } | ||
|
|
||
| c.preBlock.SetTransactions(txx) | ||
| c.preBlock.SetTransactions(slices.Clone(c.TransactionsOrdered)) |
| if d.RequestSentOrReceived() && !d.hasAllTransactions() { | ||
| d.processMissingTx() | ||
| } | ||
| // If we're here, something is wrong, we're missing some messages. |
Signed-off-by: Tural Devrishev <tural@nspcc.ru>
945ab02 to
514cc36
Compare
Extend
PrepareRequestwithTransactions().NewPrepareRequestnow also receives the full transaction bodies, andprocessMissingTxtakes 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.