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

Script to deploy smart contract changes to a network via governance #4706

Merged
merged 44 commits into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3588479
WIP make-release
Aug 4, 2020
9bff9b9
Merge branch 'master' into asaj/make-release
Aug 4, 2020
6c4ba95
Somewhat functional
Aug 4, 2020
5875573
Smarter releases WIP
Aug 11, 2020
8b6ea77
Add library proxies
Aug 11, 2020
29a2d56
Missing proxy
Aug 11, 2020
220c76e
Make it work with upgradable libraries
Aug 11, 2020
3326ccf
Read initialize data json
Aug 13, 2020
18170e5
Sanity checks for release 1
Aug 13, 2020
3d0f783
Add version number to contracts that link libraries
Aug 13, 2020
4ea8b4e
update version numbers
Aug 13, 2020
3b123df
Add version to linkedlist
Aug 13, 2020
67ca837
Ignore proxies when generating compatibility report
Aug 14, 2020
86d1abd
Version fixidity lib
Aug 14, 2020
de9e1fd
cleanup
Aug 14, 2020
57a1529
Merge branch 'master' into asaj/make-release
Aug 14, 2020
6f308cc
Add script for making releases
Aug 14, 2020
295e5e0
oops
Aug 14, 2020
995dfc8
oops
Aug 14, 2020
150aaf7
cleanup
Aug 14, 2020
1832bf9
typo
Aug 14, 2020
1ca0365
Fix
Aug 14, 2020
2817f8a
Merge branch 'master' into asaj/make-release
Aug 14, 2020
88e8fc0
Cleanup
Aug 14, 2020
bdd7de8
Start work on dry-run
Aug 18, 2020
784b476
Address comments, fix lint
Aug 18, 2020
052b2f8
Fix migrationsconfig
Aug 18, 2020
d803200
Merge branch 'master' into asaj/make-release
Aug 18, 2020
a3b58e5
Address comments
Aug 20, 2020
783c4a6
Merge branch 'master' into asaj/make-release
Aug 20, 2020
10a3278
Update docs
Aug 20, 2020
4429df1
Make work
Aug 20, 2020
b7dbc16
Merge branch 'master' into asaj/make-release
Aug 20, 2020
101c5af
Merge branch 'master' into asaj/make-release
Aug 21, 2020
14bd5b3
Inline libraries where possible
Aug 24, 2020
783e5b7
Address feedback
Aug 24, 2020
4d3a08d
Merge branch 'asaj/make-release' of https://github.com/celo-org/celo-…
Aug 24, 2020
dae202d
Merge branch 'master' into asaj/make-release
Aug 24, 2020
c0687ba
Merge branch 'master' into asaj/make-release
mergify[bot] Aug 25, 2020
48079ef
Merge branch 'master' into asaj/make-release
mergify[bot] Aug 25, 2020
e02ffbb
Merge branch 'master' into asaj/make-release
mergify[bot] Aug 25, 2020
3beb283
Merge branch 'master' into asaj/make-release
mergify[bot] Aug 25, 2020
36e977b
Inlined library should be inlined
Aug 25, 2020
2c22704
Ignore inlined libraries
Aug 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,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`)
asaj marked this conversation as resolved.
Show resolved Hide resolved

export type CeloToken = CeloContract.GoldToken | CeloContract.StableToken

Expand Down
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.3;
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) {
asaj marked this conversation as resolved.
Show resolved Hide resolved
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;
asaj marked this conversation as resolved.
Show resolved Hide resolved
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ library LinkedList {
mapping(bytes32 => Element) elements;
}

/**
* @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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ library SortedLinkedList {
mapping(bytes32 => uint256) values;
}

/**
* @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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ library SortedLinkedListWithMedian {
mapping(bytes32 => MedianRelation) relation;
}

/**
* @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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pragma solidity ^0.5.3;

import "../Proxy.sol";

/* solhint-disable no-empty-blocks */
contract AddressLinkedListProxy is Proxy {}
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason why these need to be explicitly separate instead of just reusing Proxy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we wanted separate build artifacts for each. Happy to revisit this question outside the scope of this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, this definitely made things easier when relying on Truffle for contract deployments. I guess going forward we'll be doing upgrade deployments somewhat differently (using this PR's script), but keeping with this convention might still be good to keep things organized, keep track of which contracts are proxied, + we still use Truffle for any dev deployments/new testnets.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pragma solidity ^0.5.3;

import "../Proxy.sol";

/* solhint-disable no-empty-blocks */
contract AddressSortedLinkedListProxy is Proxy {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pragma solidity ^0.5.3;

import "../Proxy.sol";

/* solhint-disable no-empty-blocks */
contract AddressSortedLinkedListWithMedianProxy is Proxy {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pragma solidity ^0.5.3;

import "../Proxy.sol";

/* solhint-disable no-empty-blocks */
contract FixidityLibProxy is Proxy {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pragma solidity ^0.5.3;

import "../Proxy.sol";

/* solhint-disable no-empty-blocks */
contract IntegerSortedLinkedListProxy is Proxy {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pragma solidity ^0.5.3;

import "../Proxy.sol";

/* solhint-disable no-empty-blocks */
contract LinkedListProxy is Proxy {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pragma solidity ^0.5.3;

import "../Proxy.sol";

/* solhint-disable no-empty-blocks */
contract SignaturesProxy is Proxy {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pragma solidity ^0.5.3;

import "../Proxy.sol";

/* solhint-disable no-empty-blocks */
contract SortedLinkedListProxy is Proxy {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pragma solidity ^0.5.3;

import "../Proxy.sol";

/* solhint-disable no-empty-blocks */
contract SortedLinkedListWithMedianProxy is Proxy {}
8 changes: 8 additions & 0 deletions packages/protocol/contracts/governance/Proposals.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ library Proposals {
string descriptionUrl;
}

/**
* @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 Constructs a proposal.
* @param proposal The proposal struct to be constructed.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pragma solidity ^0.5.3;

import "../../common/Proxy.sol";

/* solhint-disable no-empty-blocks */
contract ProposalsProxy is Proxy {}
18 changes: 17 additions & 1 deletion packages/protocol/contracts/identity/Escrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "./interfaces/IAttestations.sol";
import "./interfaces/IEscrow.sol";
import "../common/Initializable.sol";
import "../common/interfaces/ICeloVersionedContract.sol";
import "../common/UsingRegistry.sol";
import "../common/Signatures.sol";
import "../common/libraries/ReentrancyGuard.sol";

contract Escrow is IEscrow, ReentrancyGuard, Ownable, Initializable, UsingRegistry {
contract Escrow is
IEscrow,
ICeloVersionedContract,
ReentrancyGuard,
Ownable,
Initializable,
UsingRegistry
{
using SafeMath for uint256;

event Transfer(
Expand Down Expand Up @@ -61,6 +69,14 @@ contract Escrow is IEscrow, ReentrancyGuard, Ownable, Initializable, UsingRegist
// Maps senders' addresses to a list of sent escrowed payment IDs.
mapping(address => address[]) public sentPaymentIds;

/**
* @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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "../Attestations.sol";
* but mocks the implementations of the validator set getters. Otherwise we
* couldn't test `request` with the current ganache local testnet.
*/
contract TestAttestations is Attestations {
contract AttestationsTest is Attestations {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, definitely a major nit, but to me XTest sounds like "file containing tests for X", TestX like "a version of X used for testing". Most of these files I think are the latter, so just wondering why the rename?

Copy link
Contributor Author

@asaj asaj Aug 24, 2020

Choose a reason for hiding this comment

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

Just to be consistent, happy to rename to TestX rather than XTest but would prefer not to block this PR on that

address[] private __testValidators;

function __setValidators(address[] memory validators) public {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pragma solidity ^0.5.3;

import "../Random.sol";

contract TestRandom is Random {
contract RandomTest is Random {
function addTestRandomness(uint256 blockNumber, bytes32 randomness) external {
addRandomness(blockNumber, randomness);
}
Expand Down
Loading