From 11ff3884afea53e732e555ba728470dfef7c738e Mon Sep 17 00:00:00 2001 From: Jeb Bearer Date: Mon, 16 Jan 2023 12:16:32 -0800 Subject: [PATCH] Fix encoding bug in AddForcedBatch The forced_batch table expects the raw_txs_data column to be a string (specifically a hex encoding of the raw transaction bytes). The corresponding GetForcedBatch function uses hex.DecodeString to turn the value of this column back into raw bytes. However, AddForcedBatch is missing a hex.EncodeToString, so it is actually interpreting the raw transaction bytes as an ASCII representation of a hex-encoded string. --- state/pgstatestorage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/state/pgstatestorage.go b/state/pgstatestorage.go index 5fe8791917..d557597be2 100644 --- a/state/pgstatestorage.go +++ b/state/pgstatestorage.go @@ -317,7 +317,7 @@ func (p *PostgresStorage) GetTimeForLatestBatchVirtualization(ctx context.Contex // AddForcedBatch adds a new ForcedBatch to the db func (p *PostgresStorage) AddForcedBatch(ctx context.Context, forcedBatch *ForcedBatch, tx pgx.Tx) error { const addForcedBatchSQL = "INSERT INTO state.forced_batch (forced_batch_num, global_exit_root, timestamp, raw_txs_data, coinbase, block_num) VALUES ($1, $2, $3, $4, $5, $6)" - _, err := tx.Exec(ctx, addForcedBatchSQL, forcedBatch.ForcedBatchNumber, forcedBatch.GlobalExitRoot.String(), forcedBatch.ForcedAt, forcedBatch.RawTxsData, forcedBatch.Sequencer.String(), forcedBatch.BlockNumber) + _, err := tx.Exec(ctx, addForcedBatchSQL, forcedBatch.ForcedBatchNumber, forcedBatch.GlobalExitRoot.String(), forcedBatch.ForcedAt, hex.EncodeToString(forcedBatch.RawTxsData), forcedBatch.Sequencer.String(), forcedBatch.BlockNumber) return err }