From 505d1407f97f763fc17d9313ea18718b61c9295b Mon Sep 17 00:00:00 2001 From: agnusmor Date: Mon, 5 Aug 2024 15:52:34 +0200 Subject: [PATCH] fix tx order in zkevm_getBatchByNumber endpoint --- state/pgstatestorage/transaction.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/state/pgstatestorage/transaction.go b/state/pgstatestorage/transaction.go index f25554d44e..109d266726 100644 --- a/state/pgstatestorage/transaction.go +++ b/state/pgstatestorage/transaction.go @@ -124,7 +124,13 @@ func (p *PostgresStorage) GetTxsOlderThanNL1Blocks(ctx context.Context, nL1Block // GetEncodedTransactionsByBatchNumber returns the encoded field of all // transactions in the given batch. func (p *PostgresStorage) GetEncodedTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (encodedTxs []string, effectivePercentages []uint8, err error) { - const getEncodedTransactionsByBatchNumberSQL = "SELECT encoded, COALESCE(effective_percentage, 255) FROM state.transaction t INNER JOIN state.l2block b ON t.l2_block_num = b.block_num WHERE b.batch_num = $1 ORDER BY l2_block_num ASC" + const getEncodedTransactionsByBatchNumberSQL = ` + SELECT encoded, COALESCE(effective_percentage, 255) FROM state.transaction t + INNER JOIN state.l2block b ON t.l2_block_num = b.block_num + INNER JOIN state.receipt r ON t.hash = r.tx_hash + WHERE b.batch_num = $1 + ORDER BY l2_block_num, r.tx_index ASC + ` e := p.getExecQuerier(dbTx) rows, err := e.Query(ctx, getEncodedTransactionsByBatchNumberSQL, batchNumber)