Skip to content

Commit

Permalink
Cherry-pick "Script to deploy smart contract changes to a network via…
Browse files Browse the repository at this point in the history
… governance" (#4706) into "oz-prerelease" (#5194)

* Cherry pick 8a8b822

* Resolve merge conflicts from cherry-pick

* Remove double-specification of ICeloVersionedContract

Co-authored-by: Asa Oines <[email protected]>
  • Loading branch information
nambrot and Asa Oines authored Sep 24, 2020
1 parent 32d2730 commit ce93c3f
Show file tree
Hide file tree
Showing 34 changed files with 545 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ jobs:
ssh-keyscan github.com >> ~/.ssh/known_hosts
git fetch --all
RELEASE_BRANCH=$(git branch -a --list *release/contracts/* | tail -1 | sed -e 's/remotes\/origin\///g')
yarn --cwd packages/protocol check-versions -o $RELEASE_BRANCH -n $CIRCLE_BRANCH
yarn --cwd packages/protocol check-versions -a $RELEASE_BRANCH -b $CIRCLE_BRANCH
LIBRARIES_CHANGED=$(git diff $RELEASE_BRANCH --name-only packages/protocol/contracts/common/linkedlists)
if [[ $LIBRARIES_CHANGED ]]; then
Expand Down
24 changes: 1 addition & 23 deletions packages/contractkit/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,7 @@ export enum CeloContract {
Validators = 'Validators',
}

export const ProxyContracts = [
'AccountsProxy',
'AttestationsProxy',
'BlockchainParametersProxy',
'DoubleSigningSlasherProxy',
'DowntimeSlasherProxy',
'ElectionProxy',
'EpochRewardsProxy',
'EscrowProxy',
'ExchangeProxy',
'FeeCurrencyWhitelistProxy',
'FreezerProxy',
'GasPriceMinimumProxy',
'GoldTokenProxy',
'GovernanceApproverMultiSigProxy',
'GovernanceProxy',
'LockedGoldProxy',
'ReserveProxy',
'ReserveSpenderMultiSigProxy',
'StableTokenProxy',
'SortedOraclesProxy',
'RegistryProxy',
]
export const ProxyContracts = Object.keys(CeloContract).map((c) => `${c}Proxy`)

export type CeloToken = CeloContract.GoldToken | CeloContract.StableToken

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ___

Ƭ **CeloToken**: *[GoldToken](../enums/_contractkit_src_base_.celocontract.md#goldtoken) | [StableToken](../enums/_contractkit_src_base_.celocontract.md#stabletoken)*

*Defined in [contractkit/src/base.ts:53](https://github.com/celo-org/celo-monorepo/blob/master/packages/contractkit/src/base.ts#L53)*
*Defined in [contractkit/src/base.ts:31](https://github.com/celo-org/celo-monorepo/blob/master/packages/contractkit/src/base.ts#L31)*

## Variables

Expand All @@ -41,42 +41,20 @@ ___
(k) => (CeloContract as any)[k as any]
) as CeloContract[]

*Defined in [contractkit/src/base.ts:55](https://github.com/celo-org/celo-monorepo/blob/master/packages/contractkit/src/base.ts#L55)*
*Defined in [contractkit/src/base.ts:33](https://github.com/celo-org/celo-monorepo/blob/master/packages/contractkit/src/base.ts#L33)*

___

### `Const` NULL_ADDRESS

**NULL_ADDRESS**: *string* = '0x0000000000000000000000000000000000000000' as Address

*Defined in [contractkit/src/base.ts:59](https://github.com/celo-org/celo-monorepo/blob/master/packages/contractkit/src/base.ts#L59)*
*Defined in [contractkit/src/base.ts:37](https://github.com/celo-org/celo-monorepo/blob/master/packages/contractkit/src/base.ts#L37)*

___

### `Const` ProxyContracts

**ProxyContracts**: *string[]* = [
'AccountsProxy',
'AttestationsProxy',
'BlockchainParametersProxy',
'DoubleSigningSlasherProxy',
'DowntimeSlasherProxy',
'ElectionProxy',
'EpochRewardsProxy',
'EscrowProxy',
'ExchangeProxy',
'FeeCurrencyWhitelistProxy',
'FreezerProxy',
'GasPriceMinimumProxy',
'GoldTokenProxy',
'GovernanceApproverMultiSigProxy',
'GovernanceProxy',
'LockedGoldProxy',
'ReserveProxy',
'ReserveSpenderMultiSigProxy',
'StableTokenProxy',
'SortedOraclesProxy',
'RegistryProxy',
]
**ProxyContracts**: *string[]* = Object.keys(CeloContract).map((c) => `${c}Proxy`)

*Defined in [contractkit/src/base.ts:29](https://github.com/celo-org/celo-monorepo/blob/master/packages/contractkit/src/base.ts#L29)*
18 changes: 17 additions & 1 deletion packages/protocol/contracts/common/Accounts.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "./interfaces/IAccounts.sol";

import "../common/Initializable.sol";
import "../common/interfaces/ICeloVersionedContract.sol";
import "../common/Signatures.sol";
import "../common/UsingRegistry.sol";
import "../common/libraries/ReentrancyGuard.sol";

contract Accounts is IAccounts, Ownable, ReentrancyGuard, Initializable, UsingRegistry {
contract Accounts is
IAccounts,
ICeloVersionedContract,
Ownable,
ReentrancyGuard,
Initializable,
UsingRegistry
{
using SafeMath for uint256;

struct Signers {
Expand Down Expand Up @@ -60,6 +68,14 @@ contract Accounts is IAccounts, Ownable, ReentrancyGuard, Initializable, UsingRe
event AccountWalletAddressSet(address indexed account, address walletAddress);
event AccountCreated(address indexed account);

/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 0);
}

/**
* @notice Used in place of the constructor to allow the contract to be upgradable via proxy.
* @param registryAddress The address of the registry core smart contract.
Expand Down
8 changes: 8 additions & 0 deletions packages/protocol/contracts/common/FixidityLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ library FixidityLib {
uint256 value;
}

/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 0);
}

/**
* @notice Number of positions that the comma is shifted to the right.
*/
Expand Down
17 changes: 16 additions & 1 deletion packages/protocol/contracts/common/GasPriceMinimum.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ import "openzeppelin-solidity/contracts/ownership/Ownable.sol";

import "./CalledByVm.sol";
import "./Initializable.sol";
import "./interfaces/ICeloVersionedContract.sol";
import "./FixidityLib.sol";
import "./UsingRegistry.sol";
import "../stability/interfaces/ISortedOracles.sol";

/**
* @title Stores and provides gas price minimum for various currencies.
*/
contract GasPriceMinimum is Ownable, Initializable, UsingRegistry, CalledByVm {
contract GasPriceMinimum is
ICeloVersionedContract,
Ownable,
Initializable,
UsingRegistry,
CalledByVm
{
using FixidityLib for FixidityLib.Fraction;
using SafeMath for uint256;

Expand All @@ -30,6 +37,14 @@ contract GasPriceMinimum is Ownable, Initializable, UsingRegistry, CalledByVm {
// Speed of gas price minimum adjustment due to congestion.
FixidityLib.Fraction public adjustmentSpeed;

/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 0);
}

/**
* @notice Used in place of the constructor to allow the contract to be upgradable via proxy.
* @param _registryAddress The address of the registry core smart contract.
Expand Down
8 changes: 8 additions & 0 deletions packages/protocol/contracts/common/Signatures.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ pragma solidity ^0.5.13;
import "openzeppelin-solidity/contracts/cryptography/ECDSA.sol";

library Signatures {
/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 0);
}

/**
* @notice Given a signed address, returns the signer of the address.
* @param message The address that was signed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ library AddressLinkedList {
using LinkedList for LinkedList.List;
using SafeMath for uint256;

/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 0);
}

function toBytes(address a) public pure returns (bytes32) {
return bytes32(uint256(a) << 96);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ library AddressSortedLinkedList {
using SafeMath for uint256;
using SortedLinkedList for SortedLinkedList.List;

/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 0);
}

function toBytes(address a) public pure returns (bytes32) {
return bytes32(uint256(a) << 96);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ library AddressSortedLinkedListWithMedian {
using SafeMath for uint256;
using SortedLinkedListWithMedian for SortedLinkedListWithMedian.List;

/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 0);
}

function toBytes(address a) public pure returns (bytes32) {
return bytes32(uint256(a) << 96);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ library IntegerSortedLinkedList {
using SafeMath for uint256;
using SortedLinkedList for SortedLinkedList.List;

/**
* @notice Returns the storage, major, minor, and patch version of the contract.
* @return The storage, major, minor, and patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 0);
}

/**
* @notice Inserts an element into a doubly linked list.
* @param list A storage pointer to the underlying list.
Expand Down
14 changes: 7 additions & 7 deletions packages/protocol/contracts/common/linkedlists/LinkedList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ library LinkedList {
* @param previousKey The key of the element that comes before the element to insert.
* @param nextKey The key of the element that comes after the element to insert.
*/
function insert(List storage list, bytes32 key, bytes32 previousKey, bytes32 nextKey) public {
function insert(List storage list, bytes32 key, bytes32 previousKey, bytes32 nextKey) internal {
require(key != bytes32(0), "Key must be defined");
require(!contains(list, key), "Can't insert an existing element");
require(
Expand Down Expand Up @@ -82,7 +82,7 @@ library LinkedList {
* @param list A storage pointer to the underlying list.
* @param key The key of the element to insert.
*/
function push(List storage list, bytes32 key) public {
function push(List storage list, bytes32 key) internal {
insert(list, key, bytes32(0), list.tail);
}

Expand All @@ -91,7 +91,7 @@ library LinkedList {
* @param list A storage pointer to the underlying list.
* @param key The key of the element to remove.
*/
function remove(List storage list, bytes32 key) public {
function remove(List storage list, bytes32 key) internal {
Element storage element = list.elements[key];
require(key != bytes32(0) && contains(list, key), "key not in list");
if (element.previousKey != bytes32(0)) {
Expand Down Expand Up @@ -119,7 +119,7 @@ library LinkedList {
* @param previousKey The key of the element that comes before the updated element.
* @param nextKey The key of the element that comes after the updated element.
*/
function update(List storage list, bytes32 key, bytes32 previousKey, bytes32 nextKey) public {
function update(List storage list, bytes32 key, bytes32 previousKey, bytes32 nextKey) internal {
require(
key != bytes32(0) && key != previousKey && key != nextKey && contains(list, key),
"key on in list"
Expand All @@ -134,7 +134,7 @@ library LinkedList {
* @param key The element key.
* @return Whether or not the key is in the sorted list.
*/
function contains(List storage list, bytes32 key) public view returns (bool) {
function contains(List storage list, bytes32 key) internal view returns (bool) {
return list.elements[key].exists;
}

Expand All @@ -145,7 +145,7 @@ library LinkedList {
* @return The keys of the N elements at the head of the list.
* @dev Reverts if n is greater than the number of elements in the list.
*/
function headN(List storage list, uint256 n) public view returns (bytes32[] memory) {
function headN(List storage list, uint256 n) internal view returns (bytes32[] memory) {
require(n <= list.numElements, "not enough elements");
bytes32[] memory keys = new bytes32[](n);
bytes32 key = list.head;
Expand All @@ -161,7 +161,7 @@ library LinkedList {
* @param list A storage pointer to the underlying list.
* @return All element keys from head to tail.
*/
function getKeys(List storage list) public view returns (bytes32[] memory) {
function getKeys(List storage list) internal view returns (bytes32[] memory) {
return headN(list, list.numElements);
}
}
Loading

0 comments on commit ce93c3f

Please sign in to comment.