Remove deprecated Whisper code (#2726)

This commit is contained in:
Zachinquarantine 2021-09-25 11:28:25 -04:00 committed by GitHub
parent 0976b9e452
commit 5da7fb64bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 9 additions and 558 deletions

View File

@ -215,7 +215,7 @@ Provide both `--datadir` and `--private.api.addr` options:
make erigon
./build/bin/erigon --private.api.addr=localhost:9090
make rpcdaemon
./build/bin/rpcdaemon --datadir=<your_data_dir> --private.api.addr=localhost:9090 --http.api=eth,erigon,web3,net,debug,trace,txpool,shh
./build/bin/rpcdaemon --datadir=<your_data_dir> --private.api.addr=localhost:9090 --http.api=eth,erigon,web3,net,debug,trace,txpool
```
#### **For remote DB**
@ -227,7 +227,7 @@ socket connection to pass data between them. To use this mode, run Erigon in one
make erigon
./build/bin/erigon --private.api.addr=localhost:9090
make rpcdaemon
./build/bin/rpcdaemon --private.api.addr=localhost:9090 --http.api=eth,erigon,web3,net,debug,trace,txpool,shh
./build/bin/rpcdaemon --private.api.addr=localhost:9090 --http.api=eth,erigon,web3,net,debug,trace,txpool
```
**gRPC ports**: `9090` erigon, `9091` sentry, `9092` consensus engine, `9093` snapshot downloader, `9094` TxPool
@ -416,4 +416,4 @@ For example: btrfs's autodefrag option - may increase write IO 100x times
### Gnome Tracker can kill Erigon
[Gnome Tracker](https://wiki.gnome.org/Projects/Tracker) - detecting miners and kill them.
[Gnome Tracker](https://wiki.gnome.org/Projects/Tracker) - detecting miners and kill them.

View File

@ -41,7 +41,7 @@ it's much faster than TCP access. Provide both `--datadir` and `--private.api.ad
make erigon
./build/bin/erigon --datadir=<your_data_dir> --private.api.addr=localhost:9090
make rpcdaemon
./build/bin/rpcdaemon --datadir=<your_data_dir> --private.api.addr=localhost:9090 --http.api=eth,erigon,web3,net,debug,trace,txpool,shh
./build/bin/rpcdaemon --datadir=<your_data_dir> --private.api.addr=localhost:9090 --http.api=eth,erigon,web3,net,debug,trace,txpool
```
Note that we've also specified which RPC namespaces to enable in the above command by `--http.api` flag.
@ -54,7 +54,7 @@ To start the daemon remotely - just don't set `--datadir` flag:
make erigon
./build/bin/erigon --datadir=<your_data_dir> --private.api.addr=0.0.0.0:9090
make rpcdaemon
./build/bin/rpcdaemon --private.api.addr=<erigon_ip>:9090 --http.api=eth,erigon,web3,net,debug,trace,txpool,shh
./build/bin/rpcdaemon --private.api.addr=<erigon_ip>:9090 --http.api=eth,erigon,web3,net,debug,trace,txpool
```
The daemon should respond with something like:
@ -212,17 +212,6 @@ The following table shows the current implementation status of Erigon's RPC daem
| db_putHex | No | deprecated |
| db_getHex | No | deprecated |
| | | |
| 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 |
| | | |
| erigon_getHeaderByHash | Yes | Erigon only |
| erigon_getHeaderByNumber | Yes | Erigon only |
| erigon_getLogsByHash | Yes | Erigon only |

View File

@ -79,7 +79,7 @@ func RootCommand() (*cobra.Command, *Flags) {
rootCmd.PersistentFlags().StringSliceVar(&cfg.HttpCORSDomain, "http.corsdomain", []string{}, "Comma separated list of domains from which to accept cross origin requests (browser enforced)")
rootCmd.PersistentFlags().StringSliceVar(&cfg.HttpVirtualHost, "http.vhosts", node.DefaultConfig.HTTPVirtualHosts, "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.")
rootCmd.PersistentFlags().BoolVar(&cfg.HttpCompression, "http.compression", true, "Disable http compression")
rootCmd.PersistentFlags().StringSliceVar(&cfg.API, "http.api", []string{"eth", "erigon"}, "API's offered over the HTTP-RPC interface: eth,erigon,web3,net,debug,trace,txpool,shh,db. Supported methods: https://github.com/ledgerwatch/erigon/tree/devel/cmd/rpcdaemon")
rootCmd.PersistentFlags().StringSliceVar(&cfg.API, "http.api", []string{"eth", "erigon"}, "API's offered over the HTTP-RPC interface: eth,erigon,web3,net,debug,trace,txpool,db. Supported methods: https://github.com/ledgerwatch/erigon/tree/devel/cmd/rpcdaemon")
rootCmd.PersistentFlags().Uint64Var(&cfg.Gascap, "rpc.gascap", 50000000, "Sets a cap on gas that can be used in eth_call/estimateGas")
rootCmd.PersistentFlags().Uint64Var(&cfg.MaxTraces, "trace.maxtraces", 200, "Sets a limit on traces that can be returned in trace_filter")
rootCmd.PersistentFlags().BoolVar(&cfg.WebsocketEnabled, "ws", false, "Enable Websockets")

View File

@ -23,8 +23,7 @@ func APIList(ctx context.Context, db kv.RoDB, eth services.ApiBackend, txPool tx
debugImpl := NewPrivateDebugAPI(base, db, cfg.Gascap)
traceImpl := NewTraceAPI(base, db, &cfg)
web3Impl := NewWeb3APIImpl(eth)
dbImpl := NewDBAPIImpl() /* deprecated */
shhImpl := NewSHHAPIImpl() /* deprecated */
dbImpl := NewDBAPIImpl() /* deprecated */
for _, enabledAPI := range cfg.API {
switch enabledAPI {
@ -70,20 +69,13 @@ func APIList(ctx context.Context, db kv.RoDB, eth services.ApiBackend, txPool tx
Service: TraceAPI(traceImpl),
Version: "1.0",
})
case "db":
case "db": /* Deprecated */
defaultAPIList = append(defaultAPIList, rpc.API{
Namespace: "db",
Public: true,
Service: DBAPI(dbImpl),
Version: "1.0",
})
case "shh":
defaultAPIList = append(defaultAPIList, rpc.API{
Namespace: "shh",
Public: true,
Service: SHHAPI(shhImpl),
Version: "1.0",
})
case "erigon":
defaultAPIList = append(defaultAPIList, rpc.API{
Namespace: "erigon",

View File

@ -1,110 +0,0 @@
package commands
import (
"context"
"fmt"
"github.com/ledgerwatch/erigon/common/hexutil"
)
// SHHAPI the interface for the shh_ RPC commands (deprecated)
type SHHAPI interface {
Post(_ context.Context, _ SHHPost) (bool, error)
Version(_ context.Context) (string, error)
NewIdentity(_ context.Context) (string, error)
HasIdentity(_ context.Context, _ string) (bool, error)
NewGroup(_ context.Context) (string, error)
AddToGroup(_ context.Context, _ string) (bool, error)
NewFilter(_ context.Context, _ SHHFilter) (hexutil.Uint, error)
UninstallFilter(_ context.Context, _ hexutil.Uint) (bool, error)
GetFilterChanges(_ context.Context, _ hexutil.Uint) ([]string, error)
GetMessages(_ context.Context, _ hexutil.Uint) ([]string, error)
}
// SHHAPIImpl data structure to store things needed for shh_ commands
type SHHAPIImpl struct {
unused uint64
}
// NewSHHAPIImpl returns NetAPIImplImpl instance
func NewSHHAPIImpl() *SHHAPIImpl {
return &SHHAPIImpl{
unused: uint64(0),
}
}
// SHHPost type for shh_post command (deprecated)
type SHHPost struct {
_ string // from
_ string // to
_ []string // topics
_ string // payload
_ hexutil.Uint // priority
_ hexutil.Uint // ttl
}
// Post implements shh_post. Sends a whisper message.
// Deprecated: This function will be removed in the future.
func (api *SHHAPIImpl) Post(_ context.Context, _ SHHPost) (bool, error) {
return false, fmt.Errorf(NotAvailableDeprecated, "shh_post")
}
// Version implements shh_version. Returns the current whisper protocol version.
// Deprecated: This function will be removed in the future.
func (api *SHHAPIImpl) Version(_ context.Context) (string, error) {
return "", fmt.Errorf(NotAvailableDeprecated, "shh_version")
}
// NewIdentity implements shh_newIdentity. Creates new whisper identity in the client.
// Deprecated: This function will be removed in the future.
func (api *SHHAPIImpl) NewIdentity(_ context.Context) (string, error) {
return "", fmt.Errorf(NotAvailableDeprecated, "shh_newIdentity")
}
// HasIdentity implements shh_hasIdentity. Checks if the client hold the private keys for a given identity.
// Deprecated: This function will be removed in the future.
func (api *SHHAPIImpl) HasIdentity(_ context.Context, _ string) (bool, error) {
return false, fmt.Errorf(NotAvailableDeprecated, "shh_hasIdentity")
}
// NewGroup implements shh_newGroup. Create a new group.
// Deprecated: This function will be removed in the future.
func (api *SHHAPIImpl) NewGroup(_ context.Context) (string, error) {
return "", fmt.Errorf(NotAvailableDeprecated, "shh_newGroup")
}
// AddToGroup implements shh_addToGroup. Add to a group.
// Deprecated: This function will be removed in the future.
func (api *SHHAPIImpl) AddToGroup(_ context.Context, _ string) (bool, error) {
return false, fmt.Errorf(NotAvailableDeprecated, "shh_addToGroup")
}
// SHHFilter type for shh_newFilter command
type SHHFilter struct {
_ string
_ []string
}
// NewFilter implements shh_newFilter. Creates filter to notify, when client receives whisper message matching the filter options.
// Deprecated: This function will be removed in the future.
func (api *SHHAPIImpl) NewFilter(_ context.Context, _ SHHFilter) (hexutil.Uint, error) {
return hexutil.Uint(0), fmt.Errorf(NotAvailableDeprecated, "shh_newFilter")
}
// UninstallFilter implements shh_uninstallFilter. Uninstalls a filter with given id.
// Deprecated: This function will be removed in the future.
func (api *SHHAPIImpl) UninstallFilter(_ context.Context, _ hexutil.Uint) (bool, error) {
return false, fmt.Errorf(NotAvailableDeprecated, "shh_uninstallFilter")
}
// GetFilterChanges implements shh_getFilterChanges. Polling method for whisper filters. Returns new messages since the last call of this method.
// Deprecated: This function will be removed in the future.
func (api *SHHAPIImpl) GetFilterChanges(_ context.Context, _ hexutil.Uint) ([]string, error) {
return []string{}, fmt.Errorf(NotAvailableDeprecated, "shh_getFilterChanges")
}
// GetMessages implements shh_getMessages. Get all messages matching a filter. Unlike shh_getFilterChanges this returns all messages.
// Deprecated: This function will be removed in the future.
func (api *SHHAPIImpl) GetMessages(_ context.Context, _ hexutil.Uint) ([]string, error) {
return []string{}, fmt.Errorf(NotAvailableDeprecated, "shh_getMessages")
}

View File

@ -3078,396 +3078,3 @@ Stores binary data in the local database.
- ``true`` if the value was stored, ``false`` otherwise
--------------
shh_post
--------
Sends a whisper message.
.. warning::
This function has been deprecated.
**Parameters**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``OBJECT``
- An object of type Post
**Example**
::
curl -s --data '{"jsonrpc":"2.0","method":"shh_post","params":[{"from":"0xc931d93e97ab07fe42d923478ba2465f2..","topics":["0x68656c6c6f20776f726c64"],"payload":"0x68656c6c6f20776f726c64","ttl":"0x64","priority":"0x64"}],"id":"1"}' -H "Content-Type: application/json" -X POST http://localhost:8545
**Returns**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``BOOLEAN``
- ``true`` if the message was send, ``false`` otherwise
--------------
shh_version
-----------
Returns the current whisper protocol version.
.. warning::
This function has been deprecated.
**Parameters**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``NONE``
-
**Example**
::
curl -s --data '{"jsonrpc":"2.0","method":"shh_version","params":[],"id":"1"}' -H "Content-Type: application/json" -X POST http://localhost:8545
**Returns**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``STRING``
- The current whisper protocol version
--------------
shh_newIdentity
---------------
Creates new whisper identity in the client.
.. warning::
This function has been deprecated.
**Parameters**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``NONE``
-
**Example**
::
curl -s --data '{"jsonrpc":"2.0","method":"shh_newIdentity","params":[],"id":"1"}' -H "Content-Type: application/json" -X POST http://localhost:8545
**Returns**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``DATA, 60 BYTES``
- The address of the new identiy
--------------
shh_hasIdentity
---------------
Checks if the client hold the private keys for a given identity.
.. warning::
This function has been deprecated.
**Parameters**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``DATA, 60 BYTES``
- The identity address to check
**Example**
::
curl -s --data '{"jsonrpc":"2.0","method":"shh_hasIdentity","params":["0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1"],"id":"1"}' -H "Content-Type: application/json" -X POST http://localhost:8545
**Returns**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``BOOLEAN``
- ``true`` if the client holds the privatekey for that identity, ``false`` otherwise
--------------
shh_newGroup
------------
Create a new group.
.. warning::
This function has been deprecated.
**Parameters**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``NONE``
-
**Example**
::
curl -s --data '{"jsonrpc":"2.0","method":"shh_newGroup","params":[],"id":"1"}' -H "Content-Type: application/json" -X POST http://localhost:8545
**Returns**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``DATA, 60 BYTES``
- The address of the new group
--------------
shh_addToGroup
--------------
Add to a group.
.. warning::
This function has been deprecated.
**Parameters**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``DATA, 60 BYTES``
- The identity address to add to a group
**Example**
::
curl -s --data '{"jsonrpc":"2.0","method":"shh_addToGroup","params":["0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1"],"id":"1"}' -H "Content-Type: application/json" -X POST http://localhost:8545
**Returns**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``BOOLEAN``
- ``true`` if the identity was successfully added to the group, ``false`` otherwise
--------------
shh_newFilter
-------------
Creates filter to notify, when client receives whisper message matching the filter options.
.. warning::
This function has been deprecated.
**Parameters**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``OBJECT``
- An object of type Filter
**Example**
::
curl -s --data '{"jsonrpc":"2.0","method":"shh_newFilter","params":[{"topics":["0x12341234bf4b564f"],"to":"0x2341234bf4b2341234bf4b564f..."}],"id":"1"}' -H "Content-Type: application/json" -X POST http://localhost:8545
**Returns**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``QUANTITY``
- The newly created filter id
--------------
shh_uninstallFilter
-------------------
Uninstalls a filter with given id.
.. warning::
This function has been deprecated.
**Parameters**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``QUANTITY``
- The filter id
**Example**
::
curl -s --data '{"jsonrpc":"2.0","method":"shh_uninstallFilter","params":["0x7"],"id":"1"}' -H "Content-Type: application/json" -X POST http://localhost:8545
**Returns**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``BOOLEAN``
- ``true`` if the filter was successfully uninstalled, ``false`` otherwise
--------------
shh_getFilterChanges
--------------------
Polling method for whisper filters. Returns new messages since the last call of this method.
.. warning::
This function has been deprecated.
**Parameters**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``QUANTITY``
- The filter id
**Example**
::
curl -s --data '{"jsonrpc":"2.0","method":"shh_getFilterChanges","params":["0x7"],"id":"1"}' -H "Content-Type: application/json" -X POST http://localhost:8545
**Returns**
Array - An array of type Message received since last poll
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``ARRAY``
- An array of type Message received since last poll
--------------
shh_getMessages
---------------
Get all messages matching a filter. Unlike ``shh_getFilterChanges`` this returns all messages.
.. warning::
This function has been deprecated.
**Parameters**
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``QUANTITY``
- The filter id
**Example**
::
curl -s --data '{"jsonrpc":"2.0","method":"shh_getMessages","params":["0x7"],"id":"1"}' -H "Content-Type: application/json" -X POST http://localhost:8545
**Returns**
Array - An array of type Message received since last poll
.. list-table::
:widths: 25 75
:header-rows: 1
* - Type
- Description
* - ``ARRAY``
- An array of type Message received since last poll

View File

@ -29,7 +29,6 @@ var Modules = map[string]string{
"net": NetJs,
"personal": PersonalJs,
"rpc": RpcJs,
"shh": ShhJs,
"swarmfs": SwarmfsJs,
"txpool": TxpoolJs,
"les": LESJs,
@ -708,26 +707,6 @@ web3._extend({
});
`
const ShhJs = `
web3._extend({
property: 'shh',
methods: [
],
properties:
[
new web3._extend.Property({
name: 'version',
getter: 'shh_version',
outputFormatter: web3._extend.utils.toDecimal
}),
new web3._extend.Property({
name: 'info',
getter: 'shh_info'
}),
]
});
`
const SwarmfsJs = `
web3._extend({
property: 'swarmfs',

View File

@ -412,12 +412,6 @@ func (c *Client) EthSubscribe(ctx context.Context, channel interface{}, args ...
return c.Subscribe(ctx, "eth", channel, args...)
}
// ShhSubscribe registers a subscripion under the "shh" namespace.
// Deprecated: use Subscribe(ctx, "shh", ...).
func (c *Client) ShhSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (*ClientSubscription, error) {
return c.Subscribe(ctx, "shh", channel, args...)
}
// Subscribe calls the "<namespace>_subscribe" method with the given arguments,
// registering a subscription. Server notifications for the subscription are
// sent to the given channel. The element type of the channel must match the

View File

@ -48,7 +48,7 @@ func TestNewID(t *testing.T) {
func TestSubscriptions(t *testing.T) {
var (
namespaces = []string{"eth", "shh", "bzz"}
namespaces = []string{"eth", "bzz"}
service = &notificationTestService{}
subCount = len(namespaces)
notificationCount = 3