Updating RPC tests in Postman (#1340)

This commit is contained in:
Thomas Jay Rush 2020-11-09 03:52:18 -05:00 committed by GitHub
parent c0f9b57b42
commit 546b91f47e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 560 additions and 1094 deletions

View File

@ -74,7 +74,7 @@ pics:
@echo "Run \"$(GOBIN)/pics\" to launch pics."
rpcdaemon:
$(GOBUILD) -o $(GOBIN)/rpcdaemon -ldflags "-X main.gitCommit=${GIT_COMMIT}" ./cmd/rpcdaemon
$(GOBUILD) -o $(GOBIN)/rpcdaemon -ldflags "-X commands.gitCommit=${GIT_COMMIT}" ./cmd/rpcdaemon
@echo "Done building."
@echo "Run \"$(GOBIN)/rpcdaemon\" to launch rpcdaemon."

View File

@ -127,45 +127,7 @@ Run RPC daemon
Supported JSON-RPC calls ([eth](./cmd/rpcdaemon/commands/eth_api.go), [debug](./cmd/rpcdaemon/commands/debug_api.go), [net](./cmd/rpcdaemon/commands/net_api.go), [web3](./cmd/rpcdaemon/commands/web3_api.go)):
For a more detailed status, [see this table](./cmd/rpcdaemon/README.md#rpc-implementation-status).
```
eth_coinbase
eth_blockNumber
eth_call
eth_estimateGas
eth_getBlockByNumber
eth_getBlockByHash
eth_getBlockTransactionCountByHash
eth_getBlockTransactionCountByNumber
eth_getBalance
eth_getCode
eth_GetTransactionCount
eth_GetUncleByBlockNumberAndIndex
eth_GetUncleByBlockHashAndIndex
eth_GetUncleCountByBlockNumber
eth_GetUncleCountByBlockHash
eth_getLogs
eth_getStorageAt
eth_getTransactionReceipt
eth_getTransactionByHash
eth_getTransactionByBlockHashAndIndex
eth_getTransactionByBlockNumberAndIndex
eth_sendRawTransaction
eth_syncing
debug_accountRange
debug_getModifiedAccountsByNumber
debug_getModifiedAccountsByHash
debug_storageRangeAt
debug_traceTransaction
net_peerCount*
net_version
web3_clientVersion
web3_sha3
trace_filter
```
\* net_peerCount currently always returns a count of 25 as work continues on Sentry.
For a details on the implementation status of each command, [see this table](./cmd/rpcdaemon/README.md#rpc-implementation-status).
#### Grafana dashboard:

View File

@ -66,6 +66,8 @@ This should return something along the lines of this (depending on how far your
}
```
Also, there are [extensive instructions for using Postman](https://github.com/ledgerwatch/turbo-geth/wiki/Using-Postman-to-Test-TurboGeth-RPC) to test the RPC.
## Open / Known Issues
There are still many open issues with the TurboGeth tracing routines. Please see [this issue](https://github.com/ledgerwatch/turbo-geth/issues/1119#issuecomment-699028019) for the current open / known issues related to tracing.
@ -110,25 +112,24 @@ The following table shows the current implementation status of turbo-geth's RPC
| eth_getStorageAt | Yes | |
| eth_call | Yes | |
| | | |
| eth_newFilter | - | |
| eth_newBlockFilter | - | |
| eth_newPendingTransactionFilter | - | |
| eth_getFilterChanges | - | |
| eth_getFilterLogs | - | |
| eth_uninstallFilter | - | |
| eth_newFilter | - | not yet implemented |
| eth_newBlockFilter | - | not yet implemented |
| eth_newPendingTransactionFilter | - | not yet implemented |
| eth_getFilterChanges | - | not yet implemented |
| eth_uninstallFilter | - | not yet implemented |
| eth_getLogs | Yes | |
| | | |
| eth_accounts | - | |
| eth_accounts | No | deprecated |
| eth_sendRawTransaction | Yes | remote only |
| eth_sendTransaction | - | |
| eth_sign | - | |
| eth_signTransaction | - | |
| eth_signTypedData | - | |
| eth_sendTransaction | - | not yet implemented |
| eth_sign | No | deprecated |
| eth_signTransaction | - | not yet implemented |
| eth_signTypedData | - | ???? |
| | | |
| eth_getProof | - | |
| eth_getProof | - | not yet implemented |
| | | |
| eth_mining | - | |
| eth_coinbase | Yes | |
| eth_mining | Yes | mining not yet implemented (always false) |
| eth_coinbase | - | |
| eth_hashrate | - | |
| eth_submitHashrate | - | |
| eth_getWork | - | |
@ -150,34 +151,32 @@ The following table shows the current implementation status of turbo-geth's RPC
| trace_get | Limited | working - has known issues |
| trace_transaction | Limited | working - has known issues |
| | | |
| eth_getCompilers | No | depreciated |
| eth_compileLLL | No | depreciated |
| eth_compileSolidity | No | depreciated |
| eth_compileSerpent | No | depreciated |
| eth_getCompilers | No | deprecated |
| eth_compileLLL | No | deprecated |
| eth_compileSolidity | No | deprecated |
| eth_compileSerpent | No | deprecated |
| | | |
| db_putString | No | depreciated |
| db_getString | No | depreciated |
| db_putHex | No | depreciated |
| db_getHex | No | depreciated |
| db_putString | No | deprecated |
| db_getString | No | deprecated |
| db_putHex | No | deprecated |
| db_getHex | No | deprecated |
| | | |
| shh_post | No | depreciated |
| shh_version | No | depreciated |
| shh_newIdentity | No | depreciated |
| shh_hasIdentity | No | depreciated |
| shh_newGroup | No | depreciated |
| shh_addToGroup | No | depreciated |
| shh_newFilter | No | depreciated |
| shh_uninstallFilter | No | depreciated |
| shh_getFilterChanges | No | depreciated |
| shh_getMessages | No | depreciated |
| shh_post | No | deprecated |
| shh_version | No | deprecated |
| shh_newIdentity | No | deprecated |
| shh_hasIdentity | No | deprecated |
| shh_newGroup | No | deprecated |
| shh_addToGroup | No | deprecated |
| shh_newFilter | No | deprecated |
| shh_uninstallFilter | No | deprecated |
| shh_getFilterChanges | No | deprecated |
| shh_getMessages | No | deprecated |
| | | |
| tg_getHeaderByHash | Yes | turbo-geth only |
| tg_getHeaderByNumber | Yes | turbo-geth only |
| | | |
| tg_getLogsByHash | Yes | turbo-geth only |
| | | |
| tg_forks | Yes | turbo-geth only |
| tg_issuance | Yes | turbo-geth only |
This table is constantly updated. Please visit again.

View File

@ -148,6 +148,7 @@ func StartRpcServer(ctx context.Context, cfg Flags, rpcAPI []rpc.API) error {
return fmt.Errorf("could not start RPC api: %w", err)
}
// TODO(tjayrush): remove TraceType
if cfg.TraceType != "parity" {
log.Info("Tracing output type: ", cfg.TraceType)
}

View File

@ -39,11 +39,11 @@ type EthAPI interface {
GetUncleCountByBlockHash(ctx context.Context, hash common.Hash) (*hexutil.Uint, error)
// Filter related (see ./eth_filters.go)
// newPendingTransactionFilter(ctx context.Context) (string, error)
// newBlockFilter(ctx context.Context) (string, error)
// newFilter(ctx context.Context) (string, error)
// uninstallFilter(ctx context.Context) (string, error)
// getFilterChanges(ctx context.Context) (string, error)
NewPendingTransactionFilter(_ context.Context) (hexutil.Uint64, error)
NewBlockFilter(_ context.Context) (hexutil.Uint64, error)
NewFilter(_ context.Context, filter interface{}) (hexutil.Uint64, error)
UninstallFilter(_ context.Context, index hexutil.Uint64) (bool, error)
GetFilterChanges(_ context.Context, index hexutil.Uint64) ([]interface{}, error)
// Account related (see ./eth_accounts.go)
Accounts(ctx context.Context) ([]common.Address, error)
@ -63,8 +63,10 @@ type EthAPI interface {
Call(ctx context.Context, args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *map[common.Address]ethapi.Account) (hexutil.Bytes, error)
EstimateGas(ctx context.Context, args ethapi.CallArgs) (hexutil.Uint64, error)
SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error)
// SendTransaction(ctx context.Context) (string, error)
SendTransaction(_ context.Context, txObject interface{}) (common.Hash, error)
Sign(ctx context.Context, _ common.Address, _ hexutil.Bytes) (hexutil.Bytes, error)
SignTransaction(_ context.Context, txObject interface{}) (common.Hash, error)
GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNr rpc.BlockNumber) (*interface{}, error)
// Mining related (see ./eth_mining.go)
Coinbase(_ context.Context) (common.Address, error)

View File

@ -181,3 +181,9 @@ func (api *APIImpl) DoEstimateGas(ctx context.Context, args ethapi.CallArgs, blo
}
return hexutil.Uint64(hi), nil
}
// GetProof not implemented
func (api *APIImpl) GetProof(ctx context.Context, address common.Address, storageKeys []string, blockNr rpc.BlockNumber) (*interface{}, error) {
var stub interface{}
return &stub, fmt.Errorf(NotImplemented, "eth_getProof")
}

View File

@ -43,3 +43,8 @@ func (api *APIImpl) Accounts(ctx context.Context) ([]common.Address, error) {
func (api *APIImpl) Sign(ctx context.Context, _ common.Address, _ hexutil.Bytes) (hexutil.Bytes, error) {
return hexutil.Bytes(""), fmt.Errorf(NotAvailableDeprecated, "eth_sign")
}
// SignTransaction deprecated
func (api *APIImpl) SignTransaction(_ context.Context, txObject interface{}) (common.Hash, error) {
return common.Hash{0}, fmt.Errorf(NotAvailableDeprecated, "eth_signTransaction")
}

View File

@ -1,37 +1,34 @@
package commands
// NewPendingTransactionFilter implements eth_newPendingTransactionFilter. Creates a pending transaction filter in the node. To check if the state has changed, call eth_getFilterChanges.
// Parameters:
// None
// Returns:
// QUANTITY - A filter id
import (
"context"
"fmt"
// NewBlockFilter implements eth_newBlockFilter. Creates a block filter in the node, to notify when a new block arrives. To check if the state has changed, call eth_getFilterChanges.
// Parameters:
// None
// Returns:
// QUANTITY - A filter id
"github.com/ledgerwatch/turbo-geth/common/hexutil"
)
// NewFilter implements eth_newFilter. Creates an arbitrary filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call eth_getFilterChanges.
// Parameters:
// Object - The filter options
// fromBlock: QUANTITY|TAG - (optional, default 'latest') Integer block number, or 'latest' for the last mined block or 'pending', 'earliest' for not yet mined transactions
// toBlock: QUANTITY|TAG - (optional, default 'latest') Integer block number, or 'latest' for the last mined block or 'pending', 'earliest' for not yet mined transactions
// address: DATA
// Array of DATA, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate
// topics: Array of DATA, - (optional) Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with 'or' options
// Returns:
// QUANTITY - A filter id
// NewPendingTransactionFilter new transaction filter
func (api *APIImpl) NewPendingTransactionFilter(_ context.Context) (hexutil.Uint64, error) {
return 0, fmt.Errorf(NotImplemented, "eth_newPendingTransactionFilter")
}
// UninstallFilter implements eth_uninstallFilter. Uninstalls a previously-created filter given the filter's id. Always uninstall filters when no longer needed.
// Note: Filters timeout when they are not requested with eth_getFilterChanges for a period of time.
// Parameters:
// QUANTITY - The filter id
// Returns:
// Boolean - true if the filter was successfully uninstalled, false otherwise
// NewBlockFilter new transaction filter
func (api *APIImpl) NewBlockFilter(_ context.Context) (hexutil.Uint64, error) {
return 0, fmt.Errorf(NotImplemented, "eth_newBlockFilter")
}
// NewFilter implements eth_newFilter. Creates an arbitrary filter object, based on filter options, to notify when the state changes (logs).
func (api *APIImpl) NewFilter(_ context.Context, filter interface{}) (hexutil.Uint64, error) {
return 0, fmt.Errorf(NotImplemented, "eth_newFilter")
}
// UninstallFilter new transaction filter
func (api *APIImpl) UninstallFilter(_ context.Context, index hexutil.Uint64) (bool, error) {
return false, fmt.Errorf(NotImplemented, "eth_uninstallFilter")
}
// GetFilterChanges implements eth_getFilterChanges. Polling method for a previously-created filter, which returns an array of logs which occurred since last poll.
// Parameters:
// QUANTITY - The filter id
// Returns:
// Array - Array of log objects, or an empty array if nothing has changed since last poll
func (api *APIImpl) GetFilterChanges(_ context.Context, index hexutil.Uint64) ([]interface{}, error) {
var stub []interface{}
return stub, fmt.Errorf(NotImplemented, "eth_getFilterChanges")
}

View File

@ -19,15 +19,6 @@ func (api *APIImpl) SendRawTransaction(_ context.Context, encodedTx hexutil.Byte
}
// SendTransaction implements eth_sendTransaction. Creates new message call transaction or a contract creation if the data field contains code.
// Note: Use eth_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract
// Parameters:
// Object - The transaction object
// from: DATA, 20 Bytes - The address the transaction is send from
// to: DATA, 20 Bytes - (optional when creating new contract) The address the transaction is directed to
// gas: QUANTITY - (optional, default 90000) Integer of the gas provided for the transaction execution. It will return unused gas
// gasPrice: QUANTITY - (optional, default To-Be-Determined) Integer of the gasPrice used for each paid gas
// value: QUANTITY - (optional) Integer of the value sent with this transaction
// data: DATA - The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see Ethereum Contract ABI
// nonce: QUANTITY - (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce
// Returns:
// DATA, 32 Bytes - The transaction hash, or the zero hash if the transaction is not yet available
func (api *APIImpl) SendTransaction(_ context.Context, txObject interface{}) (common.Hash, error) {
return common.Hash{0}, fmt.Errorf(NotImplemented, "eth_sendTransaction")
}

View File

@ -5,27 +5,46 @@ import (
"fmt"
"github.com/ledgerwatch/turbo-geth/common"
"github.com/ledgerwatch/turbo-geth/core/types"
"github.com/ledgerwatch/turbo-geth/common/hexutil"
"github.com/ledgerwatch/turbo-geth/rpc"
)
// CallParam a parameter for a trace_callMany routine
type CallParam struct {
_ types.Transaction
_ []string
// TraceCallParam (see SendTxArgs -- this allows optional prams plus don't use MixedcaseAddress
type TraceCallParam struct {
_ *common.Address // from
_ *common.Address // to
_ *hexutil.Uint64 // gas
_ *hexutil.Big // gasPrice
_ *hexutil.Big // value
_ *hexutil.Uint64 // nonce
// We accept "data" and "input" for backwards-compatibility reasons.
_ *hexutil.Bytes // data
_ *hexutil.Bytes // input
}
// CallParams array of callMany structs
type CallParams []CallParam
// TraceCallParams array of callMany structs
type TraceCallParams []TraceCallParam
// 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 TraceCallParam, traceTypes []string, blockNr *rpc.BlockNumberOrHash) ([]interface{}, error) {
var stub []interface{}
return stub, fmt.Errorf(NotImplemented, "trace_call")
}
// TODO(tjayrush) - try to use a concrete type here
// TraceCallManyParam array of callMany structs
// type TraceCallManyParam struct {
// obj TraceCallParam
// traceTypes []string
// }
// TraceCallManyParams array of callMany structs
// type TraceCallManyParams struct {
// things []TraceCallManyParam
// }
// CallMany implements trace_callMany.
func (api *TraceAPIImpl) CallMany(ctx context.Context, calls CallParams) ([]interface{}, error) {
func (api *TraceAPIImpl) CallMany(ctx context.Context, calls []interface{}, blockNr *rpc.BlockNumberOrHash) ([]interface{}, error) {
var stub []interface{}
return stub, fmt.Errorf(NotImplemented, "trace_callMany")
}

View File

@ -15,8 +15,8 @@ type TraceAPI interface {
// Ad-hoc (see ./trace_adhoc.go)
ReplayBlockTransactions(ctx context.Context, blockNr rpc.BlockNumber, traceTypes []string) ([]interface{}, error)
ReplayTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error)
Call(ctx context.Context, call CallParam, blockNr rpc.BlockNumber) ([]interface{}, error)
CallMany(ctx context.Context, calls CallParams) ([]interface{}, error)
Call(ctx context.Context, call TraceCallParam, types []string, blockNr *rpc.BlockNumberOrHash) ([]interface{}, error)
CallMany(ctx context.Context, calls []interface{}, blockNr *rpc.BlockNumberOrHash) ([]interface{}, error)
RawTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error)
// Filtering (see ./trace_filtering.go)

View File

@ -36,8 +36,3 @@ func (api *Web3APIImpl) Sha3(_ context.Context, input hexutil.Bytes) hexutil.Byt
var (
gitCommit string
)
// SetGitStrings very hacky way to get these strings into this package
func SetGitStrings(commit string) {
gitCommit = commit
}

View File

@ -10,10 +10,6 @@ import (
"github.com/spf13/cobra"
)
var (
gitCommit string
)
func main() {
cmd, cfg := cli.RootCommand()
cmd.RunE = func(cmd *cobra.Command, args []string) error {
@ -28,9 +24,6 @@ func main() {
return cli.StartRpcServer(cmd.Context(), *cfg, apiList)
}
// Hacky way to get these strings into the commands package
commands.SetGitStrings(gitCommit)
if err := cmd.ExecuteContext(utils.RootContext()); err != nil {
log.Error(err.Error())
os.Exit(1)

File diff suppressed because it is too large Load Diff