-
Notifications
You must be signed in to change notification settings - Fork 106
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
migrations: finalize migration_5 (share encoding GOB -> SSZ) #2002
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files☔ View full report in Codecov by Sentry. |
…age package instead of copy-pasting it to migrations package)
registry/storage/shares.go
Outdated
func specShareToStorageShare(share *types.SSVShare) *storageShare { | ||
func FromSpecShare(share *types.SSVShare) *Share { |
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 would like to rename Spec
to Domain
for FromSpecShare
and ToSpecShare
since we are not exactly converting to/from spectypes.Share
(but rather to our own Domain representation of share which is types.SSVShare
), wdyt ?
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 agree. Spec share is just type embedded into the domain Share
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.
Applied in fdeb284
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 think it makes sense to use SSVShare
since that's the current name of the struct. It's not the prettiest but it's better than having two names.
if !matchGOBvsSSZ(shareGOB, shareSSZ) { | ||
return fmt.Errorf( | ||
"GOB share doesn't match corresponding SSZ share, GOB: %s, SSZ: %s", | ||
litter.Sdump(shareGOB), | ||
litter.Sdump(shareSSZ), | ||
) | ||
} |
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.
as per @moshe-blox recommendation I found litter
to be super useful for debugging, what do you think of using it like that (for printing detailed error message) ?
Alternatively we could use logger
to print the contents of shareGOB
and shareSSZ
, but since we also have to return error
that means we essentially have to duplicate error message (and it will be logged twice)
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.
It seems to have pretty good score, although, would it be enough to just use the logger? I assume the challenge is that zap logger does not log pointer objects with its full properties if to use something like zap.Any(shareGOB)
?
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 assume the challenge is that zap logger does not log pointer objects with its full properties if to use something like zap.Any(shareGOB) ?
I think zap
logger should produce full object printout with zap.Any
(although it will probably struggle if struct contains interfaces - #1981),
the main reason I don't want to use logger here is that we'll essentially be logging this GOB share doesn't match corresponding SSZ share, GOB: ...
error twice:
- here like you suggest
- and the caller will also log error we return here (and we have to return error to signal migration failed)
and only one of these logged lines will contain full contents of shareGOB
and shareSSZ
printed out (which is even more confusing - could look like 2 separate/different errors unless you look super carefully)
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 see.
I’m just slightly hesitant about adding a new dependency and increasing the binary size, especially since it’s only used in one place within the DB migration, which clients would run just once. Although, if @moshe-blox thinks it's OK, then I do not mind
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. Great work!
870da46
to
fdeb284
Compare
This PR finalizes the work started in #1837 essentially "completing" migration_5
it doesn't change migration_5 in a sense that it is still equivalent and backward-compatible with it's previous version, rather it just adds some sanity-checks.