Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Avoid non-selected txs to have info field update when the batch is fu…
Browse files Browse the repository at this point in the history
…ll (#1155)

* do not update info for discarded tx in the pool

* fix txselector when batch is full for atomic txs
  • Loading branch information
tclemos authored Oct 18, 2021
1 parent b52d699 commit b31086b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
10 changes: 1 addition & 9 deletions txselector/txselector.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,15 +470,7 @@ func (txsel *TxSelector) processL2Txs(
l2Txs[i].AtomicGroupID.String(),
))
}
// no more available slots for L2Txs, so mark this tx
// but also the rest of remaining txs as discarded
for j := i; j < len(l2Txs); j++ {
l2Txs[i].Info = obj.Message
l2Txs[i].ErrorCode = obj.Code
l2Txs[i].ErrorType = obj.Type
nonSelectedL2Txs = append(nonSelectedL2Txs, l2Txs[j])
}
break
continue
}

// Reject tx if the batch that is being selected is greater than MaxNumBatch
Expand Down
6 changes: 3 additions & 3 deletions txselector/txselector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ func TestTransferManyFromSameAccount(t *testing.T) {
assert.Equal(t, 3, len(oL1UserTxs))
require.Equal(t, 0, len(oL1CoordTxs))
assert.Equal(t, 7, len(oL2Txs))
assert.Equal(t, 4, len(discardedL2Txs))
assert.Equal(t, 0, len(discardedL2Txs))

err = txsel.l2db.StartForging(common.TxIDsFromPoolL2Txs(oL2Txs),
txsel.localAccountsDB.CurrentBatch())
Expand Down Expand Up @@ -933,7 +933,7 @@ func TestValidTxsWithLowFeeAndInvalidTxsWithHighFee(t *testing.T) {
require.Equal(t, 0, len(oL1UserTxs))
require.Equal(t, 0, len(oL1CoordTxs))
require.Equal(t, 5, len(oL2Txs)) // the 3 txs A-B
require.Equal(t, 6, len(discardedL2Txs)) // the 8 txs B-A
require.Equal(t, 0, len(discardedL2Txs)) // the 8 txs B-A
require.Equal(t, 0, len(accAuths))

err = txsel.l2db.StartForging(common.TxIDsFromPoolL2Txs(oL2Txs),
Expand All @@ -948,7 +948,7 @@ func TestValidTxsWithLowFeeAndInvalidTxsWithHighFee(t *testing.T) {
require.Equal(t, 0, len(oL1UserTxs))
require.Equal(t, 0, len(oL1CoordTxs))
require.Equal(t, 5, len(oL2Txs))
require.Equal(t, 1, len(discardedL2Txs))
require.Equal(t, 0, len(discardedL2Txs))
require.Equal(t, 0, len(accAuths))

stateDB.Close()
Expand Down

0 comments on commit b31086b

Please sign in to comment.