-
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
fix: [resharding] fix gas and balance redistribution during resharding #9449
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This no-op PR seems to be breaking a few tests 💀 but sharing for a sneak peak. |
akhi3030
approved these changes
Aug 17, 2023
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! I suppose Shreyan will also review. Some minor feedback.
shreyan-gupta
approved these changes
Aug 24, 2023
@@ -89,7 +89,11 @@ pub struct ApplySplitStateResult { | |||
// otherwise, it simply returns the state changes needed to be applied to split states | |||
#[derive(Debug)] | |||
pub enum ApplySplitStateResultOrStateChanges { | |||
/// Immediately apply the split state result. |
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.
Thanks!
nikurt
pushed a commit
to nikurt/nearcore
that referenced
this pull request
Aug 24, 2023
near#9449) During resharding we need to redistribute the gas and balance to the children shards. The old implementation relied on the fact that the split shards and indexed from 0. In the future reshardings this may not be the case, for example when splitting shard 3, the split shard ids will be 3 & 4. The principle idea of the distribution remains the same. Both quantities are distributed evenly across the children shards. If there is any remainder := quantity % num_split_shards, then we assign 1 extra unit to each of the first `remainder` children shards. e.g. splitting shard 3 -> 3' & 4' there is 5 gas to redistribute to children shard 3' will get 3 units of gas shard 4' will get 2 units of gas the old implementation relied on a math trick to do that, the new one takes a more engineering leaning approach
nikurt
pushed a commit
that referenced
this pull request
Aug 28, 2023
#9449) During resharding we need to redistribute the gas and balance to the children shards. The old implementation relied on the fact that the split shards and indexed from 0. In the future reshardings this may not be the case, for example when splitting shard 3, the split shard ids will be 3 & 4. The principle idea of the distribution remains the same. Both quantities are distributed evenly across the children shards. If there is any remainder := quantity % num_split_shards, then we assign 1 extra unit to each of the first `remainder` children shards. e.g. splitting shard 3 -> 3' & 4' there is 5 gas to redistribute to children shard 3' will get 3 units of gas shard 4' will get 2 units of gas the old implementation relied on a math trick to do that, the new one takes a more engineering leaning approach
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
During resharding we need to redistribute the gas and balance to the children shards.
The old implementation relied on the fact that the split shards and indexed from 0. In the future reshardings this may not be the case, for example when splitting shard 3, the split shard ids will be 3 & 4.
The principle idea of the distribution remains the same. Both quantities are distributed evenly across the children shards. If there is any remainder := quantity % num_split_shards, then we assign 1 extra unit to each of the first
remainder
children shards.e.g. splitting shard 3 -> 3' & 4'
there is 5 gas to redistribute to children
shard 3' will get 3 units of gas
shard 4' will get 2 units of gas
the old implementation relied on a math trick to do that, the new one takes a more engineering leaning approach