我试图理解将开发密钥添加到基板中的本地密钥库中用于开发目的的内部逻辑。例如,我可以看到,正在生成Alice的session keys并将其添加到/bin/node/cli/src/chain_spec.rs文件中的成因配置中,如下所示:
pub fn development_config() -> Result<ChainSpec, String> {
let wasm_binary =
WASM_BINARY.ok_or_else(|| "Development wasm binary not available".to_string())?;
Ok(ChainSpec::from_genesis(
// Name
"Development",
// ID
"dev",
ChainType::Development,
move || {
testnet_genesis(
wasm_binary,
// Initial PoA authorities
vec![authority_keys_from_seed("Alice")],
// Sudo account
get_account_id_from_seed::<sr25519::Public>("Alice"),
// Pre-funded accounts
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
],
true,
)
},
// Bootnodes
vec![],
// Telemetry
None,
// Protocol ID
None,
// Properties
None,
// Extensions
None,
))
}据我理解,session keys用于开发还包括ImOnlineId。我的问题是如何将密钥添加到本地密钥存储库中,以便能够访问im-online托盘中的密钥:
fn local_authority_keys() -> impl Iterator<Item=(u32, T::AuthorityId)> {
// on-chain storage
//
// At index `idx`:
// 1. A (ImOnline) public key to be used by a validator at index `idx` to send im-online
// heartbeats.
let authorities = Keys::<T>::get();
// local keystore
//
// All `ImOnline` public (+private) keys currently in the local keystore.
let mut local_keys = T::AuthorityId::all();
local_keys.sort();
authorities.into_iter()
.enumerate()
.filter_map(move |(index, authority)| {
local_keys.binary_search(&authority)
.ok()
.map(|location| (index as u32, local_keys[location].clone()))
})
}在调试过程中,我可以在local_keys中找到爱丽丝的公钥。询问是因为我想开发一些类似的东西,这样在开发中进行测试就更容易了,而不是手动地将密钥放入keystore。
发布于 2021-09-10 06:06:44
Config/Config<T>配置。例如,https://github.com/paritytech/substrate/blob/master/bin/node/runtime/src/lib.rs#L1229chain_spec。例如https://github.com/paritytech/substrate/blob/master/bin/node/cli/src/chain_spec.rs#L349注意:但是在这个例子中,这些键是由托盘会话管理的。https://github.com/paritytech/substrate/blob/master/bin/node/cli/src/chain_spec.rs#L307-L316。
https://stackoverflow.com/questions/69127883
复制相似问题