Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/mech marketplace #254

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/gnosis/customs/ofv_market_resolver/component.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ license: Apache-2.0
aea_version: '>=1.0.0, <2.0.0'
fingerprint:
__init__.py: bafybeie2727utrijcawhgm5bgj7p5lfah2pzepaufnk6m5swuwyduhf2eu
log/factcheck_dev.log: bafybeihwremece5odkxdjxk4pt2htbpszrxheccxaqs3czogne3t7rblme
ofv_market_resolver.py: bafybeic6kxngm3mdkpmcjucrrerhyex7kizn7tw7qmpehaiycnc7cb6umu
fingerprint_ignore_patterns: []
entry_point: ofv_market_resolver.py
Expand Down
14 changes: 8 additions & 6 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +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": "bafybeidsiwakhj4w4rsvpf6agbwr76dh2r73eu6wrnwmoctgwlupgh46am",
"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": "bafybeicbjm4qzztawekdr55gpbtntc6lu2sig6cfttss4zcu4tdnbypyhq",
"service/valory/mech/0.1.0": "bafybeidlte5wznzrusil2xuyd6kgvavlkkhr4agdutw5as6euvzlwr2ovi"
"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
12 changes: 8 additions & 4 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 @@ -208,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 @@ -247,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
Loading