Skip to content

Commit d0a4989

Browse files
cmd, eth, node: deprecate personal namespace (ethereum#26390)
* eth: cmd: deprecate personal namespace * eth: cmd: move deprecation to node * node: disable toml of enablepersonal * node: disable personal on ipc as well * Update node/node.go Co-authored-by: Martin Holst Swende <martin@swende.se> * console: error -> warn * node: less roulette --------- Co-authored-by: Martin Holst Swende <martin@swende.se>
1 parent a8cf439 commit d0a4989

File tree

7 files changed

+35
-8
lines changed

7 files changed

+35
-8
lines changed

cmd/geth/consolecmd.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func localConsole(ctx *cli.Context) error {
7777
// Attach to the newly started node and create the JavaScript console.
7878
client, err := stack.Attach()
7979
if err != nil {
80-
return fmt.Errorf("Failed to attach to the inproc geth: %v", err)
80+
return fmt.Errorf("failed to attach to the inproc geth: %v", err)
8181
}
8282
config := console.Config{
8383
DataDir: utils.MakeDataDir(ctx),
@@ -87,7 +87,7 @@ func localConsole(ctx *cli.Context) error {
8787
}
8888
console, err := console.New(config)
8989
if err != nil {
90-
return fmt.Errorf("Failed to start the JavaScript console: %v", err)
90+
return fmt.Errorf("failed to start the JavaScript console: %v", err)
9191
}
9292
defer console.Stop(false)
9393

cmd/geth/consolecmd_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
)
3131

3232
const (
33-
ipcAPIs = "admin:1.0 debug:1.0 engine: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"
33+
ipcAPIs = "admin:1.0 debug:1.0 engine:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 rpc:1.0 txpool:1.0 web3:1.0"
3434
httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0"
3535
)
3636

cmd/geth/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ var (
6565
utils.USBFlag,
6666
utils.SmartCardDaemonPathFlag,
6767
utils.OverrideShanghai,
68+
utils.EnablePersonal,
6869
utils.EthashCacheDirFlag,
6970
utils.EthashCachesInMemoryFlag,
7071
utils.EthashCachesOnDiskFlag,

cmd/utils/flags.go

+10
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,11 @@ var (
785785
Usage: "Allow for unprotected (non EIP155 signed) transactions to be submitted via RPC",
786786
Category: flags.APICategory,
787787
}
788+
EnablePersonal = &cli.BoolFlag{
789+
Name: "rpc.enabledeprecatedpersonal",
790+
Usage: "Enables the (deprecated) personal namespace",
791+
Category: flags.APICategory,
792+
}
788793

789794
// Network Settings
790795
MaxPeersFlag = &cli.IntFlag{
@@ -1466,6 +1471,10 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
14661471
cfg.JWTSecret = ctx.String(JWTSecretFlag.Name)
14671472
}
14681473

1474+
if ctx.IsSet(EnablePersonal.Name) {
1475+
cfg.EnablePersonal = true
1476+
}
1477+
14691478
if ctx.IsSet(ExternalSignerFlag.Name) {
14701479
cfg.ExternalSigner = ctx.String(ExternalSignerFlag.Name)
14711480
}
@@ -1853,6 +1862,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
18531862
cfg.EthDiscoveryURLs = SplitAndTrim(urls)
18541863
}
18551864
}
1865+
18561866
// Override any default configs for hard coded networks.
18571867
switch {
18581868
case ctx.Bool(MainnetFlag.Name):

console/console.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func (c *Console) initExtensions() error {
215215
}
216216

217217
// Compute aliases from server-provided modules.
218-
aliases := map[string]struct{}{"eth": {}, "personal": {}}
218+
aliases := map[string]struct{}{"eth": {}}
219219
for api := range apis {
220220
if api == "web3" {
221221
continue
@@ -260,6 +260,7 @@ func (c *Console) initPersonal(vm *goja.Runtime, bridge *bridge) {
260260
if personal == nil || c.prompter == nil {
261261
return
262262
}
263+
log.Warn("Enabling deprecated personal namespace")
263264
jeth := vm.NewObject()
264265
vm.Set("jeth", jeth)
265266
jeth.Set("openWallet", personal.Get("openWallet"))

node/config.go

+3
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ type Config struct {
199199

200200
// JWTSecret is the path to the hex-encoded jwt secret.
201201
JWTSecret string `toml:",omitempty"`
202+
203+
// EnablePersonal enables the deprecated personal namespace.
204+
EnablePersonal bool `toml:"-"`
202205
}
203206

204207
// IPCEndpoint resolves an IPC endpoint based on a configured value, taking into

node/node.go

+16-4
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,25 @@ func (n *Node) obtainJWTSecret(cliParam string) ([]byte, error) {
376376
// startup. It's not meant to be called at any time afterwards as it makes certain
377377
// assumptions about the state of the node.
378378
func (n *Node) startRPC() error {
379-
if err := n.startInProc(); err != nil {
379+
// Filter out personal api
380+
var apis []rpc.API
381+
for _, api := range n.rpcAPIs {
382+
if api.Namespace == "personal" {
383+
if n.config.EnablePersonal {
384+
log.Warn("Deprecated personal namespace activated")
385+
} else {
386+
continue
387+
}
388+
}
389+
apis = append(apis, api)
390+
}
391+
if err := n.startInProc(apis); err != nil {
380392
return err
381393
}
382394

383395
// Configure IPC.
384396
if n.ipc.endpoint != "" {
385-
if err := n.ipc.start(n.rpcAPIs); err != nil {
397+
if err := n.ipc.start(apis); err != nil {
386398
return err
387399
}
388400
}
@@ -510,8 +522,8 @@ func (n *Node) stopRPC() {
510522
}
511523

512524
// startInProc registers all RPC APIs on the inproc server.
513-
func (n *Node) startInProc() error {
514-
for _, api := range n.rpcAPIs {
525+
func (n *Node) startInProc(apis []rpc.API) error {
526+
for _, api := range apis {
515527
if err := n.inprocHandler.RegisterName(api.Namespace, api.Service); err != nil {
516528
return err
517529
}

0 commit comments

Comments
 (0)