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

Adding comments to all the database columns #6068

Merged
merged 4 commits into from
Jan 18, 2022
Merged

Conversation

mm-near
Copy link
Contributor

@mm-near mm-near commented Jan 14, 2022

Added comments on what is the row & column type to all the database columns.

Copy link
Contributor

@pmnoxx pmnoxx left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@matklad matklad left a comment

Choose a reason for hiding this comment

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

It almost feels like these comments want to be types:

impl DbCol for BlockExtraCol {
  const ID: u32 = 20;
  type Key = BlockHash;
  type Value = BlockExtra;
}

Definitely shouldn't be doing that right now, but potentially reifying columns as types could help us down the line.

/// `LightClientBlock`s corresponding to the last final block of each completed epoch
/// `LightClientBlock`s corresponding to the last final block of each completed epoch.
/// - *Rows*: EpochId (CryptoHash)
/// - *Content type*: LightClientBlockView
Copy link
Contributor

Choose a reason for hiding this comment

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

This ... feels fishy. My understanding that *View types are for RPC, not for storing directly in DB...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's not a statement about this particular change, it's a statement about pre-existing state of code.

My understanding is that *View-types are intended to be API types we use in JSON RPC. So, eg, we use Action as internal representation of what we store in the database, and we use ActionView for the RPC (which is reachable from the chunk method).

Some of the *View types are not only JSON-encodable, but also borsh-encodable. My understanding that this bottoms out in RoutedMessageBody::FinalExecutionOutcomeView. I am not sure if that should've use *View struct or not: it feels weird that here we have both *View and not *View struct. So, my current understanding is "some view types are borsh because we use then in p2p messages, which I am not sure why we do".

What I am noticing here is that there's also at least one *View type which we store in the database. And that's surprising, because that means that we store both , eg, ValidatorStakeView (through ColEpochLightClientBlocks) and ValidatorStake (through ColEpochValidatorInfo) in the database.

Overall, it seems that the codebase as a whole is confused about what *View really means, and that some things are miss-classified as *View.

Copy link
Contributor

Choose a reason for hiding this comment

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

cc #5516

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