Skip to content

Commit d54f2f2

Browse files
gballetMariusVanDerWijdenholiman
authored
whisper: remove whisper (#21487)
* whisper: remove whisper * Update cmd/geth/config.go Co-authored-by: Marius van der Wijden <[email protected]> * cmd/geth: warn on enabling whisper + remove more whisper deps * mobile: remove all whisper references Co-authored-by: Marius van der Wijden <[email protected]> Co-authored-by: Martin Holst Swende <[email protected]>
1 parent c5d28f0 commit d54f2f2

32 files changed

+17
-7894
lines changed

cmd/geth/config.go

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import (
2929
"github.com/ethereum/go-ethereum/cmd/utils"
3030
"github.com/ethereum/go-ethereum/eth"
3131
"github.com/ethereum/go-ethereum/internal/ethapi"
32+
"github.com/ethereum/go-ethereum/log"
3233
"github.com/ethereum/go-ethereum/node"
3334
"github.com/ethereum/go-ethereum/params"
34-
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
3535
"github.com/naoina/toml"
3636
)
3737

@@ -75,7 +75,6 @@ type ethstatsConfig struct {
7575

7676
type gethConfig struct {
7777
Eth eth.Config
78-
Shh whisper.Config
7978
Node node.Config
8079
Ethstats ethstatsConfig
8180
}
@@ -110,7 +109,6 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
110109
// Load defaults.
111110
cfg := gethConfig{
112111
Eth: eth.DefaultConfig,
113-
Shh: whisper.DefaultConfig,
114112
Node: defaultNodeConfig(),
115113
}
116114

@@ -131,19 +129,18 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
131129
if ctx.GlobalIsSet(utils.EthStatsURLFlag.Name) {
132130
cfg.Ethstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name)
133131
}
134-
utils.SetShhConfig(ctx, stack, &cfg.Shh)
132+
utils.SetShhConfig(ctx, stack)
135133

136134
return stack, cfg
137135
}
138136

139137
// enableWhisper returns true in case one of the whisper flags is set.
140-
func enableWhisper(ctx *cli.Context) bool {
138+
func checkWhisper(ctx *cli.Context) {
141139
for _, flag := range whisperFlags {
142140
if ctx.GlobalIsSet(flag.GetName()) {
143-
return true
141+
log.Warn("deprecated whisper flag detected. Whisper has been moved to github.com/ethereum/whisper")
144142
}
145143
}
146-
return false
147144
}
148145

149146
// makeFullNode loads geth configuration and creates the Ethereum backend.
@@ -152,21 +149,7 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
152149

153150
backend := utils.RegisterEthService(stack, &cfg.Eth)
154151

155-
// Whisper must be explicitly enabled by specifying at least 1 whisper flag or in dev mode
156-
shhEnabled := enableWhisper(ctx)
157-
shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DeveloperFlag.Name)
158-
if shhEnabled || shhAutoEnabled {
159-
if ctx.GlobalIsSet(utils.WhisperMaxMessageSizeFlag.Name) {
160-
cfg.Shh.MaxMessageSize = uint32(ctx.Int(utils.WhisperMaxMessageSizeFlag.Name))
161-
}
162-
if ctx.GlobalIsSet(utils.WhisperMinPOWFlag.Name) {
163-
cfg.Shh.MinimumAcceptedPOW = ctx.Float64(utils.WhisperMinPOWFlag.Name)
164-
}
165-
if ctx.GlobalIsSet(utils.WhisperRestrictConnectionBetweenLightClientsFlag.Name) {
166-
cfg.Shh.RestrictConnectionBetweenLightClients = true
167-
}
168-
utils.RegisterShhService(stack, &cfg.Shh)
169-
}
152+
checkWhisper(ctx)
170153
// Configure GraphQL if requested
171154
if ctx.GlobalIsSet(utils.GraphQLEnabledFlag.Name) {
172155
utils.RegisterGraphQLService(stack, backend, cfg.Node)

cmd/geth/consolecmd_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
)
3232

3333
const (
34-
ipcAPIs = "admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 shh:1.0 txpool:1.0 web3:1.0"
34+
ipcAPIs = "admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0"
3535
httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0"
3636
)
3737

@@ -43,7 +43,7 @@ func TestConsoleWelcome(t *testing.T) {
4343
// Start a geth console, make sure it's cleaned up and terminate the console
4444
geth := runGeth(t,
4545
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
46-
"--etherbase", coinbase, "--shh",
46+
"--etherbase", coinbase,
4747
"console")
4848

4949
// Gather all the infos the welcome message needs to contain
@@ -83,11 +83,9 @@ func TestIPCAttachWelcome(t *testing.T) {
8383
defer os.RemoveAll(ws)
8484
ipc = filepath.Join(ws, "geth.ipc")
8585
}
86-
// Note: we need --shh because testAttachWelcome checks for default
87-
// list of ipc modules and shh is included there.
8886
geth := runGeth(t,
8987
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
90-
"--etherbase", coinbase, "--shh", "--ipcpath", ipc)
88+
"--etherbase", coinbase, "--ipcpath", ipc)
9189

9290
defer func() {
9391
geth.Interrupt()

cmd/geth/usage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
211211
Flags: metricsFlags,
212212
},
213213
{
214-
Name: "WHISPER (EXPERIMENTAL)",
214+
Name: "WHISPER (deprecated)",
215215
Flags: whisperFlags,
216216
},
217217
{

cmd/utils/flags.go

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ import (
6363
"github.com/ethereum/go-ethereum/p2p/nat"
6464
"github.com/ethereum/go-ethereum/p2p/netutil"
6565
"github.com/ethereum/go-ethereum/params"
66-
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
6766
pcsclite "github.com/gballet/go-libpcsclite"
6867
cli "gopkg.in/urfave/cli.v1"
6968
)
@@ -639,12 +638,12 @@ var (
639638
WhisperMaxMessageSizeFlag = cli.IntFlag{
640639
Name: "shh.maxmessagesize",
641640
Usage: "Max message size accepted",
642-
Value: int(whisper.DefaultMaxMessageSize),
641+
Value: 1024 * 1024,
643642
}
644643
WhisperMinPOWFlag = cli.Float64Flag{
645644
Name: "shh.pow",
646645
Usage: "Minimum POW accepted",
647-
Value: whisper.DefaultMinimumPoW,
646+
Value: 0.2,
648647
}
649648
WhisperRestrictConnectionBetweenLightClientsFlag = cli.BoolFlag{
650649
Name: "shh.restrict-light",
@@ -1465,15 +1464,12 @@ func CheckExclusive(ctx *cli.Context, args ...interface{}) {
14651464
}
14661465

14671466
// SetShhConfig applies shh-related command line flags to the config.
1468-
func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) {
1469-
if ctx.GlobalIsSet(WhisperMaxMessageSizeFlag.Name) {
1470-
cfg.MaxMessageSize = uint32(ctx.GlobalUint(WhisperMaxMessageSizeFlag.Name))
1471-
}
1472-
if ctx.GlobalIsSet(WhisperMinPOWFlag.Name) {
1473-
cfg.MinimumAcceptedPOW = ctx.GlobalFloat64(WhisperMinPOWFlag.Name)
1474-
}
1475-
if ctx.GlobalIsSet(WhisperRestrictConnectionBetweenLightClientsFlag.Name) {
1476-
cfg.RestrictConnectionBetweenLightClients = true
1467+
func SetShhConfig(ctx *cli.Context, stack *node.Node) {
1468+
if ctx.GlobalIsSet(WhisperEnabledFlag.Name) ||
1469+
ctx.GlobalIsSet(WhisperMaxMessageSizeFlag.Name) ||
1470+
ctx.GlobalIsSet(WhisperMinPOWFlag.Name) ||
1471+
ctx.GlobalIsSet(WhisperRestrictConnectionBetweenLightClientsFlag.Name) {
1472+
log.Warn("Whisper support has been deprecated and the code has been moved to github.com/ethereum/whisper")
14771473
}
14781474
}
14791475

@@ -1697,13 +1693,6 @@ func RegisterEthService(stack *node.Node, cfg *eth.Config) ethapi.Backend {
16971693
}
16981694
}
16991695

1700-
// RegisterShhService configures Whisper and adds it to the given node.
1701-
func RegisterShhService(stack *node.Node, cfg *whisper.Config) {
1702-
if _, err := whisper.New(stack, cfg); err != nil {
1703-
Fatalf("Failed to register the Whisper service: %v", err)
1704-
}
1705-
}
1706-
17071696
// RegisterEthStatsService configures the Ethereum Stats daemon and adds it to
17081697
// the given node.
17091698
func RegisterEthStatsService(stack *node.Node, backend ethapi.Backend, url string) {

0 commit comments

Comments
 (0)