# Substrate node Build
### Build substrate node
```bash=
cargo build -p node-cli --release
```
### Gossamer(Bob account) init and run
```bash=
./bin/gossamer --chain dev init --config ~/go/src/github.com/ChainSafe/gossamer/chain/dev/config.toml --basepath /tmp/TestSync_ManyProducers/bob --genesis ~/go/src/github.com/ChainSafe/gossamer/chain/dev/genesis.json --force
./bin/gossamer --chain dev --port 9590 --config ~/go/src/github.com/ChainSafe/gossamer/chain/dev/config.toml --basepath /tmp/TestSync_ManyProducers/bob --rpchost localhost --rpcport 8541 --rpcmods system,author,chain,state,dev,rpc --rpc --log info --roles 4 --key bob --wsport 9541 --ws
```
### Substrate(Alice account) init and run
```bash=
./target/release/substrate --base-path /tmp/alice --chain ./genesis_Custom_dev.json --port 30333 --ws-port 9945 --rpc-port 9933 --validator --rpc-methods Unsafe --name Alice --bootnodes /ip4/127.0.0.1/tcp/9590/p2p/12D3KooWMHkFG8TU1x6yMdnRMdYphwxbvM4yb7Dr5csYsUiRW1s2
```
### Note:
1. Pass bootnode in command or add bootnode in genesis field.
2. Add `"childrenDefault": {}` in raw else substrate node throw error missing field childrenDefault.
3. Update `"consensusEngine": null` and remove `"consensusEngine": ""` from raw genesis file.
4. Copy dev raw genesis file and paste to substrate path or use the dev genesis path.

Gossamer bob node is able to connect to substrate alice node, peer count is increased by 1 in gossamer. But Substrate node (alice node) is showing 0 peers. Also substrate node neither building nor syncing blocks.

### Following scenarios, I have tried.
1. On running 6 substrate nodes + 1 gossamer node using Gossamer dev genesis. But no node was able to produce blocks. While gossamer node was producing blocks but none of the substrate node was syncing (bootnode provided).

2. Using substrate dev genesis. Gossamer with alice node and substrate with bob node. Alice is producing blocks at gossamer but bob is neither producing nor syncing.

Substrate with alice node producing blocks while gossamer node with bob node errored out.

```
./bin/gossamer --chain dev --port 9590 --config /Users/arijitdas/go/src/github.com/ChainSafe/gossamer/chain/dev/config.toml --basepath /tmp/TestSync_ManyProducers/bob --rpchost localhost --rpcport 8541 --rpcmods system,author,chain,state,dev,rpc --rpc --log info --roles 4 --key bob --wsport 9541 --ws
INFO[08-25|14:57:25] loading toml configuration... pkg=cmd config path=/Users/arijitdas/go/src/github.com/ChainSafe/gossamer/chain/dev/config.toml caller=config.go:62
WARN[08-25|14:57:25] overwriting default configuration with toml configuration values pkg=cmd id= config path=/Users/arijitdas/go/src/github.com/ChainSafe/gossamer/chain/dev/config.toml caller=config.go:66
INFO[08-25|14:57:25] loading toml configuration... pkg=cmd config path=./chain/dev/config.toml caller=config.go:108
INFO[08-25|14:57:25] loaded package log configuration pkg=cmd cfg="{CoreLvl:info SyncLvl:info NetworkLvl:info RPCLvl:info StateLvl:info RuntimeLvl:info BlockProducerLvl:info FinalityGadgetLvl:info}" caller=config.go:140
INFO[08-25|14:57:26] 🕸️ initialising node services... pkg=dot name=one-entire-39593 id=dev basepath=/tmp/TestSync_ManyProducers/bob caller=node.go:228
INFO[08-25|14:57:26] created state service pkg=state head=0x5e29b7eceae0e70030452a2eeac395b1885de7d99b70162d525d7e41c51257db highest number=0 caller=service.go:197
INFO[08-25|14:57:29] creating runtime... pkg=dot interpreter=wasmer caller=services.go:94
INFO[08-25|14:57:30] creating BABE service... pkg=dot authority=true caller=services.go:193
INFO[08-25|14:57:30] keystore pkg=dot keys=[0xc00031a610] caller=services.go:203
EROR[08-25|14:57:30] failed to initialise BABE service pkg=dot error="key not in BABE authority data" caller=services.go:228
EROR[08-25|14:57:30] failed to create node services pkg=cmd error="key not in BABE authority data" caller=main.go:301
key not in BABE authority data
```
3. On updating raw genesis for gossamer only for babe and grandpa authority without bootnodes. Both are creating blocks individually but not syncing.

On passing bootnodes in substrate node the substrate node panicked.

4. After updating babe and grandpa authorities for both genesis (substrate dev genesis).
Substrate node with alice key is not producing blocks and gossamer node with bob node is able to produce blocks.

Block production at gossamer node is slower than block production at substrate observed for substrate dev genesis but they didn't sync.
### Substrate dev genesis commands.
1. To save dev spec genesis command
```bash=
./target/release/substrate build-spec > myCustomSpec.json --dev
```
2. To create raw genesis from generated spec
```bash=
./target/release/substrate build-spec --chain=myCustomSpec.json --raw > customSpecRaw.json
```