Skip to content

feat: implement Indexing Agreements #1134

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

Draft
wants to merge 67 commits into
base: horizon
Choose a base branch
from

Conversation

matiasedgeandnode
Copy link
Contributor

@matiasedgeandnode matiasedgeandnode commented Mar 26, 2025

Included in the changes is a markdown file with a TODO

Additional reading: Indexing Payments technical specification v0.1

Copy link

openzeppelin-code bot commented Mar 26, 2025

feat: implement Indexing Agreements

Generated at commit: f33e23d6c4935958af7730c35ca0392a7c622f6c

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
2
4
0
15
39
60
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@matiasedgeandnode matiasedgeandnode force-pushed the ma/indexing-payments-003 branch 10 times, most recently from b0f7e7f to ae910c4 Compare April 2, 2025 13:41
@matiasedgeandnode matiasedgeandnode force-pushed the ma/indexing-payments-003 branch from b53a31a to d0a4db2 Compare April 3, 2025 20:06
@matiasedgeandnode matiasedgeandnode force-pushed the ma/indexing-payments-003 branch from 32252c4 to de6b7a1 Compare April 15, 2025 20:07
Copy link

socket-security bot commented Apr 18, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

@matiasedgeandnode matiasedgeandnode force-pushed the ma/indexing-payments-003 branch from f4ea27a to 8776a18 Compare April 22, 2025 19:03
@matiasedgeandnode matiasedgeandnode force-pushed the ma/indexing-payments-003 branch 7 times, most recently from 753442f to 7ba3dd1 Compare May 19, 2025 16:34
@matiasedgeandnode matiasedgeandnode force-pushed the ma/indexing-payments-003 branch from 65f7f1d to ef651a6 Compare May 20, 2025 18:32
wrapper.collectorAgreement.serviceProvider,
address(_getSubgraphService())
);
require(provision.tokens != 0, DisputeManagerZeroTokens());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check means we can't slash delegators (if delegation slashing is enabled some day) in a case of multiple disputes where the indexer is already fully slashed. So maybe use a different check or check if there's nonzero delegation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is also present in _createQueryDisputeWithAttestation and _createIndexingDisputeWithAllocation. Should we fix those instances as well?

This comment was marked as resolved.

Copy link
Member

@tmigone tmigone Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds reasonable. I looked at previous audits to see if this was discussed but did not find anything.

Fixed it for Indexing and query fee disputes here: d89440a (#1183)

Going to include it in the fix review OZ is going to do for us.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll port the fix...

Copy link
Contributor Author

@matiasedgeandnode matiasedgeandnode Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebase on top of Tommy's fix, port fix to indexing feees and let Trust know about this change.


import { IndexingAgreement } from "./IndexingAgreement.sol";

library UnsafeDecoder {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it unsafe?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I'm not sure I see the benefit of implementing these separately from Decoder.sol, is there a size/performance improvement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming could use some improvement. It's "unsafe" in the sense that it reverts with a generic error.

Copy link
Contributor Author

@matiasedgeandnode matiasedgeandnode May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decoder and UnsafeDecoder are two separate libs, because:

  1. Decoder is a lib to reduce size in the service.
  2. try / catch can only be used on external function call.
  3. A lib can't call itself externally.

All of these together resulted in the two separate implementations. Maybe there is a better way to do it that I'm missing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im confused by this as well, cant we put everything into a Decoder library that has only external functions?

This comment was marked as resolved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the benefit of catching and re throwing is that we can be more descriptive with the error. iirc abi.decode tends to fail with Reverted without reason. I don't mind either approach but I think if we try/catch we could combine both libraries into a single one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can't combine both libraries into one. As I mentioned before try / catch needs to call an external function and a library can't call it's own external functions. I'd prefer to keep the custom errors because the amount of time I spent debugging Reverted without reason dwarfs the added complexity of having two libs. Would be very happy to find a better name for either lib though.

Copy link
Contributor Author

@matiasedgeandnode matiasedgeandnode Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Find a new name. Decoder is too generic. Unsafe sounds dangerous. Maybe IndexingAgreementDecoder

@matiasedgeandnode matiasedgeandnode force-pushed the ma/indexing-payments-003 branch from ef651a6 to aac9682 Compare May 30, 2025 18:29
@matiasedgeandnode matiasedgeandnode force-pushed the ma/indexing-payments-003 branch from 5ebb424 to 7dee19f Compare June 5, 2025 16:29
@matiasedgeandnode

This comment was marked as resolved.

Copy link

socket-security bot commented Jun 6, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addeddebug@​4.4.010010010086100
Addedhardhat@​2.14.1941008810080
Addedhardhat@​2.23.0941009010080

View full report

@matiasedgeandnode matiasedgeandnode force-pushed the ma/indexing-payments-003 branch from 6765c56 to f0d158f Compare June 6, 2025 17:33
@matiasedgeandnode
Copy link
Contributor Author

ok, NatSpec added, pnpm lint:sol:natspec reporting same warnings as in horizon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants