From a5763a469ed6a636f0385efaeb4d21a94832d28b Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 3 Oct 2023 11:45:20 +0200 Subject: [PATCH 01/10] chore: update script --- run_service.sh | 196 +++++++++++++++++++++++++++---------------------- 1 file changed, 107 insertions(+), 89 deletions(-) diff --git a/run_service.sh b/run_service.sh index 32eb8b6d..18873020 100755 --- a/run_service.sh +++ b/run_service.sh @@ -287,6 +287,11 @@ else exit 1 fi +echo "" +echo "-----------------------------------------" +echo "Checking Autonolas Protocol service state" +echo "-----------------------------------------" + gnosis_chain_id=100 n_agents=1 @@ -362,43 +367,54 @@ then exit 1 fi - echo "[Service owner] Activating registration for service with id $service_id..." - # activate service - activation=$(poetry run autonomy service --use-custom-chain activate --key "$operator_pkey_file" "$service_id") - # validate activation - if ! [[ "$activation" = "Service activated succesfully" ]] - then - echo "Service registration activation failed: $activation" - exit 1 - fi - - echo "[Service owner] Registering agent instance for service with id $service_id..." - # register service - registration=$(poetry run autonomy service --use-custom-chain register --key "$operator_pkey_file" "$service_id" -a $agent_id -i "$agent_address") - # validate registration - if ! [[ "$registration" = "Agent instance registered succesfully" ]] - then - echo "Service registration failed: $registration" - exit 1 - fi - - echo "[Service owner] Deploying service with id $service_id..." - # deploy service - deployment=$(poetry run autonomy service --use-custom-chain deploy --key "$operator_pkey_file" "$service_id") - # validate deployment - if ! [[ "$deployment" = "Service deployed succesfully" ]] - then - echo "Service deployment failed: $deployment" - exit 1 - fi - - # delete the operator's pkey file - rm $operator_pkey_file - # store service id + # echo "[Service owner] Activating registration for service with id $service_id..." + # # activate service + # activation=$(poetry run autonomy service --use-custom-chain activate --key "$operator_pkey_file" "$service_id") + # # validate activation + # if ! [[ "$activation" = "Service activated succesfully" ]] + # then + # echo "Service registration activation failed: $activation" + # exit 1 + # fi + + # echo "[Service owner] Registering agent instance for service with id $service_id..." + # # register service + # registration=$(poetry run autonomy service --use-custom-chain register --key "$operator_pkey_file" "$service_id" -a $agent_id -i "$agent_address") + # # validate registration + # if ! [[ "$registration" = "Agent instance registered succesfully" ]] + # then + # echo "Service registration failed: $registration" + # exit 1 + # fi + + # echo "[Service owner] Deploying service with id $service_id..." + # # deploy service + # deployment=$(poetry run autonomy service --use-custom-chain deploy --key "$operator_pkey_file" "$service_id") + # # validate deployment + # if ! [[ "$deployment" = "Service deployed succesfully" ]] + # then + # echo "Service deployment failed: $deployment" + # exit 1 + # fi + + # # delete the operator's pkey file + # rm $operator_pkey_file + # # store service id echo -n "$service_id" > "../$service_id_path" fi -# Update the on-chain service if required +# generate private key files in the format required by the CLI tool +agent_pkey_file="agent_pkey.txt" +agent_pkey=$(get_private_key "../$keys_json_path") +agent_pkey="${agent_pkey#0x}" +echo -n "$agent_pkey" >"$agent_pkey_file" + +operator_pkey_file="operator_pkey.txt" +operator_pkey=$(get_private_key "../$operator_keys_file") +operator_pkey="${operator_pkey#0x}" +echo -n "$operator_pkey" >"$operator_pkey_file" + +# Update the on-chain service if outdated packages="packages/packages.json" local_service_hash="$(grep 'service' $packages | awk -F: '{print $2}' | tr -d '", ' | head -n 1)" remote_service_hash=$(poetry run python "../scripts/service_hash.py") @@ -433,17 +449,6 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then echo "Cancelling the on-chain service update prematurely could lead to an inconsistent state of the Safe or the on-chain service state, which may require manual intervention to resolve." echo "" - # generate private key files in the format required by the CLI tool - agent_pkey_file="agent_pkey.txt" - agent_pkey=$(get_private_key "../$keys_json_path") - agent_pkey="${agent_pkey#0x}" - echo -n "$agent_pkey" >"$agent_pkey_file" - - operator_pkey_file="operator_pkey.txt" - operator_pkey=$(get_private_key "../$operator_keys_file") - operator_pkey="${operator_pkey#0x}" - echo -n "$operator_pkey" >"$operator_pkey_file" - if [ $(get_on_chain_service_state $service_id) == "DEPLOYED" ]; then # transfer the ownership of the Safe from the agent to the service owner # (in a live service, this should be done by sending a 0 DAI transfer to its Safe) @@ -520,57 +525,60 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then fi fi - # activate service - if [ $(get_on_chain_service_state $service_id) == "PRE_REGISTRATION" ]; then - echo "[Service owner] Activating registration for on-chain service $service_id..." - output=$(poetry run autonomy service --use-custom-chain activate --key "$operator_pkey_file" "$service_id") - if [[ $? -ne 0 ]]; then - echo "Activating service failed.\n$output" - echo "Please, delete or rename the ./trader folder and try re-run this script again." - rm -f $agent_pkey_file - rm -f $operator_pkey_file - exit 1 - fi - fi + echo "" + echo "Finished updating on-chain service $service_id." +fi - # register agent instance - if [ $(get_on_chain_service_state $service_id) == "ACTIVE_REGISTRATION" ]; then - echo "[Operator] Registering agent instance for on-chain service $service_id..." - output=$(poetry run autonomy service --use-custom-chain register --key "$operator_pkey_file" "$service_id" -a $agent_id -i "$agent_address") - if [[ $? -ne 0 ]]; then - echo "Registering agent instance failed.\n$output" - echo "Please, delete or rename the ./trader folder and try re-run this script again." - rm -f $agent_pkey_file - rm -f $operator_pkey_file - exit 1 - fi +echo "" +echo "Ensuring on-chain service $service_id is in DEPLOYED state..." + +if [ $(get_on_chain_service_state $service_id) != "DEPLOYED" ]; then + suggested_amount=25000000000000000 + ensure_minimum_balance "$operator_address" $suggested_amount "operator's address" +fi + +# activate service +if [ $(get_on_chain_service_state $service_id) == "PRE_REGISTRATION" ]; then + echo "[Service owner] Activating registration for on-chain service $service_id..." + output=$(poetry run autonomy service --use-custom-chain activate --key "$operator_pkey_file" "$service_id") + if [[ $? -ne 0 ]]; then + echo "Activating service failed.\n$output" + echo "Please, delete or rename the ./trader folder and try re-run this script again." + rm -f $agent_pkey_file + rm -f $operator_pkey_file + exit 1 fi +fi - # deploy on-chain service - if [ $(get_on_chain_service_state $service_id) == "FINISHED_REGISTRATION" ]; then - echo "[Service owner] Deploying on-chain service $service_id..." - output=$(poetry run autonomy service --use-custom-chain deploy "$service_id" --key "$operator_pkey_file" --reuse-multisig) - if [[ $? -ne 0 ]]; then - echo "Deploying service failed.\n$output" - echo "Please, delete or rename the ./trader folder and try re-run this script again." - rm -f $agent_pkey_file - rm -f $operator_pkey_file - exit 1 - fi +# register agent instance +if [ $(get_on_chain_service_state $service_id) == "ACTIVE_REGISTRATION" ]; then + echo "[Operator] Registering agent instance for on-chain service $service_id..." + output=$(poetry run autonomy service --use-custom-chain register --key "$operator_pkey_file" "$service_id" -a $agent_id -i "$agent_address") + if [[ $? -ne 0 ]]; then + echo "Registering agent instance failed.\n$output" + echo "Please, delete or rename the ./trader folder and try re-run this script again." + rm -f $agent_pkey_file + rm -f $operator_pkey_file + exit 1 fi +fi - # delete the pkey files - rm -f $agent_pkey_file - rm -f $operator_pkey_file - echo "" - echo "Finished update of on-chain service $service_id." +# deploy on-chain service +if [ $(get_on_chain_service_state $service_id) == "FINISHED_REGISTRATION" ]; then + echo "[Service owner] Deploying on-chain service $service_id..." + output=$(poetry run autonomy service --use-custom-chain deploy "$service_id" --key "$operator_pkey_file" --reuse-multisig) + if [[ $? -ne 0 ]]; then + echo "Deploying service failed.\n$output" + echo "Please, delete or rename the ./trader folder and try re-run this script again." + rm -f $agent_pkey_file + rm -f $operator_pkey_file + exit 1 + fi fi -echo "" -echo "------------------------------" -echo "Starting the trader service..." -echo "------------------------------" -echo "" +# delete the pkey files +rm -f $agent_pkey_file +rm -f $operator_pkey_file # check state expected_state="| Service State | DEPLOYED |" @@ -584,6 +592,16 @@ then exit 1 fi +echo "" +echo "Finished checking Autonolas Protocol service $service_id state" + + +echo "" +echo "------------------------------" +echo "Starting the trader service..." +echo "------------------------------" +echo "" + # Get the deployed service's Safe address from the contract safe=$(echo "$service_info" | grep "Multisig Address") address_start_position=31 From 999e13654f97a96580af91791ea72af5399991e3 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 3 Oct 2023 11:57:21 +0200 Subject: [PATCH 02/10] chore: update script --- run_service.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/run_service.sh b/run_service.sh index 18873020..9b2a8d95 100755 --- a/run_service.sh +++ b/run_service.sh @@ -304,6 +304,7 @@ export CUSTOM_GNOSIS_SAFE_MULTISIG_ADDRESS="0x3C1fF68f5aa342D296d4DEe4Bb1cACCA91 export CUSTOM_GNOSIS_SAFE_PROXY_FACTORY_ADDRESS="0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE" export CUSTOM_GNOSIS_SAFE_SAME_ADDRESS_MULTISIG_ADDRESS="0x3d77596beb0f130a4415df3D2D8232B3d3D31e44" export CUSTOM_MULTISEND_ADDRESS="0x40A2aCCbd92BCA938b02010E17A5b8929b49130D" +export AGENT_ID=12 if [ "$first_run" = "true" ] then @@ -344,7 +345,6 @@ then echo "Minting your service on the Gnosis chain..." # create service - agent_id=12 cost_of_bonding=10000000000000000 nft="bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq" service_id=$(poetry run autonomy mint \ @@ -353,7 +353,7 @@ then service packages/valory/services/$directory/ \ --key "$operator_pkey_file" \ --nft $nft \ - -a $agent_id \ + -a $AGENT_ID \ -n $n_agents \ --threshold $n_agents \ -c $cost_of_bonding @@ -379,7 +379,7 @@ then # echo "[Service owner] Registering agent instance for service with id $service_id..." # # register service - # registration=$(poetry run autonomy service --use-custom-chain register --key "$operator_pkey_file" "$service_id" -a $agent_id -i "$agent_address") + # registration=$(poetry run autonomy service --use-custom-chain register --key "$operator_pkey_file" "$service_id" -a $AGENT_ID -i "$agent_address") # # validate registration # if ! [[ "$registration" = "Agent instance registered succesfully" ]] # then @@ -418,6 +418,8 @@ echo -n "$operator_pkey" >"$operator_pkey_file" packages="packages/packages.json" local_service_hash="$(grep 'service' $packages | awk -F: '{print $2}' | tr -d '", ' | head -n 1)" remote_service_hash=$(poetry run python "../scripts/service_hash.py") +service_safe_address=$(<"../$service_safe_address_path") +operator_address=$(get_address "../$operator_keys_file") if [ "$local_service_hash" != "$remote_service_hash" ]; then echo "" @@ -431,10 +433,7 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then echo "" # Check balances - service_safe_address=$(<"../$service_safe_address_path") - operator_address=$(get_address "../$operator_keys_file") - - suggested_amount=50000000000000000 + suggested_amount=50000000000000000 ensure_minimum_balance "$operator_address" $suggested_amount "operator's address" suggested_amount=50000000000000000 @@ -500,7 +499,6 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then # update service if [ $(get_on_chain_service_state $service_id) == "PRE_REGISTRATION" ]; then echo "[Service owner] Updating on-chain service $service_id..." - agent_id=12 cost_of_bonding=10000000000000000 nft="bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq" output=$( @@ -510,7 +508,7 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then service packages/valory/services/trader/ \ --key "$operator_pkey_file" \ --nft $nft \ - -a $agent_id \ + -a $AGENT_ID \ -n $n_agents \ --threshold $n_agents \ -c $cost_of_bonding \ @@ -553,7 +551,7 @@ fi # register agent instance if [ $(get_on_chain_service_state $service_id) == "ACTIVE_REGISTRATION" ]; then echo "[Operator] Registering agent instance for on-chain service $service_id..." - output=$(poetry run autonomy service --use-custom-chain register --key "$operator_pkey_file" "$service_id" -a $agent_id -i "$agent_address") + output=$(poetry run autonomy service --use-custom-chain register --key "$operator_pkey_file" "$service_id" -a $AGENT_ID -i "$agent_address") if [[ $? -ne 0 ]]; then echo "Registering agent instance failed.\n$output" echo "Please, delete or rename the ./trader folder and try re-run this script again." From 42d568296638e50ced5454333f99acad230ff295 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 3 Oct 2023 12:32:47 +0200 Subject: [PATCH 03/10] chore: update script --- run_service.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/run_service.sh b/run_service.sh index 9b2a8d95..3ccf96c5 100755 --- a/run_service.sh +++ b/run_service.sh @@ -579,10 +579,7 @@ rm -f $agent_pkey_file rm -f $operator_pkey_file # check state -expected_state="| Service State | DEPLOYED |" -service_info=$(poetry run autonomy service --use-custom-chain info "$service_id") -service_state=$(echo "$service_info" | grep "Service State") -if [ "$service_state" != "$expected_state" ] +if [ $(get_on_chain_service_state $service_id) != "DEPLOYED" ]; then then echo "Something went wrong while deploying the service. The service's state is:" echo "$service_state" From 529afcb11dfc2b74299a59d4955fdca4bfa36f21 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 3 Oct 2023 12:54:49 +0200 Subject: [PATCH 04/10] chore: update script --- run_service.sh | 47 +++++++---------------------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/run_service.sh b/run_service.sh index 3ccf96c5..bbaa1895 100755 --- a/run_service.sh +++ b/run_service.sh @@ -367,39 +367,6 @@ then exit 1 fi - # echo "[Service owner] Activating registration for service with id $service_id..." - # # activate service - # activation=$(poetry run autonomy service --use-custom-chain activate --key "$operator_pkey_file" "$service_id") - # # validate activation - # if ! [[ "$activation" = "Service activated succesfully" ]] - # then - # echo "Service registration activation failed: $activation" - # exit 1 - # fi - - # echo "[Service owner] Registering agent instance for service with id $service_id..." - # # register service - # registration=$(poetry run autonomy service --use-custom-chain register --key "$operator_pkey_file" "$service_id" -a $AGENT_ID -i "$agent_address") - # # validate registration - # if ! [[ "$registration" = "Agent instance registered succesfully" ]] - # then - # echo "Service registration failed: $registration" - # exit 1 - # fi - - # echo "[Service owner] Deploying service with id $service_id..." - # # deploy service - # deployment=$(poetry run autonomy service --use-custom-chain deploy --key "$operator_pkey_file" "$service_id") - # # validate deployment - # if ! [[ "$deployment" = "Service deployed succesfully" ]] - # then - # echo "Service deployment failed: $deployment" - # exit 1 - # fi - - # # delete the operator's pkey file - # rm $operator_pkey_file - # # store service id echo -n "$service_id" > "../$service_id_path" fi @@ -433,7 +400,7 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then echo "" # Check balances - suggested_amount=50000000000000000 + suggested_amount=50000000000000000 ensure_minimum_balance "$operator_address" $suggested_amount "operator's address" suggested_amount=50000000000000000 @@ -579,16 +546,15 @@ rm -f $agent_pkey_file rm -f $operator_pkey_file # check state -if [ $(get_on_chain_service_state $service_id) != "DEPLOYED" ]; then -then - echo "Something went wrong while deploying the service. The service's state is:" - echo "$service_state" - echo "Please check the output of the script for more information." +service_state=$(get_on_chain_service_state $service_id) +if [ "$service_state" != "DEPLOYED" ]; then + echo "Something went wrong while deploying on-chain service. The service's state is $service_state." + echo "Please check the output of the script and the on-chain registry for more information." exit 1 fi echo "" -echo "Finished checking Autonolas Protocol service $service_id state" +echo "Finished checking Autonolas Protocol service $service_id state." echo "" @@ -598,6 +564,7 @@ echo "------------------------------" echo "" # Get the deployed service's Safe address from the contract +service_info=$(poetry run autonomy service --use-custom-chain info "$service_id") safe=$(echo "$service_info" | grep "Multisig Address") address_start_position=31 safe=$(echo "$safe" | From 4c9f62141c1a10cdc22c06127aab0fe8089cef04 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 3 Oct 2023 13:08:13 +0200 Subject: [PATCH 05/10] chore: Update script --- run_service.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/run_service.sh b/run_service.sh index bbaa1895..6db2b2f9 100755 --- a/run_service.sh +++ b/run_service.sh @@ -438,7 +438,7 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then ) if [[ $? -ne 0 ]]; then echo "Terminating service failed.\n$output" - echo "Please, delete or rename the ./trader folder and try re-run this script again." + echo "Please, delete or rename the ./trader folder and try re-run this script again." rm -f $agent_pkey_file rm -f $operator_pkey_file exit 1 @@ -456,7 +456,7 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then ) if [[ $? -ne 0 ]]; then echo "Unbonding service failed.\n$output" - echo "Please, delete or rename the ./trader folder and try re-run this script again." + echo "Please, delete or rename the ./trader folder and try re-run this script again." rm -f $agent_pkey_file rm -f $operator_pkey_file exit 1 @@ -483,7 +483,7 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then ) if [[ $? -ne 0 ]]; then echo "Updating service failed.\n$output" - echo "Please, delete or rename the ./trader folder and try re-run this script again." + echo "Please, delete or rename the ./trader folder and try re-run this script again." rm -f $agent_pkey_file rm -f $operator_pkey_file exit 1 @@ -508,7 +508,7 @@ if [ $(get_on_chain_service_state $service_id) == "PRE_REGISTRATION" ]; then output=$(poetry run autonomy service --use-custom-chain activate --key "$operator_pkey_file" "$service_id") if [[ $? -ne 0 ]]; then echo "Activating service failed.\n$output" - echo "Please, delete or rename the ./trader folder and try re-run this script again." + echo "Please, delete or rename the ./trader folder and try re-run this script again." rm -f $agent_pkey_file rm -f $operator_pkey_file exit 1 From a115dca10aa9638a198da5e0e6a0d3e7f51794ed Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 3 Oct 2023 13:24:37 +0200 Subject: [PATCH 06/10] chore: update script --- run_service.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/run_service.sh b/run_service.sh index 6db2b2f9..0d8d874c 100755 --- a/run_service.sh +++ b/run_service.sh @@ -385,7 +385,6 @@ echo -n "$operator_pkey" >"$operator_pkey_file" packages="packages/packages.json" local_service_hash="$(grep 'service' $packages | awk -F: '{print $2}' | tr -d '", ' | head -n 1)" remote_service_hash=$(poetry run python "../scripts/service_hash.py") -service_safe_address=$(<"../$service_safe_address_path") operator_address=$(get_address "../$operator_keys_file") if [ "$local_service_hash" != "$remote_service_hash" ]; then @@ -418,6 +417,7 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then if [ $(get_on_chain_service_state $service_id) == "DEPLOYED" ]; then # transfer the ownership of the Safe from the agent to the service owner # (in a live service, this should be done by sending a 0 DAI transfer to its Safe) + service_safe_address=$(<"../$service_safe_address_path") echo "[Agent instance] Swapping Safe owner..." output=$(poetry run python "../scripts/swap_safe_owner.py" "$service_safe_address" "$agent_pkey_file" "$operator_address" "$rpc") if [[ $? -ne 0 ]]; then @@ -529,7 +529,18 @@ if [ $(get_on_chain_service_state $service_id) == "ACTIVE_REGISTRATION" ]; then fi # deploy on-chain service -if [ $(get_on_chain_service_state $service_id) == "FINISHED_REGISTRATION" ]; then +service_state=$(get_on_chain_service_state $service_id) +if [ "$service_state" == "FINISHED_REGISTRATION" ] && [ "$first_run" = "true" ]; then + echo "[Service owner] Deploying on-chain service $service_id..." + output=$(poetry run autonomy service --use-custom-chain deploy "$service_id" --key "$operator_pkey_file") + if [[ $? -ne 0 ]]; then + echo "Deploying service failed.\n$output" + echo "Please, delete or rename the ./trader folder and try re-run this script again." + rm -f $agent_pkey_file + rm -f $operator_pkey_file + exit 1 + fi +elif [ "$service_state" == "FINISHED_REGISTRATION" ]; then echo "[Service owner] Deploying on-chain service $service_id..." output=$(poetry run autonomy service --use-custom-chain deploy "$service_id" --key "$operator_pkey_file" --reuse-multisig) if [[ $? -ne 0 ]]; then From c56de66402beff694cf3ede779b4775e3a547d04 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 3 Oct 2023 13:27:51 +0200 Subject: [PATCH 07/10] chore: Update script --- run_service.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_service.sh b/run_service.sh index 0d8d874c..017a53fd 100755 --- a/run_service.sh +++ b/run_service.sh @@ -342,7 +342,7 @@ then suggested_amount=50000000000000000 ensure_minimum_balance "$operator_address" $suggested_amount "operator's address" - echo "Minting your service on the Gnosis chain..." + echo "[Service owner] Minting your service on the Gnosis chain..." # create service cost_of_bonding=10000000000000000 From abf389c97e30766680383b717954beb136d9045e Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 3 Oct 2023 13:39:36 +0200 Subject: [PATCH 08/10] chore: Update script --- run_service.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/run_service.sh b/run_service.sh index 017a53fd..6356cd62 100755 --- a/run_service.sh +++ b/run_service.sh @@ -414,6 +414,7 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then echo "Cancelling the on-chain service update prematurely could lead to an inconsistent state of the Safe or the on-chain service state, which may require manual intervention to resolve." echo "" + # TODO this condition should be increased to be service_state=DEPLOYED && current_safe_owner=agent_address. if [ $(get_on_chain_service_state $service_id) == "DEPLOYED" ]; then # transfer the ownership of the Safe from the agent to the service owner # (in a live service, this should be done by sending a 0 DAI transfer to its Safe) @@ -427,8 +428,10 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then exit 1 fi echo "$output" + fi - # terminate current service + # terminate current service + if [ $(get_on_chain_service_state $service_id) == "DEPLOYED" ]; then echo "[Service owner] Terminating on-chain service $service_id..." output=$( poetry run autonomy service \ @@ -462,7 +465,7 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then exit 1 fi fi - +exit 1 # update service if [ $(get_on_chain_service_state $service_id) == "PRE_REGISTRATION" ]; then echo "[Service owner] Updating on-chain service $service_id..." From c4fb759e4ea74019dfeea617d31f241eda2ea411 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 3 Oct 2023 13:42:12 +0200 Subject: [PATCH 09/10] chore: update script --- run_service.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_service.sh b/run_service.sh index 6356cd62..47a554d1 100755 --- a/run_service.sh +++ b/run_service.sh @@ -465,7 +465,7 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then exit 1 fi fi -exit 1 + # update service if [ $(get_on_chain_service_state $service_id) == "PRE_REGISTRATION" ]; then echo "[Service owner] Updating on-chain service $service_id..." From ae3f031085af8bdfa041100d18171f5f103cbf78 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Tue, 3 Oct 2023 13:45:55 +0200 Subject: [PATCH 10/10] chore: update script --- run_service.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/run_service.sh b/run_service.sh index 47a554d1..ae5e725c 100755 --- a/run_service.sh +++ b/run_service.sh @@ -415,6 +415,7 @@ if [ "$local_service_hash" != "$remote_service_hash" ]; then echo "" # TODO this condition should be increased to be service_state=DEPLOYED && current_safe_owner=agent_address. + # Otherwise the script will not recover the on-chain state in the (rare) case where this transaction succeeds but terminating transaction fails. if [ $(get_on_chain_service_state $service_id) == "DEPLOYED" ]; then # transfer the ownership of the Safe from the agent to the service owner # (in a live service, this should be done by sending a 0 DAI transfer to its Safe)