-
Notifications
You must be signed in to change notification settings - Fork 212
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] - ATX V2 Syntactical validation with deps - singular ATXs #5949
Conversation
e5a59af
to
5f0aa80
Compare
cdba26d
to
0557204
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5949 +/- ##
========================================
Coverage 81.2% 81.2%
========================================
Files 293 293
Lines 31123 31403 +280
========================================
+ Hits 25276 25507 +231
- Misses 4198 4229 +31
- Partials 1649 1667 +18 ☔ View full report in Codecov by Sentry. |
5f0aa80
to
71540cd
Compare
5718c00
to
a67e37d
Compare
06a2e9e
to
fe27835
Compare
|
||
func (h *HandlerV2) validateCommitmentAtx(golden, commitmentAtxId types.ATXID, publish types.EpochID) error { | ||
if commitmentAtxId != golden { | ||
commitment, err := atxs.Get(h.cdb, commitmentAtxId) |
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.
Querying the full set of ATX fields is not very efficient. For one thing, if we don't need the blob of the commitment ATX here, and doing JOIN on the atx_blobs
table (which atxs.Get
does) will slow down validation process. Another thing to consider is that multiple separate SQL queries are always slower than a single query, even if the single query fetches some excess fields. Maybe we could consider doing a single query for the deps along the lines of
select epoch, nonce, num_units where id in (?, ?, ?)
using IDs of commitment / prev / positioning ATXs?
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.
For one thing, if we don't need the blob of the commitment ATX here, and doing JOIN on the atx_blobs table (which atxs.Get does) will slow down validation process.
The atxs.Get()
doesn't read the blob anymore. It only reads the atxs
table.
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'm not sure a single query is easily doable during the handling of an incoming ATXs, since there are so many branches that need to be considered depending on
- initial vs. non-initial
- merged vs. not-merged
- ATX that resizes post vs. one that doesn't
- etc.
We could consider doing all in a single TX and see if that decreased the validation time.
|
||
func (h *HandlerV2) previous(ctx context.Context, id types.ATXID) (opaqueAtx, error) { | ||
var blob sql.Blob | ||
version, err := atxs.LoadBlob(ctx, h.cdb, id[:], &blob) |
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.
Do we use fields other then those available in the atxs
table for previous ATX validation?
That is, do we really need to decode and validate that blob?
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.
We need this because the ATX in the atxs
table contains the effective num units. Effective num units are the smallest value of the num units in the ATX and its previous ATX (the ones declared by the ATX itself). If we take a minimum of Atx.NumUnits and PrevATX.EffectiveNumUnits, then no one will be able to grow effectively their PoST size.
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.
Interesting why then we're storing atx.NumUnits
in the table. Do we have some kind of confusion here?
Line 380 in 1226fcc
stmt.BindInt64(3, int64(atx.NumUnits)) |
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.
NumUnits
as included by the ATX is only needed to be able to verify the provided post. Effective NumUnits (what we store as NumUnits
in the DB) is used to calculate the actual weight of an identity. They are not the same.
To count your NumUnits
on disk as effective numunits you need to hold them for at least one full poet round, i.e. you must generate 2 ATXs with that amount of storage - one before the poet round and one after. That's why effective NumUnits
is min(previous.NumUnits, atx.NumUnits)
(where both are the wire
form of the ATX).
|
||
func (h *HandlerV2) validateCommitmentAtx(golden, commitmentAtxId types.ATXID, publish types.EpochID) error { | ||
if commitmentAtxId != golden { | ||
commitment, err := atxs.Get(h.cdb, commitmentAtxId) |
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'm not sure a single query is easily doable during the handling of an incoming ATXs, since there are so many branches that need to be considered depending on
- initial vs. non-initial
- merged vs. not-merged
- ATX that resizes post vs. one that doesn't
- etc.
We could consider doing all in a single TX and see if that decreased the validation time.
…tactical-validation-with-deps
bors merge |
Pull request successfully merged into develop. Build succeeded: |
Description
Closes #5994
Test Plan
Added units tests
TODO