Skip to content

Commit

Permalink
Check if parameters exist before setting them (#99)
Browse files Browse the repository at this point in the history
* Check if parameteers exist before setting them

* bump version

* Create GenesisProtocolInterface.sol
  • Loading branch information
ben-kaufman authored Nov 16, 2020
1 parent 46c3d71 commit 4034ef5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
11 changes: 11 additions & 0 deletions contracts/votingMachines/GenesisProtocolInterface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pragma solidity 0.5.17;


contract GenesisProtocolInterface {
function setParameters(
uint[11] calldata _params, //use array here due to stack too deep issue.
address _voteOnBehalf
)
external
returns(bytes32);
}
6 changes: 6 additions & 0 deletions contracts/votingMachines/GenesisProtocolLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ contract GenesisProtocolLogic is IntVoteInterface {
require(_params[9] > 0, "daoBountyConst should be > 0");

bytes32 paramsHash = getParametersHash(_params, _voteOnBehalf);

if (parameters[paramsHash].queuedVoteRequiredPercentage > 0) {
//parameters already been set
return paramsHash;
}

//set a limit for power for a given alpha to prevent overflow
uint256 limitExponent = 172;//for alpha less or equal 2
uint256 j = 2;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@daostack/infra",
"version": "0.0.1-rc.19",
"version": "0.0.1-rc.20",
"description": "Base layer DAO's components",
"files": [
"contracts/",
Expand Down
16 changes: 16 additions & 0 deletions test/genesisprotocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,22 @@ contract('GenesisProtocol', accounts => {

it("Non-existent parameters hash shouldn't work - propose with wrong organization", async function() {
var testSetup = await setup(accounts);
await testSetup.genesisProtocolCallbacks.setParameters(
[
50,
60,
60,
0,
2000,
0,
60,
10,
15,
1000,
0
],
helpers.NULL_ADDRESS
);
await testSetup.genesisProtocolCallbacks.propose(2, testSetup.genesisProtocolParams.paramsHash,helpers.NULL_ADDRESS,accounts[0],helpers.NULL_ADDRESS);

try {
Expand Down

0 comments on commit 4034ef5

Please sign in to comment.