Skip to content

Commit

Permalink
Hardcoded limit of 50 validators
Browse files Browse the repository at this point in the history
  • Loading branch information
k1rill-fedoseev committed Dec 12, 2019
1 parent 869b392 commit ad3f555
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 20 deletions.
2 changes: 2 additions & 0 deletions contracts/upgradeable_contracts/BaseBridgeValidators.sol
Expand Up @@ -8,6 +8,7 @@ contract BaseBridgeValidators is InitializableBridge, Ownable {
using SafeMath for uint256;

address public constant F_ADDR = 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF;
uint256 internal constant MAX_VALIDATORS = 50;
bytes32 internal constant REQUIRED_SIGNATURES = 0xd18ea17c351d6834a0e568067fb71804d2a588d5e26d60f792b1c724b1bd53b1; // keccak256(abi.encodePacked("requiredSignatures"))
bytes32 internal constant VALIDATOR_COUNT = 0x8656d603d9f985c3483946a92789d52202f49736384ba131cb92f62c4c1aa082; // keccak256(abi.encodePacked("validatorCount"))

Expand Down Expand Up @@ -95,6 +96,7 @@ contract BaseBridgeValidators is InitializableBridge, Ownable {
}

function setValidatorCount(uint256 _validatorCount) internal {
require(_validatorCount <= MAX_VALIDATORS);
uintStorage[VALIDATOR_COUNT] = _validatorCount;
}

Expand Down
7 changes: 0 additions & 7 deletions contracts/upgradeable_contracts/BridgeValidators.sol
Expand Up @@ -3,8 +3,6 @@ pragma solidity 0.4.24;
import "./BaseBridgeValidators.sol";

contract BridgeValidators is BaseBridgeValidators {
uint256 internal constant MAX_VALIDATORS = 287;

function initialize(uint256 _requiredSignatures, address[] _initialValidators, address _owner)
external
returns (bool)
Expand Down Expand Up @@ -52,9 +50,4 @@ contract BridgeValidators is BaseBridgeValidators {
_removeValidator(_validator);
emit ValidatorRemoved(_validator);
}

function setValidatorCount(uint256 _validatorCount) internal {
require(_validatorCount <= MAX_VALIDATORS);
super.setValidatorCount(_validatorCount);
}
}
7 changes: 0 additions & 7 deletions contracts/upgradeable_contracts/RewardableValidators.sol
Expand Up @@ -3,8 +3,6 @@ pragma solidity 0.4.24;
import "./BaseBridgeValidators.sol";

contract RewardableValidators is BaseBridgeValidators {
uint256 internal constant MAX_VALIDATORS = 140;

function initialize(
uint256 _requiredSignatures,
address[] _initialValidators,
Expand Down Expand Up @@ -68,9 +66,4 @@ contract RewardableValidators is BaseBridgeValidators {
function setValidatorRewardAddress(address _validator, address _reward) internal {
addressStorage[keccak256(abi.encodePacked("validatorsRewards", _validator))] = _reward;
}

function setValidatorCount(uint256 _validatorCount) internal {
require(_validatorCount <= MAX_VALIDATORS);
super.setValidatorCount(_validatorCount);
}
}
2 changes: 1 addition & 1 deletion test/erc_to_erc/home_bridge.test.js
Expand Up @@ -23,7 +23,7 @@ const foreignDailyLimit = oneEther
const foreignMaxPerTx = halfEther
const ZERO = toBN(0)
const MAX_GAS = 8000000
const MAX_VALIDATORS = 140
const MAX_VALIDATORS = 50
const decimalShiftZero = 0
const markedAsProcessed = toBN(2)
.pow(toBN(255))
Expand Down
2 changes: 1 addition & 1 deletion test/erc_to_native/home_bridge.test.js
Expand Up @@ -22,7 +22,7 @@ const foreignDailyLimit = oneEther
const foreignMaxPerTx = halfEther
const ZERO = toBN(0)
const MAX_GAS = 8000000
const MAX_VALIDATORS = 140
const MAX_VALIDATORS = 50
const decimalShiftZero = 0

contract('HomeBridge_ERC20_to_Native', async accounts => {
Expand Down
2 changes: 1 addition & 1 deletion test/native_to_erc/foreign_bridge_test.js
Expand Up @@ -29,7 +29,7 @@ const homeDailyLimit = oneEther
const homeMaxPerTx = halfEther
const ZERO = toBN(0)
const MAX_GAS = 8000000
const MAX_VALIDATORS = 140
const MAX_VALIDATORS = 50
const decimalShiftZero = 0

contract('ForeignBridge', async accounts => {
Expand Down
2 changes: 1 addition & 1 deletion test/native_to_erc/home_bridge_test.js
Expand Up @@ -22,7 +22,7 @@ const foreignDailyLimit = oneEther
const foreignMaxPerTx = halfEther
const ZERO = toBN(0)
const MAX_GAS = 8000000
const MAX_VALIDATORS = 140
const MAX_VALIDATORS = 50
const decimalShiftZero = 0

contract('HomeBridge', async accounts => {
Expand Down
2 changes: 1 addition & 1 deletion test/rewardable_validators_test.js
Expand Up @@ -6,7 +6,7 @@ const { ERROR_MSG, ZERO_ADDRESS, F_ADDRESS, BN } = require('./setup')
const { expectEventInLogs, createAccounts } = require('./helpers/helpers')

const MAX_GAS = 8000000
const MAX_VALIDATORS = 140
const MAX_VALIDATORS = 50
const ZERO = new BN(0)

contract('RewardableValidators', async accounts => {
Expand Down
2 changes: 1 addition & 1 deletion test/validators_test.js
Expand Up @@ -6,7 +6,7 @@ const { ERROR_MSG, ZERO_ADDRESS, F_ADDRESS, BN } = require('./setup')
const { expectEventInLogs, createAccounts } = require('./helpers/helpers')

const MAX_GAS = 8000000
const MAX_VALIDATORS = 287
const MAX_VALIDATORS = 50
const ZERO = new BN(0)

contract('BridgeValidators', async accounts => {
Expand Down

0 comments on commit ad3f555

Please sign in to comment.