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

Isolate forkchoice to blockchain package #12174

Merged
merged 4 commits into from Mar 22, 2023
Merged

Isolate forkchoice to blockchain package #12174

merged 4 commits into from Mar 22, 2023

Conversation

potuz
Copy link
Contributor

@potuz potuz commented Mar 21, 2023

This PR isolates forkchoice to the blockchain package, this way consumers do not need to worry about locks.

In particular, it removes the function ForkChoicer() that exposed explicitly forkchoice to external packages.

The blockchain package exposes an interface blockchain.ForkchoiceFetcher that wraps all externally used forkchoice functions in a self-locked manner. External callers do not have access to forkchoice directly, but rather have to call blockchain package to lock forkchoice..

@potuz potuz requested a review from a team as a code owner March 21, 2023 19:51
@potuz potuz changed the title Hide forkchoice first commit Isolate forkchoice to blockchain package Mar 21, 2023
@potuz potuz added the Cleanup Code health! label Mar 21, 2023
@@ -484,3 +482,66 @@ func (s *Service) Ancestor(ctx context.Context, root []byte, slot primitives.Slo
func (s *Service) SetGenesisTime(t time.Time) {
s.genesisTime = t
}

Copy link
Member

Choose a reason for hiding this comment

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

I think all these methods specific to forkchoice should be in their own file ex: forkchoice_chain_info or something of that sort

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

terencechain
terencechain previously approved these changes Mar 21, 2023
terencechain
terencechain previously approved these changes Mar 22, 2023
)

// SetGenesisTime sets the genesis time of beacon chain.
func (s *Service) SetGenesisTime(t time.Time) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this really a forkchoice method ? Seems unrelated

@nisdas nisdas merged commit 797cc36 into develop Mar 22, 2023
5 checks passed
@delete-merged-branch delete-merged-branch bot deleted the remove-forchoicer branch March 22, 2023 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cleanup Code health!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants