Skip to content

Commit fa2868d

Browse files
authored
Merge pull request #6393 from oasisprotocol/peternose/trivial/multi-tx-bugfix
go/runtime/txpool: Add workaround for future txs bug
2 parents 82c5bcb + 335b7c4 commit fa2868d

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

.changelog/6393.trivial.md

Whitespace-only changes.

go/runtime/txpool/txpool.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,25 +571,39 @@ func (t *txPool) checkTxBatch(ctx context.Context) error {
571571
)
572572

573573
// Queue checked transactions for scheduling.
574+
stateSeqNums := make(map[string]uint64)
574575
for i, pct := range goodPcts {
575-
if err = t.mainQueue.Add(pct.TxQueueMeta, results[batchIndices[i]].Meta); err != nil {
576+
idx := batchIndices[i]
577+
res := results[idx]
578+
579+
// XXXX: Temporary workaround for an Oasis SDK bug that incorrectly
580+
// increments the sender's state sequence number during transaction
581+
// check.
582+
sender := string(res.Meta.Sender)
583+
if seq, ok := stateSeqNums[sender]; ok {
584+
res.Meta.SenderStateSeq = seq
585+
} else {
586+
stateSeqNums[sender] = res.Meta.SenderStateSeq
587+
}
588+
589+
if err = t.mainQueue.Add(pct.TxQueueMeta, res.Meta); err != nil {
576590
t.logger.Error("unable to queue transaction for scheduling",
577591
"err", err,
578592
"hash", pct.Hash(),
579593
)
580594

581595
// Change the result into an error and notify submitter.
582-
results[batchIndices[i]].Error = protocol.Error{
596+
res.Error = protocol.Error{
583597
Module: "txpool",
584598
Code: 1,
585599
Message: err.Error(),
586600
}
587-
notifySubmitter(batchIndices[i])
601+
notifySubmitter(idx)
588602
continue
589603
}
590604

591605
// Notify submitter of success.
592-
notifySubmitter(batchIndices[i])
606+
notifySubmitter(idx)
593607

594608
if !pct.flags.isRecheck() {
595609
// Mark new transactions as never having been published. The republish worker will

0 commit comments

Comments
 (0)