headerchain.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. // Copyright 2015 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. package core
  17. import (
  18. crand "crypto/rand"
  19. "errors"
  20. "fmt"
  21. "math"
  22. "math/big"
  23. mrand "math/rand"
  24. "sync/atomic"
  25. "time"
  26. "github.com/ethereum/go-ethereum/common"
  27. "github.com/ethereum/go-ethereum/consensus"
  28. "github.com/ethereum/go-ethereum/core/rawdb"
  29. "github.com/ethereum/go-ethereum/core/types"
  30. "github.com/ethereum/go-ethereum/ethdb"
  31. "github.com/ethereum/go-ethereum/log"
  32. "github.com/ethereum/go-ethereum/params"
  33. lru "github.com/hashicorp/golang-lru"
  34. )
  35. const (
  36. headerCacheLimit = 512
  37. tdCacheLimit = 1024
  38. numberCacheLimit = 2048
  39. )
  40. // HeaderChain implements the basic block header chain logic that is shared by
  41. // core.BlockChain and light.LightChain. It is not usable in itself, only as
  42. // a part of either structure.
  43. //
  44. // HeaderChain is responsible for maintaining the header chain including the
  45. // header query and updating.
  46. //
  47. // The components maintained by headerchain includes: (1) total difficult
  48. // (2) header (3) block hash -> number mapping (4) canonical number -> hash mapping
  49. // and (5) head header flag.
  50. //
  51. // It is not thread safe either, the encapsulating chain structures should do
  52. // the necessary mutex locking/unlocking.
  53. type HeaderChain struct {
  54. config *params.ChainConfig
  55. chainDb ethdb.Database
  56. genesisHeader *types.Header
  57. currentHeader atomic.Value // Current head of the header chain (may be above the block chain!)
  58. currentHeaderHash common.Hash // Hash of the current head of the header chain (prevent recomputing all the time)
  59. headerCache *lru.Cache // Cache for the most recent block headers
  60. tdCache *lru.Cache // Cache for the most recent block total difficulties
  61. numberCache *lru.Cache // Cache for the most recent block numbers
  62. procInterrupt func() bool
  63. rand *mrand.Rand
  64. engine consensus.Engine
  65. }
  66. // NewHeaderChain creates a new HeaderChain structure. ProcInterrupt points
  67. // to the parent's interrupt semaphore.
  68. func NewHeaderChain(chainDb ethdb.Database, config *params.ChainConfig, engine consensus.Engine, procInterrupt func() bool) (*HeaderChain, error) {
  69. headerCache, _ := lru.New(headerCacheLimit)
  70. tdCache, _ := lru.New(tdCacheLimit)
  71. numberCache, _ := lru.New(numberCacheLimit)
  72. // Seed a fast but crypto originating random generator
  73. seed, err := crand.Int(crand.Reader, big.NewInt(math.MaxInt64))
  74. if err != nil {
  75. return nil, err
  76. }
  77. hc := &HeaderChain{
  78. config: config,
  79. chainDb: chainDb,
  80. headerCache: headerCache,
  81. tdCache: tdCache,
  82. numberCache: numberCache,
  83. procInterrupt: procInterrupt,
  84. rand: mrand.New(mrand.NewSource(seed.Int64())),
  85. engine: engine,
  86. }
  87. hc.genesisHeader = hc.GetHeaderByNumber(0)
  88. if hc.genesisHeader == nil {
  89. return nil, ErrNoGenesis
  90. }
  91. hc.currentHeader.Store(hc.genesisHeader)
  92. if head := rawdb.ReadHeadBlockHash(chainDb); head != (common.Hash{}) {
  93. if chead := hc.GetHeaderByHash(head); chead != nil {
  94. hc.currentHeader.Store(chead)
  95. }
  96. }
  97. hc.currentHeaderHash = hc.CurrentHeader().Hash()
  98. headHeaderGauge.Update(hc.CurrentHeader().Number.Int64())
  99. return hc, nil
  100. }
  101. // GetBlockNumber retrieves the block number belonging to the given hash
  102. // from the cache or database
  103. func (hc *HeaderChain) GetBlockNumber(hash common.Hash) *uint64 {
  104. if cached, ok := hc.numberCache.Get(hash); ok {
  105. number := cached.(uint64)
  106. return &number
  107. }
  108. number := rawdb.ReadHeaderNumber(hc.chainDb, hash)
  109. if number != nil {
  110. hc.numberCache.Add(hash, *number)
  111. }
  112. return number
  113. }
  114. // WriteHeader writes a header into the local chain, given that its parent is
  115. // already known. If the total difficulty of the newly inserted header becomes
  116. // greater than the current known TD, the canonical chain is re-routed.
  117. //
  118. // Note: This method is not concurrent-safe with inserting blocks simultaneously
  119. // into the chain, as side effects caused by reorganisations cannot be emulated
  120. // without the real blocks. Hence, writing headers directly should only be done
  121. // in two scenarios: pure-header mode of operation (light clients), or properly
  122. // separated header/block phases (non-archive clients).
  123. func (hc *HeaderChain) WriteHeader(header *types.Header) (status WriteStatus, err error) {
  124. // Cache some values to prevent constant recalculation
  125. var (
  126. hash = header.Hash()
  127. number = header.Number.Uint64()
  128. )
  129. // Calculate the total difficulty of the header
  130. ptd := hc.GetTd(header.ParentHash, number-1)
  131. if ptd == nil {
  132. return NonStatTy, consensus.ErrUnknownAncestor
  133. }
  134. localTd := hc.GetTd(hc.currentHeaderHash, hc.CurrentHeader().Number.Uint64())
  135. externTd := new(big.Int).Add(header.Difficulty, ptd)
  136. // Irrelevant of the canonical status, write the td and header to the database
  137. //
  138. // Note all the components of header(td, hash->number index and header) should
  139. // be written atomically.
  140. headerBatch := hc.chainDb.NewBatch()
  141. rawdb.WriteTd(headerBatch, hash, number, externTd)
  142. rawdb.WriteHeader(headerBatch, header)
  143. if err := headerBatch.Write(); err != nil {
  144. log.Crit("Failed to write header into disk", "err", err)
  145. }
  146. // If the total difficulty is higher than our known, add it to the canonical chain
  147. // Second clause in the if statement reduces the vulnerability to selfish mining.
  148. // Please refer to http://www.cs.cornell.edu/~ie53/publications/btcProcFC.pdf
  149. if externTd.Cmp(localTd) > 0 || (externTd.Cmp(localTd) == 0 && mrand.Float64() < 0.5) {
  150. // If the header can be added into canonical chain, adjust the
  151. // header chain markers(canonical indexes and head header flag).
  152. //
  153. // Note all markers should be written atomically.
  154. // Delete any canonical number assignments above the new head
  155. markerBatch := hc.chainDb.NewBatch()
  156. for i := number + 1; ; i++ {
  157. hash := rawdb.ReadCanonicalHash(hc.chainDb, i)
  158. if hash == (common.Hash{}) {
  159. break
  160. }
  161. rawdb.DeleteCanonicalHash(markerBatch, i)
  162. }
  163. // Overwrite any stale canonical number assignments
  164. var (
  165. headHash = header.ParentHash
  166. headNumber = header.Number.Uint64() - 1
  167. headHeader = hc.GetHeader(headHash, headNumber)
  168. )
  169. for rawdb.ReadCanonicalHash(hc.chainDb, headNumber) != headHash {
  170. rawdb.WriteCanonicalHash(markerBatch, headHash, headNumber)
  171. headHash = headHeader.ParentHash
  172. headNumber = headHeader.Number.Uint64() - 1
  173. headHeader = hc.GetHeader(headHash, headNumber)
  174. }
  175. // Extend the canonical chain with the new header
  176. rawdb.WriteCanonicalHash(markerBatch, hash, number)
  177. rawdb.WriteHeadHeaderHash(markerBatch, hash)
  178. if err := markerBatch.Write(); err != nil {
  179. log.Crit("Failed to write header markers into disk", "err", err)
  180. }
  181. // Last step update all in-memory head header markers
  182. hc.currentHeaderHash = hash
  183. hc.currentHeader.Store(types.CopyHeader(header))
  184. headHeaderGauge.Update(header.Number.Int64())
  185. status = CanonStatTy
  186. } else {
  187. status = SideStatTy
  188. }
  189. hc.tdCache.Add(hash, externTd)
  190. hc.headerCache.Add(hash, header)
  191. hc.numberCache.Add(hash, number)
  192. return
  193. }
  194. // WhCallback is a callback function for inserting individual headers.
  195. // A callback is used for two reasons: first, in a LightChain, status should be
  196. // processed and light chain events sent, while in a BlockChain this is not
  197. // necessary since chain events are sent after inserting blocks. Second, the
  198. // header writes should be protected by the parent chain mutex individually.
  199. type WhCallback func(*types.Header) error
  200. func (hc *HeaderChain) ValidateHeaderChain(chain []*types.Header, checkFreq int) (int, error) {
  201. // Do a sanity check that the provided chain is actually ordered and linked
  202. for i := 1; i < len(chain); i++ {
  203. if chain[i].Number.Uint64() != chain[i-1].Number.Uint64()+1 || chain[i].ParentHash != chain[i-1].Hash() {
  204. // Chain broke ancestry, log a message (programming error) and skip insertion
  205. log.Error("Non contiguous header insert", "number", chain[i].Number, "hash", chain[i].Hash(),
  206. "parent", chain[i].ParentHash, "prevnumber", chain[i-1].Number, "prevhash", chain[i-1].Hash())
  207. return 0, fmt.Errorf("non contiguous insert: item %d is #%d [%x…], item %d is #%d [%x…] (parent [%x…])", i-1, chain[i-1].Number,
  208. chain[i-1].Hash().Bytes()[:4], i, chain[i].Number, chain[i].Hash().Bytes()[:4], chain[i].ParentHash[:4])
  209. }
  210. }
  211. // Generate the list of seal verification requests, and start the parallel verifier
  212. seals := make([]bool, len(chain))
  213. if checkFreq != 0 {
  214. // In case of checkFreq == 0 all seals are left false.
  215. for i := 0; i < len(seals)/checkFreq; i++ {
  216. index := i*checkFreq + hc.rand.Intn(checkFreq)
  217. if index >= len(seals) {
  218. index = len(seals) - 1
  219. }
  220. seals[index] = true
  221. }
  222. // Last should always be verified to avoid junk.
  223. seals[len(seals)-1] = true
  224. }
  225. abort, results := hc.engine.VerifyHeaders(hc, chain, seals)
  226. defer close(abort)
  227. // Iterate over the headers and ensure they all check out
  228. for i, header := range chain {
  229. // If the chain is terminating, stop processing blocks
  230. if hc.procInterrupt() {
  231. log.Debug("Premature abort during headers verification")
  232. return 0, errors.New("aborted")
  233. }
  234. // If the header is a banned one, straight out abort
  235. if BadHashes[header.Hash()] {
  236. return i, ErrBlacklistedHash
  237. }
  238. // Otherwise wait for headers checks and ensure they pass
  239. if err := <-results; err != nil {
  240. return i, err
  241. }
  242. }
  243. return 0, nil
  244. }
  245. // InsertHeaderChain attempts to insert the given header chain in to the local
  246. // chain, possibly creating a reorg. If an error is returned, it will return the
  247. // index number of the failing header as well an error describing what went wrong.
  248. //
  249. // The verify parameter can be used to fine tune whether nonce verification
  250. // should be done or not. The reason behind the optional check is because some
  251. // of the header retrieval mechanisms already need to verfy nonces, as well as
  252. // because nonces can be verified sparsely, not needing to check each.
  253. func (hc *HeaderChain) InsertHeaderChain(chain []*types.Header, writeHeader WhCallback, start time.Time) (int, error) {
  254. // Collect some import statistics to report on
  255. stats := struct{ processed, ignored int }{}
  256. // All headers passed verification, import them into the database
  257. for i, header := range chain {
  258. // Short circuit insertion if shutting down
  259. if hc.procInterrupt() {
  260. log.Debug("Premature abort during headers import")
  261. return i, errors.New("aborted")
  262. }
  263. // If the header's already known, skip it, otherwise store
  264. hash := header.Hash()
  265. if hc.HasHeader(hash, header.Number.Uint64()) {
  266. externTd := hc.GetTd(hash, header.Number.Uint64())
  267. localTd := hc.GetTd(hc.currentHeaderHash, hc.CurrentHeader().Number.Uint64())
  268. if externTd == nil || externTd.Cmp(localTd) <= 0 {
  269. stats.ignored++
  270. continue
  271. }
  272. }
  273. if err := writeHeader(header); err != nil {
  274. return i, err
  275. }
  276. stats.processed++
  277. }
  278. // Report some public statistics so the user has a clue what's going on
  279. last := chain[len(chain)-1]
  280. context := []interface{}{
  281. "count", stats.processed, "elapsed", common.PrettyDuration(time.Since(start)),
  282. "number", last.Number, "hash", last.Hash(),
  283. }
  284. if timestamp := time.Unix(int64(last.Time), 0); time.Since(timestamp) > time.Minute {
  285. context = append(context, []interface{}{"age", common.PrettyAge(timestamp)}...)
  286. }
  287. if stats.ignored > 0 {
  288. context = append(context, []interface{}{"ignored", stats.ignored}...)
  289. }
  290. log.Info("Imported new block headers", context...)
  291. return 0, nil
  292. }
  293. // GetBlockHashesFromHash retrieves a number of block hashes starting at a given
  294. // hash, fetching towards the genesis block.
  295. func (hc *HeaderChain) GetBlockHashesFromHash(hash common.Hash, max uint64) []common.Hash {
  296. // Get the origin header from which to fetch
  297. header := hc.GetHeaderByHash(hash)
  298. if header == nil {
  299. return nil
  300. }
  301. // Iterate the headers until enough is collected or the genesis reached
  302. chain := make([]common.Hash, 0, max)
  303. for i := uint64(0); i < max; i++ {
  304. next := header.ParentHash
  305. if header = hc.GetHeader(next, header.Number.Uint64()-1); header == nil {
  306. break
  307. }
  308. chain = append(chain, next)
  309. if header.Number.Sign() == 0 {
  310. break
  311. }
  312. }
  313. return chain
  314. }
  315. // GetAncestor retrieves the Nth ancestor of a given block. It assumes that either the given block or
  316. // a close ancestor of it is canonical. maxNonCanonical points to a downwards counter limiting the
  317. // number of blocks to be individually checked before we reach the canonical chain.
  318. //
  319. // Note: ancestor == 0 returns the same block, 1 returns its parent and so on.
  320. func (hc *HeaderChain) GetAncestor(hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64) {
  321. if ancestor > number {
  322. return common.Hash{}, 0
  323. }
  324. if ancestor == 1 {
  325. // in this case it is cheaper to just read the header
  326. if header := hc.GetHeader(hash, number); header != nil {
  327. return header.ParentHash, number - 1
  328. } else {
  329. return common.Hash{}, 0
  330. }
  331. }
  332. for ancestor != 0 {
  333. if rawdb.ReadCanonicalHash(hc.chainDb, number) == hash {
  334. ancestorHash := rawdb.ReadCanonicalHash(hc.chainDb, number-ancestor)
  335. if rawdb.ReadCanonicalHash(hc.chainDb, number) == hash {
  336. number -= ancestor
  337. return ancestorHash, number
  338. }
  339. }
  340. if *maxNonCanonical == 0 {
  341. return common.Hash{}, 0
  342. }
  343. *maxNonCanonical--
  344. ancestor--
  345. header := hc.GetHeader(hash, number)
  346. if header == nil {
  347. return common.Hash{}, 0
  348. }
  349. hash = header.ParentHash
  350. number--
  351. }
  352. return hash, number
  353. }
  354. // GetTd retrieves a block's total difficulty in the canonical chain from the
  355. // database by hash and number, caching it if found.
  356. func (hc *HeaderChain) GetTd(hash common.Hash, number uint64) *big.Int {
  357. // Short circuit if the td's already in the cache, retrieve otherwise
  358. if cached, ok := hc.tdCache.Get(hash); ok {
  359. return cached.(*big.Int)
  360. }
  361. td := rawdb.ReadTd(hc.chainDb, hash, number)
  362. if td == nil {
  363. return nil
  364. }
  365. // Cache the found body for next time and return
  366. hc.tdCache.Add(hash, td)
  367. return td
  368. }
  369. // GetTdByHash retrieves a block's total difficulty in the canonical chain from the
  370. // database by hash, caching it if found.
  371. func (hc *HeaderChain) GetTdByHash(hash common.Hash) *big.Int {
  372. number := hc.GetBlockNumber(hash)
  373. if number == nil {
  374. return nil
  375. }
  376. return hc.GetTd(hash, *number)
  377. }
  378. // GetHeader retrieves a block header from the database by hash and number,
  379. // caching it if found.
  380. func (hc *HeaderChain) GetHeader(hash common.Hash, number uint64) *types.Header {
  381. // Short circuit if the header's already in the cache, retrieve otherwise
  382. if header, ok := hc.headerCache.Get(hash); ok {
  383. return header.(*types.Header)
  384. }
  385. header := rawdb.ReadHeader(hc.chainDb, hash, number)
  386. if header == nil {
  387. return nil
  388. }
  389. // Cache the found header for next time and return
  390. hc.headerCache.Add(hash, header)
  391. return header
  392. }
  393. // GetHeaderByHash retrieves a block header from the database by hash, caching it if
  394. // found.
  395. func (hc *HeaderChain) GetHeaderByHash(hash common.Hash) *types.Header {
  396. number := hc.GetBlockNumber(hash)
  397. if number == nil {
  398. return nil
  399. }
  400. return hc.GetHeader(hash, *number)
  401. }
  402. // HasHeader checks if a block header is present in the database or not.
  403. // In theory, if header is present in the database, all relative components
  404. // like td and hash->number should be present too.
  405. func (hc *HeaderChain) HasHeader(hash common.Hash, number uint64) bool {
  406. if hc.numberCache.Contains(hash) || hc.headerCache.Contains(hash) {
  407. return true
  408. }
  409. return rawdb.HasHeader(hc.chainDb, hash, number)
  410. }
  411. // GetHeaderByNumber retrieves a block header from the database by number,
  412. // caching it (associated with its hash) if found.
  413. func (hc *HeaderChain) GetHeaderByNumber(number uint64) *types.Header {
  414. hash := rawdb.ReadCanonicalHash(hc.chainDb, number)
  415. if hash == (common.Hash{}) {
  416. return nil
  417. }
  418. return hc.GetHeader(hash, number)
  419. }
  420. func (hc *HeaderChain) GetCanonicalHash(number uint64) common.Hash {
  421. return rawdb.ReadCanonicalHash(hc.chainDb, number)
  422. }
  423. // CurrentHeader retrieves the current head header of the canonical chain. The
  424. // header is retrieved from the HeaderChain's internal cache.
  425. func (hc *HeaderChain) CurrentHeader() *types.Header {
  426. return hc.currentHeader.Load().(*types.Header)
  427. }
  428. // SetCurrentHeader sets the in-memory head header marker of the canonical chan
  429. // as the given header.
  430. func (hc *HeaderChain) SetCurrentHeader(head *types.Header) {
  431. hc.currentHeader.Store(head)
  432. hc.currentHeaderHash = head.Hash()
  433. headHeaderGauge.Update(head.Number.Int64())
  434. }
  435. type (
  436. // UpdateHeadBlocksCallback is a callback function that is called by SetHead
  437. // before head header is updated.
  438. UpdateHeadBlocksCallback func(ethdb.KeyValueWriter, *types.Header)
  439. // DeleteBlockContentCallback is a callback function that is called by SetHead
  440. // before each header is deleted.
  441. DeleteBlockContentCallback func(ethdb.KeyValueWriter, common.Hash, uint64)
  442. )
  443. // SetHead rewinds the local chain to a new head. Everything above the new head
  444. // will be deleted and the new one set.
  445. func (hc *HeaderChain) SetHead(head uint64, updateFn UpdateHeadBlocksCallback, delFn DeleteBlockContentCallback) {
  446. var (
  447. parentHash common.Hash
  448. batch = hc.chainDb.NewBatch()
  449. )
  450. for hdr := hc.CurrentHeader(); hdr != nil && hdr.Number.Uint64() > head; hdr = hc.CurrentHeader() {
  451. hash, num := hdr.Hash(), hdr.Number.Uint64()
  452. // Rewind block chain to new head.
  453. parent := hc.GetHeader(hdr.ParentHash, num-1)
  454. if parent == nil {
  455. parent = hc.genesisHeader
  456. }
  457. parentHash = hdr.ParentHash
  458. // Notably, since geth has the possibility for setting the head to a low
  459. // height which is even lower than ancient head.
  460. // In order to ensure that the head is always no higher than the data in
  461. // the database(ancient store or active store), we need to update head
  462. // first then remove the relative data from the database.
  463. //
  464. // Update head first(head fast block, head full block) before deleting the data.
  465. markerBatch := hc.chainDb.NewBatch()
  466. if updateFn != nil {
  467. updateFn(markerBatch, parent)
  468. }
  469. // Update head header then.
  470. rawdb.WriteHeadHeaderHash(markerBatch, parentHash)
  471. if err := markerBatch.Write(); err != nil {
  472. log.Crit("Failed to update chain markers", "error", err)
  473. }
  474. hc.currentHeader.Store(parent)
  475. hc.currentHeaderHash = parentHash
  476. headHeaderGauge.Update(parent.Number.Int64())
  477. // Remove the relative data from the database.
  478. if delFn != nil {
  479. delFn(batch, hash, num)
  480. }
  481. // Rewind header chain to new head.
  482. rawdb.DeleteHeader(batch, hash, num)
  483. rawdb.DeleteTd(batch, hash, num)
  484. rawdb.DeleteCanonicalHash(batch, num)
  485. }
  486. // Flush all accumulated deletions.
  487. if err := batch.Write(); err != nil {
  488. log.Crit("Failed to rewind block", "error", err)
  489. }
  490. // Clear out any stale content from the caches
  491. hc.headerCache.Purge()
  492. hc.tdCache.Purge()
  493. hc.numberCache.Purge()
  494. }
  495. // SetGenesis sets a new genesis block header for the chain
  496. func (hc *HeaderChain) SetGenesis(head *types.Header) {
  497. hc.genesisHeader = head
  498. }
  499. // Config retrieves the header chain's chain configuration.
  500. func (hc *HeaderChain) Config() *params.ChainConfig { return hc.config }
  501. // Engine retrieves the header chain's consensus engine.
  502. func (hc *HeaderChain) Engine() consensus.Engine { return hc.engine }
  503. // GetBlock implements consensus.ChainReader, and returns nil for every input as
  504. // a header chain does not have blocks available for retrieval.
  505. func (hc *HeaderChain) GetBlock(hash common.Hash, number uint64) *types.Block {
  506. return nil
  507. }