Skip to content

Commit 4034ef5

Browse files
authored
Check if parameters exist before setting them (#99)
* Check if parameteers exist before setting them * bump version * Create GenesisProtocolInterface.sol
1 parent 46c3d71 commit 4034ef5

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pragma solidity 0.5.17;
2+
3+
4+
contract GenesisProtocolInterface {
5+
function setParameters(
6+
uint[11] calldata _params, //use array here due to stack too deep issue.
7+
address _voteOnBehalf
8+
)
9+
external
10+
returns(bytes32);
11+
}

contracts/votingMachines/GenesisProtocolLogic.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ contract GenesisProtocolLogic is IntVoteInterface {
264264
require(_params[9] > 0, "daoBountyConst should be > 0");
265265

266266
bytes32 paramsHash = getParametersHash(_params, _voteOnBehalf);
267+
268+
if (parameters[paramsHash].queuedVoteRequiredPercentage > 0) {
269+
//parameters already been set
270+
return paramsHash;
271+
}
272+
267273
//set a limit for power for a given alpha to prevent overflow
268274
uint256 limitExponent = 172;//for alpha less or equal 2
269275
uint256 j = 2;

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@daostack/infra",
3-
"version": "0.0.1-rc.19",
3+
"version": "0.0.1-rc.20",
44
"description": "Base layer DAO's components",
55
"files": [
66
"contracts/",

test/genesisprotocol.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,22 @@ contract('GenesisProtocol', accounts => {
618618

619619
it("Non-existent parameters hash shouldn't work - propose with wrong organization", async function() {
620620
var testSetup = await setup(accounts);
621+
await testSetup.genesisProtocolCallbacks.setParameters(
622+
[
623+
50,
624+
60,
625+
60,
626+
0,
627+
2000,
628+
0,
629+
60,
630+
10,
631+
15,
632+
1000,
633+
0
634+
],
635+
helpers.NULL_ADDRESS
636+
);
621637
await testSetup.genesisProtocolCallbacks.propose(2, testSetup.genesisProtocolParams.paramsHash,helpers.NULL_ADDRESS,accounts[0],helpers.NULL_ADDRESS);
622638

623639
try {

0 commit comments

Comments
 (0)