Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions cl/blockbuilder/blockbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ func (bb *BlockBuilder) GetPayload(ctx context.Context) error {
if err != nil {
return fmt.Errorf("failed to set execution head from rpc: %w", err)
}
} else {
bb.logger.Debug("executionHead is not nil, using cached value")
}

mempoolStatus, err := bb.GetMempoolStatus(ctx)
Expand All @@ -144,17 +142,10 @@ func (bb *BlockBuilder) GetPayload(ctx context.Context) error {
}

lastBlockTime := time.UnixMilli(int64(bb.executionHead.BlockTime))
bb.logger.Debug("lastBlockTime from execution head", "lastBlockTime", lastBlockTime)

if mempoolStatus.Pending == 0 {
timeSinceLastBlock := time.Since(lastBlockTime)
if timeSinceLastBlock < bb.buildEmptyBlocksDelay {
bb.logger.Debug(
"Leader: Skipping empty block",
"timeSinceLastBlock", timeSinceLastBlock,
"pendingTxes", mempoolStatus.Pending,
"queuedTxes", mempoolStatus.Queued,
)
return ErrEmptyBlock
}
bb.logger.Info(
Expand Down
9 changes: 6 additions & 3 deletions cl/singlenode/payloadstore/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewPostgresRepository(ctx context.Context, dsn string, logger *slog.Logger)
schemaCreationQuery := `
CREATE TABLE IF NOT EXISTS execution_payloads (
id SERIAL PRIMARY KEY,
payload_id VARCHAR(66) UNIQUE NOT NULL, -- e.g., 0x... (32 bytes hex + 0x prefix)
payload_id VARCHAR(66) NOT NULL, -- e.g., 0x... (32 bytes hex + 0x prefix)
raw_execution_payload TEXT NOT NULL,
block_height BIGINT NOT NULL,
inserted_at TIMESTAMPTZ DEFAULT NOW(),
Expand Down Expand Up @@ -76,8 +76,11 @@ func (r *PostgresRepository) SavePayload(ctx context.Context, info *types.Payloa
query := `
INSERT INTO execution_payloads (payload_id, raw_execution_payload, block_height)
VALUES ($1, $2, $3)
ON CONFLICT (payload_id) DO NOTHING;
` // ON CONFLICT DO NOTHING will silently ignore duplicates by payload_id
ON CONFLICT (block_height) DO UPDATE
SET payload_id = EXCLUDED.payload_id,
raw_execution_payload = EXCLUDED.raw_execution_payload,
inserted_at = NOW();
`

insertCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
Expand Down
1 change: 0 additions & 1 deletion cl/singlenode/singlenode.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ func (app *SingleNodeApp) runLoop() {

if err != nil {
if errors.Is(err, blockbuilder.ErrEmptyBlock) {
app.logger.Debug("no pending transactions, will try again after timeout", "timeout", app.cfg.TxPoolPollingInterval)
time.Sleep(app.cfg.TxPoolPollingInterval)
continue
} else if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
Expand Down
Loading