Skip to content

Commit c8b60fb

Browse files
authored
Development Genesis Config has Mainnet Schemas (#2057)
# Goal The goal of this PR is to add the Schemas in at Genesis from Mainnet when on a development chain Closes #2041 # Discussion - Adds a tool `tools/genesis-schemas` that downloads the schemas from mainnet and stuffs them into a json file - GenesisConfig for Schemas Pallet that loads from a json file schemas to start with at genesis ## How to Test - You can test the pulling yourself with: - `cd tools/genesis-data && npm i && npm run schemas` or use `make genesis-schemas` - Otherwise just run `make start` and see that it has the same schemas as mainnet with the same names. # Checklist - [x] Tests added
1 parent 3ebbb71 commit c8b60fb

File tree

27 files changed

+2161
-172
lines changed

27 files changed

+2161
-172
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -891,16 +891,12 @@ jobs:
891891
fail-fast: true
892892
matrix:
893893
arch: [amd64]
894-
node: [collator-node-local, instant-seal-node, standalone-node]
894+
node: [collator-node-local, standalone-node]
895895
include:
896896
- node: collator-node-local
897897
network: local
898898
build-profile: release
899899
release-file-name-prefix: frequency-local
900-
- node: instant-seal-node
901-
network: dev
902-
build-profile: release
903-
release-file-name-prefix: frequency-dev
904900
- node: standalone-node
905901
network: dev
906902
build-profile: release

.github/workflows/verify-pr-commit.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,6 @@ jobs:
475475
platforms: "amd64"
476476
- name: Set up Docker Buildx
477477
uses: docker/setup-buildx-action@v3
478-
- name: Build collator image in instant seal mode
479-
env:
480-
IMAGE_NAME: instant-seal-node
481-
uses: docker/build-push-action@v5
482-
with:
483-
context: .
484-
push: false
485-
file: ./docker/${{env.IMAGE_NAME}}.dockerfile
486478
- name: Build collator standalone
487479
env:
488480
IMAGE_NAME: standalone-node

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,9 @@ endif
345345
.PHONY: version-reset
346346
version-reset:
347347
find ./ -type f -name 'Cargo.toml' -exec sed -i '' 's/^version = \".*+polkadot.*\"/version = \"0.0.0\"/g' {} \;
348+
349+
.PHONY: genesis-schemas
350+
genesis-schemas:
351+
cd tools/genesis-data && \
352+
npm i && \
353+
npm run --silent schemas > ../../resources/genesis-schemas.json

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ _Note, Running Frequency via following options does not require binary to be bui
158158

159159
This option runs just one collator node without the need for a relay chain.
160160

161+
This preloads into genesis all the schemas from mainnet.
162+
Use `make genesis-schemas` if the genesis is out of date.
163+
161164
### Manual Sealing
162165

163166
a. Blocks can be triggered by calling the `engine_createBlock` RPC
@@ -187,17 +190,17 @@ Great for most testing.
187190
make start
188191
```
189192

190-
Also available as a Docker image: [`frequencychain/instant-seal-node`](https://hub.docker.com/r/frequencychain/instant-seal-node)
193+
Also available as a Docker image: [`frequencychain/standalone-node`](https://hub.docker.com/r/frequencychain/standalone-node)
191194

192195
```sh
193-
docker run --rm -p 9944:9944 -p 30333:30333 frequencychain/instant-seal-node
196+
docker run --rm -p 9944:9944 frequencychain/standalone-node
194197
```
195198

196199
To stop running chain hit [Ctrl+C] in terminal where the chain was started.
197200

198-
| **Node** | **Ports** | **Explorer URL** |
199-
| ----------------------- | :----------------------------: | ----------------------------------------------------------------------------------------- |
200-
| Frequency Collator Node | ws and rpc:`9944`, p2p:`30333` | [127.0.0.1:9944](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/explorer) |
201+
| **Node** | **Ports** | **Explorer URL** |
202+
| ----------------------- | :---------------: | ----------------------------------------------------------------------------------------- |
203+
| Frequency Collator Node | ws and rpc:`9944` | [127.0.0.1:9944](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/explorer) |
201204

202205
### Interval Sealing
203206

common/primitives/src/handles.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::utils::*;
44
use frame_support::BoundedVec;
55
use parity_scale_codec::{Decode, Encode};
66
use scale_info::TypeInfo;
7+
#[cfg(feature = "std")]
78
use serde::{Deserialize, Serialize};
89
use sp_core::ConstU32;
910
use sp_std::vec::Vec;

common/primitives/src/schema.rs

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::utils;
44
use enumflags2::{bitflags, BitFlags};
55
use parity_scale_codec::{Decode, Encode, EncodeLike, MaxEncodedLen};
66
use scale_info::{build::Fields, meta_type, Path, Type, TypeInfo, TypeParameter};
7-
#[cfg(feature = "std")]
87
use serde::{Deserialize, Serialize};
98
use sp_runtime::RuntimeDebug;
109
use sp_std::prelude::*;
@@ -18,8 +17,19 @@ pub type SchemaId = u16;
1817
pub type SchemaVersion = u8;
1918

2019
/// Types of modeling in which a message payload may be defined
21-
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
22-
#[derive(Copy, Clone, Encode, Decode, PartialEq, Debug, TypeInfo, Eq, MaxEncodedLen)]
20+
#[derive(
21+
Copy,
22+
Clone,
23+
Encode,
24+
Decode,
25+
PartialEq,
26+
Debug,
27+
TypeInfo,
28+
Eq,
29+
MaxEncodedLen,
30+
Serialize,
31+
Deserialize,
32+
)]
2333
pub enum ModelType {
2434
/// Message payload modeled with Apache Avro: <https://avro.apache.org/docs/current/spec.html>
2535
AvroBinary,
@@ -28,8 +38,19 @@ pub enum ModelType {
2838
}
2939

3040
/// Types of payload locations
31-
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
32-
#[derive(Copy, Clone, Encode, Decode, PartialEq, Debug, TypeInfo, Eq, MaxEncodedLen)]
41+
#[derive(
42+
Copy,
43+
Clone,
44+
Encode,
45+
Decode,
46+
PartialEq,
47+
Debug,
48+
TypeInfo,
49+
Eq,
50+
MaxEncodedLen,
51+
Serialize,
52+
Deserialize,
53+
)]
3354
pub enum PayloadLocation {
3455
/// Message payload is located on chain
3556
OnChain,
@@ -44,8 +65,19 @@ pub enum PayloadLocation {
4465
/// Support for up to 16 user-enabled features on a collection.
4566
#[bitflags]
4667
#[repr(u16)]
47-
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
48-
#[derive(Copy, Clone, RuntimeDebug, PartialEq, Eq, Encode, Decode, MaxEncodedLen, TypeInfo)]
68+
#[derive(
69+
Copy,
70+
Clone,
71+
RuntimeDebug,
72+
PartialEq,
73+
Eq,
74+
Encode,
75+
Decode,
76+
MaxEncodedLen,
77+
TypeInfo,
78+
Serialize,
79+
Deserialize,
80+
)]
4981
pub enum SchemaSetting {
5082
/// Schema setting to enforce append-only behavior on payload.
5183
/// Applied to schemas of type `PayloadLocation::Itemized`.

docker/instant-seal-node.dockerfile

Lines changed: 0 additions & 56 deletions
This file was deleted.

docker/instant-seal-node.overview.md

Lines changed: 0 additions & 64 deletions
This file was deleted.

node/cli/src/cli.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,6 @@ pub struct Cli {
8181
#[clap(raw = true)]
8282
pub relay_chain_args: Vec<String>,
8383

84-
#[cfg(feature = "frequency-no-relay")]
85-
#[clap(long = "instant-sealing", help = "Deprecated. Use --sealing=instant instead.")]
86-
pub instant_sealing: bool,
87-
88-
#[cfg(feature = "frequency-no-relay")]
89-
#[clap(long = "manual-sealing", help = "Deprecated. Use --sealing=manual instead.")]
90-
pub manual_sealing: bool,
91-
9284
/// Instant block sealing
9385
/// Blocks are triggered to be formed each time a transaction hits the validated transaction pool
9486
/// Empty blocks can also be formed using the `engine_createBlock` RPC

node/cli/src/run_as_localchain.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
use crate::cli::Cli;
22
use frequency_service::block_sealing::frequency_dev_sealing;
33
use sc_cli::SubstrateCli;
4-
use std::process;
54

65
pub fn run_as_localchain(cli: Cli) -> sc_service::Result<(), sc_cli::Error> {
76
let runner = cli.create_runner(&cli.run.normalize())?;
87

98
runner.run_node_until_exit(|config| async move {
10-
if cli.instant_sealing {
11-
log::error!(
12-
"The --instant-sealing option is deprecated. Use --sealing=instant instead."
13-
);
14-
process::exit(1);
15-
} else if cli.manual_sealing {
16-
log::error!(
17-
"The --manual-sealing option is deprecated. Use --sealing=manual instead."
18-
);
19-
process::exit(1);
20-
}
219
frequency_dev_sealing(
2210
config,
2311
cli.sealing,

node/service/src/chain_spec/frequency_dev.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ fn template_session_keys(keys: AuraId) -> frequency_runtime::SessionKeys {
8686
frequency_runtime::SessionKeys { aura: keys }
8787
}
8888

89+
#[allow(clippy::unwrap_used)]
90+
fn load_genesis_schemas() -> Vec<frequency_runtime::pallet_schemas::GenesisSchema> {
91+
serde_json::from_slice(include_bytes!("../../../../resources/genesis-schemas.json")).unwrap()
92+
}
93+
8994
#[allow(clippy::unwrap_used)]
9095
fn development_genesis(
9196
invulnerables: Vec<(AccountId, AuraId)>,
@@ -131,7 +136,10 @@ fn development_genesis(
131136
// Assign network admin rights.
132137
key: root_key,
133138
},
134-
schemas: Default::default(),
139+
schemas: frequency_runtime::pallet_schemas::GenesisConfig {
140+
initial_schemas: load_genesis_schemas(),
141+
..Default::default()
142+
},
135143
time_release: Default::default(),
136144
democracy: Default::default(),
137145
treasury: Default::default(),

pallets/passkey/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub type PasskeyAuthenticatorData = BoundedVec<u8, ConstU32<128>>;
1919
/// Passkey ClientDataJson type
2020
/// Note: The `challenge` field inside this json MUST be replaced with `CHALLENGE_PLACEHOLDER`
2121
/// before submission to the chain
22-
/// https://w3c.github.io/webauthn/#dictdef-collectedclientdata
22+
/// <https://w3c.github.io/webauthn/#dictdef-collectedclientdata>
2323
pub type PasskeyClientDataJson = BoundedVec<u8, ConstU32<256>>;
2424
/// PassKey Public Key type in compressed encoded point format
2525
/// the first byte is the tag indicating compressed format

pallets/schemas/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ frame-support = { workspace = true }
2121
frame-system = { workspace = true }
2222
numtoa = { workspace = true, optional = true }
2323
scale-info = { workspace = true, features = ["derive"] }
24+
serde = { workspace = true, features = ["derive"] }
2425
serde_json = { workspace = true, features = ["alloc"] }
2526
smallvec = { workspace = true }
2627
sp-core = { workspace = true }

0 commit comments

Comments
 (0)