Code Monkey home page Code Monkey logo

substrate-developer-hub / substrate-docs Goto Github PK

View Code? Open in Web Editor NEW
126.0 126.0 271.0 249.61 MB

Substrate Developer Hub. Substrate is powered by best in class cryptographic research and comes with peer to peer networking, consensus mechanisms, and much more.

Home Page: https://docs.substrate.io

License: BSD Zero Clause License

JavaScript 38.08% CSS 12.52% SCSS 12.91% Rust 34.36% HTML 2.13%
blockchain documentation gatsby gatsbyjs lunrjs substrate tailwindcss

substrate-docs's Introduction

Substrate Docs





follow on Twitter

Contributing

Thank you for your interest in contributing to documentation for Substrate! As a member of the community, you are invited and encouraged to contribute by submitting issues, offering suggestions for improvements to existing content in the form of a pull request, adding review comments to existing pull requests and issues, proposing new content, or creating new pull requests to fix issues or provide new content.

Working with /docs content

URL paths

All .md files added to ./content/md/en/docs/ folder will output an URL path without the /docs prefix, eg.:

  • index.md for a category page : ./content/md/en/docs/reference/index.md/reference/
  • <article-name>.md for an article in its parent category ./content/md/en/docs/reference/glossary.md/reference/glossary/

You can use any structure nesting needed, there is no limit of depth.

Media / Images

  • use ./content/media/images/docs/ folder for images to be included in /docs/*/*.md files
  • source images in .md: /media/images/docs/path/to/your/image/<image>.ext

Navigation config

  • update ./content/config/nav.yaml to add or amend items and linking to your content
    • an exception being ./content/md/en/docs/reference/how-to-guides/... files that should only be listed on the main how-to guide page in the index page for these pages: ./content/md/en/docs/reference/how-to-guides/index.md, not to be included in the sidebar.

This config file is used to generate sidebar menu where:

  • menu is populated from the menu sequence (respecting order)
  • menu supports three level hierarchy
  • menu accepts external links, eg.: https://substrate.io

Local Development

Install

Navigate into your cloned local repo directory and install all dependencies.

# https://github.com/nvm-sh/nvm is suggested, so that you
# switch to the correct version of node set in the .nvmrc file
nvm i

# Install dependencies
yarn

gatsby-plugin-substrate submodule

This website uses a submodule for shared components. To set it up please refer to the gatsby-plugin-substrate repository.

Configure environment variables

Copy example.env.development into a new .env.development file.

Config URL variables based on your preferable local setup. URL will be used for links generation between Substrate websites.

Default localhost port configuration:

GATSBY_WEBSITE_URL=http://localhost:8100
GATSBY_DOCS_URL=http://localhost:8200

Start development server

Navigate into your new site’s directory and use the following command to start the development server locally.

yarn develop

Troubleshooting

It is sometimes the case that gastby's cache gets corrupted when making changes. If you run into issues in local development, try to clean this and restart:

yarn clean
yarn develop

Security

Please report security bugs as stated in the static/security.txt file in this repository.

License

TBD, please open an issue to request any use outside of the official host https://docs.substrate.io/ at this time.

substrate-docs's People

Contributors

alexiachen avatar bernardoaraujor avatar brunopgalvao avatar cuteolaf avatar elv-nate avatar evilrobot-01 avatar gflow33 avatar gitofdeepanshu avatar har00ga avatar hummusonrails avatar imod7 avatar je-boska avatar jonnysmillie avatar kalaninja avatar kianenigma avatar lisa-parity avatar memorycancel avatar muharem avatar niklasp avatar nuke-web3 avatar optimumood avatar platonicsocrates avatar rashmirreddy avatar rlaferla avatar rmnprkrl avatar shawntabrizi avatar thiolliere avatar viac92 avatar wirednkod avatar wyhaines avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

substrate-docs's Issues

Improvement to "Installation" instructions

So some background. I have only started with Rust at the beginning of this month and I got interested in blockchains last Sunday. Therefore that might explain why I had difficulty following the instructions on the installation steps page.

Now the problems I had are more related to Rustup but regardless of this fact, the documentation might need some reworking in my opinion.

There is a section related to installing Rustup where we are told to run:

source ~/.cargo/env

I didn't install Rustup via the shell script but instead used the Arch community package and as result, I didn't have the env file.

However, it didn't seem to matter really as I was eventually able to go through the creation of Substrate chain tutorial without any issues. I agree that yes it's my fault for not following the instructions to the letter but maybe this issue can be highlighted for people who installed Rustup the way I did.

While the previous issue was my fault, the section about the toolchain really slowed me down as I wasn't sure what to do because, Polkadot was mentioned while I was interested in Substrate. I simply ploughed ahead and installed the latest nightly toolchain and I had no problem going through the above referenced tutorial. This might well be due to my lack of understanding about the whole Rust ecosystem but I recall reading that knowledge of Rust would not be required for that tutorial.

Now, I would be happy to help rewrite that part of the documentation as long as it is deemed to be necessary/desirable and also if I can get some degree of support either from here or in Matrix.

Just my 2 cents as they say...

Making all links default to open new tab

Dan Shields:

In .mdx is it possible to enable the default x syntax actually mean target="_blank" (in tags as I am used to)

If so, is there a way to override this somehow? Specifically for internal links this would make sense (in page for sure, and within the docs in most cases)

Imad:

This was pointed out to be a while back, and generally speaking a good convention to follow.
That being said, I'm was thinking about making a component available in MDX, so in case there has to be an external link, it'll be styled a little differently. This is so users can easily differentiate visually between and external link and an internal link.

quick example would be:

<ExternalLink to="https://www.someexternalwebsite.come">BUTTON TEXT</ExternalLink>

Dan Shields:

I think this reason is the one I am after they think is "good" - but also most of these links are meant to add reference material while you read, so navigating away and back isn't intended.

We should include convention here in the style guide for contributors to if we have this external or whatever syntax to use letting people know when to and not to use it (@sacha-l @jimmychu0807 what do you think?)

Sacha:

I think that this could be a neat feature we introduce to our Devhub. I would bring it one step further, where each link type (knowledge base, Rust docs, HTGs, Tutorials and other) has a component that tells the reader where that link would take them. We have so many links and its hard to know where each will lead to.

Staying a little more on topic here, I don't think that all links need to open a new tab. IMO those that should open a new tab would be:

Rust docs (crates.io)
any other link that's going to bring someone outside of our devhub.
This is just one opinion, we should make a poll in our community and internal channels and also decide whether this is a feature we want for this first release.

How to add more authorities in a running AuRa network?

substrate-developer-hub/substrate-node-template#196

Presently there is no way to add block producers to an active chain (that I am aware of) - you need to add this to your node to allow for it. You can add this functionality: here is a (presently out of date) example of a pallet to expose this via an extrinsic call: https://github.com/gautamdhameja/substrate-validator-set

Picking up this pallet and maintaining it as part of the devhub might be required, or some more minimal version of it.

Update Account abstractions to include references to proxy and more?

https://substrate.dev/docs/en/knowledgebase/learn-substrate/account-abstractions has a reasonable overview of one type of account abstraction for stash & controller key use. I think we could expand this page a fair amount, and/or refactor to give a more broad overview with references to the polkadot wiki and other sources for deeper dives.

Some references I would point to in either case:

One caveat here - IMHO there is no pressing need for this nuanced information for those building runtimes as much as those building applications that may want to have complicated account schemes. So it may be of interest to get this kind of content more visible to that demographic than substrate devs 🤔

What are the thoughts from the team on this?

Tutorial of data migration

We found there's a page about Substrate data migration:

However it's more like an introduction, with a bunch of example PR and some caveats, but not a tutorial. Specifically, it would be helpful for readers if we can have:

  • A step-to-step instructions for how to write a migration, and tear down the related code after finished (the later point is especially useful because it's not mentioned in any of the above docs)
  • As said in the migration guide, new migration should support pallet semantic versioning. How can we leverage it?
  • The lifecycle of a migration (what will happen once we start a runtime upgrade, etc)
  • Any performance consideration? (Looks like a migration can be much heavier than a regular block and 6s is not a limitation?)
  • Reference of the related traits

Background: We are trying to migrating a StorageMap to a Child Tire

Write documentation guidelines

[WIP]
This is an issue to keep track of the items we want to address in our updated contribution guidelines for the new devhub launch.

Components

List all different components: Tip, Advice, Note, Warning, Important
Convention and examples of which instances to use them in
Docs, Tutorials, How-to guides

Full-stops after bullet-points. Convention tbd
TODO: Add link to the different guidelines (htgs, kb docs) here.

Remove "next button" on tutorial Overview / Intro pages.

Each top level "Overview" page for tutorials uses the AccentButton after the TutorialObjective components.

It would be nice to remove the generic "Next" button for just those top level pages as to avoid having two buttons serving the same purpose. Maybe by adding some frontmatter tag?

Revise Tutorial content structuring

Use components to organize content in a more uniform way across all tutorials.

  • Next steps: format "Next steps" in consistent way, using components to structure content. Perhaps RelatedMaterial block
  • Add new content to use TutorialObjective component in every Tutorial Overview page

Making sidebar scrolling independent of the main content

(from Jimmy's original issue)

If I want to scroll down on the left sidebar, I have to scroll the main content all the way down so the left sidebar will scroll downward.

Will be better if I can scroll on the left sidebar independent of where I am at in the main content. Possibly apply to the right sidebar as well if it is longer than the screen height.

[ink] Have user run tests first to see them fail?

Given how mistakes in deployed smart contracts are difficult to correct, would it make sense to encourage those following the tutorial to run the tests first to see them fail before then implementing the code to make them pass?

I was just trying that in https://substrate.dev/substrate-contracts-workshop/#/1/storing-a-mapping and was interested to review the following failures:

❯ cargo +nightly test
   Compiling incrementer v0.1.0 (/Users/samueljoseph/Documents/Github/tansaku/incrementer)
    Finished test [unoptimized + debuginfo] target(s) in 1.01s
     Running target/debug/deps/incrementer-d10a7711a3840851

running 2 tests
test incrementer::tests::it_works ... ok
test incrementer::tests::default_works ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

❯ cargo +nightly test
   Compiling incrementer v0.1.0 (/Users/samueljoseph/Documents/Github/tansaku/incrementer)
error[E0433]: failed to resolve: use of undeclared crate or module `ink`
  --> lib.rs:61:11
   |
61 |         #[ink::test]
   |           ^^^ use of undeclared crate or module `ink`

error[E0599]: no method named `get_mins` found for struct `incrementer::Incrementer` in the current scope
  --> lib.rs:65:33
   |
9  |     pub struct Incrementer {
   |     ---------------------- method `get_mins` not found for this
...
65 |             assert_eq!(contract.get_mins(), 0)
   |                                 ^^^^^^^^ method not found in `incrementer::Incrementer`

error: aborting due to 2 previous errors

Going forward I'm going to use this approach and see how I can remove errors and fix tests as I implement the code.

BTW I love the approach of showing examples and then challenging the learner to implement their own code - great fun! And great learning!

Migrate Prebuilt Pallets in FRAME -> Pallets?

https://github.com/substrate-developer-hub/substrate-developer-hub.github.io/blob/source/docs/knowledgebase/runtime/frame.md

this lists a large selection of pallets substrate comes with. I would think it be better places in
https://github.com/substrate-developer-hub/substrate-developer-hub.github.io/blob/source/docs/knowledgebase/runtime/pallets.md I would also call it "official pallets" and add a section on known community ones (awesome substrate link?)

I would opt for pointing to the whole selection in source, but having these listed for seach-ability on devhub is great.

This likely needs to be revisited every release or substrate and/or FRAME.

OCW HTTP Fetching and JSON Parsing

Based on this original OCW recipe, this how-to guide steps developers through the process of constructing HTTP request for OCWs including:

  • sending a request to a Github API remote endpoint
  • using the serde library to parse a JSON string from a HTTP response into a data structure
  • manipulating that data structure in the node's runtime

[Cumulus] Runtime upgrade example

  • use compact wasm for parachain upgrades
  • Relaychain upgrade?
  • (more?)

Note added about runtime upgrades for rococo/relay chain needs to be added:
For now you shouldn't expect upgrades to function. (needs to be tested!)

  • not like a solo chain. You break parachains if you upgrade your relaychain.
  • as your wasm blob for you parachain depends on the relay chain's runtime
  • collator sends a PoV, but the runtime will be looking for the wrong PoV, so blocks are denied
  • setcode will fail on relaychain
  • for now unclear, but work is being done to fix this

Basic OCW configuration

A how-to guide stepping through the basic configuration of an off-chain worker. This includes:

  • configuring the runtime for an OCW
  • basic off-chain worker logic
  • sending transactions back on chain (signed and unsigned with or without signed payloads)

Category: TBD

Optimize search

(Based on conversation - putting this here to keep track of progress)

See PR #26 with the first iteration of the new search.

Here are some key questions to ponder over:

what are some search metrics that MUST return certain results?
what devs are searching for on DevHub?
Does this provide them with what they are looking for?
Are the intended results in the top 5 or 10?
We are using Lunr Search and Indexing under the hood, and we can tweak it to the serve us best. Feel free to read this guide and chime in on search features that can help us enhance this feature further.

Chinese Documents (Markdown)

We are soon going to be in a place where we will need to start bringing in the Chinese documentation (either from Crowdin) or from Lion Bridge into the documentation folders.

Include basic instructions for cloud-based interation

It's common for new users to setup a remote node for testing the 101 materials and gets stuck needing the unsafe RPC and WS flags, as well as disabling mDNS and possibly other suggestions

I propose that we have a reference document (possible a how-to guide?) that we can point builders to that has a FAQ for unsafe remote nodes for dev/testing ONLY and points to further production resources to have nodes hosted with best practices (that we don't maintain on firewalls, rate limiting, rev, proxies, etc.)

Examples:
might need -- --rpc-cors=all
--ws-external
--rpc-external

related topic of remote development: https://github.com/paritytech/subport/discussions/222

Customize `FastTrackPlayground`

Give the ability for us to customize the title in the FastTrackPlayground component.

For e.g. when using this component for X we'll want to title it:
"Try your X in just one click".
And there may be an instance where we'll want to use this same component for Y.

Port over Ink Workshop

All Ink workshop content ported over.

Need to coordinate with maintainers and rework the workshop a little to make it FRAME v2.

Document Transaction Pool Logic

It would be useful to have an article e.g. in the knowledge base that explains the fundamental behavior of the transaction pool.
What's the life cycle of a transaction? Which transactions are propagated?

One thing included there would be that transactions that return an error here in validate_transaction are dropped and not propagated.

Creating and Using Local Storage in OCWs

Based on this OCW recipe, this guide aims to step developers through:

  • defining a persistent storage value
  • defining a storage lock that sets the locking time limit by amount of time passed in blocks
  • use the lock to perform an external process and write data back to storage
  • use the offchain_index API to write to the offchain database (Note: this may be its own How-to guide)

Other ressources:

A guide to on-chain randomness

  • understanding the coin flip
  • understanding the outer assumptions one can and can't take from the traits
  • hardening the randomness, which are useful for what scenario, which drawbacks comes with them

Add note on Runtime WASM compression

One does not need to "enable compression" for a runtime.
Wasm compression has been added to the substrate-wasm-builder on April 7th.
Polkadot and Kusama (presently) use the wasm-builder v3.0.0 which was tagged Feb 10th (so no compression).

Compressed WASM is critical for parachains. We should note this in the KB (#1027) and possibly explain in some new content what all build artifacts substrate produces and why.

Provide more examples of and explanations for custom origins

The scenario:
A pallet has a custom origin used with proposals similar to the collective pallet.
Examples of:
How to use that custom origin to set rules for extrinsics within the same pallet.
How to use that custom origin to set a rule for all extrinsics in another pallet. (eg require a certain threshold of votes)
How to use that custom origin to set a rule to be checked within each extrinsic of another pallet ie check the number of votes within the extrinsic based on logic.

I figured out the above eventually, but it took a while to understand how it was done. It would have been helpful to have a basic description of how it works and what is going on behind the scenes in the macros. I am not yet a Rust expert and the macros make it even harder to understand.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.