@@ -155,11 +155,14 @@ func (t *TestSuite) ApplyEpochActions(epoch iotago.EpochIndex, actions map[strin
155
155
for alias , action := range actions {
156
156
epochPerformanceFactor := action .SlotPerformance * action .ActiveSlotsCount >> t .api .ProtocolParameters ().SlotsPerEpochExponent ()
157
157
poolRewards := t .calculatePoolReward (epoch , totalValidatorsStake , totalStake , action .PoolStake , action .ValidatorStake , epochPerformanceFactor )
158
+ poolRewardsFloat := t .calculatePoolRewardFloat (epoch , totalValidatorsStake , totalStake , action .PoolStake , action .ValidatorStake , epochPerformanceFactor )
158
159
t.poolRewards [epoch ][alias ] = & model.PoolRewards {
159
160
PoolStake : action .PoolStake ,
160
161
PoolRewards : iotago .Mana (poolRewards ),
161
162
FixedCost : action .FixedCost ,
162
163
}
164
+
165
+ require .InEpsilon (t .T , poolRewards , poolRewardsFloat , 0.01 )
163
166
}
164
167
}
165
168
@@ -284,14 +287,29 @@ func (t *TestSuite) calculatePoolReward(epoch iotago.EpochIndex, totalValidators
284
287
params := t .api .ProtocolParameters ()
285
288
targetReward , err := params .RewardsParameters ().TargetReward (epoch , t .api )
286
289
require .NoError (t .T , err )
287
-
288
290
poolCoefficient := t .calculatePoolCoefficient (poolStake , totalStake , validatorStake , totalValidatorsStake )
289
291
scaledPoolReward := poolCoefficient * uint64 (targetReward ) * performanceFactor
290
292
poolRewardNoFixedCost := scaledPoolReward / uint64 (params .ValidationBlocksPerSlot ()) >> (params .RewardsParameters ().PoolCoefficientExponent + 1 )
291
293
292
294
return poolRewardNoFixedCost
293
295
}
294
296
297
+ func (t * TestSuite ) calculatePoolRewardFloat (epoch iotago.EpochIndex , totalValidatorsStake , totalStake , poolStake , validatorStake iotago.BaseToken , performanceFactor uint64 ) float64 {
298
+ params := t .api .ProtocolParameters ()
299
+ totalValidatorsStakeFloat := float64 (totalValidatorsStake )
300
+ totalStakeFloat := float64 (totalStake )
301
+ poolStakeFloat := float64 (poolStake )
302
+ validatorStakeFloat := float64 (validatorStake )
303
+ performanceFactorFloat := float64 (performanceFactor ) / float64 (params .ValidationBlocksPerSlot ())
304
+
305
+ targetReward , _ := params .RewardsParameters ().TargetReward (epoch , t .api )
306
+ targetRewardFloat := float64 (targetReward )
307
+
308
+ poolCoefficientFloat := (poolStakeFloat / totalStakeFloat + validatorStakeFloat / totalValidatorsStakeFloat ) / 2.0
309
+ PoolRewardFloat := poolCoefficientFloat * targetRewardFloat * performanceFactorFloat
310
+ return PoolRewardFloat
311
+ }
312
+
295
313
func (t * TestSuite ) calculatePoolCoefficient (poolStake , totalStake , validatorStake , totalValidatorStake iotago.BaseToken ) uint64 {
296
314
poolCoeffExponent := t .api .ProtocolParameters ().RewardsParameters ().PoolCoefficientExponent
297
315
poolCoeff := (poolStake << poolCoeffExponent )/ totalStake +
0 commit comments