Skip to content

Commit

Permalink
Introduce Polkadot-Sdk developer_hub (#2102)
Browse files Browse the repository at this point in the history
This PR introduces the new crate `developer_hub` into the polkadot-sdk
repo. The vision for the developer-hub crate is detailed in [this
document](https://docs.google.com/document/d/1XLLkFNE8v8HLvZpI2rzsa8N2IN1FcKntc8q-Sc4xBAk/edit?usp=sharing).

<img width="1128" alt="Screenshot 2023-11-02 at 10 45 48"
src="https://github.com/paritytech/polkadot-sdk/assets/5588131/1e12b60f-fef5-42c4-8503-a3ba234077c3">


Other than adding the new crate, it also does the following: 

* Remove the `substrate` crate, as there is now a unique umbrella crate
for multiple things in `developer_hub::polkadot_sdk`.
* (backport candidate) A minor change to `frame-support` macros that
allows `T::RuntimeOrigin` to also be acceptable as the origin type.
* (backport candidate) A minor change to `frame-system` that allows us
to deposit events at genesis because now the real genesis config is
generated via wasm, and we can safely assume `cfg!(feature = "std")`
means only testing. related to #62.
* (backport candidate) Introduces a small `read_events_for_pallet` to
`frame_system` for easier event reading in tests.
* From paritytech/polkadot-sdk-docs#31, it
takes action on improving the `pallet::call` docs.
* From paritytech/polkadot-sdk-docs#31, it
takes action on improving the `UncheckedExtrinsic` docs.

## Way Forward

First, a version of this is deployed temporarily
[here](https://blog.kianenigma.nl/polkadot-sdk/developer_hub/index.html).
I will keep it up to date on a daily basis.

### This Pull Request

I see two ways forward: 

1. We acknowledge that everything in `developer-hub` is going to be WIP,
and merge this asap. We should not yet use links to this crate anywhere.
2. We make this be the feature branch, make PRs against this, and either
gradually backport it, or only merge to master once it is done.

I am personally in favor of option 1. If we stick to option 2, we need a
better way to deploy a staging version of this to gh-pages.

### Issue Tracking

The main issues related to the future of `developer_hub` are: 

- paritytech/polkadot-sdk-docs#31
- paritytech/polkadot-sdk-docs#4
- paritytech/polkadot-sdk-docs#26 
- paritytech/polkadot-sdk-docs#32
- paritytech/polkadot-sdk-docs#36


### After This Pull Request

- [ ] create a redirect for
https://paritytech.github.io/polkadot-sdk/master/substrate/
- [x] analytics 
- [ ] link checker
- [ ] the matter of publishing, and how all of these relative links for
when we do, that is still an open question. There is section on this in
the landing page.
- [ ] updated https://paritytech.github.io/

---------

Co-authored-by: Liam Aharon <[email protected]>
Co-authored-by: Juan Girini <[email protected]>
Co-authored-by: bader y <[email protected]>
Co-authored-by: Sebastian Kunert <[email protected]>
Co-authored-by: James Wilson <[email protected]>
Co-authored-by: Michal Kucharczyk <[email protected]>
  • Loading branch information
7 people authored Nov 30, 2023
1 parent 180a6ad commit eaf1bc5
Show file tree
Hide file tree
Showing 96 changed files with 3,410 additions and 471 deletions.
2 changes: 1 addition & 1 deletion .gitlab/pipeline/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ build-rustdoc:
find "$path" -name '*.html' | xargs -I {} -P "$(nproc)" bash -c 'process_file "$@"' _ {}
}
inject_simple_analytics "./crate-docs"
- echo "<meta http-equiv=refresh content=0;url=polkadot_service/index.html>" > ./crate-docs/index.html
- echo "<meta http-equiv=refresh content=0;url=developer_hub/index.html>" > ./crate-docs/index.html

build-implementers-guide:
stage: build
Expand Down
76 changes: 51 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ license = "GPL-3.0-only"
resolver = "2"

members = [
"developer-hub",
"bridges/bin/runtime-common",
"bridges/modules/grandpa",
"bridges/modules/messages",
Expand Down Expand Up @@ -186,7 +187,6 @@ members = [
"polkadot/xcm/xcm-simulator",
"polkadot/xcm/xcm-simulator/example",
"polkadot/xcm/xcm-simulator/fuzzer",
"substrate",
"substrate/bin/minimal/node",
"substrate/bin/minimal/runtime",
"substrate/bin/node-template/node",
Expand Down Expand Up @@ -476,8 +476,7 @@ default-members = [ "polkadot", "substrate/bin/node/cli" ]
panic = "unwind"
opt-level = 3

# make sure dev builds with backtrace do
# not slow us down
# make sure dev builds with backtrace do not slow us down
[profile.dev.package.backtrace]
inherits = "release"

Expand Down
3 changes: 1 addition & 2 deletions cumulus/parachain-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,7 @@ impl pallet_parachain_template::Config for Runtime {

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime
{
pub struct Runtime {
// System support stuff.
System: frame_system = 0,
ParachainSystem: cumulus_pallet_parachain_system = 1,
Expand Down
66 changes: 66 additions & 0 deletions developer-hub/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[package]
name = "developer-hub"
description = "The one stop shop for developers of the polakdot-sdk"
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
homepage = "paritytech.github.io"
repository.workspace = true
authors.workspace = true
edition.workspace = true
# This crate is not publish-able to crates.io for now because of docify.
publish = false
version = "0.0.1"

[dependencies]
# Needed for all FRAME-based code
parity-scale-codec = { version = "3.0.0", default-features = false }
scale-info = { version = "2.6.0", default-features = false }
frame = { path = "../substrate/frame", features = ["runtime", "experimental"] }
pallet-examples = { path = "../substrate/frame/examples" }
pallet-default-config-example = { path = "../substrate/frame/examples/default-config" }

# How we build docs in rust-docs
simple-mermaid = { git = "https://github.com/kianenigma/simple-mermaid.git", branch = "main" }
docify = "0.2.6"

# Polkadot SDK deps, typically all should only be scope such that we can link to their doc item.
node-cli = { package = "staging-node-cli", path = "../substrate/bin/node/cli" }
kitchensink-runtime = { path = "../substrate/bin/node/runtime" }
chain-spec-builder = { package = "staging-chain-spec-builder", path = "../substrate/bin/utils/chain-spec-builder" }
subkey = { path = "../substrate/bin/utils/subkey" }

# Substrate
sc-network = { path = "../substrate/client/network" }
sc-rpc-api = { path = "../substrate/client/rpc-api" }
sc-rpc = { path = "../substrate/client/rpc" }
sc-client-db = { path = "../substrate/client/db" }
sc-cli = { path = "../substrate/client/cli" }
sc-consensus-aura = { path = "../substrate/client/consensus/aura" }
sc-consensus-babe = { path = "../substrate/client/consensus/babe" }
sc-consensus-grandpa = { path = "../substrate/client/consensus/grandpa" }
sc-consensus-beefy = { path = "../substrate/client/consensus/beefy" }
sc-consensus-manual-seal = { path = "../substrate/client/consensus/manual-seal" }
sc-consensus-pow = { path = "../substrate/client/consensus/pow" }
substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" }

# Cumulus
cumulus-pallet-aura-ext = { path = "../cumulus/pallets/aura-ext" }
cumulus-pallet-parachain-system = { path = "../cumulus/pallets/parachain-system", features = [
"parameterized-consensus-hook",
] }
parachain-info = { package = "staging-parachain-info", path = "../cumulus/parachains/pallets/parachain-info" }
pallet-aura = { path = "../substrate/frame/aura", default-features = false }
pallet-timestamp = { path = "../substrate/frame/timestamp" }

# Primitives
sp-io = { path = "../substrate/primitives/io" }
sp-api = { path = "../substrate/primitives/api" }
sp-core = { path = "../substrate/primitives/core" }
sp-keyring = { path = "../substrate/primitives/keyring" }
sp-runtime = { path = "../substrate/primitives/runtime" }

[dev-dependencies]
parity-scale-codec = "3.6.5"
scale-info = "2.9.0"

[features]
experimental = [ "pallet-aura/experimental" ]
54 changes: 54 additions & 0 deletions developer-hub/headers/toc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<script>
window.addEventListener("DOMContentLoaded", (event) => {
// if the crate is one that starts with `developer_hub`
let crate_name = document.querySelector("#main-content > div > h1 > a:nth-child(1)");
if (!crate_name.textContent.startsWith("developer_hub")) {
console.log("skipping -- not `developer_hub`");
return;
}

let sidebar = document.querySelector(".sidebar");
let headers = document.querySelectorAll("#main-content h2, #main-content h3, #main-content h4");
console.log(`detected developer_hub: headers: ${headers.length}`);

let toc = document.createElement("div");
toc.classList.add("table-of-contents");
toc.appendChild(document.createElement("h2").appendChild(document.createTextNode("Table of Contents")).parentNode);

// the first two headers are always junk
headers.forEach(header => {
let link = document.createElement("a");
link.href = "#" + header.id;
link.textContent = header.textContent;
link.className = header.tagName.toLowerCase();
toc.appendChild(link);
});

sidebar.insertBefore(toc, sidebar.firstChild);
console.log("injecting ToC");
});
</script>
<style>
.table-of-contents {
margin-bottom: 1em;
padding: 0.5em;
}

.table-of-contents a {
display: block;
margin: 0.2em 0;
}

.table-of-contents .h2 {
font-weight: bold;
margin-left: 0;
}

.table-of-contents .h3 {
margin-left: 1em;
}

.table-of-contents .h4 {
margin-left: 2em;
}
</style>
1 change: 1 addition & 0 deletions developer-hub/src/guides/changing_consensus.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//! # Changing Consensus
1 change: 1 addition & 0 deletions developer-hub/src/guides/cumulus_enabled_parachain.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//! # Cumulus Enabled Parachain
25 changes: 25 additions & 0 deletions developer-hub/src/guides/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//! # Polkadot Developer Hub Guides
//!
//! This crate contains a collection of guides that are foundational to the developers of
//! Polkadot SDK. They common user-journeys that are traversed in the Polkadot ecosystem.

/// Write your first simple pallet, learning the most most basic features of FRAME along the way.
pub mod your_first_pallet;

/// Writing your first real [runtime](`crate::reference_docs::wasm_meta_protocol`), and successfully
/// compiling it to [WASM](crate::polkadot_sdk::substrate#wasm-build).
pub mod your_first_runtime;

/// Running the given runtime with a node. No specific consensus mechanism is used at this stage.
pub mod your_first_node;

/// How to change the consensus engine of both the node and the runtime.
pub mod changing_consensus;

/// How to enhance a given runtime and node to be cumulus-enabled, run it as a parachain and connect
/// it to a relay-chain.
pub mod cumulus_enabled_parachain;

/// How to make a given runtime XCM-enabled, capable of sending messages (`Transact`) between itself
/// and the relay chain to which it is connected.
pub mod xcm_enabled_parachain;
1 change: 1 addition & 0 deletions developer-hub/src/guides/xcm_enabled_parachain.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//! # XCM Enabled Parachain
1 change: 1 addition & 0 deletions developer-hub/src/guides/your_first_node.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//! # Your first Node
Loading

0 comments on commit eaf1bc5

Please sign in to comment.