Skip to content
This repository was archived by the owner on Jan 7, 2026. It is now read-only.

Commit 0b80954

Browse files
committed
Remove dynamic tasking
- Remove dynamic tasking algorithm - Create fixed number of tasks per round per node
1 parent df43b26 commit 0b80954

3 files changed

Lines changed: 52 additions & 310 deletions

File tree

api/lib/round-tracker.js

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,7 @@ import assert from 'node:assert'
22
import * as Sentry from '@sentry/node'
33
import { createMeridianContract } from './ie-contract.js'
44

5-
// Tweak this to control the network's overall task count.
6-
export const TASKS_EXECUTED_PER_ROUND = 250_000
7-
8-
// Baseline values for how many tasks should be completed every round, and how
9-
// many tasks each SPARK checker node is expected to complete (every round, at
10-
// most). The actual value will be set dynamically based on
11-
// TASKS_EXECUTED_PER_ROUND and the number of tasks executed in the last round.
12-
export const BASELINE_TASKS_PER_ROUND = 1000
13-
export const BASELINE_TASKS_PER_NODE = 15
14-
export const MAX_TASKS_PER_NODE_LIMIT = 50
15-
16-
export const ROUND_TASKS_TO_NODE_TASKS_RATIO = BASELINE_TASKS_PER_ROUND / BASELINE_TASKS_PER_NODE
5+
export const TASKS_PER_ROUND = 100
176

187
/** @typedef {Awaited<ReturnType<import('./ie-contract.js').createMeridianContract>>} MeridianContract */
198

@@ -242,24 +231,16 @@ export async function maybeCreateSparkRound (pgClient, {
242231
roundStartEpoch,
243232
recordTelemetry
244233
}) {
245-
// maxTasksPerNode(round(n)) =
246-
// BASELINE_TASKS_PER_NODE
247-
// if n=0
248-
// BASELINE_TASKS_PER_NODE
249-
// if measurementCount(round(n-1)) = 0
250-
// min(
251-
// maxTasksPerNode(round(n-1)) * (TASKS_EXECUTED_PER_ROUND / measurementCount(round(n-1))),
252-
// MAX_TASKS_PER_NODE_LIMIT
253-
// )
254-
// otherwise
255234
const { rows: [previousRound] } = await pgClient.query(`
256235
SELECT measurement_count, max_tasks_per_node
257236
FROM spark_rounds
258237
WHERE id = $1 - 1::bigint
259238
`, [
260239
sparkRoundNumber
261240
])
262-
const { rows, rowCount } = await pgClient.query(`
241+
242+
// Simplified: Always assign 100 tasks per node, every round.
243+
const { rowCount } = await pgClient.query(`
263244
INSERT INTO spark_rounds
264245
(id, created_at, meridian_address, meridian_round, start_epoch, max_tasks_per_node)
265246
VALUES (
@@ -268,14 +249,7 @@ export async function maybeCreateSparkRound (pgClient, {
268249
$2,
269250
$3,
270251
$4,
271-
GREATEST(1,
272-
LEAST(
273-
$5, /* MAX_TASKS_PER_NODE_LIMIT */
274-
$6::bigint /* previousRound.max_tasks_per_node || BASELINE_TASKS_PER_NODE */
275-
* $7::bigint /* TASKS_EXECUTED_PER_ROUND */
276-
/ $8::bigint /* previousRound.measurement_count || TASKS_EXECUTED_PER_ROUND */
277-
)
278-
)
252+
$5
279253
)
280254
ON CONFLICT DO NOTHING
281255
RETURNING max_tasks_per_node
@@ -284,23 +258,17 @@ export async function maybeCreateSparkRound (pgClient, {
284258
meridianContractAddress,
285259
meridianRoundIndex,
286260
roundStartEpoch,
287-
MAX_TASKS_PER_NODE_LIMIT,
288-
previousRound?.max_tasks_per_node || BASELINE_TASKS_PER_NODE,
289-
TASKS_EXECUTED_PER_ROUND,
290-
previousRound?.measurement_count || TASKS_EXECUTED_PER_ROUND
261+
TASKS_PER_ROUND
291262
])
292263

293264
if (rowCount) {
294265
// We created a new SPARK round. Let's define retrieval tasks for this new round.
295266
// This is a short- to medium-term solution until we move to fully decentralized tasking
296-
const taskCount = Math.floor(
297-
rows[0].max_tasks_per_node * ROUND_TASKS_TO_NODE_TASKS_RATIO
298-
)
299-
await defineTasksForRound(pgClient, sparkRoundNumber, taskCount)
267+
await defineTasksForRound(pgClient, sparkRoundNumber, TASKS_PER_ROUND)
300268
recordTelemetry('round', point => {
301-
point.intField('current_round_measurement_count_target', TASKS_EXECUTED_PER_ROUND)
302-
point.intField('current_round_task_count', taskCount)
303-
point.intField('current_round_node_max_task_count', rows[0].max_tasks_per_node)
269+
point.intField('current_round_measurement_count_target', TASKS_PER_ROUND)
270+
point.intField('current_round_task_count', TASKS_PER_ROUND)
271+
point.intField('current_round_node_max_task_count', TASKS_PER_ROUND)
304272
point.intField('previous_round_measurement_count', previousRound?.measurement_count ?? 0)
305273
point.intField('previous_round_node_max_task_count', previousRound?.max_tasks_per_node ?? 0)
306274
})

0 commit comments

Comments
 (0)