Skip to content

Commit

Permalink
fix: calculate RSR using honest measurements only (#128)
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Bajtoš <[email protected]>
  • Loading branch information
bajtos authored Jan 16, 2024
1 parent d495910 commit 716bfc5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {
// FIXME Add back chain.love either when it's online or once onContractEvent
// supports rpc failover
// RPC_URLS = 'https://api.node.glif.io/rpc/v0,https://api.chain.love/rpc/v1',
RPC_URLS = 'https://api.node.glif.io/rpc/v0'
RPC_URLS = 'https://api.node.glif.io/rpc/v0',
GLIF_TOKEN,
DATABASE_URL = 'postgres://localhost:5432/spark_stats',
SPARK_API = 'https://api.filspark.com'
Expand Down
2 changes: 1 addition & 1 deletion lib/evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export const evaluate = async ({
}

try {
await updatePublicStats({ createPgClient, measurements })
await updatePublicStats({ createPgClient, honestMeasurements })
} catch (err) {
console.error('Cannot update public stats.', err)
Sentry.captureException(err)
Expand Down
6 changes: 3 additions & 3 deletions lib/public-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const debug = createDebug('spark:public-stats')
/**
* @param {object} args
* @param {import('./typings').CreatePgClient} args.createPgClient
* @param {import('./preprocess').Measurement[]} args.measurements
* @param {import('./preprocess').Measurement[]} args.honestMeasurements
*/
export const updatePublicStats = async ({ createPgClient, measurements }) => {
export const updatePublicStats = async ({ createPgClient, honestMeasurements }) => {
let total = 0
let successful = 0
for (const m of measurements) {
for (const m of honestMeasurements) {
total++
// TODO: take into account fraud detection
if (m.retrievalResult === 'OK') successful++
Expand Down
4 changes: 2 additions & 2 deletions test/evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ describe('evaluate', () => {
const { rows: publicStats } = await pgClient.query('SELECT * FROM retrieval_stats')
assert.deepStrictEqual(publicStats, [{
day: today(),
total: 10,
successful: 10
total: 1,
successful: 1
}])
})

Expand Down

0 comments on commit 716bfc5

Please sign in to comment.