eth, internal: add console endpoint

This commit is contained in:
Gary Rong 2026-03-03 10:29:09 +08:00
parent e70d87274f
commit 287a55072a
2 changed files with 8 additions and 29 deletions

View file

@ -494,9 +494,9 @@ func (api *DebugAPI) StateSize(blockHashOrNumber *rpc.BlockNumberOrHash) (interf
}, nil }, nil
} }
func (api *DebugAPI) ExecutionWitness(bn rpc.BlockNumber) (*stateless.ExtWitness, error) { func (api *DebugAPI) ExecutionWitness(bn rpc.BlockNumberOrHash) (*stateless.ExtWitness, error) {
bc := api.eth.blockchain bc := api.eth.blockchain
block, err := api.eth.APIBackend.BlockByNumber(context.Background(), bn) block, err := api.eth.APIBackend.BlockByNumberOrHash(context.Background(), bn)
if err != nil { if err != nil {
return &stateless.ExtWitness{}, fmt.Errorf("block number %v not found", bn) return &stateless.ExtWitness{}, fmt.Errorf("block number %v not found", bn)
} }
@ -515,25 +515,3 @@ func (api *DebugAPI) ExecutionWitness(bn rpc.BlockNumber) (*stateless.ExtWitness
} }
return result.Witness().ToExtWitness(), nil 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)
}
config := core.ExecuteConfig{
WriteState: false,
EnableTracer: false,
MakeWitness: true,
}
result, err := bc.ProcessBlock(context.Background(), parent.Root, block, config)
if err != nil {
return nil, err
}
return result.Witness().ToExtWitness(), nil
}

View file

@ -427,11 +427,6 @@ web3._extend({
params: 2, params: 2,
inputFormatter:[null, null], inputFormatter:[null, null],
}), }),
new web3._extend.Method({
name: 'freezeClient',
call: 'debug_freezeClient',
params: 1,
}),
new web3._extend.Method({ new web3._extend.Method({
name: 'getAccessibleState', name: 'getAccessibleState',
call: 'debug_getAccessibleState', call: 'debug_getAccessibleState',
@ -474,6 +469,12 @@ web3._extend({
params: 1, params: 1,
inputFormatter: [null], inputFormatter: [null],
}), }),
new web3._extend.Method({
name: 'executionWitness',
call: 'debug_executionWitness',
params: 1,
inputFormatter: [null],
}),
], ],
properties: [] properties: []
}); });