Skip to content

Commit

Permalink
Load local key if MiningConfig.Enabled is true (#7267)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukaszRozmej authored Jul 17, 2024
1 parent 0315f4a commit aad6777
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Consensus/IMiningConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ public interface IMiningConfig : IConfig
Description = "Url for an external signer like clef: https://github.com/ethereum/go-ethereum/blob/master/cmd/clef/tutorial.md",
HiddenFromDocs = false,
DefaultValue = "null")]
string Signer { get; set; }
string? Signer { get; set; }
}
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.Consensus/MiningConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ public IBlocksConfig? BlocksConfig
}
}

public string Signer { get; set; }
public string? Signer { get; set; }
}
10 changes: 6 additions & 4 deletions src/Nethermind/Nethermind.Init/Steps/SetupKeyStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ await Task.Run(() =>

set.Wallet = get.Config<IInitConfig>() switch
{
var config when config.EnableUnsecuredDevWallet && config.KeepDevWalletInMemory => new DevWallet(get.Config<IWalletConfig>(), get.LogManager),
var config when config.EnableUnsecuredDevWallet && !config.KeepDevWalletInMemory => new DevKeyStoreWallet(get.KeyStore, get.LogManager),
{ EnableUnsecuredDevWallet: true, KeepDevWalletInMemory: true } => new DevWallet(get.Config<IWalletConfig>(), get.LogManager),
{ EnableUnsecuredDevWallet: true, KeepDevWalletInMemory: false } => new DevKeyStoreWallet(get.KeyStore, get.LogManager),
_ => new ProtectedKeyStoreWallet(keyStore, new ProtectedPrivateKeyFactory(get.CryptoRandom, get.Timestamper, keyStoreConfig.KeyStoreDirectory),
get.Timestamper, get.LogManager),
};
Expand All @@ -62,9 +62,11 @@ await Task.Run(() =>
ProtectedPrivateKey? nodeKey = set.NodeKey = nodeKeyManager.LoadNodeKey();

IMiningConfig miningConfig = get.Config<IMiningConfig>();
//Don't load the local key if an external signer is configured
if (!miningConfig.Enabled && string.IsNullOrEmpty(miningConfig.Signer))
//Don't load the local key if an external signer is configured
if (string.IsNullOrEmpty(miningConfig.Signer))
{
set.OriginalSignerKey = nodeKeyManager.LoadSignerKey();
}

IPAddress ipAddress = networkConfig.ExternalIp is not null ? IPAddress.Parse(networkConfig.ExternalIp) : IPAddress.Loopback;
IEnode enode = set.Enode = new Enode(nodeKey.PublicKey, ipAddress, networkConfig.P2PPort);
Expand Down

0 comments on commit aad6777

Please sign in to comment.