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

Migrate Governance Tests #10697

Merged
merged 21 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
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
14 changes: 7 additions & 7 deletions .github/workflows/protocol_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,32 @@ jobs:

- name: Run tests common
# can't use gas limit because some setUp function use more than the limit
run: forge test -vvv --match-path "test-sol/common/*" # --block-gas-limit 20000000
run: forge test -vvv --match-path "test-sol/common/*" # --block-gas-limit 50000000

- name: Run tests compatibility
if: success() || failure()
run: forge test -vvv --block-gas-limit 20000000 --match-path "test-sol/compatibility/*"
run: forge test -vvv --block-gas-limit 50000000 --match-path "test-sol/compatibility/*"

- name: Run tests governance/network
if: success() || failure()
run: forge test -vvv --block-gas-limit 20000000 --match-path "test-sol/governance/network/*"
run: forge test -vvv --block-gas-limit 50000000 --match-path "test-sol/governance/network/*"

- name: Run tests governance/validators
if: success() || failure()
run: forge test -vvv --block-gas-limit 20000000 --match-path "test-sol/governance/validators/*"
run: forge test -vvv --block-gas-limit 50000000 --match-path "test-sol/governance/validators/*"

- name: Run tests governance/voting
# can't use gas limit because some setUp function use more than the limit
if: success() || failure()
run: forge test -vvv --match-path "test-sol/governance/voting/*" # --block-gas-limit 20000000
run: forge test -vvv --match-path "test-sol/governance/voting/*" --block-gas-limit 50000000

- name: Run tests stability
if: success() || failure()
run: forge test -vvv --block-gas-limit 20000000 --match-path "test-sol/stability/*"
run: forge test -vvv --block-gas-limit 50000000 --match-path "test-sol/stability/*"

- name: Run tests identity
if: success() || failure()
run: forge test -vvv --match-path "test-sol/identity/*"
run: forge test -vvv --block-gas-limit 50000000 --match-path "test-sol/identity/*"

- name: Fail if there are tests without folder
if: success() || failure()
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "packages/protocol/lib/celo-foundry"]
path = packages/protocol/lib/celo-foundry
url = https://github.com/celo-org/celo-foundry
[submodule "packages/protocol/lib/solidity-bytes-utils"]
path = packages/protocol/lib/solidity-bytes-utils
url = https://github.com/GNSPS/solidity-bytes-utils
Expand All @@ -13,6 +10,9 @@
[submodule "packages/protocol/lib/memview.sol"]
path = packages/protocol/lib/memview.sol
url = https://github.com/summa-tx/memview.sol
[submodule "packages/protocol/lib/celo-foundry"]
path = packages/protocol/lib/celo-foundry
url = https://github.com/celo-org/celo-foundry
[submodule "packages/protocol/lib/openzeppelin-contracts8"]
path = packages/protocol/lib/openzeppelin-contracts8
url = https://github.com/OpenZeppelin/openzeppelin-contracts
Expand Down
6 changes: 3 additions & 3 deletions SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ Once you have go installed run the following to install gobind

#### Install Node

Currently Node.js v18.14.2 is required in order to work with this repo.
Currently Node.js v18 is required in order to work with this repo.

Install `nvm` (allows you to manage multiple versions of Node) by following the [instructions here](https://github.com/nvm-sh/nvm).

Once `nvm` is successfully installed, restart the terminal and run the following commands to install the `npm` versions that [celo-monorepo](https://github.com/celo-org/celo-monorepo) will need:

```bash
# restart the terminal after installing nvm
nvm install 18.14.2
nvm alias default 18.14.2
nvm install 18
nvm alias default 18
```

### MacOS
Expand Down
23 changes: 20 additions & 3 deletions packages/protocol/contracts/governance/Governance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ contract Governance is
* @return Patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 4, 0, 0);
return (1, 4, 1, 0);
}

/**
Expand Down Expand Up @@ -762,7 +762,6 @@ contract Governance is
noVotes,
abstainVotes
);

} else {
proposal.updateVote(
previousVoteRecord.yesVotes,
Expand Down Expand Up @@ -953,7 +952,7 @@ contract Governance is
uint256[] calldata dataLengths,
bytes32 salt
) external {
bytes32 hash = keccak256(abi.encode(values, destinations, data, dataLengths, salt));
bytes32 hash = this.getHotfixHash(values, destinations, data, dataLengths, salt);
soloseng marked this conversation as resolved.
Show resolved Hide resolved

(bool approved, bool executed, uint256 preparedEpoch) = getHotfixRecord(hash);
require(!executed, "hotfix already executed");
Expand Down Expand Up @@ -1592,6 +1591,24 @@ contract Governance is
.fromFixed();
}

/**
* @param values The values of CELO to be sent in the proposed transactions.
* @param destinations The destination addresses of the proposed transactions.
* @param data The concatenated data to be included in the proposed transactions.
* @param dataLengths The lengths of each transaction's data.
* @param salt Arbitrary salt associated with hotfix which guarantees uniqueness of hash.
* @return The hash of the hotfix.
*/
function getHotfixHash(
uint256[] calldata values,
address[] calldata destinations,
bytes calldata data,
uint256[] calldata dataLengths,
bytes32 salt
) external pure returns (bytes32) {
return keccak256(abi.encode(values, destinations, data, dataLengths, salt));
}

/**
* @notice Returns the stage of a dequeued proposal.
* @param proposal The proposal struct.
Expand Down
40 changes: 0 additions & 40 deletions packages/protocol/contracts/governance/test/GovernanceTest.sol

This file was deleted.

4 changes: 2 additions & 2 deletions packages/protocol/migrationsConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,10 @@ NetworkConfigs.alfajoresstaging = NetworkConfigs.alfajores
NetworkConfigs.mainnet = NetworkConfigs.rc1

const linkedLibraries = {
Proposals: ['Governance', 'GovernanceTest'],
Proposals: ['Governance'],
AddressLinkedList: ['Validators', 'ValidatorsTest'],
AddressSortedLinkedList: ['Election', 'ElectionTest'],
IntegerSortedLinkedList: ['Governance', 'GovernanceTest', 'IntegerSortedLinkedListTest'],
IntegerSortedLinkedList: ['Governance', 'IntegerSortedLinkedListTest'],
AddressSortedLinkedListWithMedian: ['SortedOracles', 'AddressSortedLinkedListWithMedianTest'],
Signatures: [
'Accounts',
Expand Down
Loading
Loading