Skip to content

Commit 898ee1c

Browse files
authored
docs: clean changelog, update user guides, write developer guide for update to future release (#945)
1 parent 01cc383 commit 898ee1c

File tree

3 files changed

+107
-24
lines changed

3 files changed

+107
-24
lines changed

changelog.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ prevent unauthorized re-submission of metadata updates. The `sign-block-producer
2424
match this change.
2525
* `partner-chain-cli` (wizards) does not execute `<pc-node> build-spec` but creates the chain-spec.json file directly with a code injected into the command.
2626
* Debug strings generated by `byte-string-derive` crate now fully pad output hex with zeros
27-
* Generic candidates keys:
28-
* * getAriadneParameters and getRegistrations results format has changed, `auraPubKey` and `grandpaPubKey` are replaced by `"keys": {"aura": "...", "gran": "..."}`
29-
* * toolkit user should provide a way of mapping `CandidateKeys` from and into their chain session keys
3027
* `authority-selection-inherents` crate now exports all its public members from the crate root
3128
* `select_authorities` in `authority-selection-inherents` crate now returns a `BoundedVec` of `CommitteeMembers`. Projects that used the old version no longer
3229
need to transform the data in their own runtime code
@@ -35,7 +32,22 @@ need to transform the data in their own runtime code
3532

3633
## Added
3734

38-
* Parsing of V1 datum of Permissioned Candidate
35+
### Generic keys feature
36+
37+
Up to v1.7.x the toolkit has supported only a triplet of keys: Partner-Chain keys, AURA, and Grandpa. Partner Chain key's special meaning and presence is preserved, but the number and types of the remaining keys can be configured according to the needs of a particular Partner Chain.
38+
39+
This enables use of additional pallets that require other keys.
40+
41+
Integration with the `wizards` CLI is done by means of `PartnerChainRuntime` trait implementation. See [Update Guide](docs/developer-guides/sdk-update-v1.7-to-v1.8.0.md) for more details.
42+
43+
On Cardano side the Plutus Data format has been changed from `[Partner-chain, AURA, Grandpa]`, to `[Partner-chain, [[key_1_id, key_1_bytes],...,[key_n_id, key_n_bytes]]]`, where `key_i_id` is 4 bytes encoding key type. This is present in version 1 of datums that are now used in place of version 0.
44+
45+
In SCALE encoding of inherent data custom implementations of `Encode` and `Decode` have been added to make this transition backward and forward compatible and transparent for the toolkit users. This change does not imply any order of nodes and runtime upgrade.
46+
47+
`getAriadneParameters` and `getRegistrations` RPC results format has changed, `auraPubKey` and `grandpaPubKey` are replaced by `"keys": {"aura": "...", "gran": "..."}`.
48+
49+
### Other additions
50+
3951
* `delete_metadata` extrinsic in `pallet-block-producer-metadata`
4052
* Added litep2p networking stack support to pc demo node as default. libp2p can be set with explicitly `--network-backend` parameter.
4153

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Migration from v1.7.1 to v1.8.0
2+
3+
## Generic keys
4+
5+
The biggest change in the Partner Chains Toolkit v1.8.0 is the support of generic session keys.
6+
One implication of having the keys generic and not hardcoded is that the toolkit users have to inject some behavior to the toolkit.
7+
This dependency injection is required by `partner-chains-cli` create (`wizards` subcommand), and it is done by implementing the `PartnerChainRuntime` trait.
8+
Following items have to be defined:
9+
* `type Keys: MaybeFromCandidateKeys` - should be the type of the session keys used in the Runtime. This type is used for the chain-spec creation, to insert initial committee and validators keys into genesis.
10+
* `fn key_definitions() -> Vec<KeyDefinition<'static>>` - should define textual information about `Keys`. This function is used in the user interface and for interactions with the substrate CLI keystore commands.
11+
* `fn create_chain_spec(config: &CreateChainSpecConfig<Self::Keys>) -> serde_json::Value` - should return a JSON object of the chain-spec. This function is used by the `create-chain-spec` subcommand. The toolkit no longer makes assumptions about `build-spec` behavior when no `--chain` parameter is supplied. The toolkit provides functions from `CreateChainSpecConfig` to `GenesisConfig`, for each of the pallets, to be used when implementing `create_chain_spec`.
12+
13+
Changes required:
14+
1. Add `impl authority_selection_inherents::MaybeFromCandidateKeys for SessionKeys {}` for your runtime SessionKeys type
15+
1. `select_authorities` function now requires explicit type annotations, please provide them in your runtime implementation, also remove wrapping of the result into `BoundedVec` - function returns this type now
16+
1. Add dependency on `partner-chains-cli` in the node (final executable) crate
17+
1. Implement `PartnerChainRuntime` for your chain and pass it to the code that wires in partner-chains-commands
18+
1. Remove `impl RuntimeTypeWrapper`
19+
20+
## Export changes in `authority-selection-inherents` crate
21+
22+
* `authority-selection-inherents` crate now exports types from the top level, please adjust `use` clauses.
23+
24+
## `pallet-address-associations` - security fixes
25+
26+
This pallet is now protected against space attacks. Runtime implementation has to be updated.
27+
28+
* Please define cost of association:
29+
```rust
30+
parameter_types! {
31+
/// Amount of tokens to burn when making irreversible, forever association
32+
pub const AddressAssociationBurnAmount: Balance = 1_000_000;
33+
}
34+
```
35+
* Set the cost and currency in the pallet config:
36+
```rust
37+
type Currency = Balances;
38+
type BurnAmount = AddressAssociationBurnAmount;
39+
```
40+
41+
## `block-producer-metadata` - security fixes
42+
43+
The pallet is now protected against space, front running and replay attacks
44+
Required changes are:
45+
* update `type RuntimeHoldReason = RuntimeHoldReason;` in `pallet-balances` config implementations
46+
* define the metadata deposit amount for space attack prevention:
47+
```rust
48+
parameter_types! {
49+
/// Amount of tokens to hold when upserting block producer metadata.
50+
pub const MetadataHoldAmount: Balance = 1_000_000;
51+
}
52+
```
53+
* set the hold amount, currency and possible reason types and the current time getter in the `pallet-block-producer-metadata` implementation config implementation:
54+
```rust
55+
type Currency = Balances;
56+
type HoldAmount = MetadataHoldAmount;
57+
type RuntimeHoldReason = RuntimeHoldReason;
58+
59+
fn current_time() -> u64 {
60+
pallet_timestamp::Now::<Runtime>::get() / 1000
61+
}
62+
```

docs/user-guides/chain-builder.md

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,11 @@ Now the wizard will output `partner-chains-public-keys.json` containing three ke
225225

226226
```javascript
227227
{
228-
"sidechain_pub_key": "0x<key>",
229-
"aura_pub_key": "0x<key>",
230-
"grandpa_pub_key": "0x<key>"
228+
"partner_chains_key": "0x<key>",
229+
"keys": {
230+
"aura": "0x<key>",
231+
"gran": "0x<key>"
232+
}
231233
}
232234
```
233235

@@ -265,14 +267,17 @@ Example:
265267
```
266268
"initial_permissioned_candidates": [
267269
{
268-
"aura_pub_key": "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d",
269-
"grandpa_pub_key": "0x88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee",
270-
"sidechain_pub_key": "0x020a1091341fe5664bfa1782d5e04779689068c916b04cb365ec3153755684d9a1"
270+
"partner_chains_key": "0x020a1091341fe5664bfa1782d5e04779689068c916b04cb365ec3153755684d9a1",
271+
"keys": {
272+
"aura": "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d",
273+
"gran": "0x88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee"
271274
},
272275
{
273-
"aura_pub_key": "0x8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48",
274-
"grandpa_pub_key": "0xd17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae69",
275-
"sidechain_pub_key": "0x0390084fdbf27d2b79d26a4f13f0ccd982cb755a661969143c37cbc49ef5b91f27"
276+
"partner_chains_key": "0x0390084fdbf27d2b79d26a4f13f0ccd982cb755a661969143c37cbc49ef5b91f27",
277+
"keys": {
278+
"aura": "0x8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48",
279+
"gran": "0xd17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae69"
280+
}
276281
}
277282
],
278283
```
@@ -320,17 +325,21 @@ A sample file:
320325
"genesis_utxo": "0000000000000000000000000000000000000000000000000000000000000000#0",
321326
},
322327
"initial_permissioned_candidates": [
323-
{
324-
"aura_pub_key": "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d",
325-
"grandpa_pub_key": "0x88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee",
326-
"sidechain_pub_key": "0x020a1091341fe5664bfa1782d5e04779689068c916b04cb365ec3153755684d9a1"
327-
},
328-
{
329-
"aura_pub_key": "0x8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48",
330-
"grandpa_pub_key": "0xd17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae69",
331-
"sidechain_pub_key": "0x0390084fdbf27d2b79d26a4f13f0ccd982cb755a661969143c37cbc49ef5b91f27"
332-
}
333-
],
328+
{
329+
"partner_chains_key": "0x020a1091341fe5664bfa1782d5e04779689068c916b04cb365ec3153755684d9a1",
330+
"keys": {
331+
"aura": "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d",
332+
"gran": "0x88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee"
333+
}
334+
},
335+
{
336+
"partner_chains_key": "0x0390084fdbf27d2b79d26a4f13f0ccd982cb755a661969143c37cbc49ef5b91f27",
337+
"keys": {
338+
"aura": "0x8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48",
339+
"gran": "0xd17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae69"
340+
}
341+
}
342+
]
334343
}
335344
```
336345

0 commit comments

Comments
 (0)