Skip to content

Commit 20cc03a

Browse files
authored
chore(polkadot): upgrade to v1.0.0 (#898)
1 parent 56ffc1f commit 20cc03a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+944
-852
lines changed

clients/tfchain-client-go/readme.md

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,84 @@
22

33
# **TFchain go client**
44

5-
- This library is a go implementation of a client for the TFChain.
6-
- Internally, our own [fork](https://github.com/threefoldtech/go-substrate-rpc-client) of <https://github.com/centrifuge/go-substrate-rpc-client> is used to make substrate rpc calls.
7-
- Used in multiple repos like [zos](https://github.com/threefoldtech/zos), [rmb-go](https://github.com/threefoldtech/rmb_go), and [terraform-provider-grid](https://github.com/threefoldtech/terraform-provider-grid).
5+
* This library is a go implementation of a client for the TFChain.
6+
* Internally, our own [fork](https://github.com/threefoldtech/go-substrate-rpc-client) of <https://github.com/centrifuge/go-substrate-rpc-client> is used to make substrate rpc calls.
7+
* Used in multiple repos like [zos](https://github.com/threefoldtech/zos), [rmb-go](https://github.com/threefoldtech/rmb_go), and [terraform-provider-grid](https://github.com/threefoldtech/terraform-provider-grid).
88

99
## **Usage**
1010

1111
To make substrate calls:
1212

13-
- First, start a substrate connection against the desired url for the chain:
13+
* First, start a substrate connection against the desired url for the chain:
1414

15-
```go
16-
manager := NewManager("wss://tfchain.grid.tf/ws")
17-
substrateConnection, err := manager.Substrate()
18-
```
15+
```go
16+
manager := NewManager("wss://tfchain.grid.tf/ws")
17+
substrateConnection, err := manager.Substrate()
18+
```
19+
20+
* These are the urls for different chain networks:
1921

20-
- These are the urls for different chain networks:
21-
22-
- devnet: <wss://tfchain.dev.grid.tf/ws>
23-
- testnet: <wss://tfchain.test.grid.tf/ws>
24-
- qanet: <wss://tfchain.qa.grid.tf/ws>
25-
- mainnet: <wss://tfchain.grid.tf/ws>
22+
* devnet: <wss://tfchain.dev.grid.tf/ws>
23+
* testnet: <wss://tfchain.test.grid.tf/ws>
24+
* qanet: <wss://tfchain.qa.grid.tf/ws>
25+
* mainnet: <wss://tfchain.grid.tf/ws>
2626

27-
- It is the user's responsibility to close the connection.
27+
* It is the user's responsibility to close the connection.
2828
29-
```go
30-
defer substrateConnection.Close()
31-
```
29+
```go
30+
defer substrateConnection.Close()
31+
```
3232
33-
- Then, a user could use the provided api calls to communicate with the chain. like:
33+
* Then, a user could use the provided api calls to communicate with the chain. like:
3434
35-
```go
36-
contractID, err := substrateConnection.CreateNodeContract(identity, nodeID, body, hash, publicIPsCount, solutionProviderID)
37-
```
35+
```go
36+
contractID, err := substrateConnection.CreateNodeContract(identity, nodeID, body, hash, publicIPsCount, solutionProviderID)
37+
```
3838
39-
- Also, if a connection is closed for some reason like timing out, internally, it is reopened if nothing blocks.
40-
- All provided api calls are found under the Substrate struct.
39+
* Also, if a connection is closed for some reason like timing out, internally, it is reopened if nothing blocks.
40+
41+
* All provided api calls are found under the Substrate struct.
4142
4243
## **Run tests**
4344
44-
To run the tests, you could either run it against a local docker image of the TFChain, or against devnet
45+
To run the tests, you could either run it against a local docker image of the TFChain, or against devnet
4546
46-
- ### **Run against local docker image**
47+
* ### **Run against local docker image**
4748
48-
To run tests against a local docker image of tfchain, you need to set CI environment variable to anything actually.
49+
To run tests against a local docker image of tfchain, you need to set CI environment variable to anything actually.
4950
50-
```bash
51-
docker run -d -p 9944:9944 threefolddev/tfchain:2.2.0-rc8 --dev --ws-external
52-
sleep 3
53-
export CI="true"
54-
go test . -v
55-
```
51+
```bash
52+
docker run -d -p 9944:9944 threefolddev/tfchain:2.2.0-rc8 --dev --rpc-external
53+
sleep 3
54+
export CI="true"
55+
go test . -v
56+
```
5657
57-
- ### **Run against devnet**
58+
* ### **Run against devnet**
5859
59-
```bash
60-
unset CI
61-
go test . -v
62-
```
60+
```bash
61+
unset CI
62+
go test . -v
63+
```
6364
6465
### **Test Coverage**
6566
66-
- 30.6% of statements
67+
* 30.6% of statements
6768
6869
## **Workflows**
6970
70-
- ### **Test**
71-
72-
- This workflow runs all tests found in the root directory against a local docker image of the [TFChain](https://github.com/threefoldtech/tfchain) found [here](https://hub.docker.com/r/threefolddev/tfchain).
71+
* ### **Test**
7372
74-
- ### **Lint**
73+
* This workflow runs all tests found in the root directory against a local docker image of the [TFChain](https://github.com/threefoldtech/tfchain) found [here](https://hub.docker.com/r/threefolddev/tfchain).
7574
76-
- This workflow ensures linting, so make sure to run these commands without any errors before pushing code:
75+
* ### **Lint**
7776
78-
```bash
79-
golangci-lint run
80-
```
77+
* This workflow ensures linting, so make sure to run these commands without any errors before pushing code:
8178
82-
```bash
83-
gofmt -d -l .
84-
```
79+
```bash
80+
golangci-lint run
81+
```
82+
83+
```bash
84+
gofmt -d -l .
85+
```

docs/development/README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ cargo build
2626
```
2727

2828
## Run a dev node
29+
2930
A dev node is a single-node network that runs on your local machine. It is useful for testing and debugging purposes. To run a dev node, you need to do the following:
3031

3132
```sh
3233
cd tfchain/substrate-node
3334
cargo build
3435

35-
./target/debug/tfchain --dev --ws-external --pruning archive
36+
./target/debug/tfchain --dev --rpc-external --pruning archive
3637
```
38+
3739
This will run the node in default development mode. This flag sets `--chain=dev`, `--force-authoring`, `--rpc-cors=all`, `--alice`, and `--tmp` flags, unless explicitly overridden.
3840

3941
## Run multiple local nodes
@@ -45,11 +47,12 @@ If you want to run tfchain in a multi node network (more than one node), see [lo
4547
You can use the Polkadot JS Apps ui to connect to your dev node. You can access the web interface at https://polkadot.js.org/apps/ and change the settings to use a local node with the address `ws://127.0.0.1:9944`.
4648

4749
This will allow you to interact with your dev node and perform basic operations.
48-
- Use the Polkadot JS Apps to interact with your nodes. You can access the web interface at https://polkadot.js.org/apps/ and change the settings to use a local node or a remote node with the appropriate address.
49-
- Use the `Accounts` tab to manage your accounts and balances. You can create new accounts, import existing accounts, transfer tokens, and view your transaction history.
50-
- Use the `Explorer` tab to view the network status and activity. You can see the latest blocks, events, validators, and peers.
51-
- Use the `Chain State` tab to query the state of the network. You can select a module and a storage item and see its value at any given block.
52-
- Use the `Extrinsics` tab to submit extrinsics to the network. You can select an account, a module, and a function and provide any required parameters.
50+
51+
* Use the Polkadot JS Apps to interact with your nodes. You can access the web interface at https://polkadot.js.org/apps/ and change the settings to use a local node or a remote node with the appropriate address.
52+
* Use the `Accounts` tab to manage your accounts and balances. You can create new accounts, import existing accounts, transfer tokens, and view your transaction history.
53+
* Use the `Explorer` tab to view the network status and activity. You can see the latest blocks, events, validators, and peers.
54+
* Use the `Chain State` tab to query the state of the network. You can select a module and a storage item and see its value at any given block.
55+
* Use the `Extrinsics` tab to submit extrinsics to the network. You can select an account, a module, and a function and provide any required parameters.
5356

5457
## Create an account
5558

@@ -79,19 +82,18 @@ A pallet is a modular component that defines some logic and functionality for th
7982

8083
To learn about pallet development, you can start by checking these resources:
8184

82-
- Get start by reading The substrate [Build application logic tutorials](https://docs.substrate.io/tutorials/build-application-logic/). these tutorials focus on how you can customize the runtime using pallets, creating a custom pallet using macros, adding it to the runtime, and testing its functionality.
83-
84-
- Check the [the Substrate collectibles workshop](https://docs.substrate.io/tutorials/collectibles-workshop/runtime-and-pallets/). This is an interactive, hands-on, and self-paced workshop that introduces the basic steps for building a blockchain-based application using Substrate.
85+
* Get start by reading The substrate [Build application logic tutorials](https://docs.substrate.io/tutorials/build-application-logic/). these tutorials focus on how you can customize the runtime using pallets, creating a custom pallet using macros, adding it to the runtime, and testing its functionality.
8586

86-
- Explore other existing pallets on the [Substrate GitHub repository](https://github.com/paritytech/substrate/tree/master/frame) and learn from their code. You can see how different pallets implement different features and patterns, such as storage, events, errors, hooks, traits, weights, origins, calls, etc.
87+
* Check the [the Substrate collectibles workshop](https://docs.substrate.io/tutorials/collectibles-workshop/runtime-and-pallets/). This is an interactive, hands-on, and self-paced workshop that introduces the basic steps for building a blockchain-based application using Substrate.
8788

89+
* Explore other existing pallets on the [Substrate GitHub repository](https://github.com/paritytech/substrate/tree/master/frame) and learn from their code. You can see how different pallets implement different features and patterns, such as storage, events, errors, hooks, traits, weights, origins, calls, etc.
8890

8991
## Writing tests for pallets
9092

9193
Every pallet should have all functionality tested, you can write unit tests and integration tests for a pallet:
9294

93-
- Unit tests: check this [guide](https://docs.substrate.io/reference/how-to-guides/testing/)
94-
- Integration tests: see this [document](../../substrate-node/tests/readme.md)
95+
* Unit tests: check this [guide](https://docs.substrate.io/reference/how-to-guides/testing/)
96+
* Integration tests: see this [document](../../substrate-node/tests/readme.md)
9597

9698
## Upgrading Substrate version
9799

docs/development/fork-off-substrate.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,53 @@ The fork-off-substrate tool is a handy tool that allows you to download and run
55
In this guide, we will show you how to use the tool to create a local fork of the TFchain network.
66

77
### Prerequisites
8+
89
Before you start, you need to have the following items:
910

10-
- The executable binary and the runtime WASM blob of the target blockchain. You can either compile them from the source code of the blockchain project, or copy them from a trusted node that runs the blockchain. For TFchain, you can find the source code [here](https://github.com/threefoldtech/tfchain) and the instructions on how to compile it [here](https://github.com/threefoldtech/tfchain/tree/development/docs/development). Find the Wasm binary file in the target directory. The file name should be `tfchain_runtime.compact.wasm` and the file path should be something like this:
11+
* The executable binary and the runtime WASM blob of the target blockchain. You can either compile them from the source code of the blockchain project, or copy them from a trusted node that runs the blockchain. For TFchain, you can find the source code [here](https://github.com/threefoldtech/tfchain) and the instructions on how to compile it [here](https://github.com/threefoldtech/tfchain/tree/development/docs/development). Find the Wasm binary file in the target directory. The file name should be `tfchain_runtime.compact.wasm` and the file path should be something like this:
1112

1213
```bash
1314
./substrate-node/target/debug/wbuild/tfchain-runtime/tfchain_runtime.compact.wasm
1415
```
1516

1617
### Steps
17-
- Install the `fork-off-substrate` tool dependencies on your computer, go to `tfchain` directory then follow these steps:
18+
19+
* Install the `fork-off-substrate` tool dependencies on your computer, go to `tfchain` directory then follow these steps:
1820
```bash
1921
cd ./tools/fork-off-substrate
2022
npm i
2123
```
22-
- Create a folder called data inside the top folder (fork-off-substrate).
24+
* Create a folder called data inside the top folder (fork-off-substrate).
2325
```bash
2426
mkdir data
2527
```
26-
- Copy the executable/binary of your substrate based node inside the data folder and rename it to `binary`
28+
* Copy the executable/binary of your substrate based node inside the data folder and rename it to `binary`
2729
```bash
2830
cp ../../substrate-node/target/debug/tfchain ./data/binary
2931
```
30-
- Copy the runtime WASM blob of your substrate based blockchain to the data folder and rename it to `runtime.wasm`.
32+
* Copy the runtime WASM blob of your substrate based blockchain to the data folder and rename it to `runtime.wasm`.
3133
```bash
3234
cp ../../substrate-node/target/debug/wbuild/tfchain-runtime/tfchain_runtime.compact.wasm ./data/runtime.wasm
3335
```
34-
- Run a full node for your blockchain locally (Recommended but should be fully synced) or have an external endpoint handy (but should be running with `--rpc-methods Unsafe` flag)
36+
* Run a full node for your blockchain locally (Recommended but should be fully synced) or have an external endpoint handy (but should be running with `--rpc-methods Unsafe` flag)
3537
```bash
36-
../../substrate-node/target/debug/tfchain --chain ../../substrate-node/chainspecs/dev/chainSpecRaw.json --ws-external --rpc-methods Unsafe
38+
../../substrate-node/target/debug/tfchain --chain ../../substrate-node/chainspecs/dev/chainSpecRaw.json --rpc-external --rpc-methods Unsafe
3739
```
38-
- Run the script
40+
* Run the script
3941

40-
- If using a local node, simply run the script using
42+
* If using a local node, simply run the script using
4143
```bash
4244
npm start
4345
```
4446

45-
- If you are using an external/non-default endpoint, you need to provide it to the script via the HTTP_RPC_ENDPOINT environment variable
47+
* If you are using an external/non-default endpoint, you need to provide it to the script via the HTTP\_RPC\_ENDPOINT environment variable
4648
```bash
4749
HTTP_RPC_ENDPOINT=https://<EXTERNAL END POINT> npm start
4850
```
49-
- You should have the genesis file for the forked chain inside the data folder. It will be called `fork.json`.
50-
- You can now run a new chain using this genesis file
51+
* You should have the genesis file for the forked chain inside the data folder. It will be called `fork.json`.
52+
* You can now run a new chain using this genesis file
5153
```bash
5254
./data/binary --chain ./data/fork.json --alice
5355
```
5456

55-
for more information about this tool, you can read this [blog post](https://mudit.blog/fork-substrate-blockchain/).
57+
for more information about this tool, you can read this [blog post](https://mudit.blog/fork-substrate-blockchain/).

docs/development/local_multinode.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ cd substrate-node
99
cargo build
1010
```
1111

12-
you can
12+
you can
13+
1314
## Start the network
1415

1516
In a terminal window execute the following command:
@@ -20,8 +21,7 @@ In a terminal window execute the following command:
2021
--chain local \
2122
--alice \
2223
--port 30333 \
23-
--ws-port 9945 \
24-
--rpc-port 9933 \
24+
--rpc-port 9945 \
2525
--node-key 0000000000000000000000000000000000000000000000000000000000000001 \
2626
--validator
2727
```
@@ -36,8 +36,7 @@ In a second terminal window executing the following command:
3636
--chain local \
3737
--bob \
3838
--port 30334 \
39-
--ws-port 9946 \
40-
--rpc-port 9934 \
39+
--rpc-port 9946 \
4140
--telemetry-url "wss://telemetry.polkadot.io/submit/ 0" \
4241
--validator \
4342
--bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp
@@ -73,25 +72,23 @@ Verify that you see lines similar to the following in the terminal where you sta
7372
7473
In these lines, you can see the following information about your blockchain:
7574
76-
- The second node identity was discovered on the network (12D3KooWBCbmQovz78Hq7MzPxdx9d1gZzXMsn6HtWj29bW51YUKB).
77-
- The node has a one peer (1 peers).
78-
- The nodes have produced some blocks (best: #3 (0x0c55…d51b)).
79-
- The blocks are being finalized (finalized #1 (0xf086…9847)).
75+
* The second node identity was discovered on the network (12D3KooWBCbmQovz78Hq7MzPxdx9d1gZzXMsn6HtWj29bW51YUKB).
76+
* The node has a one peer (1 peers).
77+
* The nodes have produced some blocks (best: #3 (0x0c55…d51b)).
78+
* The blocks are being finalized (finalized #1 (0xf086…9847)).
8079
8180
## Review the command-line options
8281
8382
Before moving on, have a look at how the following options are used to start the node.
8483
85-
- --base-path Specifies the directory for storing all of the data related to this chain.
86-
- --chain local Specifies the chain specification to use. Valid predefined chain specifications include local, development, and staging.
87-
- --alice Adds the predefined keys for the alice account to the node's keystore. With this setting, the alice account is used for block production and finalization.
88-
- --port 30333 Specifies the port to listen on for peer-to-peer (p2p) traffic. Because this tutorial uses two nodes running on the same physical computer to simulate a network, you must explicitly specify a different port for at least one account.
89-
- --ws-port 9945 Specifies the port to listen on for incoming WebSocket traffic. The default port is 9944. This tutorial uses a custom web socket port number (9945).
90-
- --rpc-port 9933 Specifies the port to listen on for incoming RPC traffic. The default port is 9933.
91-
- --node-key <key> Specifies the Ed25519 secret key to use for libp2p networking. You should only use this option for development and testing.
92-
- --telemetry-url Specifies where to send telemetry data. For this tutorial, you can send telemetry data to a server hosted by Parity that is available for anyone to use.
93-
- --validator Specifies that this node participates in block production and finalization for the network.
94-
84+
* \--base-path Specifies the directory for storing all of the data related to this chain.
85+
* \--chain local Specifies the chain specification to use. Valid predefined chain specifications include local, development, and staging.
86+
* \--alice Adds the predefined keys for the alice account to the node's keystore. With this setting, the alice account is used for block production and finalization.
87+
* \--port 30333 Specifies the port to listen on for peer-to-peer (p2p) traffic. Because this tutorial uses two nodes running on the same physical computer to simulate a network, you must explicitly specify a different port for at least one account.
88+
* \--rpc-port 9945 Specifies the port to listen on for incoming RPC traffic. The default port is 9944.
89+
* \--node-key <key> Specifies the Ed25519 secret key to use for libp2p networking. You should only use this option for development and testing.
90+
* \--telemetry-url Specifies where to send telemetry data. For this tutorial, you can send telemetry data to a server hosted by Parity that is available for anyone to use.
91+
* \--validator Specifies that this node participates in block production and finalization for the network.
9592
9693
## What next
9794

0 commit comments

Comments
 (0)