From 5a8c4ffbd4cb023a98d4913bc8538a123833f033 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Thu, 7 Nov 2024 13:50:34 +0100 Subject: [PATCH] cmd/geth: remove flag and config related to insecure unlock --- accounts/manager.go | 17 +---------------- cmd/geth/accountcmd.go | 2 +- cmd/utils/flags.go | 7 +------ cmd/utils/flags_legacy.go | 5 +++++ internal/ethapi/api_test.go | 2 +- node/config.go | 2 +- node/node.go | 2 +- signer/core/api.go | 2 +- 8 files changed, 12 insertions(+), 27 deletions(-) diff --git a/accounts/manager.go b/accounts/manager.go index cbe4f7c79d..24c4eac3cf 100644 --- a/accounts/manager.go +++ b/accounts/manager.go @@ -29,14 +29,6 @@ import ( // the manager will buffer in its channel. const managerSubBufferSize = 50 -// Config contains the settings of the global account manager. -// -// TODO(rjl493456442, karalabe, holiman): Get rid of this when account management -// is removed in favor of Clef. -type Config struct { - InsecureUnlockAllowed bool // Whether account unlocking in insecure environment is allowed -} - // newBackendEvent lets the manager know it should // track the given backend for wallet updates. type newBackendEvent struct { @@ -47,7 +39,6 @@ type newBackendEvent struct { // Manager is an overarching account manager that can communicate with various // backends for signing transactions. type Manager struct { - config *Config // Global account manager configurations backends map[reflect.Type][]Backend // Index of backends currently registered updaters []event.Subscription // Wallet update subscriptions for all backends updates chan WalletEvent // Subscription sink for backend wallet changes @@ -63,7 +54,7 @@ type Manager struct { // NewManager creates a generic account manager to sign transaction via various // supported backends. -func NewManager(config *Config, backends ...Backend) *Manager { +func NewManager(backends ...Backend) *Manager { // Retrieve the initial list of wallets from the backends and sort by URL var wallets []Wallet for _, backend := range backends { @@ -78,7 +69,6 @@ func NewManager(config *Config, backends ...Backend) *Manager { } // Assemble the account manager and return am := &Manager{ - config: config, backends: make(map[reflect.Type][]Backend), updaters: subs, updates: updates, @@ -106,11 +96,6 @@ func (am *Manager) Close() error { return <-errc } -// Config returns the configuration of account manager. -func (am *Manager) Config() *Config { - return am.config -} - // AddBackend starts the tracking of an additional backend for wallet updates. // cmd/geth assumes once this func returns the backends have been already integrated. func (am *Manager) AddBackend(backend Backend) { diff --git a/cmd/geth/accountcmd.go b/cmd/geth/accountcmd.go index 51721a54e5..78f6812789 100644 --- a/cmd/geth/accountcmd.go +++ b/cmd/geth/accountcmd.go @@ -193,7 +193,7 @@ nodes. // makeAccountManager creates an account manager with backends func makeAccountManager(ctx *cli.Context) *accounts.Manager { cfg := loadBaseConfig(ctx) - am := accounts.NewManager(&accounts.Config{InsecureUnlockAllowed: cfg.Node.InsecureUnlockAllowed}) + am := accounts.NewManager() keydir, isEphemeral, err := cfg.Node.GetKeyStoreDir() if err != nil { utils.Fatalf("Failed to get the keystore directory: %v", err) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 98898f05be..303007d4d0 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -510,11 +510,6 @@ var ( Value: "", Category: flags.AccountCategory, } - InsecureUnlockAllowedFlag = &cli.BoolFlag{ - Name: "allow-insecure-unlock", - Usage: "Allow insecure account unlocking when account-related RPCs are exposed by http", - Category: flags.AccountCategory, - } // EVM settings VMEnableDebugFlag = &cli.BoolFlag{ Name: "vmdebug", @@ -1361,7 +1356,7 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) { cfg.USB = ctx.Bool(USBFlag.Name) } if ctx.IsSet(InsecureUnlockAllowedFlag.Name) { - cfg.InsecureUnlockAllowed = ctx.Bool(InsecureUnlockAllowedFlag.Name) + log.Warn(fmt.Sprintf("Option %q is deprecated and has no effect", InsecureUnlockAllowedFlag.Name)) } if ctx.IsSet(DBEngineFlag.Name) { dbEngine := ctx.String(DBEngineFlag.Name) diff --git a/cmd/utils/flags_legacy.go b/cmd/utils/flags_legacy.go index 6d454266e8..ff63dd5685 100644 --- a/cmd/utils/flags_legacy.go +++ b/cmd/utils/flags_legacy.go @@ -165,6 +165,11 @@ var ( Value: "", Category: flags.DeprecatedCategory, } + InsecureUnlockAllowedFlag = &cli.BoolFlag{ + Name: "allow-insecure-unlock", + Usage: "Allow insecure account unlocking when account-related RPCs are exposed by http (deprecated)", + Category: flags.DeprecatedCategory, + } ) // showDeprecated displays deprecated flags that will be soon removed from the codebase. diff --git a/internal/ethapi/api_test.go b/internal/ethapi/api_test.go index 758638cb16..e5d0243907 100644 --- a/internal/ethapi/api_test.go +++ b/internal/ethapi/api_test.go @@ -416,7 +416,7 @@ func allBlobTxs(addr common.Address, config *params.ChainConfig) []txData { func newTestAccountManager(t *testing.T) (*accounts.Manager, accounts.Account) { var ( dir = t.TempDir() - am = accounts.NewManager(&accounts.Config{InsecureUnlockAllowed: true}) + am = accounts.NewManager() b = keystore.NewKeyStore(dir, 2, 1) testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") ) diff --git a/node/config.go b/node/config.go index 949db887e4..dc436876cc 100644 --- a/node/config.go +++ b/node/config.go @@ -83,7 +83,7 @@ type Config struct { // scrypt KDF at the expense of security. UseLightweightKDF bool `toml:",omitempty"` - // InsecureUnlockAllowed allows user to unlock accounts in unsafe http environment. + // InsecureUnlockAllowed is a deprecated option to allow users to accounts in unsafe http environment. InsecureUnlockAllowed bool `toml:",omitempty"` // NoUSB disables hardware wallet monitoring and connectivity. diff --git a/node/node.go b/node/node.go index 92c0c35607..fb94475121 100644 --- a/node/node.go +++ b/node/node.go @@ -130,7 +130,7 @@ func New(conf *Config) (*Node, error) { node.keyDirTemp = isEphem // Creates an empty AccountManager with no backends. Callers (e.g. cmd/geth) // are required to add the backends later on. - node.accman = accounts.NewManager(&accounts.Config{InsecureUnlockAllowed: conf.InsecureUnlockAllowed}) + node.accman = accounts.NewManager() // Initialize the p2p server. This creates the node key and discovery databases. node.server.Config.PrivateKey = node.config.NodeKey() diff --git a/signer/core/api.go b/signer/core/api.go index 23ddcd0a20..9280431603 100644 --- a/signer/core/api.go +++ b/signer/core/api.go @@ -186,7 +186,7 @@ func StartClefAccountManager(ksLocation string, nousb, lightKDF bool, scpath str } // Clef doesn't allow insecure http account unlock. - return accounts.NewManager(&accounts.Config{InsecureUnlockAllowed: false}, backends...) + return accounts.NewManager(backends...) } // MetadataFromContext extracts Metadata from a given context.Context