-
Notifications
You must be signed in to change notification settings - Fork 476
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
catchpoints: Add onlineaccounts and onlineroundparamstail tables to snapshot files #6177
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6177 +/- ##
==========================================
- Coverage 51.86% 51.79% -0.08%
==========================================
Files 639 640 +1
Lines 85492 85818 +326
==========================================
+ Hits 44344 44447 +103
- Misses 38331 38525 +194
- Partials 2817 2846 +29 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
Balances []encoded.BalanceRecordV6 `codec:"bl,allocbound=BalancesPerCatchpointFileChunk"` | ||
numAccounts uint64 | ||
KVs []encoded.KVRecordV6 `codec:"kv,allocbound=BalancesPerCatchpointFileChunk"` | ||
OnlineAccounts []encoded.OnlineAccountRecordV6 `codec:"oa,allocbound=BalancesPerCatchpointFileChunk"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why adding into v6 struct and not defining v7 struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good point, when KVs were added to the catchpoint V6 format's chunk encoding in #4455 it did not require making a new catchpoint version V7, because the existence of the KV fields signaled they were there, and the merkle trie implementation was updated to include KVs as a possible node type for the trie. So the KVs got hashed along with accounts and resources, and overall the verification scheme was the same as existing V6, so it was not a bump to V7. Once the KV consensus flag flipped over, then KVs would be populated in catchpoint files.
Later state proof recovery was added to catchpoints, that was a whole new and separate hash added to the header and label-generating scheme, so it got bumped to V7 to support state proofs (plus a consensus flag so all nodes switched to the new hashing scheme at the same time). V7 did not touch the catchpointFileChunkV6
type at all so its name was left alone.
Similarly, I am adding two new hashes (onlineaccounts and onlineroundparams) so I am bumping the catchpoint file format to "V8" (like state proof recovery did with V7) but still extending the "catchpiontFileChunkV6" struct with two new fields (like KV for catchpoints did). I guess that is a weird thing to do.. and maybe I should make a new V8 type like you're suggesting
@@ -1165,7 +1201,7 @@ func (ct *catchpointTracker) isWritingCatchpointDataFile() bool { | |||
// - Balance and KV chunk (named balances.x.msgpack). | |||
// ... | |||
// - Balance and KV chunk (named balances.x.msgpack). | |||
func (ct *catchpointTracker) generateCatchpointData(ctx context.Context, accountsRound basics.Round, catchpointGenerationStats *telemetryspec.CatchpointGenerationEventDetails, encodedSPData []byte) (totalKVs, totalAccounts, totalChunks, biggestChunkLen uint64, err error) { | |||
func (ct *catchpointTracker) generateCatchpointData(ctx context.Context, accountsRound basics.Round, catchpointGenerationStats *telemetryspec.CatchpointGenerationEventDetails, encodedSPData []byte) (totalAccounts, totalKVs, totalOnlineAccounts, totalOnlineRoundParams, totalChunks, biggestChunkLen uint64, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like it is time to switch from 7 return params to struct?
} | ||
} | ||
|
||
func (l *CatchpointLabelMakerCurrent) buffer() []byte { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got lost, we added online account into v8 label, didn't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation looks correct. Our versioning is very confusing though
@@ -854,7 +854,7 @@ func TestExactAccountChunk(t *testing.T) { | |||
catchpointFilePath := filepath.Join(tempDir, t.Name()+".catchpoint.tar.gz") | |||
|
|||
cph := testWriteCatchpoint(t, dl.validator.trackerDB(), catchpointDataFilePath, catchpointFilePath, 0) | |||
require.EqualValues(t, cph.TotalChunks, 1) | |||
require.EqualValues(t, cph.TotalChunks, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is there one more chunk? Added online accounts overgrew the max chunk size?
…e corruption in catchpointtracker
…hpoint-onlineaccts-separatehashes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I guess a manual test needs to be done:
- make a new catchpoint and restore using new algod. Ensure it joins the network and processes blocks/transactions.
- make sure the old algod rejects a new catchpoint with a clear error message
durOnlineAccounts = time.Since(writeOnlineAccountsStart) | ||
}() | ||
|
||
// start the kv store writer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// start the kv store writer | |
// start the rounds params writer |
@@ -255,6 +277,18 @@ func (*reader) MakeKVsIter(ctx context.Context) (trackerdb.KVsIter, error) { | |||
return nil, nil | |||
} | |||
|
|||
// MakeOnlineAccountsIter implements trackerdb.Reader | |||
func (*reader) MakeOnlineAccountsIter(ctx context.Context) (trackerdb.TableIterator[*encoded.OnlineAccountRecordV6], error) { | |||
// TODO: catchpoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
planning to add this in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No — the generickv and dualdriver trackerdb implementations all have a bunch of TODO: catchpoint
comments, so I just copied that text, and the other catchpoint-related iterators aren't implemented in dualdriver, so I was planning to leave it as is.
…accts-separatehashes
…ashes' into catchpoint-onlineaccts-separatehashes
Summary
The new opcodes in #5984 require access to historical lookups of online account details and total circulation amounts. During catchpoint restore, replaying and evaluating old blocks bootstraps the tracker DBs. However transactions that use these opcodes will fail, since they need access to historical ledger amounts earlier than the horizon of the catchpoint snapshot. This PR adds the
onlineaccounts
andonlineroundparamstail
tables to the snapshot files, which provide online account lookup and total circulation amounts, respectively.Test Plan
Existing tests should pass — working on extending an existing catchpoint test to use the
voter_params_get
andonline_stake
opcodes (similar to some catchpoint tests written for testing use of box opcodes).