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

Named Static Cached PCVDeposit #379

Merged
merged 46 commits into from
Dec 27, 2021

Conversation

ElliotFriedman
Copy link
Contributor

No description provided.

contracts/pcv/utils/NamedStaticPCVDepositWrapper.sol Outdated Show resolved Hide resolved
contracts/pcv/utils/NamedStaticPCVDepositWrapper.sol Outdated Show resolved Hide resolved
contracts/pcv/utils/NamedStaticPCVDepositWrapper.sol Outdated Show resolved Hide resolved
test/unit/pcv/NamedStaticPCVDepositWrapper.test.ts Outdated Show resolved Hide resolved
test/unit/pcv/NamedStaticPCVDepositWrapper.test.ts Outdated Show resolved Hide resolved
test/unit/pcv/NamedStaticPCVDepositWrapper.test.ts Outdated Show resolved Hide resolved
test/unit/pcv/NamedStaticPCVDepositWrapper.test.ts Outdated Show resolved Hide resolved
contracts/pcv/utils/NamedStaticPCVDepositWrapper.sol Outdated Show resolved Hide resolved
Joeysantoro
Joeysantoro previously approved these changes Dec 16, 2021
Copy link
Contributor

@kryptoklob kryptoklob left a comment

Choose a reason for hiding this comment

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

Three main things:

  1. see my idea for a uint256-type UUID for the set; if we implement this, we'll need to also ensure that the hash-params of the pcv deposit are immutable; alternatively we can just use a random UUID (but I do like the deterministic approach)

  2. error messages should be readable in natural-language-style and understandable as to what exactly they check against

  3. make sure that array index parameters are checked for out-of-bounds issues

contracts/pcv/utils/NamedStaticPCVDepositWrapper.sol Outdated Show resolved Hide resolved
contracts/pcv/utils/NamedStaticPCVDepositWrapper.sol Outdated Show resolved Hide resolved
contracts/pcv/utils/NamedStaticPCVDepositWrapper.sol Outdated Show resolved Hide resolved
contracts/pcv/utils/NamedStaticPCVDepositWrapper.sol Outdated Show resolved Hide resolved
contracts/pcv/utils/NamedStaticPCVDepositWrapper.sol Outdated Show resolved Hide resolved
test/unit/pcv/NamedStaticPCVDepositWrapper.test.ts Outdated Show resolved Hide resolved
test/unit/pcv/NamedStaticPCVDepositWrapper.test.ts Outdated Show resolved Hide resolved
test/unit/pcv/NamedStaticPCVDepositWrapper.test.ts Outdated Show resolved Hide resolved
test/unit/pcv/NamedStaticPCVDepositWrapper.test.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@Joeysantoro Joeysantoro left a comment

Choose a reason for hiding this comment

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

Main issue is missing feiAmount in edit

contracts/pcv/utils/NamedStaticPCVDepositWrapper.sol Outdated Show resolved Hide resolved
Comment on lines 92 to 93
balance = balance - updatePCVDeposit.usdAmount + usdAmount;
feiReportBalance = feiReportBalance - updatePCVDeposit.feiAmount + feiAmount;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can store the intermediate sums in a local var to reuse

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We only use this value once so no need to store intermediately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to a cached system to save 2 SLOADs when emitting event

// ----------- Helper methods to change state -----------

/// @notice helper method to add a PCV deposit
function _addDeposit(DepositInfo memory newPCVDeposit) internal {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we store a mapping of names -> DepositInfo for lookups? Can also be used to ensure that no duplicate names are added to @ditchfieldcaleb 's earlier concerns

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We shouldn't need to think adversarially about deposit names as only OA and the governor can update the list and guardian can remove deposits instantly.

If we were to do this feature, the data structure would be name -> DepositInfo Index so that we aren't storing each struct and it's data twice.

Comment on lines 91 to 92
uint256 newBalance = balance - updatePCVDeposit.usdAmount + usdAmount;
uint256 newFeiReportBalance = feiReportBalance - updatePCVDeposit.feiAmount + feiAmount;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use oldBalance and oldFeiBalance to save another sload

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Joeysantoro
Joeysantoro previously approved these changes Dec 23, 2021
Copy link
Contributor

@Joeysantoro Joeysantoro left a comment

Choose a reason for hiding this comment

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

One nit and LGTM

@Joeysantoro Joeysantoro merged commit 53f8a06 into develop Dec 27, 2021
@Joeysantoro Joeysantoro deleted the feat/named-static-cached-pcvdeposit branch December 27, 2021 23:50
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.

4 participants