From b31086b83868e9242a033da023b5607baa2a1f2c Mon Sep 17 00:00:00 2001 From: Thiago Coimbra Lemos Date: Mon, 18 Oct 2021 09:47:57 -0300 Subject: [PATCH] Avoid non-selected txs to have info field update when the batch is full (#1155) * do not update info for discarded tx in the pool * fix txselector when batch is full for atomic txs --- txselector/txselector.go | 10 +--------- txselector/txselector_test.go | 6 +++--- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/txselector/txselector.go b/txselector/txselector.go index 9d41d8171..a422709d1 100644 --- a/txselector/txselector.go +++ b/txselector/txselector.go @@ -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 diff --git a/txselector/txselector_test.go b/txselector/txselector_test.go index 3d29195c0..0aa3e43f0 100644 --- a/txselector/txselector_test.go +++ b/txselector/txselector_test.go @@ -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()) @@ -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), @@ -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()