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

improve(dec-20-audit): [N04] Naming issues hinder code understanding #2332

Merged
merged 11 commits into from
Dec 24, 2020

Conversation

pemulis
Copy link
Contributor

@pemulis pemulis commented Dec 22, 2020

…and readability

Motivation

Improve naming according to audit recommendations, except in cases which would require upgrading contracts that are already live.

Summary

There are numerous naming updates here, concentrated on the new contracts that have yet to be released, and setting aside existing contracts that would need to be upgraded.

Details

We may want to go back and take a second look at the other contracts that we may want to more thoroughly refactor and upgrade later. I'm also seeing some failing tests and would like to better understand if this is a code issue (bytecode limit problems?) or some deficiency in my current testing set-up.

Issue(s)

N/A

…and readability

Signed-off-by: pemulis <john.d.shutt@gmail.com>
…otocol/protocol into pemulis/dec-2020-audit-N04

Signed-off-by: pemulis <john.d.shutt@gmail.com>
@nicholaspai nicholaspai added the dec-2020-audit Fixes for the perpetual, optimistic oracle, ancillary DVM data and financial product library audit. label Dec 22, 2020
Copy link
Member

@nicholaspai nicholaspai left a comment

Choose a reason for hiding this comment

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

High level comments

  • Since we're going to be upgrading the EMP related contracts as well do you think its worth making the changes to them now? Or should we just not touch the EMP at all.
  • What about changing the Liquidatable states: {PreDispute, PendingDispute}
  • What about other changes in the audit suggestions such as renaming dispute etc.

@nicholaspai
Copy link
Member

nicholaspai commented Dec 22, 2020

High level comments

  • Since we're going to be upgrading the EMP related contracts as well do you think its worth making the changes to them now? Or should we just not touch the EMP at all.
  • What about changing the Liquidatable states: {PreDispute, PendingDispute}
  • What about other changes in the audit suggestions such as renaming dispute etc.

Apologies @pemulis I'm going to take back my statements and just go through the audit suggestions for renaming one by one to aid you. The overall philosophy I'm going to recommend stays true to your original goal, which is to NOT introduce any breaking changes to the off-chain infrastructure such as the liquidator or monitor:

Changes we should make:

  • PreDispute to NotDisputed.
  • PendingDispute to Disputed.

These suggestions would change internal enums and should therefore be implemented for both the EMP and Perpetual.

  • disputeBondPct to disputeBondPercentage.
  • sponsorDisputeRewardPct to sponsorDisputeRewardPercentage.
  • disputerDisputeRewardPct to disputerDisputeRewardPercentage.
  • rewardRate and proposerBond in both events to rewardRatePerSecond and proposerBondPercentage respectively.

These suggestions introduce breaking changes to the interface but are not called by the bots, and therefore should be implemented for both the EMP and Perpetual.

  • regularFees to paysRegularFees.

This is an internal modifier renaming and should be changed for both FeePayer and FundingRateApplier.

- _collateralAddress to _collateralTokenAddress.

This is a constructor argument renaming and should be changed for both EMP and Perpetual.

  • proposeNewRate to proposeFundingRate.

This changes the interface for the Perpetual, which has not been integrated into any off-chain infra yet, so can be changed.

Changes we should not make:

  • _collateralAddress to _collateralTokenAddress.

See full explanation here

  • _getIdentifierWhitelist to _getIdentifierApprovedList.

I actually don't agree with this change because the contract being returned is named IdentifierWhitelist so it makes sense to leave this function name as is.

  • dispute to disputeLiquidation.
  • tokenCurrency to syntheticToken.
  • Deposit to Deposited.
  • Withdrawal to Withdrawn.
  • RequestWithdrawal to WithdrawalRequested.
  • RequestWithdrawalExecuted to WithdrawalExecuted.
  • RequestWithdrawalCanceled to WithdrawalCanceled.
  • NewSponsor to SponsorAdded.
  • Redeem to Redeemed.
  • EmergencyShutdown to EmergencyShutdownEnabled.
  • SettleEmergencyShutdown to EmergencyShutdownSettled.

These changes would introduce breaking changes to the interface functions and events that would break off-chain infra in affiliates and/or bot code. So I don't think these should be implemented.

@daywiss @chrismaree can you verify that these changes are ok with the affiliates package?
@mrice32 can you verify the bot implications?

@daywiss daywiss self-requested a review December 22, 2020 20:45
@daywiss
Copy link
Contributor

daywiss commented Dec 22, 2020

thanks @pemulis and @nicholaspai for the update and analysis. I agree we really should try to just go with non breaking changes here.

That said, any changes to emp events will break affiliates as it is. I'm leaning towards not changing the EMP because its high risk to break infrastructure in general. So far affiliates has only had to run with a single version of the EMP abi, but having to apply rewards across different ABI versions will be tricky ( but not impossible). I'm ok with the inconsistency between EMP and perp for now so id rather reduce code churn.

@mrice32
Copy link
Member

mrice32 commented Dec 23, 2020

@nicholaspai totally agree with your conclusions.

Copy link
Member

@nicholaspai nicholaspai left a comment

Choose a reason for hiding this comment

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

Drive by: I thought we had decided to not change _collateralAddress ==> _collateralTokenAddress because we are leaving _tokenAddress and tokenCurrency as is?

I updated this comment to reflect this decision just now, apologies if you were going by that comment before!

@pemulis
Copy link
Contributor Author

pemulis commented Dec 23, 2020

Drive by: I thought we had decided to not change _collateralAddress ==> _collateralTokenAddress because we are leaving _tokenAddress and tokenCurrency as is?

I updated this comment to reflect this decision just now, apologies if you were going by that comment before!

Yep! I was going by that comment but can revert that change.

@coveralls
Copy link

coveralls commented Dec 23, 2020

Coverage Status

Coverage remained the same at 93.284% when pulling ebfd6ad on pemulis/dec-2020-audit-N04 into 26ef98f on master.

Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dec-2020-audit Fixes for the perpetual, optimistic oracle, ancillary DVM data and financial product library audit.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants