This repository has been archived by the owner on Aug 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Sketch the idea. #27
Draft
JoshOrndorff
wants to merge
1
commit into
master
Choose a base branch
from
joshy-exporting-state
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Sketch the idea. #27
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+50.3 KB
tuts/clone-a-live-chain/assets/private-network-apps-insert-key-aura.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.3 KB
tuts/clone-a-live-chain/assets/private-network-top-left-network-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"slug": "config", | ||
"lang": "en", | ||
"title": "Clone a Live Chain", | ||
"excerpt": "Clone a Live Substrate Chain", | ||
"tags": [ "Medium", "2 Hours", "Prerequisites" ], | ||
"versions": [ "v2.0.0-alpha.6" ], | ||
"menu": [ | ||
{ "title": "Overview", "slug": "index" }, | ||
{ "title": "Start the Original Chain", "slug": "original-chain" }, | ||
{ "title": "Export Chain State", "slug": "export" }, | ||
{ "title": "Start the Clone Chain", "slug": "clone-chain"} | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
slug: clone-chain | ||
lang: en | ||
title: Start the Clone Chain | ||
--- | ||
|
||
Now that we've exported the state of the original chain into a chain spec file, we are able to use that as the genesis state of our new clone chain. Before starting the process, it is useful to observe some properties about the clone chain and this process. | ||
|
||
The clone chain will: | ||
* Have the same state (including token balances) as the original | ||
|
||
The clone chain will not | ||
* Have the same number of blocks or transactions as the original | ||
* Have the same transactions as the original | ||
* Be a hard fork of the original | ||
|
||
Unsure need to experiment: | ||
* Be able to execute transactions designed for the original - definitely not if it has the checkGenesis. unsure about if it doesn't have that. | ||
|
||
## Starting the new Chain | ||
|
||
```bash | ||
./target/release/node-template --chain=clone-spec.json --alice --base-path /tmp/clone/alice | ||
``` | ||
|
||
## Submitting a Transaction | ||
|
||
Connect Apps or another UI. Ensure the balances and othe rstate are as expected. Submit a transaction and ensure it works. | ||
|
||
## Observing the Difference | ||
|
||
Connect Apps to the original chain and see that the transaction you submitted to the clone has not executed on the original. | ||
|
||
Submit a transaction to the original and ensure it doesn't execute on the clone. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
slug: export | ||
lang: en | ||
title: Export Chain State | ||
--- | ||
|
||
To clone a live chain in the wild, you will need a synchronized node from which you can export the existing state. In this tutorial, we already have a node to do this, and we will use it. | ||
|
||
## Create the export | ||
|
||
```bash | ||
./target/release/node-template export-state --dev --base-path /tmp/original/alice > clone-spec.json | ||
``` | ||
|
||
|
||
I got stuck here because latest node template won't start, and old node templates don't have the `export-state`. I'll still sketch out the rest of the idea though. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
slug: index | ||
lang: en | ||
title: Clone a Live Chain | ||
--- | ||
|
||
In this tutorial we will learn to start a Substrate chain that takes its initial state from an existing live blockchain. This technique is useful for investigating bugs, testing runtime upgrades, performing airdrops, and "forking" a community during a contentious disagreement. | ||
|
||
## Install the Node Template | ||
|
||
You should already have version `v2.0.0-alpha.6` of the [Substrate Node | ||
Template](https://github.com/substrate-developer-hub/substrate-node-template) compiled on your | ||
computer from when you completed the [Create Your First Substrate Chain | ||
Tutorial](/tutorials/create-your-first-substrate-chain/v2.0.0-alpha.6). If you do not, please complete that | ||
tutorial. | ||
|
||
> Experienced developers who truly prefer to skip that tutorial, you may install the node template according to the instructions in its readme. | ||
|
||
## What you will be doing | ||
|
||
Before we even get started, let's lay out what we are going to do over the course of this tutorial. | ||
We will: | ||
|
||
1. Launch a Substrate blockchain based on a template project. | ||
3. Export that chain's state to a file. | ||
4. Use the file to create a second chain that is a clone of the first. | ||
|
||
Sound reasonable? Good, then let's begin! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
slug: original chain | ||
lang: en | ||
title: Start the Original Chain | ||
--- | ||
|
||
Before we can perform any cloning, we need an original chain that will be coned. | ||
|
||
## Start the chain | ||
|
||
`./target/release/node-template --dev --base-path /tmp/original/alice` | ||
|
||
The custom base path will help us avoid mixing up our two chains. | ||
|
||
## Accumulate some State | ||
|
||
There's no use forking a chain that doesn't yet have any interesting state. IT would be easier to jsut start a new chain. Let's build up some interesting state. The exact state is up to you. But for example you might. | ||
|
||
* Transfer tokens to various accounts | ||
* Create your own account and get some tokens | ||
* Store a value in the template pallet | ||
* Perform some kind of runtime upgrade (would need to test whether this works) | ||
|
||
## Kill your chain | ||
|
||
It isn't truly necessary to kill it. In the wild, the original chain wouldn't die. But it may help prevent confusion or mixing up the two chains to not have it actively running. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be interesting for this tutorial to be wrapped up in an exercise of investigating a bug or testing an upgrade...or both. It would also be nice to hear about how this technique can be used for airdops or forking. Also may want to consider rewording the events that may lead to a fork.