substrate-docs
substrate-docs copied to clipboard
Trouble adding NodeAuthorization to genesis config
Is there an existing issue?
- [X] I have searched the existing issues
Experiencing problems? Have you tried our Stack Exchange first?
- [X] This is not a support question.
Bug report for compiling, code snippets, templates, etc.
Hello, I am going through the Build a Blockchain -> Authorize specific nodes tutorial and am having some issues with two steps.
Step 4 - Adding the NodeAuthorization to the construct_runtime!
macro. This macro does not seem to be used anymore, instead I added it to the mod runtime
as follows:
mod runtime {
//...existing code
//...
#[runtime::pallet_index(9)]
pub type NodeAuthorization = pallet_node_authorization;
}
The cargo check
command works after adding it this way, so it seems to be fine; however, making this more clear in the tutorial steps would be very helpful, especially for folks (like myself) who are new to Rust and Substrate 🙏 🙏
The bigger issue I am experiencing is under Add genesis storage for authorized nodes
step 6 & 7 where we need to add NodeAuthorization
to the testnet_genesis
function in node/src/chain_spec.rs
. The body of the function in the current codebase is different than what's in the tutorial. instead of adding to the GenesisConfig
struct, it's returning a JSON object by using serde_json::json!
. tried adding a JSON object with key nodeAuthorization
with a few different schemas, but cannot get the node to run. for example:
"nodeAuthorization": [
{
"opaquePeerId": bs58::decode("12D3KooWBmAwcd4PJNJvfV89HwE48nwkRmAgo8Vy3uQEyNNHBox2").into_vec().unwrap(),
"accountId": endowed_accounts[0].clone(),
},
{
"opaquePeerId": bs58::decode("12D3KooWQYV9dGMFoRzNStwpXztXaBUjtPqi6aU76ZgUriHhKust").into_vec().unwrap(),
"accountId": endowed_accounts[1].clone(),
}
],
however I am getting an error when starting the node - Invalid JSON blob: invalid type: map, expected a sequence at line 1 column 1189
any guidance on what the expected JSON structure is here would be greatly appreciated!
Steps to reproduce the problem
No response