Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Staking params upgradability #2166

Merged
merged 11 commits into from
Sep 17, 2019
Merged

Staking params upgradability #2166

merged 11 commits into from
Sep 17, 2019

Conversation

abandeali1
Copy link
Member

Description

This PR:

  • Creates a unified interface for upgrading any params within the staking contracts. wethAssetProxy, ethVault, rewardVault, and zrxVault are all now initialized in init and upgradable via setParams. Their old setter methods have been removed.
  • Note that attachStakingContract now also requires these params to be passed in. However, they will be ignored in favor of the already stored params if null addresses are passed in.

Testing instructions

Types of changes

Checklist:

  • Prefix PR title with [WIP] if necessary.
  • Add tests to cover changes as needed.
  • Update documentation as needed.
  • Add new entries to the relevant CHANGELOG.jsons.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 75.804% when pulling bb46f18 on feat/3.0/staking-upgradability into 1d1dd4b on feat/3.0/cleanup-staking-contracts.

@dorothy-zbornak dorothy-zbornak self-assigned this Sep 17, 2019
@moodlezoup moodlezoup self-assigned this Sep 17, 2019
Copy link
Contributor

@dorothy-zbornak dorothy-zbornak left a comment

Choose a reason for hiding this comment

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

Just some small changes then g2g! 💯

/**
* Generates a random address.
*/
export function randomAddress(): string {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know why it took us so long. 🙃

'InitAddresses',
);
for (const args of logsArgs) {
expect(args.wethProxyAddress).to.eq(wethProxyAddress);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we just asserting wethProxyAddress and not the others?

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, forgot to add those in 😅

'InitAddresses',
);
for (const args of logsArgs) {
expect(args.wethProxyAddress).to.eq(wethProxyAddress);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

@abandeali1 abandeali1 changed the base branch from feat/3.0/cleanup-staking-contracts to 3.0 September 17, 2019 20:03
Copy link
Contributor

@jalextowle jalextowle 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 to me! Just a couple of nits and thoughts

@@ -13,7 +13,7 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('Libs tests', () => {
let coordinatorContract: CoordinatorContract;
let chainId: number;
const exchangeAddress = addressUtils.generatePseudoRandomAddress();
const exchangeAddress = randomAddress();
Copy link
Contributor

Choose a reason for hiding this comment

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

🙏

@@ -4,11 +4,15 @@ import { constants } from './constants';

export interface StakingParams {
epochDurationInSeconds: BigNumber;
rewardDelegatedStakeWeight: BigNumber;
rewardDelegatedStakeWeight: number | BigNumber;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Let's just use Numberish here, unless there is a reason why Strings shouldn't be allowed. I feel like we should just make this change everywhere that accepts BigNumber.

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 Numberish, but some of the contract wrapper functions don't accept strings as inputs and had to revert back to this.

/// @dev Assert param values before initializing them.
/// This must be updated for each migration.
function _assertMixinParamsBeforeInit()
/// @dev Initialzize storage belonging to this mixin.
Copy link
Contributor

Choose a reason for hiding this comment

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

small nit: Initialzize => Initialize

// Set up defaults.
// These cannot be set to variables, or we go over the stack variable limit.
_setParams(
2 weeks, // epochDurationInSeconds
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Rather than setting these to variables, it would probably be good to make these constants, in case we ever want to change them. Additionally, if they are constants, we can use the internal function pattern to stub out these values, if necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

Had to do this to get around stack limitations unfortunately.

/// @param _ethVaultAddress Address of the EthVault contract.
/// @param _rewardVaultAddress Address of the StakingPoolRewardVault contract.
/// @param _zrxVaultAddress Address of the ZrxVault contract.
function _assertValidAddresses(
Copy link
Contributor

Choose a reason for hiding this comment

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

Since these addresses should all be contracts and this function will be called extremely infrequently, I think it might be worth checking that these accounts are in fact deployed contracts. I think this could be good for trustlessness and as a sanity check on the addresses that are registered.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it really trustless if it's just a contract that allows someone to arbitrarily withdraw funds? 🤷‍♂

Copy link
Contributor

@moodlezoup moodlezoup 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 to me, just some small nits

@@ -20,29 +23,9 @@ blockchainTests('Configurable Parameters', env => {
});

blockchainTests.resets('setParams()', () => {
interface Params {
Copy link
Contributor

Choose a reason for hiding this comment

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

🙏

{
zrxVault = IZrxVault(zrxVaultAddress);
}

/// @dev Deposits Zrx Tokens from the `owner` into the vault.
/// @param owner of Zrx Tokens
/// @param amount of tokens to deposit.
function _depositFromOwnerIntoZrxVault(address owner, uint256 amount)
internal
{
IZrxVault _zrxVault = zrxVault;
Copy link
Contributor

Choose a reason for hiding this comment

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

we no longer need to cache this

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'm probably going to just delete this mixin in a separate PR. It doesn't really do anything at the moment.

@@ -57,10 +44,6 @@ contract MixinZrxVault is
internal
{
IZrxVault _zrxVault = zrxVault;
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@@ -72,10 +55,6 @@ contract MixinZrxVault is
returns (uint256)
{
IZrxVault _zrxVault = zrxVault;
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

from: notOwnerAddress,
});
const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
attachedAddress,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: initTargetContract.address for consistency

@abandeali1 abandeali1 merged commit 2ea354f into 3.0 Sep 17, 2019
@abandeali1 abandeali1 mentioned this pull request Sep 21, 2019
4 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants