Skip to content

Node logs "creating a new Ethereum account" even when -ethKeystorePath/-ethAcctAddr are valid #3858

@eliteprox

Description

@eliteprox

Describe the bug
When starting a Livepeer node with an existing Ethereum account via -ethKeystorePath and/or -ethAcctAddr flags, the node incorrectly logs "No Ethereum account found. Creating a new account" messages, even though an account is explicitly provided. The node proceeds to use the provided account but the misleading logs suggest account creation is happening when it shouldn't be.

To Reproduce
Steps to reproduce the behavior:

  1. Configure a node launch with existing account flags (example from .vscode/launch.json):
    • -ethAcctAddr 0x0074780FefF1FD0277FAD6ccdb5a29908df6051F
    • Optionally: -ethKeystorePath /path/to/keystore
  2. Start the Livepeer node
  3. Observe the startup logs
  4. See erroneous "Creating a new account" messages followed by the node using the provided account

Expected behavior

  • The node should parse and validate ethKeystorePath and ethAcctAddr before emitting any account creation logs
  • When either ethAcctAddr or ethKeystorePath is provided, the node should not log account creation messages
  • If a specified account/keystore cannot be found, the node should fail immediately with a clear error rather than attempting to create a new account
  • Keystore path resolution should be standardized so that provided keystores are always respected and defaults don't trigger unexpected behavior

Screenshots
Example startup logs showing the issue:

I0120 16:53:29.578794   28725 accountmanager.go:51] No Ethereum account found. Creating a new account
I0120 16:53:29.578854   28725 accountmanager.go:52] This process will create a new Ethereum account for this Livepeer node
I0120 16:53:31.690998   28725 accountmanager.go:80] Using Ethereum account: 0xb91853dEF334E5fA78da1ED4e7f36D7BDe7DAf51
I0120 16:53:32.747881   28725 accountmanager.go:114] Unlocked ETH account: 0xb91853dEF334E5fA78da1ED4e7f36D7BDe7DAf51

Desktop (please complete the following information):

  • OS: Linux (WSL2)
  • Version: go-livepeer (development/master branch)

Additional context

Root Cause Analysis:
The issue occurs because account creation logs are emitted inside eth/accountmanager.go:NewAccountManager() at lines 51-52 when len(keyStore.Accounts()) == 0 or the provided address isn't found. However, keystore path and account address parsing happens earlier in cmd/livepeer/starter/starter.go at lines 792-809. This ordering mismatch causes:

  1. The keystore directory defaults to filepath.Join(*cfg.Datadir, "keystore")
  2. If this default location is empty or doesn't contain the specified account, the creation logs trigger
  3. Later validation logic may then find or use the account from the correct location

Code References:

  • Creation logs: eth/accountmanager.go lines 50-53
  • Keystore path parsing: cmd/livepeer/starter/starter.go lines 792-809
  • Path parser function: cmd/livepeer/starter/starter.go lines 2314-2340

Proposed Fix:

  1. Move keystore/account parsing and validation to occur before NewAccountManager is called
  2. Add explicit checks: if -ethAcctAddr or -ethKeystorePath is provided, require the keystore to exist and the address to be found; exit with clear error otherwise
  3. Standardize keystore path resolution between dataDir defaults and explicit -ethKeystorePath to eliminate silent fallbacks
  4. Update NewAccountManager to accept a flag indicating whether account creation is allowed based on whether explicit account flags were provided

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: triagethis issue has not been evaluated yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions