Преглед на файлове

chain-spec-builder: upgrade to substrate v2.0.1

conectado преди 3 години
родител
ревизия
64680707c4
променени са 6 файла, в които са добавени 122 реда и са изтрити 7 реда
  1. 50 0
      Cargo.lock
  2. 1 1
      Cargo.toml
  3. 1 1
      setup.sh
  4. 64 0
      tests/network-tests/run-local-node-test.sh
  5. 5 5
      utils/chain-spec-builder/Cargo.toml
  6. 1 0
      utils/chain-spec-builder/src/main.rs

+ 50 - 0
Cargo.lock

@@ -729,6 +729,21 @@ dependencies = [
  "zeroize",
 ]
 
+[[package]]
+name = "chain-spec-builder"
+version = "3.1.0"
+dependencies = [
+ "ansi_term 0.12.1",
+ "enum-utils",
+ "joystream-node",
+ "rand 0.7.3",
+ "sc-chain-spec",
+ "sc-keystore",
+ "sc-telemetry",
+ "sp-core",
+ "structopt",
+]
+
 [[package]]
 name = "chrono"
 version = "0.4.19"
@@ -1188,6 +1203,30 @@ version = "1.6.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
 
+[[package]]
+name = "enum-utils"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed327f716d0d351d86c9fd3398d20ee39ad8f681873cc081da2ca1c10fed398a"
+dependencies = [
+ "enum-utils-from-str",
+ "failure",
+ "proc-macro2",
+ "quote",
+ "serde_derive_internals",
+ "syn",
+]
+
+[[package]]
+name = "enum-utils-from-str"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d49be08bad6e4ca87b2b8e74146987d4e5cb3b7512efa50ef505b51a22227ee1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+]
+
 [[package]]
 name = "env_logger"
 version = "0.7.1"
@@ -6452,6 +6491,17 @@ dependencies = [
  "syn",
 ]
 
+[[package]]
+name = "serde_derive_internals"
+version = "0.25.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1dbab34ca63057a1f15280bdf3c39f2b1eb1b54c17e98360e511637aef7418c6"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
 [[package]]
 name = "serde_json"
 version = "1.0.64"

+ 1 - 1
Cargo.toml

@@ -17,7 +17,7 @@ members = [
 	"runtime-modules/working-group",
 	"runtime-modules/content",
 	"node",
-	#"utils/chain-spec-builder/"
+	"utils/chain-spec-builder/"
 ]
 
 [profile.release]

+ 1 - 1
setup.sh

@@ -45,4 +45,4 @@ volta install npx
 
 echo "Starting new terminal/shell session to make newly installed tools available."
 
-exec bash -l
+exec bash -l

+ 64 - 0
tests/network-tests/run-local-node-test.sh

@@ -0,0 +1,64 @@
+# Location that will be mounted as the /data volume in containers
+# This is how we access the initial members and balances files from
+# the containers and where generated chainspec files will be located.
+DATA_PATH="test-data"
+
+# Initial account balance for Alice
+# Alice is the source of funds for all new accounts that are created in the tests.
+ALICE_INITIAL_BALANCE=100000000
+
+rm -Rf ${DATA_PATH}
+mkdir -p ${DATA_PATH}
+
+echo "{
+  \"balances\":[
+    [\"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY\", ${ALICE_INITIAL_BALANCE}]
+  ]
+}" > ${DATA_PATH}/initial-balances.json
+
+# Make Alice a member
+echo '
+  [{
+    "member_id": 0,
+    "root_account": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
+    "controller_account": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
+    "handle":"alice_with_a_long_handle",
+    "avatar_uri":"https://alice.com/avatar.png",
+    "about":"Alice",
+    "name": "Alice",
+    "registered_at_time": 0
+  },
+  {
+    "member_id": 1,
+    "root_account": "5FUeDYFzvvizNhhHyidsuchG7jnToKj7zfimbWBpWKzT9Fqe",
+    "controller_account": "5FUeDYFzvvizNhhHyidsuchG7jnToKj7zfimbWBpWKzT9Fqe",
+    "handle":"bob_with_a_long_handle",
+    "avatar_uri":"https://bob.com/avatar.png",
+    "about":"Bob",
+    "name": "Bob",
+    "registered_at_time": 0
+  }
+]
+' > ${DATA_PATH}/initial-members.json
+
+# Create a chain spec file
+./target/release/chain-spec-builder generate -a 2 -e 2 -k ${DATA_PATH} --chain-spec-path ${DATA_PATH}/chain-spec.json --initial-balances-path ${DATA_PATH}/initial-balances.json --initial-members-path ${DATA_PATH}/initial-members.json --deployment live > ${DATA_PATH}/seeds
+
+jq -c '.id = "js_babylon_test"' ${DATA_PATH}/chain-spec.json > tmp.$$.json && mv tmp.$$.json ${DATA_PATH}/chain-spec.json
+jq -c '.protocolId = "js/babylon/test"' ${DATA_PATH}/chain-spec.json > tmp.$$.json && mv tmp.$$.json ${DATA_PATH}/chain-spec.json
+
+timeout 3s ./target/release/joystream-node --base-path ${DATA_PATH}/alice3  --validator --chain ${DATA_PATH}/chain-spec.json
+
+
+timeout 3s ./target/release/joystream-node --base-path ${DATA_PATH}/bob4  --validator --port 30334 --ws-port 9945 --chain ${DATA_PATH}/chain-spec.json
+
+
+mv  ${DATA_PATH}/auth-0/* ${DATA_PATH}/alice3/chains/js_babylon_test/keystore
+mv  ${DATA_PATH}/auth-1/* ${DATA_PATH}/bob4/chains/js_babylon_test/keystore
+
+rm -Rf ${DATA_PATH}/alice3/chains/js_babylon_test/db
+rm -Rf ${DATA_PATH}/bob4/chains/js_babylon_test/db
+
+# RUN
+#./target/release/joystream-node --base-path test-data/alice3  --validator --chain test-data/chain-spec.json --pruning=archive --log runtime,txpool,transaction-pool
+#./target/release/joystream-node --base-path test-data/bob4 --validator --port 30334 --ws-port 9945 --chain test-data/chain-spec.json --pruning=archive --log runtime,txpool,transaction-pool

+ 5 - 5
utils/chain-spec-builder/Cargo.toml

@@ -9,10 +9,10 @@ version = '3.1.0'
 ansi_term = "0.12.1"
 rand = "0.7.2"
 structopt = "0.3.8"
-sc-keystore = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-telemetry = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sc-chain-spec = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
-sp-core = { git = 'https://github.com/paritytech/substrate.git', rev = '00768a1f21a579c478fe5d4f51e1fa71f7db9fd4' }
+sc-keystore = { git = 'https://github.com/paritytech/substrate.git', rev = '2cd20966cc09b059817c3ebe12fc130cdd850d62' }
+sc-telemetry = { git = 'https://github.com/paritytech/substrate.git', rev = '2cd20966cc09b059817c3ebe12fc130cdd850d62' }
+sc-chain-spec = { git = 'https://github.com/paritytech/substrate.git', rev = '2cd20966cc09b059817c3ebe12fc130cdd850d62' }
+sp-core = { git = 'https://github.com/paritytech/substrate.git', rev = '2cd20966cc09b059817c3ebe12fc130cdd850d62' }
 joystream-node = { path = "../../node" }
 
-enum-utils = "0.1.2"
+enum-utils = "0.1.2"

+ 1 - 0
utils/chain-spec-builder/src/main.rs

@@ -48,6 +48,7 @@ enum ChainDeployment {
     live,
 }
 
+#[allow(clippy::from_over_into)]
 impl Into<ChainType> for ChainDeployment {
     fn into(self) -> ChainType {
         match self {