@@ -14,10 +14,10 @@ contract SFCState is Initializable, Ownable {
14
14
uint256 status;
15
15
uint256 deactivatedTime;
16
16
uint256 deactivatedEpoch;
17
- uint256 receivedStake;
17
+ uint256 receivedStake; // from all delegators (weight of the validator)
18
18
uint256 createdEpoch;
19
19
uint256 createdTime;
20
- address auth;
20
+ address auth; // self-stake delegator
21
21
}
22
22
23
23
NodeDriverAuth internal node;
@@ -28,26 +28,34 @@ contract SFCState is Initializable, Ownable {
28
28
uint256 unlockedReward;
29
29
}
30
30
31
+ // last sealed epoch (currentEpoch - 1)
31
32
uint256 public currentSealedEpoch;
32
33
mapping (uint256 => Validator) public getValidator;
33
34
mapping (address => uint256 ) public getValidatorID;
34
35
mapping (uint256 => bytes ) public getValidatorPubkey;
35
36
36
37
uint256 public lastValidatorID;
38
+
39
+ // total stake of all validators - includes slashed/offline validators
37
40
uint256 public totalStake;
41
+ // total stake of active (OK_STATUS) validators (total weight)
38
42
uint256 public totalActiveStake;
43
+ // sum of penalties subtracted from successful withdrawals - TODO misleading - remove?
39
44
uint256 public totalSlashedStake;
40
45
41
- mapping (address => mapping (uint256 => Rewards)) internal _rewardsStash; // addr, validatorID -> Rewards
46
+ // delegator => validator ID => stashed rewards (to be claimed/restaked)
47
+ mapping (address => mapping (uint256 => Rewards)) internal _rewardsStash;
42
48
49
+ // delegator => validator ID => last epoch number for which were rewards stashed
43
50
mapping (address => mapping (uint256 => uint256 )) public stashedRewardsUntilEpoch;
44
51
45
52
struct WithdrawalRequest {
46
- uint256 epoch;
47
- uint256 time;
53
+ uint256 epoch; // epoch where undelegated
54
+ uint256 time; // when undelegated
48
55
uint256 amount;
49
56
}
50
57
58
+ // delegator => validator ID => withdrawal ID => withdrawal request
51
59
mapping (address => mapping (uint256 => mapping (uint256 => WithdrawalRequest))) public getWithdrawalRequest;
52
60
53
61
struct LockedDelegation {
@@ -57,43 +65,56 @@ contract SFCState is Initializable, Ownable {
57
65
uint256 duration;
58
66
}
59
67
68
+ // delegator => validator ID => current stake (locked+unlocked)
60
69
mapping (address => mapping (uint256 => uint256 )) public getStake;
61
70
71
+ // delegator => validator ID => locked stake info
62
72
mapping (address => mapping (uint256 => LockedDelegation)) public getLockupInfo;
63
73
64
74
mapping (address => mapping (uint256 => Rewards)) public getStashedLockupRewards;
65
75
66
76
struct EpochSnapshot {
77
+ // validator ID => validator weight in the epoch
67
78
mapping (uint256 => uint256 ) receivedStake;
79
+ // validator ID => accumulated ( delegatorsReward * 1e18 / receivedStake )
68
80
mapping (uint256 => uint256 ) accumulatedRewardPerToken;
81
+ // validator ID => accumulated online time
69
82
mapping (uint256 => uint256 ) accumulatedUptime;
83
+ // validator ID => gas fees from txs originated by the validator
70
84
mapping (uint256 => uint256 ) accumulatedOriginatedTxsFee;
71
85
mapping (uint256 => uint256 ) offlineTime;
72
86
mapping (uint256 => uint256 ) offlineBlocks;
73
87
uint256 [] validatorIDs;
74
88
uint256 endTime;
75
89
uint256 endBlock;
76
- uint256 epochFee;
77
- uint256 totalBaseRewardWeight;
78
- uint256 totalTxRewardWeight;
79
- uint256 baseRewardPerSecond;
80
- uint256 totalStake;
81
- uint256 totalSupply;
90
+ uint256 epochFee; // gas fees from txs in the epoch
91
+ uint256 totalBaseRewardWeight; // sum( stake * uptimeRatio ^ 2 ) TODO write only - remove?
92
+ uint256 totalTxRewardWeight; // sum( originatedTxsFee * uptimeRatio ) TODO write only - remove?
93
+ uint256 baseRewardPerSecond; // the base reward to divide among validators for each second of the epoch
94
+ uint256 totalStake; // total weight of all validators
95
+ uint256 totalSupply; // total supply of native tokens
82
96
}
83
97
98
+ // the total supply of native tokens in the chain
84
99
uint256 public totalSupply;
100
+ // epoch id => epoch snapshot
85
101
mapping (uint256 => EpochSnapshot) public getEpochSnapshot;
86
102
87
- mapping (uint256 => uint256 ) public slashingRefundRatio; // validator ID -> (slashing refund ratio)
103
+ // validator ID -> slashing refund ratio (allows to withdraw slashed stake)
104
+ mapping (uint256 => uint256 ) public slashingRefundRatio;
88
105
106
+ // the minimal gas price calculated for the current epoch
89
107
uint256 public minGasPrice;
90
108
109
+ // the treasure contract (receives unlock penalties and a part of epoch fees)
91
110
address public treasuryAddress;
92
111
112
+ // the SFCLib contract
93
113
address internal libAddress;
94
114
95
115
ConstantsManager internal c;
96
116
117
+ // the governance contract (to recalculate votes when the stake changes)
97
118
address public voteBookAddress;
98
119
99
120
struct Penalty {
@@ -103,13 +124,18 @@ contract SFCState is Initializable, Ownable {
103
124
// delegator => validatorID => penalties info
104
125
mapping (address => mapping (uint256 => Penalty[])) public getStashedPenalties;
105
126
127
+ // validator ID => amount of pubkey updates
106
128
mapping (uint256 => uint256 ) internal validatorPubkeyChanges;
107
129
130
+ // keccak256(pubkey bytes) => validator ID (prevents using the same key by multiple validators)
108
131
mapping (bytes32 => uint256 ) internal pubkeyHashToValidatorID;
109
132
133
+ // address authorized to initiate redirection
110
134
address public redirectionAuthorizer;
111
135
136
+ // delegator => withdrawals receiver
112
137
mapping (address => address ) public getRedirectionRequest;
113
138
139
+ // delegator => withdrawals receiver
114
140
mapping (address => address ) public getRedirection;
115
141
}
0 commit comments