Skip to content

Commit

Permalink
Merge pull request #343 from valory-xyz/develop
Browse files Browse the repository at this point in the history
Release 0.19.3
  • Loading branch information
jmoreira-valory authored Aug 28, 2024
2 parents 3f12eea + 62ee394 commit 257d706
Show file tree
Hide file tree
Showing 12 changed files with 297 additions and 3,283 deletions.
614 changes: 0 additions & 614 deletions contracts/AgentMech.json

This file was deleted.

1,899 changes: 0 additions & 1,899 deletions contracts/ServiceRegistryL2.json

This file was deleted.

279 changes: 0 additions & 279 deletions contracts/wxdai.json

This file was deleted.

58 changes: 37 additions & 21 deletions run_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ensure_minimum_balance() {
if [ "$cycle_count" -eq 100 ]; then
balance_hex=$(get_balance "$address")
balance=$(hex_to_decimal "$balance_hex")
balance=$((erc20_balance+balance))
balance=$($PYTHON_CMD -c "print(int($balance) + int($erc20_balance))")
cycle_count=0
fi
done
Expand Down Expand Up @@ -673,6 +673,12 @@ echo ""
echo "This script will assist you in setting up and running the Trader service ($service_repo)."
echo ""

# Display information of the Git repository
current_branch=$(git rev-parse --abbrev-ref HEAD)
latest_commit_hash=$(git rev-parse HEAD)
echo "Current branch: $current_branch"
echo "Commit hash: $latest_commit_hash"

# Check the command-line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
Expand Down Expand Up @@ -880,15 +886,26 @@ remote_service_hash=$(poetry run python "../scripts/service_hash.py")
operator_address=$(get_address "../$operator_keys_file")
on_chain_agent_id=$(get_on_chain_agent_ids "$service_id")

if [ "$local_service_hash" != "$remote_service_hash" ] || [ "$on_chain_agent_id" != "$AGENT_ID" ]; then
# On-chain agent bond for the expected agent ID ($AGENT_ID)
on_chain_agent_bond=$(poetry run python "../scripts/get_agent_bond.py" "$CUSTOM_SERVICE_REGISTRY_TOKEN_UTILITY_ADDRESS" "$service_id" "$AGENT_ID" "$rpc")

if [ "${USE_STAKING}" = true ]; then
cost_of_bonding=$MIN_STAKING_BOND_OLAS
else
cost_of_bonding=$MIN_STAKING_BOND_XDAI
fi

if [ "$local_service_hash" != "$remote_service_hash" ] || [ "$on_chain_agent_id" != "$AGENT_ID" ] || [ "$on_chain_agent_bond" != "$cost_of_bonding" ]; then
echo ""
echo "WARNING: Your on-chain service configuration is out-of-date"
echo "-----------------------------------------------------------"
echo "Your currently minted on-chain service (id $service_id) mismatches the local configuration:"
echo " - Local service hash ($service_version): $local_service_hash"
echo " - On-chain service hash: $remote_service_hash"
echo " - Local agent id: $AGENT_ID"
echo " - Expected agent id: $AGENT_ID"
echo " - On-chain agent id: $on_chain_agent_id"
echo " - Expected agent bond: $cost_of_bonding"
echo " - On-chain agent bond: $on_chain_agent_bond"
echo ""
echo "This is most likely caused due to an update of the trader service code or agent id."
echo "The script will proceed now to update the on-chain service."
Expand Down Expand Up @@ -971,25 +988,26 @@ if [ "$local_service_hash" != "$remote_service_hash" ] || [ "$on_chain_agent_id"
verify_staking_slots

nft="bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq"
export cmd=""
cmd="poetry run autonomy mint \
--retries $RPC_RETRIES \
--timeout $RPC_TIMEOUT_SECONDS \
--use-custom-chain \
service packages/valory/services/trader/ \
--key \"../$operator_pkey_path\" $password_argument \
--nft $nft \
-a $AGENT_ID \
-n $n_agents \
--threshold $n_agents \
--update \"$service_id\""

if [ "${USE_STAKING}" = true ]; then
cost_of_bonding=$MIN_STAKING_BOND_OLAS
poetry run python "../scripts/update_service.py" "../$operator_pkey_path" "$nft" "$AGENT_ID" "$service_id" "$CUSTOM_OLAS_ADDRESS" "$cost_of_bonding" "packages/valory/services/trader/" "$rpc" $password_argument
cmd+=" -c $cost_of_bonding --token $CUSTOM_OLAS_ADDRESS"
else
cost_of_bonding=$MIN_STAKING_BOND_XDAI
cmd="poetry run autonomy mint \
--retries $RPC_RETRIES \
--timeout $RPC_TIMEOUT_SECONDS \
--use-custom-chain \
service packages/valory/services/trader/ \
--key \"../$operator_pkey_path\" $password_argument \
--nft $nft \
-a $AGENT_ID \
-n $n_agents \
-c $cost_of_bonding \
--threshold $n_agents \
--update \"$service_id\""
cmd+=" -c $cost_of_bonding"
fi

eval "$cmd"

# Updating a service does not change the on-chain service state.
Expand Down Expand Up @@ -1071,9 +1089,7 @@ fi
# perform staking operations
# the following will stake the service in case it is not staked, and there are available rewards
# if the service is already staked, and there are no available rewards, it will unstake the service
if [ "${USE_STAKING}" = true ]; then
perform_staking_ops
fi
perform_staking_ops


# ensure Safe owner is agent
Expand Down Expand Up @@ -1131,7 +1147,7 @@ export STOP_TRADING_IF_STAKING_KPI_MET=true
export RESET_PAUSE_DURATION=45
export MECH_WRAPPED_NATIVE_TOKEN_ADDRESS=$WXDAI_ADDRESS
export MECH_CHAIN_ID=ethereum
export TOOLS_ACCURACY_HASH=QmZnwodYVedKYChEUtGVVCCw2FCYP9xPQFYK3yL7VHXkid
export TOOLS_ACCURACY_HASH=QmceqDQixda5tU6BBNTYFqBTqfhVeqeBC4NhsC136WYEvP

if [ -n "$SUBGRAPH_API_KEY" ]; then
export CONDITIONAL_TOKENS_SUBGRAPH_URL="https://gateway-arbitrum.network.thegraph.com/api/$SUBGRAPH_API_KEY/subgraphs/id/7s9rGBffUTL8kDZuxvvpuc46v44iuDarbrADBFw5uVp2"
Expand Down
Loading

0 comments on commit 257d706

Please sign in to comment.