trace read parent header from snapshot and lru #4042

This commit is contained in:
Alex Sharov 2022-05-01 10:35:30 +07:00 committed by GitHub
parent c896807bfe
commit 533970d31c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,7 +17,6 @@ import (
"github.com/ledgerwatch/erigon/common/hexutil"
math2 "github.com/ledgerwatch/erigon/common/math"
"github.com/ledgerwatch/erigon/core"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/core/state"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/core/types/accounts"
@ -1034,7 +1033,13 @@ func (api *TraceAPIImpl) CallMany(ctx context.Context, calls json.RawMessage, pa
if err != nil {
return nil, err
}
parentHeader := rawdb.ReadHeader(dbtx, hash, blockNumber)
// TODO: can read here only parent header
parentBlock, err := api.blockWithSenders(dbtx, hash, blockNumber)
if err != nil {
return nil, err
}
parentHeader := parentBlock.Header()
if parentHeader == nil {
return nil, fmt.Errorf("parent header %d(%x) not found", blockNumber, hash)
}
@ -1085,7 +1090,12 @@ func (api *TraceAPIImpl) doCallMany(ctx context.Context, dbtx kv.Tx, msgs []type
noop := state.NewNoopWriter()
cachedWriter := state.NewCachedWriter(noop, stateCache)
parentHeader := rawdb.ReadHeader(dbtx, hash, blockNumber)
// TODO: can read here only parent header
parentBlock, err := api.blockWithSenders(dbtx, hash, blockNumber)
if err != nil {
return nil, err
}
parentHeader := parentBlock.Header()
if parentHeader == nil {
return nil, fmt.Errorf("parent header %d(%x) not found", blockNumber, hash)
}