/
InitializerAuRa.sol
79 lines (75 loc) · 3.55 KB
/
InitializerAuRa.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
pragma solidity 0.5.10;
import "./interfaces/IBlockRewardAuRa.sol";
import "./interfaces/ICertifier.sol";
import "./interfaces/IRandomAuRa.sol";
import "./interfaces/IStakingAuRa.sol";
import "./interfaces/ITxPermission.sol";
import "./interfaces/IValidatorSetAuRa.sol";
/// @dev Used once on network startup and then destroyed.
/// Needed for initializing upgradeable contracts since
/// upgradeable contracts can't have constructors.
contract InitializerAuRa {
/// @param _contracts An array of the contracts:
/// 0 is ValidatorSetAuRa,
/// 1 is BlockRewardAuRa,
/// 2 is RandomAuRa,
/// 3 is StakingAuRa,
/// 4 is TxPermission,
/// 5 is Certifier.
/// @param _owner The contracts' owner.
/// @param _miningAddresses The array of initial validators' mining addresses.
/// @param _stakingAddresses The array of initial validators' staking addresses.
/// @param _firstValidatorIsUnremovable The boolean flag defining whether the first validator in the
/// `_miningAddresses/_stakingAddresses` array is non-removable.
/// Should be `false` for production network.
/// @param _delegatorMinStake The minimum allowed amount of delegator stake in Wei
/// (see the `StakingAuRa` contract).
/// @param _candidateMinStake The minimum allowed amount of candidate stake in Wei
/// (see the `StakingAuRa` contract).
/// @param _stakingEpochDuration The duration of a staking epoch in blocks
/// (e.g., 120954 = 1 week for 5-seconds blocks in AuRa).
/// @param _stakingEpochStartBlock The number of the first block of initial staking epoch
/// (must be zero if the network is starting from genesis block).
/// @param _stakeWithdrawDisallowPeriod The duration period (in blocks) at the end of a staking epoch
/// during which participants cannot stake or withdraw their staking tokens
/// (e.g., 4320 = 6 hours for 5-seconds blocks in AuRa).
/// @param _collectRoundLength The length of a collection round in blocks (see the `RandomAuRa` contract).
constructor(
address[] memory _contracts,
address _owner,
address[] memory _miningAddresses,
address[] memory _stakingAddresses,
bool _firstValidatorIsUnremovable,
uint256 _delegatorMinStake,
uint256 _candidateMinStake,
uint256 _stakingEpochDuration,
uint256 _stakingEpochStartBlock,
uint256 _stakeWithdrawDisallowPeriod,
uint256 _collectRoundLength
) public {
IValidatorSetAuRa(_contracts[0]).initialize(
_contracts[1], // _blockRewardContract
_contracts[2], // _randomContract
_contracts[3], // _stakingContract
_miningAddresses,
_stakingAddresses,
_firstValidatorIsUnremovable
);
IStakingAuRa(_contracts[3]).initialize(
_contracts[0], // _validatorSetContract
_stakingAddresses,
_delegatorMinStake,
_candidateMinStake,
_stakingEpochDuration,
_stakingEpochStartBlock,
_stakeWithdrawDisallowPeriod
);
IBlockRewardAuRa(_contracts[1]).initialize(_contracts[0], address(0));
IRandomAuRa(_contracts[2]).initialize(_collectRoundLength, _contracts[0], true);
address[] memory permittedAddresses = new address[](1);
permittedAddresses[0] = _owner;
ITxPermission(_contracts[4]).initialize(permittedAddresses, _contracts[5], _contracts[0]);
ICertifier(_contracts[5]).initialize(permittedAddresses, _contracts[0]);
selfdestruct(msg.sender);
}
}