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

refactor: addressing internal audit #72

Merged
merged 78 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
c48e4f5
refactor: addressing internal audit
kupermind Jan 8, 2025
229d96a
test: adding test
kupermind Jan 8, 2025
00a42df
chore: solcover
kupermind Jan 8, 2025
6f03c8e
chore: comment
kupermind Jan 8, 2025
fd6a917
chore: unused error
kupermind Jan 8, 2025
688d2a0
chore: unused error
kupermind Jan 8, 2025
bbf3223
chore: unused events
kupermind Jan 8, 2025
95167e3
chore: test contract
kupermind Jan 8, 2025
0ba444e
chore: abis
kupermind Jan 8, 2025
79616da
chore: script to count lines
kupermind Jan 8, 2025
ccc1abc
chore: base for mech fixed price
kupermind Jan 8, 2025
03b5ea6
refactor: balance trackers to comply with nvm subscription
kupermind Jan 9, 2025
3163d5b
refactor: nvm enhancement
kupermind Jan 9, 2025
07eff28
chore: todo-s and reentrancy in external
kupermind Jan 9, 2025
8a51444
refactor: initial off-chain requests handling
kupermind Jan 9, 2025
08fed26
refactor: request verifications
kupermind Jan 9, 2025
b159db6
refactor: batch off-chain logic
kupermind Jan 9, 2025
05c0a45
chore: comments and small fix
kupermind Jan 9, 2025
be4385c
refactor: hash verification function and unused requests checks
kupermind Jan 10, 2025
23d5590
chore: deployment scripts
kupermind Jan 10, 2025
abc1e36
refactor: requests and deliveries in bulk and optimization
kupermind Jan 10, 2025
45cf574
chore: allow for zero fee value setting
kupermind Jan 10, 2025
c015724
refactor: stop withdraws fo rrequesters
kupermind Jan 10, 2025
aacb997
refactor: almost compiling
kupermind Jan 11, 2025
42a6e44
refactor: code compilation
kupermind Jan 11, 2025
9ecbaa1
chore: linters
kupermind Jan 11, 2025
da5a7c8
chore: transient
kupermind Jan 11, 2025
c268caf
chore: interface
kupermind Jan 11, 2025
ba6f493
chore: check array length
kupermind Jan 11, 2025
04d44cf
chore: additional comments
kupermind Jan 12, 2025
4660716
feat: add payment type checking
kupermind Jan 12, 2025
3f72d99
test: fixign tests
kupermind Jan 12, 2025
95d4867
test: fixign tests
kupermind Jan 12, 2025
550f7bc
test: fixed tests
kupermind Jan 13, 2025
a5fc76e
chore: updating solhint
kupermind Jan 13, 2025
e9e0307
chore: linters
kupermind Jan 13, 2025
031c988
refactor: converging on nvm subscription
kupermind Jan 13, 2025
bd7869a
refactor: no deposits
kupermind Jan 13, 2025
5c83eda
chore: deployment scripts
kupermind Jan 13, 2025
69f5289
refactor and test: converging on reverts / skips
kupermind Jan 13, 2025
7b31870
chore: linter
kupermind Jan 13, 2025
c3ea4d8
test: updating tests to batch
kupermind Jan 13, 2025
5ba163e
doc: init internal-audit4
Jan 14, 2025
c04ad06
doc: internal-audit4
Jan 14, 2025
bd47d7f
doc: internal-audit4
Jan 14, 2025
e3b2095
refactor and chore: addressing audit comments
kupermind Jan 14, 2025
d46f26a
chore: adding mech address into event
kupermind Jan 14, 2025
f4ba8c0
chore and test: requestId uint to bytes32, adding signature testing
kupermind Jan 14, 2025
82c2762
Merge pull request #79 from valory-xyz/address_audit5
DavidMinarsch Jan 14, 2025
8e5515e
Merge pull request #77 from valory-xyz/nvm_enhancement
DavidMinarsch Jan 14, 2025
2515cd6
Merge pull request #74 from valory-xyz/off_chain
DavidMinarsch Jan 14, 2025
4fdf8dc
Merge pull request #78 from valory-xyz/v0.4.0-internal-audit4
DavidMinarsch Jan 14, 2025
ea65c64
Merge pull request #73 from valory-xyz/nvm_adjustment
DavidMinarsch Jan 14, 2025
7ce80cf
Merge pull request #75 from valory-xyz/test_subscription
DavidMinarsch Jan 14, 2025
981234a
Merge pull request #76 from valory-xyz/arrays
DavidMinarsch Jan 14, 2025
1922c23
Merge branch 'address_audit' into signature_testing
kupermind Jan 15, 2025
f0e9691
chore: resolving merge conflicts
kupermind Jan 15, 2025
9378c7b
Merge pull request #80 from valory-xyz/signature_testing
kupermind Jan 15, 2025
317cf17
chore: updating error name
kupermind Jan 15, 2025
a5e5b19
test: adding more tests with signatures
kupermind Jan 15, 2025
9ea7a24
test: contracts signatures
kupermind Jan 15, 2025
965e439
test: adding NVM subscription tests
kupermind Jan 15, 2025
aba1b3f
test: adding weth into testing
kupermind Jan 16, 2025
d61285e
test: more coverage
kupermind Jan 16, 2025
7f5403a
chore: linters
kupermind Jan 16, 2025
3acc441
chore: shuffling internal functions and updating ABIs
kupermind Jan 16, 2025
45d86a1
Merge pull request #81 from valory-xyz/function_order
DavidMinarsch Jan 16, 2025
39b6cfc
refactor: NVM subscription token-credit ratio update
kupermind Jan 16, 2025
4418365
Merge pull request #82 from valory-xyz/token_credit_ratio_update
DavidMinarsch Jan 16, 2025
3aa99e6
chore: fork scripts and setup
kupermind Jan 16, 2025
5824669
chore: linters
kupermind Jan 16, 2025
0fc9b77
refactor: on-liner to account for NVM subscription for signatures
kupermind Jan 17, 2025
6daf643
Merge pull request #83 from valory-xyz/fork_testing
kupermind Jan 17, 2025
ca3a488
chore: linters
kupermind Jan 17, 2025
a4f3fcb
doc: readme
kupermind Jan 17, 2025
08d8e8a
doc-and-readme
mariapiamo Jan 17, 2025
bdade31
refactor and doc: inherit for factories
kupermind Jan 17, 2025
fe60f8c
Merge pull request #84 from valory-xyz/nvm_signatures
kupermind Jan 17, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
with:
go-version: "1.17.7"
- run: |
wget https://github.com/zricethezav/gitleaks/releases/download/v8.10.1/gitleaks_8.10.1_linux_x64.tar.gz && \
tar -xzf gitleaks_8.10.1_linux_x64.tar.gz && \
wget https://github.com/gitleaks/gitleaks/releases/download/v8.21.2/gitleaks_8.21.2_linux_x64.tar.gz && \
tar -xzf gitleaks_8.21.2_linux_x64.tar.gz && \
sudo install gitleaks /usr/bin && \
gitleaks detect --report-format json --report-path leak_report -v
5 changes: 5 additions & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ e8bc0c8e0ef330ba14e6006a2ced4a5b86366ca9:scripts/deployment/globals_gnosis_mainn
9d842115357c585bc68f868b00aef15d11502f5f:scripts/deployment/globals_gnosis_mainnet.json:generic-api-key:2
64134200ff4bf323d9fe13a9e7342bddb2f75fc1:scripts/deployment/globals_gnosis_mainnet.json:generic-api-key:1
64134200ff4bf323d9fe13a9e7342bddb2f75fc1:scripts/deployment/globals_gnosis_mainnet.json:generic-api-key:2
23d559046dd8c12882b7551a70b1b25fc71425e8:scripts/deployment/globals_gnosis_mainnet.json:generic-api-key:1
23d559046dd8c12882b7551a70b1b25fc71425e8:scripts/deployment/globals_gnosis_mainnet_deprecated.json:generic-api-key:1
5c83eda827b648fb2c66bace1eb914dc403a940f:scripts/deployment/globals_gnosis_mainnet_subscription_native_test.json:generic-api-key:1
3aa99e683bc392cf443211b0adc3da7b390f5bb7:scripts/deployment/globals_gnosis_mainnet_subscription_native_test.json:generic-api-key:1
3aa99e683bc392cf443211b0adc3da7b390f5bb7:scripts/deployment/test/globals_gnosis_mainnet.json:generic-api-key:1
8 changes: 6 additions & 2 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
module.exports = {
skipFiles: [
"test/ImportsSetup.sol",
"test/MockServiceStaking.sol",
"test/MechReentrancyAttacker.sol"
"test/ImportWETH.sol",
"test/MockMech.sol",
"test/MockMechFactory.sol",
"test/MockNvmSubscriptionNative.sol",
"test/MechReentrancyAttacker.sol",
"test/MockServiceStaking.sol"
]
};
60 changes: 47 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

