Created
September 1, 2021 21:42
-
-
Save 2075/a964f2b2a420d2fdd730102c7088e24b to your computer and use it in GitHub Desktop.
polkadot+kusama: create a local relaychain and parachain setup
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
# setup your node parameters here | |
ROOT_DIR = $(CURDIR) | |
RELAY_DIR = $(ROOT_DIR)/polkadot | |
RELAY_NAME = rococo-local | |
PARA_NAME = gamedao | |
PARA_DIR = $(ROOT_DIR)/$(PARA_NAME)-parachain | |
RES_DIR = $(ROOT_DIR)/resources | |
PARA_ID = 2075 | |
# build all nodes and required configs and specs | |
build: build-relay setup-relay build-parachain build-parachain-genesis | |
build-relay: | |
@echo build relay chain | |
@cargo build --release --manifest-path $(RELAY_DIR)/Cargo.toml | |
@echo build complete | |
@$(RELAY_DIR)/target/release/polkadot --version | |
setup-relay: | |
@echo build chain spec for $(RELAY_NAME) relay | |
@mkdir -p $(RES_DIR) | |
@$(RELAY_DIR)/target/release/polkadot build-spec \ | |
--chain $(RELAY_NAME) \ | |
--raw \ | |
--disable-default-bootnode \ | |
> $(RES_DIR)/$(RELAY_NAME).json | |
run-relay: run-relay-alice | |
run-relay-alice: | |
@echo run relay node alice | |
@$(RELAY_DIR)/target/release/polkadot \ | |
--chain $(RES_DIR)/$(RELAY_NAME).json \ | |
-d $(ROOT_DIR)/tmp/$(RELAY_NAME)/alice \ | |
--validator \ | |
--alice \ | |
--port 50555 | |
# for the second node on the test relay, | |
# you need to grab the node address from the alice node, | |
# e.g. /ip4/172.27.0.1/tcp/50555/p2p/12D3KooWHrmghkzzo4YvqnYgLFX2YG3ebyg65uynyZk4hQtJsaXa | |
# and run the bob node like this: make BOOTNODE=<alice-node-address> run-relay-bob | |
run-relay-bob: | |
@echo run relay node bob | |
@$(RELAY_DIR)/target/release/polkadot \ | |
--chain $(RES_DIR)/$(RELAY_NAME).json \ | |
-d $(ROOT_DIR)/tmp/$(RELAY_NAME)/bob \ | |
--validator \ | |
--bob \ | |
--port 50556 \ | |
--bootnodes=$(BOOTNODE) | |
build-parachain: | |
@echo build parachain $(PARA_NAME) | |
@cargo build --release --manifest-path $(PARA_DIR)/Cargo.toml | |
@echo build complete | |
@$(PARA_DIR)/target/release/parachain-collator --version | |
setup-parachain: | |
@echo build the chainspec | |
@mkdir -p $(RES_DIR) | |
@$(PARA_DIR)/target/release/parachain-collator build-spec \ | |
--disable-default-bootnode \ | |
> $(RES_DIR)/$(PARA_NAME)-plain-$(PARA_ID).json | |
@sed -i 's/"para_id": [^\]*/"para_id": $(PARA_ID),/' $(RES_DIR)/$(PARA_NAME)-plain-$(PARA_ID).json | |
@sed -i 's/"parachainId": [^\]*/"parachainId": $(PARA_ID)/' $(RES_DIR)/$(PARA_NAME)-plain-$(PARA_ID).json | |
@echo build the raw chainspec file | |
@$(PARA_DIR)/target/release/parachain-collator build-spec \ | |
--chain=$(RES_DIR)/$(PARA_NAME)-plain-$(PARA_ID).json \ | |
--raw \ | |
--disable-default-bootnode \ | |
> $(RES_DIR)/$(PARA_NAME)-raw-$(PARA_ID).json | |
@echo export genesis state using ParaId $(PARA_ID) | |
@$(PARA_DIR)/target/release/parachain-collator export-genesis-state \ | |
--parachain-id $(PARA_ID) \ | |
> $(RES_DIR)/$(PARA_NAME)-$(PARA_ID)-genesis | |
@echo export the genesis wasm | |
@$(PARA_DIR)/target/release/parachain-collator export-genesis-wasm \ | |
> $(RES_DIR)/$(PARA_NAME)-$(PARA_ID)-wasm | |
@echo genesis complete for parachain $(PARA_NAME) with id $(PARA_ID) | |
run-parachain: run-parachain-collator | |
# for the collator node on the test relay, | |
# you need to grab the node address from the relay alice node, | |
# and run the node like this: make RELAY=<alice-realy-node-address> run-parachain-collator | |
run-parachain-collator: | |
@echo run parachain collator for $(PARA_NAME) | |
@$(PARA_DIR)/target/release/parachain-collator \ | |
-d $(ROOT_DIR)/tmp/$(PARA_NAME)/alice \ | |
--collator \ | |
--alice \ | |
--force-authoring \ | |
--ws-port 8844 \ | |
--parachain-id $(PARA_ID) \ | |
-- \ | |
--execution wasm \ | |
--chain $(RES_DIR)/$(RELAY_NAME).json \ | |
--port 30343 \ | |
--ws-port 9977 | |
--bootnodes=$(RELAY) | |
# for the second collator node on the test relay, | |
# you need to grab the node address from the collator alice node, | |
# e.g. /ip4/172.27.0.1/tcp/50555/p2p/12D3KooWHrmghkzzo4YvqnYgLFX2YG3ebyg65uynyZk4hQtJsaXa | |
# and the node address from the relay alice node | |
# and run the bob node like this: make BOOT=<alice-collator-node-address> RELAY=<alice-realy-node-address> run-parachain-collator-bob | |
run-parachain-collator-bob: | |
@echo run parachain collator for $(PARA_NAME) | |
@$(PARA_DIR)/target/release/parachain-collator \ | |
--bob \ | |
--collator \ | |
--force-authoring \ | |
--parachain-id $(PARA_ID) \ | |
-d $(ROOT_DIR)/tmp/$(PARA_NAME)/bob \ | |
--port 40334 \ | |
--ws-port 9946 \ | |
--bootnodes=$(BOOT) \ | |
-- \ | |
--execution wasm \ | |
--chain $(RES_DIR)/$(RELAY_NAME).json \ | |
--port 30344 \ | |
--ws-port 9978 | |
--bootnodes=$(RELAY) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment