-
Notifications
You must be signed in to change notification settings - Fork 661
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
Conversation
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
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 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 |
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 ... feels fishy. My understanding that *View
types are for RPC, not for storing directly in DB...
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 found this code:
https://github.com/near/nearcore/blob/master/chain/chain/src/store.rs#L2603
And this type is BorshSerializable:
https://github.com/near/nearcore/blob/master/core/primitives/src/views.rs#L1433
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.
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
.
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.
cc #5516
Added comments on what is the row & column type to all the database columns.