Skip to content

Commit

Permalink
fix(gar): update the logic for compute prescribed observers and tests (
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler authored Aug 5, 2024
2 parents 8075c5c + d89917e commit bf2ead6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
5 changes: 3 additions & 2 deletions spec/gar_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,9 @@ describe("gar", function()
local timestamp = 100
local expectedTenureWeight = timestamp / gar.getSettings().observers.tenureWeightPeriod
local expectedStakeWeight = 1
local expectedObserverRatioWeight = 1 / 3
local expectedGatewayRatioWeight = 3 / 10
-- NOTE: we increment by one to avoid division by zero
local expectedObserverRatioWeight = 2 / 4 -- (the stats are 1/3)
local expectedGatewayRatioWeight = 4 / 11 -- (the tats are 3/10)
local expectedCompositeWeight = expectedStakeWeight
* expectedTenureWeight
* expectedGatewayRatioWeight
Expand Down
8 changes: 2 additions & 6 deletions src/gar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,10 @@ function gar.getGatewayWeightsAtTimestamp(gatewayAddresses, timestamp)

local totalEpochsGatewayPassed = gateway.stats.passedEpochCount or 0
local totalEpochsParticipatedIn = gateway.stats.totalEpochCount or 0
local gatewayRewardRatioWeight = totalEpochsParticipatedIn > 0
and totalEpochsGatewayPassed / totalEpochsParticipatedIn
or 1

local gatewayRewardRatioWeight = (1 + totalEpochsGatewayPassed) / (1 + totalEpochsParticipatedIn)
local totalEpochsPrescribed = gateway.stats.prescribedEpochCount or 0
local totalEpochsSubmitted = gateway.stats.observedEpochCount or 0
local observerRewardRatioWeight = totalEpochsPrescribed > 0 and totalEpochsSubmitted / totalEpochsPrescribed
or 1
local observerRewardRatioWeight = (1 + totalEpochsSubmitted) / (1 + totalEpochsPrescribed)

local compositeWeight = stakeWeightRatio
* gatewayTenureWeight
Expand Down
4 changes: 2 additions & 2 deletions tools/evolve.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const wallet = JSON.parse(process.env.WALLET);
const signer = createAoSigner(new ArweaveSigner(wallet));
const networkProcess = new AOProcess({ processId });

const evolveResult = await networkProcess.send({
const { id } = await networkProcess.send({
tags: [{ name: 'Action', value: 'Eval' }],
data: constants.BUNDLED_AOS_LUA,
signer,
});
console.log(`Evolve result: ${evolveResult}`);
console.log(`Evolve result tx: ${id}`);

0 comments on commit bf2ead6

Please sign in to comment.