From eea44b399020ed876495386187bc5b687ae4248a Mon Sep 17 00:00:00 2001 From: arnaucube Date: Wed, 23 Dec 2020 12:15:18 +0100 Subject: [PATCH] Fix StateDB & Til Nonce increment --- db/historydb/historydb_test.go | 8 ++++---- db/statedb/txprocessors.go | 2 +- db/statedb/txprocessors_test.go | 6 +++--- test/til/txs.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/db/historydb/historydb_test.go b/db/historydb/historydb_test.go index 6c30ac3..78702f0 100644 --- a/db/historydb/historydb_test.go +++ b/db/historydb/historydb_test.go @@ -551,10 +551,10 @@ func TestTxs(t *testing.T) { assert.Equal(t, common.TxTypeExit, dbL2Txs[3].Type) // Tx ID - assert.Equal(t, "0x020000000001030000000001", dbL2Txs[0].TxID.String()) - assert.Equal(t, "0x020000000001010000000001", dbL2Txs[1].TxID.String()) - assert.Equal(t, "0x020000000001000000000001", dbL2Txs[2].TxID.String()) - assert.Equal(t, "0x020000000001000000000002", dbL2Txs[3].TxID.String()) + assert.Equal(t, "0x020000000001030000000000", dbL2Txs[0].TxID.String()) + assert.Equal(t, "0x020000000001010000000000", dbL2Txs[1].TxID.String()) + assert.Equal(t, "0x020000000001000000000000", dbL2Txs[2].TxID.String()) + assert.Equal(t, "0x020000000001000000000001", dbL2Txs[3].TxID.String()) // Tx From and To IDx assert.Equal(t, dbL2Txs[0].ToIdx, dbL2Txs[2].FromIdx) diff --git a/db/statedb/txprocessors.go b/db/statedb/txprocessors.go index ca50f6f..03078f2 100644 --- a/db/statedb/txprocessors.go +++ b/db/statedb/txprocessors.go @@ -595,7 +595,7 @@ func (s *StateDB) ProcessL2Tx(coordIdxsMap map[common.TokenID]common.Idx, collec log.Errorw("GetAccount", "fromIdx", tx.FromIdx, "err", err) return nil, nil, false, tracerr.Wrap(err) } - tx.Nonce = acc.Nonce + 1 + tx.Nonce = acc.Nonce tx.TokenID = acc.TokenID } diff --git a/db/statedb/txprocessors_test.go b/db/statedb/txprocessors_test.go index d1f2232..6b91932 100644 --- a/db/statedb/txprocessors_test.go +++ b/db/statedb/txprocessors_test.go @@ -413,9 +413,9 @@ func TestProcessTxsSynchronizer(t *testing.T) { require.NoError(t, err) // after processing expect l2Txs[0:2].Nonce!=0 and has expected value - assert.Equal(t, common.Nonce(6), l2Txs[0].Nonce) - assert.Equal(t, common.Nonce(7), l2Txs[1].Nonce) - assert.Equal(t, common.Nonce(8), l2Txs[2].Nonce) + assert.Equal(t, common.Nonce(5), l2Txs[0].Nonce) + assert.Equal(t, common.Nonce(6), l2Txs[1].Nonce) + assert.Equal(t, common.Nonce(7), l2Txs[2].Nonce) assert.Equal(t, 4, len(ptOut.ExitInfos)) // the 'ForceExit(1)' is not computed yet, as the batch is without L1UserTxs assert.Equal(t, 1, len(ptOut.CreatedAccounts)) diff --git a/test/til/txs.go b/test/til/txs.go index 9214f91..359ccf1 100644 --- a/test/til/txs.go +++ b/test/til/txs.go @@ -880,8 +880,8 @@ func (tc *Context) FillBlocksExtra(blocks []common.BlockData, cfg *ConfigExtra) tx := &batch.L2Txs[k] tx.Position = position position++ - tc.extra.nonces[tx.FromIdx]++ tx.Nonce = tc.extra.nonces[tx.FromIdx] + tc.extra.nonces[tx.FromIdx]++ if err := tx.SetID(); err != nil { return tracerr.Wrap(err) }