-
Notifications
You must be signed in to change notification settings - Fork 211
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
[Merged by Bors] - vm, api: add smesherID to rewards #5199
Conversation
Migrates existing database table. All future database writes will include smesherID. We do not update old data, which will simply have missing smesherID data. This is fine for most use cases.
primary key of rewards table has changed: it used to be (coinbase, layer) but is now (smesherID, layer). rewards must thus have distinct smesherID values.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #5199 +/- ##
=======================================
Coverage 77.5% 77.5%
=======================================
Files 253 252 -1
Lines 29641 29650 +9
=======================================
+ Hits 22972 22983 +11
- Misses 5208 5209 +1
+ Partials 1461 1458 -3 ☔ View full report in Codecov by Sentry. |
In tests, rather than using rand Fix changelog
Drop "WITHOUT ROWID" to prevent NOT NULL error on new primary key column.
@fasmat @dshulyak please take a look at the latest commit: 1595ea9 I had to remove the |
Lost in merge
Adds one more migration
To prevent import cycle in tests
I think this will add 8 bytes per row that are persisted in the DB but not really needed even at ~ 1 mio entries we have for that table that's probably negligible since the PR also adds 32 bytes for the smesher ID. I don't think queries are slower with a Row ID, so I'd be OK with the change. |
what it does is that you have to query 2 b-trees instead of one. so if you have small unique key it is always better to have one b-tree. i can't tell without measuring, but generally single tree will be much better for range queries that hit that exact primary index (for example all rewards from smesher X, or all rewards inbetween from smesher X inbeetween layers Y and Z) |
The only other option here is to force a resync from scratch, or to rerun all transactions through the VM to reconstruct the missing data. Even if we merge this PR as-is, those options are still on the table for the future - that would be my preference. |
yes i don't mind looking into any perf issues later |
Final review feedback, h/t @mafa
bors merge |
## Motivation See #4863 Based on #4850 Closes #4529 Closes #4850 Closes #4863 Closes #4964 Closes #5183 ## Changes - Refactors `rewards` table. Adds smesherID column, migrates data. Does not update old data (smesherID will be NULL for old data, unless resynced). - Updates database queries. - Returns smesherID in all API queries Co-authored-by: Piers Powlesland <pierspowlesland@gmail.com> Co-authored-by: piersy <pierspowlesland@gmail.com> Co-authored-by: Dmitry Shulyak <yashulyak@gmail.com>
Pull request successfully merged into develop. Build succeeded: |
Motivation
See #4863
Based on #4850
Closes #4529
Closes #4850
Closes #4863
Closes #4964
Closes #5183
Changes
rewards
table. Adds smesherID column, migrates data. Does not update old data (smesherID will be NULL for old data, unless resynced).