berachain / beacon-kit

A modular framework for building EVM consensus clients ⛵️✨
https://berachain.com
Other
162 stars 120 forks source link

beacond doesn't honor `config.toml:priv_validator_key_file` path for signing blocks #1513

Closed jmo-staked closed 4 months ago

jmo-staked commented 4 months ago

problem: our validator node would start up with the correct identity, report in the logs it was a validator, but upon trying to submit a block for validation we get the error:

2024-06-17T18:37:27.856345127Z stdout F {"level":"error","module":"server","module":"baseapp","height":403750,"time":"2024-06-17T18:37:26Z","err":"expected signature length 96, got 64: signer returned an invalid signature","time":"2024-06-17T18:37:27Z","message":"failed to prepare proposal"}

Issues

1) the function ProvideBlsSigner has a hardcoded path to look for your private key at homeDir+"/config/priv_validator_key.json", overriding the value of config.toml:priv_validator_key_file

@po-bera actually flagged this as a problem on the initial PR review:

2) In the block signing code the functionNewBLSSigner uses the method privval.LoadOrGenFilePV(keyFilePath, stateFilePath). And since keyFilePath from issue 1 selects what can be a non-existant, hardcoded path, the method .LoadOrGenFilePV silently creates a new private key at homeDir+"/config/priv_validator_key.json and attempts to sign blocks with that second private key. This conflicts with the validator identity beacond is setting via config.toml:priv_validator_key_file

Silently creating a second pair of private keys instead of just erroring out if no keys are found also seems like a somewhat dangerous choice for validator operation

Workaround

For anyone hitting this issue our ugly workaround is to run this command before node startup:

cp -a <config.toml:priv_validator_key_file> ${BEACOND_HOME}/config/priv_validator_key.json
linear[bot] commented 4 months ago

BERA-136 beacond doesn't honor `config.toml:priv_validator_key_file` path for signing blocks

archbear commented 4 months ago

closed by #1526