-
Notifications
You must be signed in to change notification settings - Fork 622
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
refactor: use shard uid in flat state keys #8685
Conversation
/// | ||
/// WARNING: flat storage keeps changing, so the results might be inconsistent, unless you're running | ||
/// this method on the shapshot of the data. | ||
// TODO(#8676): Support non-trivial ranges. | ||
pub fn iter_flat_state_entries<'a>( |
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 looks like we also need to chage this method to accept shard_uid
instead of shard_id
and do a proper prefix-read? or do you please to do that as a separate PR?
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, I would do it separately. Maybe even outside MVP, because we don't use this logic much.
also update
|
@pugachAG: please ping me when you are satisfied with this PR and it is ready to be merged. |
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! @akhi3030
Prepend `ShardUId` to flat state keys, as motivated in near#8670. Ideally we need to replace `shard_id` with `shard_uid` everywhere, including other DB keys and `RuntimeAdapter` flat storage methods. But this change would be too involved, so let's do it incrementally. The biggest structural consequence is that `FlatStorage` now stores `shard_uid`, which makes sense, and later it will be used for writing deltas as well. It's not a big deal, but because of that changes are scattered throughout the code and may look scary. ## Testing * `test_flat_storage_iter` checks that new `key_belongs_to_shard` impl is aligned with shard layout; also we can see that the change takes place in this failing test: https://buildkite.com/nearprotocol/nearcore/builds/25676#0186bc8f-12a2-410a-b74c-e326f3b963fa * https://nayduck.near.org/#/run/2898
Prepend
ShardUId
to flat state keys, as motivated in #8670.Ideally we need to replace
shard_id
withshard_uid
everywhere, including other DB keys andRuntimeAdapter
flat storage methods. But this change would be too involved, so let's do it incrementally.The biggest structural consequence is that
FlatStorage
now storesshard_uid
, which makes sense, and later it will be used for writing deltas as well. It's not a big deal, but because of that changes are scattered throughout the code and may look scary.Testing
test_flat_storage_iter
checks that newkey_belongs_to_shard
impl is aligned with shard layout; also we can see that the change takes place in this failing test: https://buildkite.com/nearprotocol/nearcore/builds/25676#0186bc8f-12a2-410a-b74c-e326f3b963fa