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

doc: internal audit 0.4.1 #106

Merged
merged 10 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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: 1 addition & 0 deletions audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ An internal audit with a focus on updated marketplace contracts is located in th
An internal audit with a focus on re-design marketplace contracts is located in this folder: [internal audit 3](https://github.com/valory-xyz/ai-registry-mech/blob/main/audits/internal3). <br>
An internal audit with a focus on latest re-design marketplace contracts is located in this folder: [internal audit 4](https://github.com/valory-xyz/ai-registry-mech/blob/main/audits/internal4). <br>
An internal audit with a focus on latest re-design ref:nmv marketplace contracts is located in this folder: [internal audit 5](https://github.com/valory-xyz/ai-registry-mech/blob/main/audits/internal5). <br>
An internal audit with a focus on token-usdc ref:nmv marketplace contracts is located in this folder: [internal audit 6](https://github.com/valory-xyz/ai-registry-mech/blob/main/audits/internal6). <br>


### External audits
Expand Down
47 changes: 47 additions & 0 deletions audit/internal6/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Internal audit of ai-registry-mech
The review has been performed based on the contract code in the following repository:<br>
`https://github.com/valory-xyz/ai-registry-mech` <br>
commit: c72195a6be5bbefcfa40af87f2e1c1bfed2fa9e7 (tag: v0.4.1-pre-internal-audit) <br>

## Objectives
The audit focused on NVM-usdc marketplace contracts in this repo. <br>
Limits: The subject of the audit is not contracts used as library contracts. Thus, this audit is not a full-fledged audit of contracts underlying the contract ERC721Mech. <br>


## Coverage
```
------------------------------------------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
------------------------------------------|----------|----------|----------|----------|----------------|
contracts/mechs/nevermined_token/ | 94.12 | 87.5 | 57.14 | 85.71 | |
BalanceTrackerNvmSubscriptionToken.sol | 94.12 | 87.5 | 57.14 | 85.71 |... 122,160,166 |
contracts/mechs/nevermined_token/usdc/ | 100 | 100 | 100 | 100 | |
MechFactoryNvmSubscriptionTokenUSDC.sol | 100 | 100 | 100 | 100 | |
MechNvmSubscriptionTokenUSDC.sol | 100 | 100 | 100 | 100 | |

```
insufficient testing coverage
[]

### Security issues.
#### Notes
```
Does different decimals in ERC20 affect it somehow? I don't think so, and everything is calculated and compared in raw values. For discussion.
// Convert mech credits balance into tokens
balance = (balance * tokenCreditRatio) / 1e18;
mapMechBalances[mech] = balance;

// Check current contract balance
uint256 trackerBalance = IERC20(token).balanceOf(address(this));
if (balance > trackerBalance) {
revert Overflow(balance, trackerBalance);
}
```
[x] Discussed, not an issue







28 changes: 0 additions & 28 deletions scripts/deployment/e_check_00_agent_mech.js

This file was deleted.

33 changes: 33 additions & 0 deletions scripts/deployment/e_verify_olas_mech.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*global process, hre*/

async function main() {
const fs = require("fs");
const globalsFile = "globals.json";
const dataFromJSON = fs.readFileSync(globalsFile, "utf8");
let parsedData = JSON.parse(dataFromJSON);

const provider = new ethers.providers.JsonRpcProvider(parsedData.networkURL);

Check warning on line 9 in scripts/deployment/e_verify_olas_mech.js

View workflow job for this annotation

GitHub Actions / build

'provider' is assigned a value but never used

Check failure on line 9 in scripts/deployment/e_verify_olas_mech.js

View workflow job for this annotation

GitHub Actions / build

'ethers' is not defined
const signers = await ethers.getSigners();

Check failure on line 10 in scripts/deployment/e_verify_olas_mech.js

View workflow job for this annotation

GitHub Actions / build

'ethers' is not defined

const deployer = signers[0];
console.log("Deployer is:", deployer.address);

const mechAddress = "";
const mech = await ethers.getContractAt("MechFixedPriceNative", mechAddress);

Check failure on line 16 in scripts/deployment/e_verify_olas_mech.js

View workflow job for this annotation

GitHub Actions / build

'ethers' is not defined
const mechMarketplaceAddress = await mech.mechMarketplace();
const serviceRegistryAddress = await mech.serviceRegistry();
const serviceId = await mech.tokenId();
const maxDeliveryRate = await mech.maxDeliveryRate();
await hre.run("verify:verify", {
address: mechAddress,
constructorArguments: [mechMarketplaceAddress, serviceRegistryAddress, serviceId, maxDeliveryRate],
});
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

Loading