@@ -291,40 +291,35 @@ func CheckLogs(block *types.Block, provider *ethrpc.Provider, ignoreZeroGasLogs
291291 }
292292
293293 filteredLogs := logs
294- var optCheck []ethutil.LogsBloomCheckFunc
295-
296294 if ignoreZeroGasLogs {
297- // Build a quick lookup of tx hash -> gas price so we can drop system (zero price) tx logs.
298- gasPriceByTx := make (map [common.Hash ]* big.Int , len (block .Transactions ()))
299- for _ , tx := range block .Transactions () {
300- gasPriceByTx [tx .Hash ()] = tx .GasPrice ()
301- }
302-
303- filter := func (ls []types.Log ) []types.Log {
304- out := make ([]types.Log , 0 , len (ls ))
305- for _ , l := range ls {
306- if gp , ok := gasPriceByTx [l .TxHash ]; ok && gp .Sign () == 0 {
307- // HyperEVM system tx (gas price = 0) — ignore for bloom validation.
308- continue
309- }
310- out = append (out , l )
311- }
312- return out
313- }
314-
315- filteredLogs = filter (logs )
316-
317- optCheck = append (optCheck , func (ls []types.Log , header * types.Header ) bool {
318- return ethutil .ValidateLogsWithBlockHeader (filter (ls ), header )
319- })
295+ filteredLogs = zeroGasLogsFilter (logs , h , block )
320296 }
321297
322298 fmt .Printf ("Block: %d\n " , h .Number .Uint64 ())
323299 fmt .Printf ("Logs Count: %d\n " , len (filteredLogs ))
324- fmt .Printf ("Match: %v\n " , ethutil .ValidateLogsWithBlockHeader (filteredLogs , h , optCheck ... ))
300+ fmt .Printf ("Match: %v\n " , ethutil .ValidateLogsWithBlockHeader (filteredLogs , h ))
325301 fmt .Println ()
326302 fmt .Printf ("Calculated Log Bloom: 0x%x\n " , ethutil .ConvertLogsToBloom (filteredLogs ).Bytes ())
327303 fmt .Println ()
328304 fmt .Printf ("Header Log Bloom: 0x%x\n " , h .Bloom .Bytes ())
329305 fmt .Println ()
330306}
307+
308+ // zeroGasLogsFilter removes logs from transactions whose gas price is zero
309+ // (HyperEVM system transactions).
310+ func zeroGasLogsFilter (ls []types.Log , _ * types.Header , block * types.Block ) []types.Log {
311+ gasPriceByTx := make (map [common.Hash ]* big.Int , len (block .Transactions ()))
312+ for _ , tx := range block .Transactions () {
313+ gasPriceByTx [tx .Hash ()] = tx .GasPrice ()
314+ }
315+
316+ out := make ([]types.Log , 0 , len (ls ))
317+ for _ , l := range ls {
318+ if gp , ok := gasPriceByTx [l .TxHash ]; ok && gp .Sign () == 0 {
319+ // HyperEVM system tx (gas price = 0) — ignore for bloom validation.
320+ continue
321+ }
322+ out = append (out , l )
323+ }
324+ return out
325+ }
0 commit comments