Skip to content

Commit 2a21200

Browse files
committed
cmd, console, node : deprecate personal namespace ethereum#26390
1 parent 10c7e1d commit 2a21200

File tree

7 files changed

+35
-8
lines changed

7 files changed

+35
-8
lines changed

cmd/XDC/consolecmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func localConsole(ctx *cli.Context) error {
8282
// Attach to the newly started node and start the JavaScript console
8383
client, err := stack.Attach()
8484
if err != nil {
85-
utils.Fatalf("Failed to attach to the inproc XDC: %v", err)
85+
utils.Fatalf("failed to attach to the inproc XDC: %v", err)
8686
}
8787
config := console.Config{
8888
DataDir: utils.MakeDataDir(ctx),
@@ -93,7 +93,7 @@ func localConsole(ctx *cli.Context) error {
9393

9494
console, err := console.New(config)
9595
if err != nil {
96-
utils.Fatalf("Failed to start the JavaScript console: %v", err)
96+
utils.Fatalf("failed to start the JavaScript console: %v", err)
9797
}
9898
defer console.Stop(false)
9999

cmd/XDC/consolecmd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
)
3131

3232
const (
33-
ipcAPIs = "XDCx:1.0 XDCxlending:1.0 XDPoS:1.0 admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0"
33+
ipcAPIs = "XDCx:1.0 XDCxlending:1.0 XDPoS:1.0 admin:1.0 debug:1.0 eth: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/XDC/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ var (
6868
utils.NoUSBFlag, // deprecated
6969
utils.USBFlag,
7070
utils.SmartCardDaemonPathFlag,
71+
utils.EnablePersonal,
7172
//utils.EthashCacheDirFlag,
7273
//utils.EthashCachesInMemoryFlag,
7374
//utils.EthashCachesOnDiskFlag,

cmd/utils/flags.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,11 @@ var (
587587
Usage: "Allow for unprotected (non EIP155 signed) transactions to be submitted via RPC",
588588
Category: flags.APICategory,
589589
}
590+
EnablePersonal = &cli.BoolFlag{
591+
Name: "rpc.enabledeprecatedpersonal",
592+
Usage: "Enables the (deprecated) personal namespace",
593+
Category: flags.APICategory,
594+
}
590595
BatchRequestLimit = &cli.IntFlag{
591596
Name: "rpc-batch-request-limit",
592597
Usage: "Maximum number of requests in a batch",
@@ -1278,6 +1283,10 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
12781283
cfg.JWTSecret = ctx.String(JWTSecretFlag.Name)
12791284
}
12801285

1286+
if ctx.IsSet(EnablePersonal.Name) {
1287+
cfg.EnablePersonal = true
1288+
}
1289+
12811290
switch {
12821291
case ctx.IsSet(DataDirFlag.Name):
12831292
cfg.DataDir = ctx.String(DataDirFlag.Name)

console/console.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/XinFinOrg/XDPoSChain/internal/jsre"
3131
"github.com/XinFinOrg/XDPoSChain/internal/jsre/deps"
3232
"github.com/XinFinOrg/XDPoSChain/internal/web3ext"
33+
"github.com/XinFinOrg/XDPoSChain/log"
3334
"github.com/XinFinOrg/XDPoSChain/rpc"
3435
"github.com/dop251/goja"
3536
"github.com/mattn/go-colorable"
@@ -186,7 +187,7 @@ func (c *Console) initExtensions() error {
186187
if err != nil {
187188
return fmt.Errorf("api modules: %v", err)
188189
}
189-
aliases := map[string]struct{}{"eth": {}, "personal": {}}
190+
aliases := map[string]struct{}{"eth": {}}
190191
for api := range apis {
191192
if api == "web3" {
192193
continue
@@ -231,6 +232,7 @@ func (c *Console) initPersonal(vm *goja.Runtime, bridge *bridge) {
231232
if personal == nil || c.prompter == nil {
232233
return
233234
}
235+
log.Warn("Enabling deprecated personal namespace")
234236
jeth := vm.NewObject()
235237
vm.Set("jeth", jeth)
236238
jeth.Set("openWallet", personal.Get("openWallet"))

node/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ type Config struct {
194194

195195
// JWTSecret is the path to the hex-encoded jwt secret.
196196
JWTSecret string `toml:",omitempty"`
197+
198+
// EnablePersonal enables the deprecated personal namespace.
199+
EnablePersonal bool `toml:"-"`
197200
}
198201

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

node/node.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,13 +392,25 @@ func (n *Node) obtainJWTSecret(cliParam string) ([]byte, error) {
392392
// startup. It's not meant to be called at any time afterwards as it makes certain
393393
// assumptions about the state of the node.
394394
func (n *Node) startRPC() error {
395-
if err := n.startInProc(); err != nil {
395+
// Filter out personal api
396+
var apis []rpc.API
397+
for _, api := range n.rpcAPIs {
398+
if api.Namespace == "personal" {
399+
if n.config.EnablePersonal {
400+
log.Warn("Deprecated personal namespace activated")
401+
} else {
402+
continue
403+
}
404+
}
405+
apis = append(apis, api)
406+
}
407+
if err := n.startInProc(apis); err != nil {
396408
return err
397409
}
398410

399411
// Configure IPC.
400412
if n.ipc.endpoint != "" {
401-
if err := n.ipc.start(n.rpcAPIs); err != nil {
413+
if err := n.ipc.start(apis); err != nil {
402414
return err
403415
}
404416
}
@@ -541,8 +553,8 @@ func (n *Node) stopRPC() {
541553
}
542554

543555
// startInProc registers all RPC APIs on the inproc server.
544-
func (n *Node) startInProc() error {
545-
for _, api := range n.rpcAPIs {
556+
func (n *Node) startInProc(apis []rpc.API) error {
557+
for _, api := range apis {
546558
if err := n.inprocHandler.RegisterName(api.Namespace, api.Service); err != nil {
547559
return err
548560
}

0 commit comments

Comments
 (0)