Skip to content

Commit 22a11f1

Browse files
committed
Add filtering to logs bloom check for gas price
1 parent 2344cb5 commit 22a11f1

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

cmd/ethkit/block.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,26 @@ func CheckLogs(block *types.Block, provider *ethrpc.Provider) {
284284
fmt.Println("Error getting logs:", err)
285285
}
286286

287+
// Build a quick lookup of tx hash -> gas price so we can drop system (zero price) tx logs.
288+
gasPriceByTx := make(map[common.Hash]*big.Int, len(block.Transactions()))
289+
for _, tx := range block.Transactions() {
290+
gasPriceByTx[tx.Hash()] = tx.GasPrice()
291+
}
292+
293+
filteredLogs := make([]types.Log, 0, len(logs))
294+
for _, log := range logs {
295+
if gp, ok := gasPriceByTx[log.TxHash]; ok && gp.Sign() == 0 {
296+
// HyperEVM system tx (gas price = 0) — ignore for bloom validation.
297+
continue
298+
}
299+
filteredLogs = append(filteredLogs, log)
300+
}
301+
287302
fmt.Printf("Block: %d\n", h.Number.Uint64())
288-
fmt.Printf("Logs Count: %d\n", len(logs))
289-
fmt.Printf("Match: %v\n", ethutil.ValidateLogsWithBlockHeader(logs, h))
303+
fmt.Printf("Logs Count (after filtering zero gas price txs): %d\n", len(filteredLogs))
304+
fmt.Printf("Match: %v\n", ethutil.ValidateLogsWithBlockHeader(filteredLogs, h))
290305
fmt.Println()
291-
fmt.Printf("Calculated Log Bloom: 0x%x\n", logsToBloom(logs).Bytes())
306+
fmt.Printf("Calculated Log Bloom: 0x%x\n", logsToBloom(filteredLogs).Bytes())
292307
fmt.Println()
293308
fmt.Printf("Header Log Bloom: 0x%x\n", h.Bloom.Bytes())
294309
fmt.Println()

0 commit comments

Comments
 (0)