Skip to content

Commit

Permalink
Updating RPC tests in Postman (#1340)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjayrush authored Nov 9, 2020
1 parent c0f9b57 commit 546b91f
Show file tree
Hide file tree
Showing 14 changed files with 566 additions and 1,100 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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."

Expand Down
40 changes: 1 addition & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
69 changes: 34 additions & 35 deletions cmd/rpcdaemon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 | - | |
Expand All @@ -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.

Expand Down
1 change: 1 addition & 0 deletions cmd/rpcdaemon/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
14 changes: 8 additions & 6 deletions cmd/rpcdaemon/commands/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions cmd/rpcdaemon/commands/eth_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
5 changes: 5 additions & 0 deletions cmd/rpcdaemon/commands/eth_deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
57 changes: 27 additions & 30 deletions cmd/rpcdaemon/commands/eth_filters.go
Original file line number Diff line number Diff line change
@@ -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")
}
15 changes: 3 additions & 12 deletions cmd/rpcdaemon/commands/send_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Loading

0 comments on commit 546b91f

Please sign in to comment.