Skip to content

Commit

Permalink
Merge pull request #251 from valory-xyz/feat/ofv-support-agent
Browse files Browse the repository at this point in the history
Feat/ofv support agent
  • Loading branch information
0xArdi authored Oct 3, 2024
2 parents ac2bd3a + 4181561 commit 56028df
Show file tree
Hide file tree
Showing 19 changed files with 2,572 additions and 1,342 deletions.
23 changes: 23 additions & 0 deletions deployment/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ARG AUTONOMY_IMAGE_VERSION="latest"
ARG AUTONOMY_IMAGE_NAME="valory/open-autonomy"
FROM ${AUTONOMY_IMAGE_NAME}:${AUTONOMY_IMAGE_VERSION}

ARG AEA_AGENT
ARG AUTHOR
ARG EXTRA_DEPENDENCIES

RUN aea init --reset --remote --ipfs --author ${AUTHOR}

WORKDIR /root

RUN AEA_AGENT=${AEA_AGENT} EXTRA_DEPENDENCIES=${EXTRA_DEPENDENCIES} bash /root/scripts/install.sh

RUN pip uninstall -y opencv-python || echo "opencv-python not installed"
RUN pip uninstall opencv-python-headless || echo "opencv-python-headless not installed"

# re-install headless opencv
RUN pip install opencv-python-headless==4.10.0.84

CMD ["/root/scripts/start.sh"]

HEALTHCHECK --interval=3s --timeout=600s --retries=600 CMD netstat -ltn | grep -c 26658 > /dev/null; if [ 0 != $? ]; then exit 1; fi;
2 changes: 1 addition & 1 deletion packages/gnosis/customs/ofv_market_resolver/component.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fingerprint:
__init__.py: bafybeie2727utrijcawhgm5bgj7p5lfah2pzepaufnk6m5swuwyduhf2eu
ofv_market_resolver.py: bafybeic6kxngm3mdkpmcjucrrerhyex7kizn7tw7qmpehaiycnc7cb6umu
fingerprint_ignore_patterns: []
entry_point: omen_buy_sell.py
entry_point: ofv_market_resolver.py
callable: run
dependencies:
pydantic:
Expand Down
13 changes: 7 additions & 6 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,23 @@
"custom/gnosis/omen_tools/0.1.0": "bafybeiglmyy3esctsejdqmz63juvaridbbjwjw3ch4mqudicsrgoir4qrq",
"custom/victorpolisetty/dalle_request/0.1.0": "bafybeieqqtd6gtlry7vheix54nj3ok4cag3uy47yoxlufhi6y3u5i6doti",
"custom/jhehemann/prediction_sentence_embeddings/0.1.0": "bafybeifyyb2wpa77tl7a7fs3fabns45llivhgccbnrpupubojmq2fwe4si",
"custom/gnosis/ofv_market_resolver/0.1.0": "bafybeiemvfq6uxiz3wvdplnxg7wloy6siuggejerlkfkchks6ytgk27uqa",
"custom/gnosis/ofv_market_resolver/0.1.0": "bafybeigapoti2ysukapphspjawktkb4qkeltlollt4d2z4u7mrddk3u3rq",
"custom/valory/tee_openai_request/0.1.0": "bafybeictmezaorzxelsy4dztbxh5n2343zio3rk6vo7wc5lptxlobhdnku",
"protocol/valory/acn_data_share/0.1.0": "bafybeih5ydonnvrwvy2ygfqgfabkr47s4yw3uqxztmwyfprulwfsoe7ipq",
"protocol/valory/websocket_client/0.1.0": "bafybeifjk254sy65rna2k32kynzenutujwqndap2r222afvr3zezi27mx4",
"contract/valory/agent_mech/0.1.0": "bafybeiah6b5epo2hlvzg5rr2cydgpp2waausoyrpnoarf7oa7bw33rex34",
"contract/valory/agent_registry/0.1.0": "bafybeiarzhzs2wm2sl47qg37tqoc3qok54enxlcj6vx3hldozg537uslnq",
"contract/valory/hash_checkpoint/0.1.0": "bafybeicbycr6rxods7sg3f2qlhgkjqrbh7kymmy2yw7bewxdwjyp7ibtg4",
"contract/valory/mech_marketplace/0.1.0": "bafybeich3a3oh5w4u533w6y7ideojudqp2m5gxta7pqmsfiaohdhuw7yz4",
"connection/valory/websocket_client/0.1.0": "bafybeic4ag3gqc7kd3k2o3pucddj2odck5yrfbgmwh5veqny7zao5qayli",
"skill/valory/contract_subscription/0.1.0": "bafybeiefuemlp75obgpxrp6iuleb3hn6vcviwh5oetk5djbuprf4xsmgjy",
"skill/valory/mech_abci/0.1.0": "bafybeicvbtbmtdps7lsbsutojiic4sam3jmi3prev5u22tps6pxy4du7nq",
"skill/valory/task_submission_abci/0.1.0": "bafybeihvvp6ovstb7po7kx6o7dno6kvjmffnmlerfw6qxhhzyrxmktd67e",
"skill/valory/task_execution/0.1.0": "bafybeie5obeuqn2g2rgtubqmdfxgyiri2yb5gbkvpvnyw7xapkqykoxmj4",
"skill/valory/mech_abci/0.1.0": "bafybeidkwahhblv6d6shzrk665yguyfar3w6qbld5ryjolw4zibdwr73vi",
"skill/valory/task_submission_abci/0.1.0": "bafybeifkd76popxwociq2ryojbcjyesmxoagqyjrbs73qoyd5o4szz6cgu",
"skill/valory/task_execution/0.1.0": "bafybeicg7rvme6dajqzwval3igq352mjor6k4lnw3tachrml66o7cm7mvm",
"skill/valory/websocket_client/0.1.0": "bafybeif7rrvsu6z4evqkhblxj3u6wwv2eqou576hgkyoehxuj7cntw7o2m",
"skill/valory/subscription_abci/0.1.0": "bafybeihtortmv4fqua5wrnshpnvqsbpaf52frwynrmpuv2uw5j7wkauhze",
"agent/valory/mech/0.1.0": "bafybeiebo5ysylvl3hktjn7s7smh4zyk4z3ceyuqtzr3o6wfhenolrovdu",
"service/valory/mech/0.1.0": "bafybeicy4f7cgrzjokzii65uvhiihhvsxbpqnkjdfbjtryxugeywtldkcu"
"agent/valory/mech/0.1.0": "bafybeib4ptljwzt34isrcmbkloexgp2wdmbrinl5a57xxvgjqub2ikhzvm",
"service/valory/mech/0.1.0": "bafybeieetllbqkol5nsreusrra553diyc3ec5n3lw5p23d5sromggarsc4"
},
"third_party": {
"protocol/valory/default/1.0.0": "bafybeifqcqy5hfbnd7fjv4mqdjrtujh2vx3p2xhe33y67zoxa6ph7wdpaq",
Expand Down
83 changes: 45 additions & 38 deletions packages/valory/agents/mech/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ contracts:
- valory/hash_checkpoint:0.1.0:bafybeicbycr6rxods7sg3f2qlhgkjqrbh7kymmy2yw7bewxdwjyp7ibtg4
- valory/multisend:0.1.0:bafybeig5byt5urg2d2bsecufxe5ql7f4mezg3mekfleeh32nmuusx66p4y
- valory/service_registry:0.1.0:bafybeicbxmbzt757lbmyh6762lrkcrp3oeum6dk3z7pvosixasifsk6xlm
- valory/mech_marketplace:0.1.0:bafybeich3a3oh5w4u533w6y7ideojudqp2m5gxta7pqmsfiaohdhuw7yz4
protocols:
- open_aea/signing:1.0.0:bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi
- valory/abci:0.1.0:bafybeiaqmp7kocbfdboksayeqhkbrynvlfzsx4uy4x6nohywnmaig4an7u
Expand All @@ -38,12 +39,12 @@ skills:
- valory/abstract_abci:0.1.0:bafybeihat4giyc4bz6zopvahcj4iw53356pbtwfn7p4d5yflwly2qhahum
- valory/abstract_round_abci:0.1.0:bafybeih3enhagoql7kzpeyzzu2scpkif6y3ubakpralfnwxcvxexdyvy5i
- valory/contract_subscription:0.1.0:bafybeiefuemlp75obgpxrp6iuleb3hn6vcviwh5oetk5djbuprf4xsmgjy
- valory/mech_abci:0.1.0:bafybeicvbtbmtdps7lsbsutojiic4sam3jmi3prev5u22tps6pxy4du7nq
- valory/mech_abci:0.1.0:bafybeidkwahhblv6d6shzrk665yguyfar3w6qbld5ryjolw4zibdwr73vi
- valory/registration_abci:0.1.0:bafybeiek7zcsxbucjwzgqfftafhfrocvc7q4yxllh2q44jeemsjxg3rcfm
- valory/reset_pause_abci:0.1.0:bafybeidw4mbx3os3hmv7ley7b3g3gja7ydpitr7mxbjpwzxin2mzyt5yam
- valory/subscription_abci:0.1.0:bafybeihtortmv4fqua5wrnshpnvqsbpaf52frwynrmpuv2uw5j7wkauhze
- valory/task_execution:0.1.0:bafybeie5obeuqn2g2rgtubqmdfxgyiri2yb5gbkvpvnyw7xapkqykoxmj4
- valory/task_submission_abci:0.1.0:bafybeihvvp6ovstb7po7kx6o7dno6kvjmffnmlerfw6qxhhzyrxmktd67e
- valory/task_execution:0.1.0:bafybeicg7rvme6dajqzwval3igq352mjor6k4lnw3tachrml66o7cm7mvm
- valory/task_submission_abci:0.1.0:bafybeifkd76popxwociq2ryojbcjyesmxoagqyjrbs73qoyd5o4szz6cgu
- valory/termination_abci:0.1.0:bafybeihq6qtbwt6i53ayqym63vhjexkcppy26gguzhhjqywfmiuqghvv44
- valory/transaction_settlement_abci:0.1.0:bafybeigtzlk4uakmd54rxnznorcrstsr52kta474lgrnvx5ovr546vj7sq
- valory/websocket_client:0.1.0:bafybeif7rrvsu6z4evqkhblxj3u6wwv2eqou576hgkyoehxuj7cntw7o2m
Expand Down Expand Up @@ -80,65 +81,68 @@ dependencies:
aiohttp:
version: <4.0.0,>=3.8.5
anthropic:
version: ==0.21.3
version: ==0.23.1
beautifulsoup4:
version: ==4.12.2
chromadb:
version: ==0.4.13
docstring-parser:
version: ==0.15
faiss-cpu:
version: ==1.7.4
fastapi:
version: ==0.110.3
google-api-python-client:
version: ==2.95.0
googlesearch-python:
version: ==1.2.3
hypothesis:
version: ==6.21.6
langchain:
version: ==0.2.1
langchain-community:
version: ==0.2.1
langchain-core:
version: ==0.2.1
langchain-openai:
version: ==0.1.7
langgraph:
version: ==0.0.55
lxml:
version: ==5.1.0
markdownify:
version: ==0.11.6
moviepy:
version: ==1.0.3
open-aea-ledger-ethereum:
version: ==1.50.0
pandas:
version: ==2.1.1
version: ==2.2.2
pypdf2:
version: ==3.0.1
python-dateutil:
version: ==2.8.2
readability-lxml:
version: ==0.8.1
replicate:
version: ==0.15.7
scikit-learn:
version: ==1.3.1
spacy:
version: ==3.7.2
tavily-python:
version: ==0.3.3
tiktoken:
version: ==0.7.0
fastapi:
version: ==0.110.3
typer:
version: ==0.9.4
readability-lxml:
version: ==0.8.1
lxml:
version: ==5.1.0
docstring-parser:
version: ==0.15
faiss-cpu:
version: ==1.7.4
pypdf2:
version: ==3.0.1
tavily-python:
version: ==0.3.3
chromadb:
version: ==0.4.13
markdownify:
version: ==0.11.6
moviepy:
version: ==1.0.3
replicate:
version: ==0.15.7
langchain:
version: ==0.2.1
langchain-core:
version: ==0.2.1
langchain-openai:
version: ==0.1.7
langgraph:
version: ==0.0.55
langchain-community:
version: ==0.2.1
prediction-market-agent-tooling:
version: '>=0.39.0,<0.40.0'
google-generativeai:
version: ==0.6.0
openfactverification-kongzii:
version: ==0.1.0
customs: []
default_connection: null
---
public_id: valory/websocket_client:0.1.0:bafybeiexove4oqyhoae5xmk2hilskthosov5imdp65olpgj3cfrepbouyy
Expand Down Expand Up @@ -205,6 +209,8 @@ models:
round_timeout_seconds: ${float:30.0}
reset_period_count: ${int:1000}
on_chain_service_id: ${int:1}
mech_staking_instance_address: ${str:0x0000000000000000000000000000000000000000}
mech_marketplace_address: ${str:0x0000000000000000000000000000000000000000}
agent_registry_address: ${str:0x0000000000000000000000000000000000000000}
agent_id: ${int:3}
metadata_hash: ${str:0000000000000000000000000000000000000000000000000000000000000000}
Expand Down Expand Up @@ -244,7 +250,8 @@ models:
agent_index: ${int:0}
num_agents: ${int:4}
from_block_range: ${int:50000}
mech_to_config: ${list:[["0xFf82123dFB52ab75C417195c5fDB87630145ae81",["use_dynamic_pricing","false"]]]}
mech_marketplace_address: ${str:0x0000000000000000000000000000000000000000}
mech_to_config: ${list:[["0xFf82123dFB52ab75C417195c5fDB87630145ae81",["use_dynamic_pricing","false"],["is_marketplace_mech","false"]]]}
timeout_limit: ${int:3}
max_block_window: ${int:500}
---
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;


struct MechDelivery {
// Priority mech address
address priorityMech;
// Delivery mech address
address deliveryMech;
// Requester address
address requester;
// Response timeout window
uint32 responseTimeout;
}

interface IMechMarketplace {
function mapRequestIdDeliveries(uint256) external view returns (MechDelivery memory);
}

contract BatchPriorityPassedCheck {
constructor(IMechMarketplace _marketplace, uint256[] memory _requestIds) {
// cache requestIds length
uint256 requestIdsLength = _requestIds.length;

// create temporary array with requestIds length to populate only with requestIds that have passed the priority timeout
uint256[] memory tempRequestIds = new uint256[](requestIdsLength);

// declare counter to know how many of the request are eligible
uint256 eligibleRequestIdsCount;

for (uint256 _i; _i < requestIdsLength;) {
MechDelivery memory delivery = _marketplace.mapRequestIdDeliveries(_requestIds[_i]);
if (block.timestamp >= delivery.responseTimeout) {
tempRequestIds[eligibleRequestIdsCount] = _requestIds[_i];
++eligibleRequestIdsCount;
}
unchecked {++_i;}
}

// create a new array with the actual length of the eligible to not corrupt memory with a wrong length
uint256[] memory eligibleRequestIds = new uint256[](eligibleRequestIdsCount);

// populate the array with the eligible requestIds
for (uint256 _i; _i < eligibleRequestIdsCount;) {
eligibleRequestIds[_i] = tempRequestIds[_i];
unchecked {++_i;}
}

// encode eligible referrers to ensure a proper layout in memory
bytes memory data = abi.encode(eligibleRequestIds);

assembly {
// pointer to the beginning of the data containing the eligible referrers in memory
let _dataStartPointer := add(data, 32)
// return everything from the start of the data to the end of memory
return (_dataStartPointer, sub(msize(), _dataStartPointer))
}
}
}
20 changes: 20 additions & 0 deletions packages/valory/contracts/mech_marketplace/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2023-2024 Valory AG
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------------------------------------------------------------------

"""This module contains the support resources for the agent mech contract."""
Loading

0 comments on commit 56028df

Please sign in to comment.