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: subgraph availability manager contract #882

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open

Conversation

Maikol
Copy link
Member

@Maikol Maikol commented Nov 16, 2023

No description provided.

Copy link

openzeppelin-code bot commented Nov 16, 2023

feat: subgraph availability manager contract

Generated at commit: bcf69579662fcf3e2fee87cf3a0aa5ee4196cf6d

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
2
4
0
15
37
58
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

Copy link

codecov bot commented Nov 16, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.83%. Comparing base (59154f7) to head (bcf6957).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #882      +/-   ##
==========================================
+ Coverage   92.70%   92.83%   +0.13%     
==========================================
  Files          46       47       +1     
  Lines        2370     2416      +46     
  Branches      426      439      +13     
==========================================
+ Hits         2197     2243      +46     
  Misses        173      173              
Flag Coverage Δ
unittests 92.83% <100.00%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@tmigone tmigone left a comment

Choose a reason for hiding this comment

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

Looking good! left a few comments

contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
test/rewards/subgraphAvailability.test.ts Outdated Show resolved Hide resolved
contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
@Maikol Maikol marked this pull request as ready for review December 1, 2023 21:12
Copy link
Member

@pcarranzav pcarranzav left a comment

Choose a reason for hiding this comment

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

Some details while I'm still reviewing

contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
@pcarranzav
Copy link
Member

Finished reviewing, I'm ready to approve after hearing what you think about the previous comments.
Nice work, and very good test suite 🔥

@Maikol
Copy link
Member Author

Maikol commented Dec 8, 2023

@pcarranzav thanks for the review, addressed comments!

pcarranzav
pcarranzav previously approved these changes Dec 8, 2023
Copy link
Member

@pcarranzav pcarranzav left a comment

Choose a reason for hiding this comment

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

One remaining detail but LGTM

contracts/rewards/SubgraphAvailabilityManager.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@tmigone tmigone left a comment

Choose a reason for hiding this comment

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

Looks good, just one comment.


executionThreshold = _executionThreshold;
voteTimeLimit = _voteTimeLimit;
oracles = _oracles;
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm i think we should set the oracles inside the for loop above and emit OracleSet for each one.

Otherwise the subgraph will have a tough time getting the initial list of oracles

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch. I guess we should update the subgraph when we're ready to release this, I'll note that.

@@ -159,3 +159,13 @@ contracts:
controller: "${{Controller.address}}"
calls:
- fn: "syncAllContracts"
SubgraphAvailabilityManager:
init:
governor: "${{Env.deployer}}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we don't set the council as the governor from the get go?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was using the deployer while I'm testing so I don't have to use the multisig.


/// @notice Mapping of current nonce to subgraph deployment ID to oracle index to timestamp of last deny vote
/// currentNonce => subgraphDeploymentId => oracleIndex => timestamp
mapping(uint256 => mapping(bytes32 => mapping(uint256 => uint256))) public lastDenyVote;
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 this could be mapping(uint256 => mapping(bytes32 => uint256[NUM_ORACLES]) now? which I think would be a bit cheaper?

Copy link
Member Author

Choose a reason for hiding this comment

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

Definitely, good idea!


/// @notice Mapping of current nonce to subgraph deployment ID to oracle index to timestamp of last allow vote
/// currentNonce => subgraphDeploymentId => oracleIndex => timestamp
mapping(uint256 => mapping(bytes32 => mapping(uint256 => uint256))) public lastAllowVote;
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, the last mapping could be an array now

pcarranzav
pcarranzav previously approved these changes Jan 16, 2024
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.

None yet

3 participants