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

feat(parachain/availability-distribution): implement get_block_ancestors_in_same_session #4490

Open
1 task
Tracked by #3598
haikoschol opened this issue Jan 21, 2025 · 0 comments
Open
1 task
Tracked by #3598
Labels
C-simple Minor changes changes, no additional research needed. Good first issue/review. S-subsystems-availability issues related to polkadot host availability subsystem functionality. T-implementation this issue/pr is a new feature or functionality.

Comments

@haikoschol
Copy link
Contributor

haikoschol commented Jan 21, 2025

Issue summary

This function is part of the message handling logic for ActiveLeavesUpdateSignal.

Implementation details

As part of this issue, no caching of runtime information should be implemented. That is covered by #4494, which should be worked on after this issue is completed.

For each newly activated leaf, retrieve the headers of up to leafAncestryLenWithinSession ancestors. Instantiate the runtime for the first ancestor and call ParachainHostSessionIndexForChild() to get the session index of the newly activated leaf. If no ancestors have been found, set this value to 0 instead.

If the list of ancestors is not empty, iterate through the remaining ones and check that they have the same session index as the newly activated leaf. Stop iterating if a different session index is found and discard those ancestors.

package availabilitydistribution

const leafAncestryLenWithinSession = 3

type BlockState interface {
    GetHeader(hash common.Hash) (*types.Header, error)
    GetRuntime(hash common.Hash) (instance runtime.Instance, err error)
}

type AvailabilityDistribution struct {
    blockState BlockState
    // ...
}

func (av *AvailabilityDistribution) getBlockAncestorsInSameSession(
    head common.Hash,
    limit uint,
) (index parachaintypes.SessionIndex, ancestors []common.Hash, err error) {
    runtime, err := av.blockState.GetRuntime(head)
    // ...
}

Other information and links

Acceptance criteria

  • New code is 60% covered with unit tests
@haikoschol haikoschol added C-simple Minor changes changes, no additional research needed. Good first issue/review. S-subsystems-availability issues related to polkadot host availability subsystem functionality. T-implementation this issue/pr is a new feature or functionality. labels Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-simple Minor changes changes, no additional research needed. Good first issue/review. S-subsystems-availability issues related to polkadot host availability subsystem functionality. T-implementation this issue/pr is a new feature or functionality.
Projects
None yet
Development

No branches or pull requests

1 participant