Selaa lähdekoodia

fixed fork-off.ts & migration script fixes

ignazio 3 vuotta sitten
vanhempi
commit
7e6ece8bb4

+ 0 - 2
tests/network-tests/.env

@@ -56,5 +56,3 @@ STAKE_DECREMENT=3
 MINT_CAPACITY_INCREMENT=1000
 # Storage node address to download content from
 STORAGE_NODE_URL=http://localhost:3001/asset/v0
-# Weather or not to clone chain live state using fork-off
-CLONE_LIVE_STATE=$false

+ 1 - 0
tests/network-tests/node-utils.sh

@@ -120,6 +120,7 @@ function cleanup() {
     # fi
     docker-compose -f ../../docker-compose.yml down -v
     find ./assets/ -name '[A-Z0-9]*__rejectedContent.json' -delete
+    rm -rf $DATA_PATH
 }
 
 #######################################

+ 12 - 15
tests/network-tests/run-migration-tests.sh

@@ -19,6 +19,8 @@ POST_MIGRATION_CLI_ASSERTIONS=${POST_MIGRATION_CLI_ASSERTIONS=$true}
 # Post migration assertions by means of typescript scenarios required
 POST_MIGRATION_ASYNC_ASSERTIONS=${POST_MIGRATION_ASYNC_ASSERTIONS=$false}
 
+export WS_RPC_ENDPOINT="wss://testnet-rpc-3-uk.joystream.org"
+    
 # source common function used for node setup
 source ./node-utils.sh
 source ./.env
@@ -33,16 +35,13 @@ source ./.env
 function fork_off_init() {
     # chain-spec-raw already existing
 
-    WS_RPC_ENDPOINT="wss://testnet-rpc-3-uk.joystream.org"
-    
-    if ! [[ -f "$(pwd)/storage.json" ]]; then
+    if ! [[ -f $(pwd)/storage.json ]]; then
 	scp ignazio@testnet-rpc-3-uk.joystream.org:/home/ignazio/storage.json ./storage.json
-	cp ./storage.json ${DATA_PATH}/storage.json
     fi
+	cp $(pwd)/storage.json ${DATA_PATH}/storage.json    
 
     if ! [[ -f ${DATA_PATH}/schema.json ]]; then
-	cp $(pwd)/../../types/augment/all/defs.json \
-	     ${DATA_PATH}/schema.json
+	cp $(pwd)/../../types/augment/all/defs.json ${DATA_PATH}/schema.json
     fi
 
     id=$(docker create joystream/node:${TARGET_RUNTIME_TAG})
@@ -148,18 +147,16 @@ function main {
     convert_chainspec
     echo "**** EMPTY CHAINSPEC CREATED SUCCESSFULLY ****"
 
-    if ( $CLONE_LIVE_STATE ); then
-	# use forkoff to update chainspec with the live state + update runtime code
-	fork_off_init
-    else
-	# use the uprade_runtime to upgrade runtime code
-	upgrade_runtime
-    fi
-    
+    # use forkoff to update chainspec with the live state + update runtime code
+    # fork_off_init
+
+    echo "***** STARTING NODE WITH FORKED STATE *****"
+    JOYSTREAM_NODE_TAG=$TARGET_RUNTIME_TAG
+    CONTAINER_ID=$(start_node)
 
     # Section C: assertions
     # verify that the number of outstanding channels & videos == 0
-    if [[ $POST_MIGRATION_CLI_ASSERTIONS ]]; then
+    if ( $POST_MIGRATION_CLI_ASSERTIONS ); then
 	# verify assertion using cli
 	echo "***** POST MIGRATION CLI *****"
 	post_migration_cli

+ 11 - 10
utils/api-scripts/src/fork-off.ts

@@ -31,14 +31,15 @@ const provider = new WsProvider(process.env.WS_RPC_ENDPOINT || 'http://localhost
 let prefixes = ['0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9' /* System.Account */];
 const skippedModulesPrefix = ['System', 'Session', 'Babe', 'Grandpa', 'GrandpaFinality', 'FinalityTracker', 'Authorship'];
 
-async function fixParachinStates(api: ApiPromise, chainSpec: any) {
-    const skippedKeys = [
-        api.query["parasScheduler"].sessionStartBlock.key()
-    ];
-    for (const k of skippedKeys) {
-        delete chainSpec.genesis.raw.top[k];
-    }
-}
+// Apparently not needed: To review
+// async function fixParachinStates(api: ApiPromise, chainSpec: any) {
+//     const skippedKeys = [
+//         api.query["parasScheduler"].sessionStartBlock.key()
+//     ];
+//     for (const k of skippedKeys) {
+//         delete chainSpec.genesis.raw.top[k];
+//     }
+// }
 
 async function main() {
 
@@ -89,7 +90,7 @@ async function main() {
     // Delete System.LastRuntimeUpgrade to ensure that the on_runtime_upgrade event is triggered
     delete chainSpec.genesis.raw.top['0x26aa394eea5630e07c48ae0c9558cef7f9cce9c888469bb1a0dceaa129672ef8'];
 
-    fixParachinStates(api, chainSpec);
+    //    fixParachinStates(api, chainSpec);
 
     // Set the code to the current runtime code: this replaces the set code transaction
     chainSpec.genesis.raw.top['0x3a636f6465'] = '0x' + fs.readFileSync(hexPath, 'utf8').trim();
@@ -104,7 +105,7 @@ async function main() {
 
     fs.writeFileSync(specPath, JSON.stringify(chainSpec, null, 4));
 
-    console.log('Forked genesis generated successfully. Find it at ./data/fork.json');
+    console.log('****** INITIAL CHAINSPEC UPDATED TO REFLECT LIVE STATE ******');
     process.exit();
 }