Skip to content

Commit

Permalink
fix tx order in zkevm_getBatchByNumber endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
agnusmor committed Aug 5, 2024
1 parent 520c9e3 commit 505d140
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 @@ -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)
Expand Down

0 comments on commit 505d140

Please sign in to comment.