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

migrations: finalize migration_5 (share encoding GOB -> SSZ) #2002

Merged
merged 10 commits into from
Jan 26, 2025

Conversation

iurii-ssv
Copy link
Contributor

@iurii-ssv iurii-ssv commented Jan 22, 2025

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.

@iurii-ssv iurii-ssv marked this pull request as draft January 22, 2025 17:13
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 19.33702% with 146 lines in your changes missing coverage. Please review.

Project coverage is 47.7%. Comparing base (3e76188) to head (7bdae58).
Report is 9 commits behind head on stage.

Files with missing lines Patch % Lines
migrations/migration_5_share_gob_to_ssz.go 0.0% 129 Missing ⚠️
registry/storage/shares_encoding.go 33.3% 8 Missing ⚠️
migrations/migration_5_gob.go 0.0% 6 Missing ⚠️
registry/storage/shares.go 91.3% 2 Missing ⚠️
operator/storage/storage.go 90.9% 0 Missing and 1 partial ⚠️
Additional details and impacted files

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@iurii-ssv iurii-ssv marked this pull request as ready for review January 23, 2025 12:18
Comment on lines 262 to 265
func specShareToStorageShare(share *types.SSVShare) *storageShare {
func FromSpecShare(share *types.SSVShare) *Share {
Copy link
Contributor Author

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 ?

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied in fdeb284

Copy link
Contributor

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.

Comment on lines +100 to +106
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),
)
}
Copy link
Contributor Author

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)

Copy link
Contributor

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) ?

Copy link
Contributor Author

@iurii-ssv iurii-ssv Jan 23, 2025

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)

Copy link
Contributor

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

Copy link
Contributor

@oleg-ssvlabs oleg-ssvlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Great work!

@y0sher y0sher merged commit 61ad5b5 into stage Jan 26, 2025
6 of 7 checks passed
@y0sher y0sher deleted the migration-5-finalize branch January 26, 2025 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants