-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #251 from valory-xyz/feat/ofv-support-agent
Feat/ofv support agent
- Loading branch information
Showing
19 changed files
with
2,572 additions
and
1,342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/valory/contracts/mech_marketplace/BatchPriorityPassedCheck.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.""" |
Oops, something went wrong.