## Introduction

This repository contains the Agent and Mech registry.
This repository contains the Mech Marketplace set of contracts registering mechs and performing their interactions for
requests delivery via the means of the Marketplace. Read [docs](https://github.com/valory-xyz/ai-registry-mech/docs)
for a detailed Mech Marketplace description.


## Development

### Prerequisites
- This repository follows the standard [`Hardhat`](https://hardhat.org/tutorial/) development process.
- The code is written on Solidity `0.8.19`.
- The standard versions of Node.js along with Yarn are required to proceed further (confirmed to work with Yarn `1.22.10` and npx/npm `6.14.11` and node `v12.22.0`).
- The code is written on Solidity `0.8.28`.
- The standard versions of Node.js along with Yarn are required to proceed further (confirmed to work with Yarn `1.22.19` and npx/npm `10.8.2` and node `v20.18.1`).

### Install the dependencies
The project has submodules to get the dependencies. Make sure you run `git clone --recursive` or init the submodules yourself.
Expand Down Expand Up @@ -38,6 +40,19 @@ Run the tests:
npx hardhat test
```

### Linters
- [`ESLint`](https://eslint.org) is used for JS code.
- [`solhint`](https://github.com/protofire/solhint) is used for Solidity linting.


### Github Workflows
The PR process is managed by github workflows, where the code undergoes
several steps in order to be verified. Those include:
- code installation
- running linters
- running tests


## Deployment and redeployment
The deployment of contracts to the test- and main-net is split into step-by-step series of scripts for more control and checkpoint convenience.
The description of deployment procedure can be found here: [deployment](https://github.com/valory-xyz/ai-registry-mech/blob/main/scripts/deployment).
Expand All @@ -48,7 +63,15 @@ Each folder there contains contracts compiled with the solidity version before t
The list of contract addresses for different chains and their full contract configuration can be found [here](https://github.com/valory-xyz/ai-registry-mech/blob/main/docs/configuration.json).


## Deployments
### Audits
- The audit is provided as development matures. The latest audit report can be found here: [audits](https://github.com/valory-xyz/autonolas-registries/blob/main/audits).


## Deployment addresses

The list of contract addresses for different chains and their full contract configuration can be found [here](https://github.com/valory-xyz/autonolas-registries/blob/main/docs/configuration.json).

### Previous versions, to be deprecated soon

| Network | AI Agent Registry | AgentFactory | AgentFactorySubscription | MechMarketplace |
| :---: | :---: | :---: | :---: | :---: |
Expand All @@ -70,16 +93,27 @@ The list of contract addresses for different chains and their full contract conf

```mermaid
flowchart LR
Deployer -- deploy --> MechMarketplace
Deployer -- deploy --> AgentFactory
Deployer -- deploy --> KarmaProxy
Deployer -- deploy --> Karma
User -- create --> AgentFactory
User -- request --> MechMarketplace -- requestFromMarketplace --> priorityMech
MechMarketplace -- changeRequesterMechKarma --> KarmaProxy --> Karma
MechService -- deliverToMarketplace --> priorityMech -- deliverMarketplace --> MechMarketplace -- changeMechKarma --> KarmaProxy --> Karma
MechService -- deliverToMarketplace --> AgentMech -- deliverMarketplace --> MechMarketplace -- revokeRequest (If delivery mech is different from the priority one) --> priorityMech
DAO -- changeMarketplaceParams --> MechMarketplace
DAO -- setMechFactoryStatuses --> MechMarketplace
DAO -- setPaymentTypeBalanceTrackers --> MechMarketplace
DAO -- setMechMarketplaceStatuses --> Karma
Account -- create --> MechMarketplace
Account -- request --> MechMarketplace
Account -- requestBatch --> MechMarketplace
MechMarketplace -- create --> MechFactory
MechFactory -- new --> Mech
MechMarketplace -- requestFromMarketplace --> Mech
MechMarketplace -- changeRequesterMechKarma --> Karma
MechMarketplace -- changeMechKarma --> Karma
MechService -- deliverToMarketplace (priority or delivery mech) --> Mech
MechService -- deliverMarketplaceWithSignatures --> Mech
Mech -- deliverMarketplace --> MechMarketplace
Mech -- deliverMarketplaceWithSignatures --> MechMarketplace
MechMarketplace -- checkAndRecordDeliveryRates --> BalanceTracker
MechMarketplace -- finalizeDeliveryRates --> BalanceTracker
MechMarketplace -- adjustMechRequesterBalances --> BalanceTracker
```
The core workflow of the Mech Marketplace, including the roles and interactions of key participants, as well as an overview of the smart contracts, can be found [here](https://github.com/valory-xyz/ai-registry-mech/tree/main/docs/MechMarketplaceDescriptionAndContractsOverviewRepo.pdf).

## Acknowledgements
The registry mech contracts were inspired and based on the following sources:
Expand Down
Loading
Loading