Skip to content

Commit b10fb49

Browse files
authored
More cleanup and TODOs for runtime (#49)
* WIP * Removed export-genesis-state / export-genesis-wasm * Update more TODOs * Update more TODOs * More TODOs to check
1 parent f376523 commit b10fb49

File tree

5 files changed

+66
-49
lines changed

5 files changed

+66
-49
lines changed

README.md

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Polkadot Bulletin chain
1+
# Polkadot Bulletin chain
22

33
The Bulletin chain consists of a customized node implementation and a single runtime.
44

@@ -29,7 +29,6 @@ The core functionality of the bulletin chain is in the transaction-storage palle
2929

3030
Data is added via the `transactionStorage.store` extrinsic, provided the storage of the data is authorized by root call. Authorization is granted either for a specific account via authorize_account or for data with a specific preimage via authorize_preimage. Once data is stored, it can be retrieved from IPFS with the Blake2B hash of the data.
3131

32-
3332
#### Bridge to PeopleChain
3433
For Rococo, we have a PeopleRococo → BridgeHubRococo → Bulletin connection.
3534

@@ -49,40 +48,14 @@ Controls the validator set. Currently set in genesis and validators can be added
4948
#### polkadot-bulletin-chain/pallets/transaction-storage
5049
Stores arbitrary data on IPFS via the `store` extrinsic, provided that either the signer or the preimage of the data are pre-authorized. Stored data can be retrieved from IPFS or directly from the node via the transaction index or hash.
5150

52-
## Polkadot Bulletin production/live runtime
53-
54-
### Initial genesis chain spec
55-
56-
[bulletin-polkadot-genesis.json](./node/chain-specs/bulletin-polkadot.json)
57-
58-
```
59-
cargo build --release -p polkadot-bulletin-chain
60-
61-
./target/release/polkadot-bulletin-chain build-spec --chain bulletin-polkadot
62-
or
63-
./target/release/polkadot-bulletin-chain build-spec --chain bulletin-polkadot --raw
64-
```
51+
# Polkadot Bulletin production/live runtime
6552

66-
### Run local chain
67-
```
68-
cargo build --release -p polkadot-bulletin-chain
69-
70-
POLKADOT_BULLETIN_BINARY_PATH=./target/release/polkadot-bulletin-chain zombienet -p native spawn ./zombienet/bulletin-polkadot-local.toml
71-
```
72-
73-
### Run a production chain (but only with Alice validator)
74-
You can override the Alice validator keys here: [adjust\_bp\_spec.sh](./zombienet/adjust_bp_spec.sh) (you should see finalized blocks in the logs).
75-
76-
```
77-
cargo build --release -p polkadot-bulletin-chain
78-
79-
POLKADOT_BULLETIN_BINARY_PATH=./target/release/polkadot-bulletin-chain ENV_PATH=<path-to-zombienet-dir-in-bulletin-repo> zombienet -p native spawn ./zombienet/bulletin-polkadot.toml
80-
```
81-
82-
### Run a production chain
53+
## Prepare for a production
8354

8455
### Prepare keys for a production chain
8556

57+
This chapter provides a one-time example setup. For more details about running a validator and key management, see: [https://docs.polkadot.com/infrastructure/running-a-validator/#running-a-validator.”](https://docs.polkadot.com/infrastructure/running-a-validator/#running-a-validator.”).
58+
8659
**Prerequisites:**
8760
```
8861
# Build the node
@@ -92,7 +65,7 @@ cargo build --release -p polkadot-bulletin-chain
9265
mkdir /tmp/bulletin
9366
```
9467

95-
**Generate a validator account**
68+
#### Generate a validator account
9669
```
9770
./target/release/polkadot-bulletin-chain key generate --scheme sr25519 --output-type json
9871
{
@@ -106,7 +79,7 @@ mkdir /tmp/bulletin
10679
}
10780
```
10881

109-
**Generate node-key (used for networking and peerId)**
82+
#### Generate node-key (used for networking and peerId)
11083
```
11184
./target/release/polkadot-bulletin-chain key generate-node-key --chain bulletin-polkadot --base-path /tmp/bulletin
11285
(example output)
@@ -118,7 +91,7 @@ Generating key in "/tmp/bulletin/chains/bulletin-polkadot/network/secret_ed25519
11891
(should print the same public key as above)
11992
```
12093

121-
**Generate initial session keys for genesis chain spec**
94+
#### Generate initial session keys for genesis chain spec
12295
```
12396
# Babe (suri is `secretSeed`)
12497
./target/release/polkadot-bulletin-chain key insert --chain bulletin-polkadot --base-path /tmp/bulletin --scheme sr25519 --key-type babe --suri 0x749a0904471df8d128b49dfeedf4081af0846b839c6eb69c536cf500e3886646
@@ -174,7 +147,10 @@ Secret Key URI `0x749a0904471df8d128b49dfeedf4081af0846b839c6eb69c536cf500e38866
174147
SS58 Address: 5H5jr87N42Bpt36LKZxZcWS7P1ppgH5Yyf31C4LGb6PFFz9w
175148
```
176149

177-
**Update genesis chain spec script**
150+
#### Update genesis chain spec script
151+
152+
_Note: This is relevant only for the initial launch; after that, we expect Polkadot OpenGov to manage the validator set._
153+
178154
* File `./scripts/create_bulletin_polkadot_spec.sh`
179155
* Update `.genesis.runtimeGenesis.patch.validatorSet.initialValidators` with a validator account public key (example above: `5DWpUqkKHHCaRHVqgocGMnJhuvNtCfm7xvqtSd23Mu6kEVQ9`)
180156
* Update `genesis.runtimeGenesis.patch.session.keys` (and new element)
@@ -199,7 +175,43 @@ Secret Key URI `0x749a0904471df8d128b49dfeedf4081af0846b839c6eb69c536cf500e38866
199175
* **You should see finalized blocks in the logs.**
200176
* **!!! Push changes `./scripts/create_bulletin_polkadot_spec.sh` !!!**
201177

202-
### Fresh benchmarks
178+
## Run node
179+
180+
### Run production chain
181+
```
182+
# You can omit `--validator` if you are not part of the active validator set.
183+
./target/release/polkadot-bulletin-chain --validator --chain bulletin-polkadot <other-relevant-params: ./target/release/polkadot-bulletin-chain --help>
184+
```
185+
186+
### Run local chain
187+
```
188+
cargo build --release -p polkadot-bulletin-chain
189+
190+
POLKADOT_BULLETIN_BINARY_PATH=./target/release/polkadot-bulletin-chain zombienet -p native spawn ./zombienet/bulletin-polkadot-local.toml
191+
```
192+
193+
### Run a production chain (but only with Alice validator)
194+
You can override the Alice validator keys here: [adjust\_bp\_spec.sh](./zombienet/adjust_bp_spec.sh) (you should see finalized blocks in the logs).
195+
196+
```
197+
cargo build --release -p polkadot-bulletin-chain
198+
199+
POLKADOT_BULLETIN_BINARY_PATH=./target/release/polkadot-bulletin-chain ENV_PATH=<path-to-zombienet-dir-in-bulletin-repo> zombienet -p native spawn ./zombienet/bulletin-polkadot.toml
200+
```
201+
202+
## Initial genesis chain spec
203+
204+
[bulletin-polkadot-genesis.json](./node/chain-specs/bulletin-polkadot.json)
205+
206+
```
207+
cargo build --release -p polkadot-bulletin-chain
208+
209+
./target/release/polkadot-bulletin-chain build-spec --chain bulletin-polkadot
210+
or
211+
./target/release/polkadot-bulletin-chain build-spec --chain bulletin-polkadot --raw
212+
```
213+
214+
## Fresh benchmarks
203215

204216
Run on the dedicated machine from the root directory:
205217
```

node/src/command.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ impl SubstrateCli for Cli {
4646

4747
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
4848
Ok(match id {
49+
// TODO: put behind feature and remove dependencies
4950
"dev" | "rococo-dev" => Box::new(chain_spec::rococo_development_config()?),
5051
"local" | "rococo-local" => Box::new(chain_spec::rococo_local_testnet_config()?),
5152
"polkadot-dev" | "bulletin-polkadot-dev" => Box::new(chain_spec::bulletin_polkadot_development_config()?),

runtimes/bulletin-polkadot/src/polkadot_bridge_config.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl pallet_bridge_parachains::Config<WithPolkadotBridgeParachainsInstance> for
206206

207207
const LOG_TARGET_BRIDGE_DISPATCH: &str = "runtime::bridge-dispatch";
208208

209-
/// Message dispatch result type for single message.
209+
/// Message dispatch result type for a single message.
210210
#[derive(
211211
CloneNoBound,
212212
EqNoBound,
@@ -218,11 +218,11 @@ const LOG_TARGET_BRIDGE_DISPATCH: &str = "runtime::bridge-dispatch";
218218
TypeInfo,
219219
)]
220220
pub enum XcmBlobMessageDispatchResult {
221-
/// We've been unable to decode message payload.
221+
/// We've been unable to decode the message payload.
222222
InvalidPayload,
223223
/// Message has been dispatched.
224224
Dispatched,
225-
/// Message has **NOT** been dispatched because of given error.
225+
/// Message has **NOT** been dispatched because of a given error.
226226
NotDispatched(#[codec(skip)] Option<DispatchBlobError>),
227227
}
228228

@@ -432,7 +432,8 @@ pub mod benchmarking {
432432
pallet_bridge_messages::LaneIdOf<Runtime, WithPeoplePolkadotMessagesInstance>,
433433
>;
434434
}
435-
//
435+
436+
// TODO: enable tests as much as possible
436437
// #[cfg(test)]
437438
// pub(crate) mod tests {
438439
// use super::*;

runtimes/bulletin-polkadot/src/xcm_config.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl WeightTrader for NoopTrader {
9999
/// Allows execution from `origin` if it is contained in `AllowedOrigin`
100100
/// and if it is just a straight `Transact` which contains any call.
101101
///
102-
/// That's a 1:1 copy of corresponding Cumulus structure.
102+
/// That's a 1:1 copy of the corresponding Cumulus structure.
103103
pub struct AllowUnpaidTransactsFrom<RuntimeCall, AllowedOrigin>(
104104
sp_std::marker::PhantomData<(RuntimeCall, AllowedOrigin)>,
105105
);
@@ -119,6 +119,8 @@ impl<RuntimeCall: Decode, AllowedOrigin: Contains<Location>> ShouldExecute
119119
{:?}", origin, instructions, max_weight, _properties,
120120
);
121121

122+
// TODO: check if this is enough, because we don't filter `Transact` at all,
123+
// but instead we allow all XCM instruction processing.
122124
// we only allow from configured origins
123125
ensure!(AllowedOrigin::contains(origin), ProcessMessageError::Unsupported);
124126

@@ -138,7 +140,8 @@ pub type XcmRouter = LocalExporter<ToBridgeHaulBlobExporter, UniversalLocation>;
138140
/// The barriers one of which must be passed for an XCM message to be executed.
139141
pub type Barrier = TrailingSetTopicAsId<
140142
WithComputedOrigin<
141-
// We only allow unpaid execution from the PeoplePolkadot parachain.
143+
// TODO: check if this is working, I think we executed `Trap` in zombienet with
144+
// `DescendOrigin`. We only allow unpaid execution from the PeoplePolkadot parachain.
142145
AllowUnpaidTransactsFrom<RuntimeCall, OnlyPeoplePolkadotLocation>,
143146
UniversalLocation,
144147
ConstU32<2>,
@@ -170,6 +173,7 @@ impl xcm_executor::Config for XcmConfig {
170173
type PalletInstancesInfo = AllPalletsWithSystem;
171174
type MaxAssetsIntoHolding = ConstU32<0>;
172175
type FeeManager = ();
176+
// TODO: Why? This could allow processing of `ExportMessage` from People?
173177
type MessageExporter = ToBridgeHaulBlobExporter;
174178
type UniversalAliases = UniversalAliases;
175179
type CallDispatcher = WithOriginFilter<Everything>;
@@ -180,10 +184,11 @@ impl xcm_executor::Config for XcmConfig {
180184
type HrmpChannelAcceptedHandler = ();
181185
type HrmpChannelClosingHandler = ();
182186
type XcmRecorder = ();
183-
// TODO: add here some impl?
187+
// TODO: maybe add here some emitter?
184188
type XcmEventEmitter = ();
185189
}
186190

191+
// TODO: setup pallet-message-queue and dispatch with MessageQueue, so we don't need this.
187192
/// XCM blob dispatcher that executes XCM message at this chain.
188193
///
189194
/// That's a copy of `xcm_builder::BridgeBlobDispatcher` struct. The only difference is
@@ -225,6 +230,8 @@ impl DispatchBlob for ImmediateXcmDispatcher {
225230
// execute the XCM program
226231
let mut message_hash = message.using_encoded(blake2_256);
227232
XcmExecutor::<XcmConfig>::prepare_and_execute(
233+
// TODO: double-check if this, maybe should be just `Here`, I think we executed `Trap`
234+
// in zombienet with `DescendOrigin`.
228235
PeoplePolkadotLocation::get(),
229236
message,
230237
&mut message_hash,
@@ -246,6 +253,7 @@ impl DispatchBlob for ImmediateXcmDispatcher {
246253
}
247254
}
248255

256+
// TODO: check - remove and use BridgeMessage
249257
/// Decode inbound `BridgeMessage` from PeoplePolkadot parachain.
250258
pub(crate) fn decode_bridge_message(
251259
blob: &XcmAsPlainPayload,

scripts/create_bulletin_polkadot_spec.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,3 @@ $binary build-spec --chain edited-chain-spec-plain.json --raw > chain-spec-raw.j
7979
cp edited-chain-spec-plain.json ./node/chain-specs/bulletin-polkadot-plain.json
8080
cp chain-spec-raw.json ./node/chain-specs/bulletin-polkadot.json
8181

82-
# build genesis data
83-
$binary export-genesis-state --chain chain-spec-raw.json > bulletin-polkadot-genesis-head-data
84-
85-
# build genesis wasm
86-
$binary export-genesis-wasm --chain chain-spec-raw.json > bulletin-polkadot-wasm

0 commit comments

Comments
 (0)