diff --git a/cmd/rpcdaemon/commands/trace_filtering.go b/cmd/rpcdaemon/commands/trace_filtering.go index 9ac33de24..ba752d2d0 100644 --- a/cmd/rpcdaemon/commands/trace_filtering.go +++ b/cmd/rpcdaemon/commands/trace_filtering.go @@ -325,6 +325,7 @@ func (api *TraceAPIImpl) Filter(ctx context.Context, req TraceFilterRequest, str nExported := uint64(0) it := allBlocks.Iterator() + isPos := false for it.HasNext() { b := it.Next() // Extract transactions from block @@ -367,6 +368,10 @@ func (api *TraceAPIImpl) Filter(ctx context.Context, req TraceFilterRequest, str blockHash := block.Hash() blockNumber := block.NumberU64() + if !isPos && api._chainConfig.TerminalTotalDifficulty != nil { + header := block.Header() + isPos = header.Difficulty.Cmp(common.Big0) == 0 || header.Difficulty.Cmp(api._chainConfig.TerminalTotalDifficulty) >= 0 + } txs := block.Transactions() t, tErr := api.callManyTransactions(ctx, dbtx, txs, []string{TraceTypeTrace}, block.ParentHash(), rpc.BlockNumber(block.NumberU64()-1), block.Header(), -1 /* all tx indices */, types.MakeSigner(chainConfig, b), chainConfig.Rules(b)) if tErr != nil { @@ -416,6 +421,13 @@ func (api *TraceAPIImpl) Filter(ctx context.Context, req TraceFilterRequest, str } } } + + // if we are in POS + // we dont check for uncles or block rewards + if isPos { + continue + } + minerReward, uncleRewards := ethash.AccumulateRewards(chainConfig, block.Header(), block.Uncles()) if _, ok := toAddresses[block.Coinbase()]; ok || includeAll { nSeen++ diff --git a/eth/stagedsync/stage_headers.go b/eth/stagedsync/stage_headers.go index bde0c1a0b..54da1445d 100644 --- a/eth/stagedsync/stage_headers.go +++ b/eth/stagedsync/stage_headers.go @@ -616,6 +616,10 @@ func verifyAndSaveDownloadedPoSHeaders(tx kv.RwTx, cfg HeadersCfg, headerInserte headerLoadFunc := func(key, value []byte, _ etl.CurrentTableReader, _ etl.LoadNextFunc) error { var h types.Header + // no header to process + if value == nil { + return nil + } if err := rlp.DecodeBytes(value, &h); err != nil { return err }