mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-11 13:30:05 +00:00
Fetch header correctly (including snapshots) for debug_traceCall, fix… (#6273)
… formatting when error Fixes https://github.com/ledgerwatch/erigon/issues/5365 Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
parent
f512c887dc
commit
983f41790d
@ -199,38 +199,37 @@ func (api *PrivateDebugAPIImpl) TraceTransaction(ctx context.Context, hash commo
|
|||||||
func (api *PrivateDebugAPIImpl) TraceCall(ctx context.Context, args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, config *tracers.TraceConfig, stream *jsoniter.Stream) error {
|
func (api *PrivateDebugAPIImpl) TraceCall(ctx context.Context, args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, config *tracers.TraceConfig, stream *jsoniter.Stream) error {
|
||||||
dbtx, err := api.db.BeginRo(ctx)
|
dbtx, err := api.db.BeginRo(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stream.WriteNil()
|
return fmt.Errorf("create ro transaction: %v", err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
defer dbtx.Rollback()
|
defer dbtx.Rollback()
|
||||||
|
|
||||||
chainConfig, err := api.chainConfig(dbtx)
|
chainConfig, err := api.chainConfig(dbtx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stream.WriteNil()
|
return fmt.Errorf("read chain config: %v", err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
engine := api.engine()
|
engine := api.engine()
|
||||||
|
|
||||||
blockNumber, hash, _, err := rpchelper.GetBlockNumber(blockNrOrHash, dbtx, api.filters)
|
blockNumber, hash, _, err := rpchelper.GetBlockNumber(blockNrOrHash, dbtx, api.filters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stream.WriteNil()
|
return fmt.Errorf("get block number: %v", err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stateReader, err := rpchelper.CreateStateReader(ctx, dbtx, blockNrOrHash, 0, api.filters, api.stateCache, api.historyV3(dbtx), api._agg)
|
stateReader, err := rpchelper.CreateStateReader(ctx, dbtx, blockNrOrHash, 0, api.filters, api.stateCache, api.historyV3(dbtx), api._agg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("create state reader: %v", err)
|
||||||
|
}
|
||||||
|
header, err := api._blockReader.Header(context.Background(), dbtx, hash, blockNumber)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not fetch header %d(%x): %v", blockNumber, hash, err)
|
||||||
}
|
}
|
||||||
header := rawdb.ReadHeader(dbtx, hash, blockNumber)
|
|
||||||
if header == nil {
|
if header == nil {
|
||||||
stream.WriteNil()
|
|
||||||
return fmt.Errorf("block %d(%x) not found", blockNumber, hash)
|
return fmt.Errorf("block %d(%x) not found", blockNumber, hash)
|
||||||
}
|
}
|
||||||
ibs := state.New(stateReader)
|
ibs := state.New(stateReader)
|
||||||
|
|
||||||
if config != nil && config.StateOverrides != nil {
|
if config != nil && config.StateOverrides != nil {
|
||||||
if err := config.StateOverrides.Override(ibs); err != nil {
|
if err := config.StateOverrides.Override(ibs); err != nil {
|
||||||
return err
|
return fmt.Errorf("override state: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +243,7 @@ func (api *PrivateDebugAPIImpl) TraceCall(ctx context.Context, args ethapi.CallA
|
|||||||
}
|
}
|
||||||
msg, err := args.ToMessage(api.GasCap, baseFee)
|
msg, err := args.ToMessage(api.GasCap, baseFee)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("convert args to msg: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
blockCtx := transactions.NewEVMBlockContext(engine, header, blockNrOrHash.RequireCanonical, dbtx, api._blockReader)
|
blockCtx := transactions.NewEVMBlockContext(engine, header, blockNrOrHash.RequireCanonical, dbtx, api._blockReader)
|
||||||
|
Loading…
Reference in New Issue
Block a user