Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add daily scheduled rewards #131

Merged
merged 67 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
5d1a0c7
add read scheduled rewards
juliangruber Jun 6, 2024
ea46819
fix lint
juliangruber Jun 6, 2024
6d41532
Merge branch 'main' into add/scheduled-rewards
juliangruber Jun 7, 2024
5baa7dc
fix lint
juliangruber Jun 7, 2024
cfd9b8c
fix migration number
juliangruber Jun 7, 2024
6647e52
wrap observation functions
juliangruber Jun 7, 2024
af65a20
wip
juliangruber Jun 7, 2024
c7b25b3
simplify, dry run works
juliangruber Jun 7, 2024
a5c0187
fix lint
juliangruber Jun 7, 2024
a6d1c16
Merge branch 'main' into add/scheduled-rewards
juliangruber Jun 9, 2024
2e291c4
Merge branch 'main' into add/scheduled-rewards
juliangruber Jun 10, 2024
8e047e8
split up loops
juliangruber Jun 11, 2024
716e589
get participants from db
juliangruber Jun 11, 2024
fa46614
sentry
juliangruber Jun 11, 2024
109c4f9
read from last 3 days of participants
juliangruber Jun 11, 2024
043af01
big refactor
juliangruber Jun 11, 2024
158bf59
add tests
juliangruber Jun 11, 2024
cb2cead
tests pass
juliangruber Jun 11, 2024
e1bd872
Merge branch 'main' into add/scheduled-rewards
juliangruber Jun 11, 2024
2b46dfa
fix lint
juliangruber Jun 11, 2024
0577ddc
add missing env
juliangruber Jun 11, 2024
f146179
fix missing ci db
juliangruber Jun 11, 2024
f12a51e
fix missing migrate call
juliangruber Jun 11, 2024
db3ecb1
fix migration bin
juliangruber Jun 11, 2024
fdb37fa
clean up
juliangruber Jun 11, 2024
a0866e6
fix lint
juliangruber Jun 11, 2024
5b8a082
fix migrate bin
juliangruber Jun 11, 2024
6f574ac
clean up
juliangruber Jun 11, 2024
f992097
Revert "clean up"
juliangruber Jun 12, 2024
c83d40a
refactor `migrate()`
juliangruber Jun 12, 2024
a3ea5f1
remove implicit migrate
juliangruber Jun 12, 2024
82a8d26
create `db` package
juliangruber Jun 12, 2024
f3c0271
Merge branch 'main' into add/scheduled-rewards
juliangruber Jun 12, 2024
cc9ad5d
add missing dep
juliangruber Jun 12, 2024
883a9ce
add missing dependency
juliangruber Jun 12, 2024
2aca0de
try run `npm ci` first
juliangruber Jun 12, 2024
19f0f5e
try run `npm install` first
juliangruber Jun 12, 2024
8323e13
clean up
juliangruber Jun 12, 2024
b217338
try update node
juliangruber Jun 12, 2024
f588f02
fix Dockerfile
juliangruber Jun 12, 2024
ba1fdec
downgrade again to keep diff small
juliangruber Jun 12, 2024
5da6faa
add back implicit migrate
juliangruber Jun 12, 2024
c09f608
Update db/index.js
juliangruber Jun 12, 2024
4e74845
rename pg pools
juliangruber Jun 12, 2024
fb79b4e
Update db/typings.d.ts
juliangruber Jun 12, 2024
7455209
harden tests using hooks
juliangruber Jun 12, 2024
d57e042
improve test assertions
juliangruber Jun 12, 2024
d162516
refactor loop
juliangruber Jun 12, 2024
7c98e1c
move `migrations` into `db`
juliangruber Jun 12, 2024
cae8594
inline `observer()` in `dry-run.js`
juliangruber Jun 12, 2024
0a0f417
use helper from spark-evaluate
juliangruber Jun 12, 2024
99a6ba9
fix test
juliangruber Jun 12, 2024
b97e9ac
ci: add dry-run
juliangruber Jun 12, 2024
6337958
add glif token to dry-run
juliangruber Jun 12, 2024
46db5b9
fix dry-run import
juliangruber Jun 12, 2024
fb5ac66
refine migration
juliangruber Jun 12, 2024
ad79c95
fix import
juliangruber Jun 12, 2024
3a2090b
docs
juliangruber Jun 12, 2024
8f0d740
fix version
juliangruber Jun 12, 2024
83719b5
revert
juliangruber Jun 12, 2024
db09bc8
log
juliangruber Jun 12, 2024
201fc76
refactor
juliangruber Jun 12, 2024
a9bf998
observer: add missing Sentry init
juliangruber Jun 12, 2024
ec5e592
Update README.md
juliangruber Jun 12, 2024
f2811b5
fix export
juliangruber Jun 12, 2024
1cf47b1
fix test
juliangruber Jun 12, 2024
7d39cb5
fix
juliangruber Jun 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Base URL: http://stats.filspark.com/

- `GET /participants/scheduled-rewards/?address=<address>&from=<day>&to=<day>`
juliangruber marked this conversation as resolved.
Show resolved Hide resolved

http://stats.filspark.com/participants/scheduled-rewards/
http://stats.filspark.com/participants/scheduled-rewards

- `GET /miners/retrieval-success-rate/summary?from=<day>&to=<day>`

Expand Down
13 changes: 2 additions & 11 deletions db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import Postgrator from 'postgrator'

export { migrateEvaluateDB, migrateStatsDB }

const {
// DATABASE_URL points to `spark_stats` database managed by this monorepo
DATABASE_URL = 'postgres://localhost:5432/spark_stats',
Expand Down Expand Up @@ -71,17 +73,6 @@ export const getPgPools = async () => {
return { stats, evaluate, end }
}

export const migrate = async () => {
const pgPools = await getPgPools()

console.log('Migrating spark_evaluate database')
await migrateEvaluateDB(pgPools.evaluate)
console.log('Migrating spark_stats database')
await migrateStatsDB(pgPools.stats)

await pgPools.end()
}

/**
* @param {pg.Client} client
*/
Expand Down
2 changes: 1 addition & 1 deletion observer/bin/dry-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ethers } from 'ethers'

import { RPC_URL, rpcHeaders } from '../lib/config.js'
import { observeTransferEvents, observeScheduledRewards } from '../lib/observer.js'
import { getPgPools } from '../../db-clients/index.js'
import { getPgPools } from '@filecoin-station/spark-stats-db'

const pgPools = await getPgPools()

Expand Down
6 changes: 4 additions & 2 deletions observer/bin/migrate.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { migrate } from '@filecoin-station/spark-stats-db'
import { migrateStatsDB, migrateEvaluateDB, getPgPools } from '@filecoin-station/spark-stats-db'

await migrate()
const pgPools = await getPgPools()
await migrateStatsDB(pgPools.stats)
await migrateEvaluateDB(pgPools.evaluate)
6 changes: 4 additions & 2 deletions stats/bin/migrate.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { migrate } from '@filecoin-station/spark-stats-db'
import { migrateStatsDB, migrateEvaluateDB, getPgPools } from '@filecoin-station/spark-stats-db'

await migrate()
const pgPools = await getPgPools()
await migrateStatsDB(pgPools.stats)
await migrateEvaluateDB(pgPools.evaluate)