mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
eth: add debug_executionWitness and an error check for the parent
fix names
This commit is contained in:
parent
675bcbd3b0
commit
b02b70ea4a
1 changed files with 29 additions and 4 deletions
|
|
@ -493,13 +493,38 @@ func (api *DebugAPI) StateSize(blockHashOrNumber *rpc.BlockNumberOrHash) (interf
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *DebugAPI) ExecuteWitnessByHash(hash common.Hash) (*stateless.ExtWitness, error) {
|
func (api *DebugAPI) ExecutionWitness(bn rpc.BlockNumber) (*stateless.ExtWitness, error) {
|
||||||
bc := api.eth.blockchain
|
bc := api.eth.blockchain
|
||||||
block := bc.GetBlockByHash(hash)
|
block, err := api.eth.APIBackend.BlockByNumber(context.Background(), bn)
|
||||||
if block == nil {
|
if err != nil {
|
||||||
return &stateless.ExtWitness{}, fmt.Errorf("block hash %x not found", hash)
|
return &stateless.ExtWitness{}, fmt.Errorf("block number %v not found", bn)
|
||||||
}
|
}
|
||||||
|
|
||||||
parent := bc.GetHeader(block.ParentHash(), block.NumberU64()-1)
|
parent := bc.GetHeader(block.ParentHash(), block.NumberU64()-1)
|
||||||
|
if parent == nil {
|
||||||
|
return &stateless.ExtWitness{}, fmt.Errorf("block number %v found, but parent missing", bn)
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := bc.ProcessBlock(parent.Root, block, false, true)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.Witness().ToExtWitness(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (api *DebugAPI) ExecutionWitnessByHash(hash common.Hash) (*stateless.ExtWitness, error) {
|
||||||
|
bc := api.eth.blockchain
|
||||||
|
block := bc.GetBlockByHash(hash)
|
||||||
|
if block == nil {
|
||||||
|
return &stateless.ExtWitness{}, fmt.Errorf("block hash %x not found", hash)
|
||||||
|
}
|
||||||
|
|
||||||
|
parent := bc.GetHeader(block.ParentHash(), block.NumberU64()-1)
|
||||||
|
if parent == nil {
|
||||||
|
return &stateless.ExtWitness{}, fmt.Errorf("block number %x found, but parent missing", hash)
|
||||||
|
}
|
||||||
|
|
||||||
result, err := bc.ProcessBlock(parent.Root, block, false, true)
|
result, err := bc.ProcessBlock(parent.Root, block, false, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue