-
Notifications
You must be signed in to change notification settings - Fork 44
BEEFY session keys and worker #2084
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
base: main
Are you sure you want to change the base?
Changes from all commits
f52db46
55fced3
31e1d09
8e360d4
9596e72
1adb3eb
37247bd
09e6998
8d89cd9
c851135
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -288,6 +288,7 @@ Chain specifications are located in `/res/` directory. | |
| | AURA seed | `AURA_SEED_FILE=/path/to/seed` | - | Path to AURA consensus seed file | | ||
| | GRANDPA seed | `GRANDPA_SEED_FILE=/path/to/seed` | - | Path to GRANDPA finality seed file | | ||
| | Cross-chain seed | `CROSS_CHAIN_SEED_FILE=/path/to/seed` | - | Path to cross-chain seed file | | ||
| | BEEFY seed | `BEEFY_SEED_FILE=/path/to/seed` | - | Path to BEEFY seed file (ECDSA, like cross-chain) | | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The single-node example immediately below this new option still supplies only AURA, GRANDPA, and cross-chain seeds and does not use AGENTS.md reference: AGENTS.md:L69-L69 Useful? React with 👍 / 👎. |
||
| | Chain spec | `CHAIN=dev` | `--chain dev` | Network to connect to | | ||
| | Base path | `BASE_PATH=/tmp/node-1` | `--base-path /tmp/node-1` | Data directory | | ||
| | Validator mode | `VALIDATOR=true` | `--validator` | Run as validator (true/1/TRUE) | | ||
|
|
@@ -312,35 +313,35 @@ CFG_PRESET=dev AURA_SEED_FILE=/tmp/alice-seed GRANDPA_SEED_FILE=/tmp/alice-seed | |
|
|
||
| ```shell | ||
| echo "//Alice" > /tmp/alice-seed && echo "0000000000000000000000000000000000000000000000000000000000000001" > /tmp/alice-key && \ | ||
| CFG_PRESET=dev AURA_SEED_FILE=/tmp/alice-seed GRANDPA_SEED_FILE=/tmp/alice-seed CROSS_CHAIN_SEED_FILE=/tmp/alice-seed \ | ||
| CFG_PRESET=dev AURA_SEED_FILE=/tmp/alice-seed GRANDPA_SEED_FILE=/tmp/alice-seed CROSS_CHAIN_SEED_FILE=/tmp/alice-seed BEEFY_SEED_FILE=/tmp/alice-seed \ | ||
| NODE_KEY_FILE=/tmp/alice-key BASE_PATH=/tmp/node-1 CHAIN=dev VALIDATOR=true ./target/release/midnight-node --port 30333 | ||
|
|
||
| echo "//Bob" > /tmp/bob-seed && echo "0000000000000000000000000000000000000000000000000000000000000002" > /tmp/bob-key && \ | ||
| CFG_PRESET=dev AURA_SEED_FILE=/tmp/bob-seed GRANDPA_SEED_FILE=/tmp/bob-seed CROSS_CHAIN_SEED_FILE=/tmp/bob-seed \ | ||
| CFG_PRESET=dev AURA_SEED_FILE=/tmp/bob-seed GRANDPA_SEED_FILE=/tmp/bob-seed CROSS_CHAIN_SEED_FILE=/tmp/bob-seed BEEFY_SEED_FILE=/tmp/bob-seed \ | ||
| NODE_KEY_FILE=/tmp/bob-key BASE_PATH=/tmp/node-2 CHAIN=dev VALIDATOR=true \ | ||
| BOOTNODES="/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp" \ | ||
| ./target/release/midnight-node --port 30334 | ||
|
|
||
| echo "//Charlie" > /tmp/charlie-seed && echo "0000000000000000000000000000000000000000000000000000000000000003" > /tmp/charlie-key && \ | ||
| CFG_PRESET=dev AURA_SEED_FILE=/tmp/charlie-seed GRANDPA_SEED_FILE=/tmp/charlie-seed CROSS_CHAIN_SEED_FILE=/tmp/charlie-seed \ | ||
| CFG_PRESET=dev AURA_SEED_FILE=/tmp/charlie-seed GRANDPA_SEED_FILE=/tmp/charlie-seed CROSS_CHAIN_SEED_FILE=/tmp/charlie-seed BEEFY_SEED_FILE=/tmp/charlie-seed \ | ||
| NODE_KEY_FILE=/tmp/charlie-key BASE_PATH=/tmp/node-3 CHAIN=dev VALIDATOR=true \ | ||
| BOOTNODES="/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp" \ | ||
| ./target/release/midnight-node --port 30335 | ||
|
|
||
| echo "//Dave" > /tmp/dave-seed && echo "0000000000000000000000000000000000000000000000000000000000000004" > /tmp/dave-key && \ | ||
| CFG_PRESET=dev AURA_SEED_FILE=/tmp/dave-seed GRANDPA_SEED_FILE=/tmp/dave-seed CROSS_CHAIN_SEED_FILE=/tmp/dave-seed \ | ||
| CFG_PRESET=dev AURA_SEED_FILE=/tmp/dave-seed GRANDPA_SEED_FILE=/tmp/dave-seed CROSS_CHAIN_SEED_FILE=/tmp/dave-seed BEEFY_SEED_FILE=/tmp/dave-seed \ | ||
| NODE_KEY_FILE=/tmp/dave-key BASE_PATH=/tmp/node-4 CHAIN=dev VALIDATOR=true \ | ||
| BOOTNODES="/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp" \ | ||
| ./target/release/midnight-node --port 30336 | ||
|
|
||
| echo "//Eve" > /tmp/eve-seed && echo "0000000000000000000000000000000000000000000000000000000000000005" > /tmp/eve-key && \ | ||
| CFG_PRESET=dev AURA_SEED_FILE=/tmp/eve-seed GRANDPA_SEED_FILE=/tmp/eve-seed CROSS_CHAIN_SEED_FILE=/tmp/eve-seed \ | ||
| CFG_PRESET=dev AURA_SEED_FILE=/tmp/eve-seed GRANDPA_SEED_FILE=/tmp/eve-seed CROSS_CHAIN_SEED_FILE=/tmp/eve-seed BEEFY_SEED_FILE=/tmp/eve-seed \ | ||
| NODE_KEY_FILE=/tmp/eve-key BASE_PATH=/tmp/node-5 CHAIN=dev VALIDATOR=true \ | ||
| BOOTNODES="/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp" \ | ||
| ./target/release/midnight-node --port 30337 | ||
|
|
||
| echo "//Ferdie" > /tmp/ferdie-seed && echo "0000000000000000000000000000000000000000000000000000000000000006" > /tmp/ferdie-key && \ | ||
| CFG_PRESET=dev AURA_SEED_FILE=/tmp/ferdie-seed GRANDPA_SEED_FILE=/tmp/ferdie-seed CROSS_CHAIN_SEED_FILE=/tmp/ferdie-seed \ | ||
| CFG_PRESET=dev AURA_SEED_FILE=/tmp/ferdie-seed GRANDPA_SEED_FILE=/tmp/ferdie-seed CROSS_CHAIN_SEED_FILE=/tmp/ferdie-seed BEEFY_SEED_FILE=/tmp/ferdie-seed \ | ||
| NODE_KEY_FILE=/tmp/ferdie-key BASE_PATH=/tmp/node-6 CHAIN=dev VALIDATOR=true \ | ||
| BOOTNODES="/ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp" \ | ||
| ./target/release/midnight-node --port 30338 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #node #keystore #beefy | ||
|
|
||
| # Provide BEEFY keys via seed file, and add them to the local-env validators | ||
|
|
||
| Added `BEEFY_SEED_FILE`, alongside the existing `AURA_SEED_FILE`, | ||
| `BABE_SEED_FILE`, `GRANDPA_SEED_FILE` and `CROSS_CHAIN_SEED_FILE`. The seed is | ||
| inserted into the keystore under the `beef` key type as ECDSA, like the | ||
| cross-chain key. | ||
|
|
||
| Validators need a BEEFY key in their keystore once beefy is part of | ||
| `SessionKeys`; the key is looked up by `(key type, public key)`, so a key | ||
| inserted only under another key type does not satisfy a BEEFY request even when | ||
| the bytes are identical. | ||
|
|
||
| The local-env validators (nodes 2 to 5) now carry one. The committee registers | ||
| each validator's cross-chain key as its beefy key — `beefy_pub_key` equals | ||
| `sidechain_pub_key` in `res/local/permissioned-candidates-config.json` — so the | ||
| existing cross-chain key material is reused rather than new keys generated: | ||
| keystore entries for the keystore-mounted nodes, and `seeds/beefy.seed` plus | ||
| `BEEFY_SEED_FILE` for the seed-file node. | ||
|
|
||
| PR: https://github.com/midnightntwrk/midnight-node/pull/2084 | ||
| Issue: https://github.com/midnightntwrk/midnight-node/issues/1742 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #node #genesis #beefy | ||
|
|
||
| # Let session seed the BEEFY genesis authorities | ||
|
|
||
| Building genesis panicked once beefy became a session key: | ||
|
|
||
| ``` | ||
| GenesisBuilder_build_state -> pallet_session::GenesisConfig::build | ||
| -> <(_, _, _) as SessionHandler>::on_genesis_session -> unwrap_failed | ||
| ``` | ||
|
|
||
| `pallet_beefy` (pallet index 21) initialized its authorities from the chain | ||
| spec's `BeefyConfig::authorities`, and then `pallet_session` (index 30) | ||
| initialized them a second time via the now three-element `SessionHandler`. | ||
| `pallet_beefy::initialize` returns `Err` when the authority list is already | ||
| populated, and `on_genesis_session` turns that into | ||
| `.expect("Authorities vec too big")` — a misleading message, since nothing is | ||
| too big. | ||
|
|
||
| The chain spec now leaves `beefy: Default::default()` (empty authorities, | ||
| `genesis_block: Some(1)`), matching `aura`, `babe` and `grandpa` beside it, and | ||
| lets `pallet_session` seed the BEEFY authorities from the committee's session | ||
| keys. Note this changes genesis storage, and therefore the genesis hash, so it | ||
| applies to chains created from this version onward. | ||
|
|
||
| PR: https://github.com/midnightntwrk/midnight-node/pull/2084 | ||
| Issue: https://github.com/midnightntwrk/midnight-node/issues/1742 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #node #committee-selection #beefy | ||
|
|
||
| # Decode the committee by pallet storage version in the membership watcher | ||
|
|
||
| The committee-membership watcher called the `get_current_committee` runtime | ||
| API, which decodes committee members with the node binary's own `SessionKeys`. | ||
| Between updating the nodes and running the runtime upgrade, that meant decoding | ||
| pre-beefy (aura + grandpa) committee bytes as the three-key shape: the decode | ||
| falls short and yields the empty default, so the watcher logged every validator | ||
| as not being in a zero-size committee. | ||
|
|
||
| It now reads `CurrentCommittee` and `pallet-session-validator-management`'s | ||
| on-chain storage version straight from state and lets the runtime pick the | ||
| matching shape (`committee_keys_migrated` / `decode_current_committee`), | ||
| upgrading legacy-shaped members on the fly. Storage version `>= 2` means the | ||
| committee carries beefy keys; absent or lower means it does not. | ||
|
|
||
| PR: https://github.com/midnightntwrk/midnight-node/pull/2084 | ||
| Issue: https://github.com/midnightntwrk/midnight-node/issues/1742 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #runtime #session-keys #beefy | ||
|
|
||
| # Add the BEEFY session key | ||
|
|
||
| `opaque::SessionKeys` gains `beefy`, translated by the | ||
| `AddBeefyToSessionKeysMigration` cutover, which gives each validator its own | ||
| cross-chain key as its beefy key. Both are ECDSA and the committee registers | ||
| them as equal (`beefy_pub_key == sidechain_pub_key`), so the migrated | ||
| authority set is one the validators actually hold secrets for — a derived | ||
| placeholder would leave BEEFY unable to reach a quorum until the next | ||
| committee rotation. | ||
|
|
||
| Because BEEFY is now a session key, `pallet_session`'s genesis initializes | ||
| the BEEFY authorities from the committee, so the chain spec no longer sets | ||
| `BeefyConfig::authorities` itself — see the separate genesis change. | ||
|
|
||
| The runtime version moves to `002_001_001`. | ||
|
|
||
| PR: https://github.com/midnightntwrk/midnight-node/pull/2084 | ||
| Issue: https://github.com/midnightntwrk/midnight-node/issues/1742 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #runtime #migration #committee-selection | ||
|
|
||
| # Combine committee v1-to-v2 and session-key migrations in the runtime | ||
|
|
||
| This chain moves `pallet-session-validator-management` from v1 to v2 in a single | ||
| upgrade, which spans two changes the toolkit ships as separate migrations: the | ||
| `AuthorityKeys` shape change (`migrations::authority_keys`) and v2's new | ||
| `QueuedCommittee` (`migrations::v2`). They cannot be wired one after the other, | ||
| so a custom migration that combines both is added. | ||
|
|
||
| PR: https://github.com/midnightntwrk/midnight-node/pull/2084 | ||
| Issue: https://github.com/midnightntwrk/midnight-node/issues/1742 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| "//Bob" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 0xf8d74108dbe199c4a6e4ef457046db37c325ba3f709b14cabfa1885663e4c589 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| "volume wire damp response scene tape truck easily enjoy shaft face message" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| "victory horse scatter empty silly live royal differ friend nurse poverty benefit" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -417,6 +417,7 @@ services: | |
| AURA_SEED_FILE: "/seeds/aura.seed" | ||
| CROSS_CHAIN_SEED_FILE: "/seeds/cross_chain.seed" | ||
| GRANDPA_SEED_FILE: "/seeds/grandpa.seed" | ||
| BEEFY_SEED_FILE: "/seeds/beefy.seed" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This provisions the checked-in local environment, but the from-genesis and fork/mock paths generate validator overrides through AGENTS.md reference: AGENTS.md:L69-L69 Useful? React with 👍 / 👎. |
||
| entrypoint: ["/bin/bash", "/entrypoint.sh"] | ||
| labels: | ||
| io.midnight.role: validator | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.