Skip to content

Commit

Permalink
fix tx order in zkevm_getBatchByNumber endpoint (#3749) (#3767)
Browse files Browse the repository at this point in the history
  • Loading branch information
agnusmor authored Aug 14, 2024
1 parent a15dcc2 commit a3f4da9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion state/pgstatestorage/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,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)
Expand Down

0 comments on commit a3f4da9

Please sign in to comment.