Skip to content

Commit

Permalink
fix(epochs): mark gatewway as failed based on the number of observati…
Browse files Browse the repository at this point in the history
…ons submitted, not the number of prescribed observers
  • Loading branch information
dtfiedler committed Jul 12, 2024
1 parent e67128e commit b324aef
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/epochs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ function epochs.distributeRewardsForEpoch(currentTimestamp)
local totalEligibleRewards = math.floor(balances.getBalance(ao.id) * epochs.getSettings().rewardPercentage)
local gatewayReward = math.floor(totalEligibleRewards * 0.95 / #activeGatewayAddresses)
local observerReward = math.floor(totalEligibleRewards * 0.05 / #prescribedObservers)
local totalObservationsSubmitted = #epoch.observations.reports or 0

-- check if already distributed rewards for epoch
if epoch.distributions.distributedTimestamp then
Expand All @@ -421,7 +422,7 @@ function epochs.distributeRewardsForEpoch(currentTimestamp)
local observersMarkedFailed = epoch.observations.failureSummaries
and epoch.observations.failureSummaries[gatewayAddress]
or {}
local failed = #observersMarkedFailed > (#prescribedObservers / 2) -- more than 50% of observers marked as failed
local failed = #observersMarkedFailed > (totalObservationsSubmitted / 2) -- more than 50% of observerations submitted marked gateway as failed

-- if prescribed, we'll update the prescribed stats as well - find if the observer address is in prescribed observers
local observerIndex = utils.findInArray(prescribedObservers, function(prescribedObserver)
Expand Down

0 comments on commit b324aef

Please sign in to comment.