mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
* Fixes issue #1139 - crash when running chaindata mode * Cleaning up error messages as per feedback
This commit is contained in:
parent
5b4445ecea
commit
784bc9dc85
@ -79,9 +79,9 @@ The following table shows the current implementation status of turbo-geth's RPC
|
|||||||
| web3_clientVersion | Yes | |
|
| web3_clientVersion | Yes | |
|
||||||
| web3_sha3 | Yes | |
|
| web3_sha3 | Yes | |
|
||||||
| | | |
|
| | | |
|
||||||
| net_listening | HC | (hard coded returns true) |
|
| net_listening | HC | (remote only hard coded returns true) |
|
||||||
| net_peerCount | HC | (hard coded 25 - work continues on Sentry) |
|
| net_peerCount | HC | (hard coded 25 - work continues on Sentry) |
|
||||||
| net_version | Yes | |
|
| net_version | Yes | remote only |
|
||||||
| | | |
|
| | | |
|
||||||
| eth_blockNumber | Yes | |
|
| eth_blockNumber | Yes | |
|
||||||
| eth_chainID | Yes | |
|
| eth_chainID | Yes | |
|
||||||
@ -119,10 +119,10 @@ The following table shows the current implementation status of turbo-geth's RPC
|
|||||||
| eth_getFilterChanges | - | |
|
| eth_getFilterChanges | - | |
|
||||||
| eth_getFilterLogs | - | |
|
| eth_getFilterLogs | - | |
|
||||||
| eth_uninstallFilter | - | |
|
| eth_uninstallFilter | - | |
|
||||||
| eth_getLogs | Yes | |
|
| eth_getLogs | Yes | remote only |
|
||||||
| | | |
|
| | | |
|
||||||
| eth_accounts | - | |
|
| eth_accounts | - | |
|
||||||
| eth_sendRawTransaction | Yes | |
|
| eth_sendRawTransaction | Yes | remote only |
|
||||||
| eth_sendTransaction | - | |
|
| eth_sendTransaction | - | |
|
||||||
| eth_sign | - | |
|
| eth_sign | - | |
|
||||||
| eth_signTransaction | - | |
|
| eth_signTransaction | - | |
|
||||||
|
@ -2,11 +2,16 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/ledgerwatch/turbo-geth/common"
|
"github.com/ledgerwatch/turbo-geth/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Etherbase is the address that mining rewards will be send to
|
// Coinbase is the address that mining rewards will be sent to
|
||||||
func (api *APIImpl) Coinbase(_ context.Context) (common.Address, error) {
|
func (api *APIImpl) Coinbase(_ context.Context) (common.Address, error) {
|
||||||
|
if api.ethBackend == nil {
|
||||||
|
// We're running in --chaindata mode or otherwise cannot get the backend
|
||||||
|
return common.Address{}, fmt.Errorf(NotAvailableChainData, "eth_coinbase")
|
||||||
|
}
|
||||||
return api.ethBackend.Etherbase()
|
return api.ethBackend.Etherbase()
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ func (api *PrivateDebugAPIImpl) AccountRange(ctx context.Context, blockNrOrHash
|
|||||||
|
|
||||||
blockNumber, _, err = stages.GetStageProgress(api.dbReader, stages.Execution)
|
blockNumber, _, err = stages.GetStageProgress(api.dbReader, stages.Execution)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return state.IteratorDump{}, fmt.Errorf("las block has not found: %w", err)
|
return state.IteratorDump{}, fmt.Errorf("last block has not found: %w", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
blockNumber = uint64(number)
|
blockNumber = uint64(number)
|
||||||
|
7
cmd/rpcdaemon/commands/error_messages.go
Normal file
7
cmd/rpcdaemon/commands/error_messages.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package commands
|
||||||
|
|
||||||
|
// NotImplemented is the URI prefix for smartcard wallets.
|
||||||
|
const NotImplemented = "the function %s is currently not implemented"
|
||||||
|
|
||||||
|
// NotAvailableChainData x
|
||||||
|
const NotAvailableChainData = "the function %s is not available, please use --private.api.addr option instead of --chaindata option"
|
@ -259,6 +259,11 @@ func (f *Filter) Logs(ctx context.Context, api *APIImpl) ([]*types.Log, error) {
|
|||||||
end = latest
|
end = latest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if api.ethBackend == nil {
|
||||||
|
// We're running in --chaindata mode or otherwise cannot get the backend
|
||||||
|
return nil, fmt.Errorf(NotAvailableChainData, "eth_getLogs")
|
||||||
|
}
|
||||||
|
|
||||||
// Gather all indexed logs, and finish with non indexed ones
|
// Gather all indexed logs, and finish with non indexed ones
|
||||||
var logs []*types.Log
|
var logs []*types.Log
|
||||||
size, sections, _ := api.ethBackend.BloomStatus()
|
size, sections, _ := api.ethBackend.BloomStatus()
|
||||||
|
@ -2,6 +2,7 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/ledgerwatch/turbo-geth/common/hexutil"
|
"github.com/ledgerwatch/turbo-geth/common/hexutil"
|
||||||
@ -9,24 +10,26 @@ import (
|
|||||||
"github.com/ledgerwatch/turbo-geth/ethdb"
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NetAPI the interface for the net_ RPC commands
|
||||||
type NetAPI interface {
|
type NetAPI interface {
|
||||||
Listening(_ context.Context) (bool, error)
|
Listening(_ context.Context) (bool, error)
|
||||||
Version(_ context.Context) (string, error)
|
Version(_ context.Context) (string, error)
|
||||||
PeerCount(_ context.Context) (hexutil.Uint, error)
|
PeerCount(_ context.Context) (hexutil.Uint, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NetAPIImpl data structure to store things needed for net_ commands
|
||||||
type NetAPIImpl struct {
|
type NetAPIImpl struct {
|
||||||
ethBackend ethdb.Backend
|
ethBackend ethdb.Backend
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewtNetAPIImpl returns NetAPIImplImpl instance
|
// NewNetAPIImpl returns NetAPIImplImpl instance
|
||||||
func NewNetAPIImpl(eth ethdb.Backend) *NetAPIImpl {
|
func NewNetAPIImpl(eth ethdb.Backend) *NetAPIImpl {
|
||||||
return &NetAPIImpl{
|
return &NetAPIImpl{
|
||||||
ethBackend: eth,
|
ethBackend: eth,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listen implements RPC call for net_listening
|
// Listening implements RPC call for net_listening
|
||||||
// TODO(tjayrush) remove hard coded value
|
// TODO(tjayrush) remove hard coded value
|
||||||
func (api *NetAPIImpl) Listening(_ context.Context) (bool, error) {
|
func (api *NetAPIImpl) Listening(_ context.Context) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
@ -34,10 +37,16 @@ func (api *NetAPIImpl) Listening(_ context.Context) (bool, error) {
|
|||||||
|
|
||||||
// Version implements RPC call for net_version
|
// Version implements RPC call for net_version
|
||||||
func (api *NetAPIImpl) Version(_ context.Context) (string, error) {
|
func (api *NetAPIImpl) Version(_ context.Context) (string, error) {
|
||||||
|
if api.ethBackend == nil {
|
||||||
|
// We're running in --chaindata mode or otherwise cannot get the backend
|
||||||
|
return "", fmt.Errorf(NotAvailableChainData, "net_version")
|
||||||
|
}
|
||||||
|
|
||||||
res, err := api.ethBackend.NetVersion()
|
res, err := api.ethBackend.NetVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return strconv.FormatUint(res, 10), nil
|
return strconv.FormatUint(res, 10), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,12 +2,18 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/ledgerwatch/turbo-geth/common"
|
"github.com/ledgerwatch/turbo-geth/common"
|
||||||
"github.com/ledgerwatch/turbo-geth/common/hexutil"
|
"github.com/ledgerwatch/turbo-geth/common/hexutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// SendRawTransaction send a raw transaction
|
||||||
func (api *APIImpl) SendRawTransaction(_ context.Context, encodedTx hexutil.Bytes) (common.Hash, error) {
|
func (api *APIImpl) SendRawTransaction(_ context.Context, encodedTx hexutil.Bytes) (common.Hash, error) {
|
||||||
|
if api.ethBackend == nil {
|
||||||
|
// We're running in --chaindata mode or otherwise cannot get the backend
|
||||||
|
return common.Hash{}, fmt.Errorf(NotAvailableChainData, "eth_sendRawTransaction")
|
||||||
|
}
|
||||||
res, err := api.ethBackend.AddLocal(encodedTx)
|
res, err := api.ethBackend.AddLocal(encodedTx)
|
||||||
return common.BytesToHash(res), err
|
return common.BytesToHash(res), err
|
||||||
}
|
}
|
||||||
|
@ -21,29 +21,29 @@ type CallParams []CallParam
|
|||||||
// Call Implements trace_call
|
// Call Implements trace_call
|
||||||
func (api *TraceAPIImpl) Call(ctx context.Context, call CallParam, blockNr rpc.BlockNumber) ([]interface{}, error) {
|
func (api *TraceAPIImpl) Call(ctx context.Context, call CallParam, blockNr rpc.BlockNumber) ([]interface{}, error) {
|
||||||
var stub []interface{}
|
var stub []interface{}
|
||||||
return stub, fmt.Errorf("function trace_call not implemented")
|
return stub, fmt.Errorf(NotImplemented, "trace_call")
|
||||||
}
|
}
|
||||||
|
|
||||||
// CallMany Implements trace_call
|
// CallMany Implements trace_call
|
||||||
func (api *TraceAPIImpl) CallMany(ctx context.Context, calls CallParams) ([]interface{}, error) {
|
func (api *TraceAPIImpl) CallMany(ctx context.Context, calls CallParams) ([]interface{}, error) {
|
||||||
var stub []interface{}
|
var stub []interface{}
|
||||||
return stub, fmt.Errorf("function trace_callMany not implemented")
|
return stub, fmt.Errorf(NotImplemented, "trace_callMany")
|
||||||
}
|
}
|
||||||
|
|
||||||
// RawTransaction Implements trace_rawtransaction
|
// RawTransaction Implements trace_rawtransaction
|
||||||
func (api *TraceAPIImpl) RawTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error) {
|
func (api *TraceAPIImpl) RawTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error) {
|
||||||
var stub []interface{}
|
var stub []interface{}
|
||||||
return stub, fmt.Errorf("function trace_rawTransaction not implemented")
|
return stub, fmt.Errorf(NotImplemented, "trace_rawTransaction")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReplayBlockTransactions Implements trace_replayBlockTransactions
|
// ReplayBlockTransactions Implements trace_replayBlockTransactions
|
||||||
func (api *TraceAPIImpl) ReplayBlockTransactions(ctx context.Context, blockNr rpc.BlockNumber, traceTypes []string) ([]interface{}, error) {
|
func (api *TraceAPIImpl) ReplayBlockTransactions(ctx context.Context, blockNr rpc.BlockNumber, traceTypes []string) ([]interface{}, error) {
|
||||||
var stub []interface{}
|
var stub []interface{}
|
||||||
return stub, fmt.Errorf("function trace_replayBlockTransactions not implemented")
|
return stub, fmt.Errorf(NotImplemented, "trace_replayBlockTransactions")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReplayTransaction Implements trace_replaytransactions
|
// ReplayTransaction Implements trace_replaytransactions
|
||||||
func (api *TraceAPIImpl) ReplayTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error) {
|
func (api *TraceAPIImpl) ReplayTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error) {
|
||||||
var stub []interface{}
|
var stub []interface{}
|
||||||
return stub, fmt.Errorf("function trace_replayTransaction not implemented")
|
return stub, fmt.Errorf(NotImplemented, "trace_replayTransaction")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user