Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load local key if MiningConfig.Enabled is true #7267

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main change here

{
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