Skip to content

PCV Oracle Refactor#195

Merged
ElliotFriedman merged 18 commits intofeat/market-governancefrom
feat/pcv-oracle-refactor
Feb 10, 2023
Merged

PCV Oracle Refactor#195
ElliotFriedman merged 18 commits intofeat/market-governancefrom
feat/pcv-oracle-refactor

Conversation

@ElliotFriedman
Copy link
Copy Markdown
Collaborator

@ElliotFriedman ElliotFriedman commented Feb 7, 2023

Refactor PCV Oracle to track last recorded profit, last recorded balance and last recorded global PCV.

Comment thread src/oracle/PCVOracle.sol Outdated
Comment thread src/oracle/PCVOracle.sol Outdated
Comment thread src/oracle/PCVOracle.sol Outdated
Comment thread src/oracle/PCVOracle.sol
Comment thread src/oracle/PCVOracle.sol Outdated
mapping(address => VenueData) public venueRecord;

/// @notice cached total PCV amount
uint256 public totalRecordedPcv;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i'd rename to lastRecordedTotalPcv and remove the getter getTotalCachedPcv because it should have the same value and the state variable is public

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

@ElliotFriedman ElliotFriedman marked this pull request as ready for review February 8, 2023 19:05
Copy link
Copy Markdown
Collaborator

@eswak eswak left a comment

Choose a reason for hiding this comment

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

Would be nice to maintain the good coverage this contract has, and add tests for the new functions you added:

Coverage before:
| File                                            | % Lines         | % Statements     | % Branches      | % Funcs         |
|-------------------------------------------------|-----------------|------------------|-----------------|-----------------|
| src/oracle/PCVOracle.sol                        | 100.00% (63/63) | 100.00% (80/80)  | 75.00% (24/32)  | 100.00% (12/12) |

Coverage after:
| File                                            | % Lines         | % Statements      | % Branches      | % Funcs        |
|-------------------------------------------------|-----------------|-------------------|-----------------|----------------|
| src/oracle/PCVOracle.sol                        | 90.59% (77/85)  | 90.74% (98/108)   | 66.67% (24/36)  | 76.47% (13/17) |

The following functions don't have unit tests :

  • venueRecord(address)
  • getNumVenues()
  • lastRecordedProfit()
  • getVenueBalance() + its revert cases
  • new revert case on updateBalance(...) (impossible to have negative balances)

You can get the coverage for your current work by running something like:

$> forge coverage --match-contract PCVOracleUnitTest --report lcov

And then use a VS code extension like Coverage Gutters to show the coverage of the contracts

Also you mentioned on Discord that getTotalLastRecordedPcv has been deleted, which is not the case in the diff, so maybe you have some local commits that aren't in the PR

@ElliotFriedman
Copy link
Copy Markdown
Collaborator Author

Would be nice to maintain the good coverage this contract has, and add tests for the new functions you added

Added tests, at 100% function coverage and 77.78% of branches:
| src/oracle/PCVOracle.sol | 100.00% (80/80) | 100.00% (100/100) | 77.78% (28/36) | 100.00% (16/16) |

Copy link
Copy Markdown
Collaborator

@eswak eswak left a comment

Choose a reason for hiding this comment

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

🔥 🔥 🔥 😄

* remove reentrancy checks when lock is set to address 0

* add lock tests

* add additional reentrancy tests when lock is set to 0

* update comments
@ElliotFriedman ElliotFriedman merged commit 319371c into feat/market-governance Feb 10, 2023
@ElliotFriedman ElliotFriedman deleted the feat/pcv-oracle-refactor branch February 10, 2023 17:19
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.

2 participants