core: fix benchmark panic (#24657)

This PR fixes a few panics in the chain marker benchmarks. The root
cause for panic is in chain marker the genesis header/block is not
accessible, while it's expected to be obtained in tests. So this PR
avoids touching genesis header at all to avoid panic.
This commit is contained in:
rjl493456442 2022-04-12 16:34:07 +08:00 committed by GitHub
parent c40943a167
commit 195c979168
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -160,7 +160,7 @@ func genTxRing(naccounts int) func(int, *BlockGen) {
// genUncles generates blocks with two uncle headers. // genUncles generates blocks with two uncle headers.
func genUncles(i int, gen *BlockGen) { func genUncles(i int, gen *BlockGen) {
if i >= 6 { if i >= 7 {
b2 := gen.PrevBlock(i - 6).Header() b2 := gen.PrevBlock(i - 6).Header()
b2.Extra = []byte("foo") b2.Extra = []byte("foo")
gen.AddUncle(b2) gen.AddUncle(b2)