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

Simplify next Fork boilerplate creation. #14761

Merged
merged 9 commits into from
Jan 3, 2025
Merged

Conversation

nalepae
Copy link
Contributor

@nalepae nalepae commented Dec 31, 2024

What type of PR is this?
Other

What does this PR do? Why is it needed?
This PR aims to simplify the creation of the boilerplate for a new fork.

It uses

if version.<fork> > ... {
   ...
}

instead of

switch v {
case version.<fork>:
   ...
}

when possible.

The rationale is we assume, from fork <n> to fork <n+1>, that changing items are less numerous than remaining ones.
Using the > approach instead of the switch/case one lets the developer not to add the new fork version as a specific case when not needed.

This PR re-organises when possible functions by fork.
When adding the boilerplate for a new fork is needed, only the tail of the file needs to be modified.

Some types (example: enginev1.ExecutionPayloadHeaderElectra) where aliased to the same type from previous forks (example: enginev1.ExecutionPayloadHeaderDeneb). This usage is quite exceptional in the codebase. In the vast majority of the code base, when a fork use a struct defined in a previous fork, then this struct is directly used.
Aliased types are removed to keep the codebase consistent.

Other notes for review
This PR does not bring any functional change.

Acknowledgements

  • I have read CONTRIBUTING.md.
  • I have made an appropriate entry to CHANGELOG.md.
  • I have added a description to this PR with sufficient context for reviewers to understand this PR.

@nalepae nalepae added the Cleanup Code health! label Dec 31, 2024
@nalepae nalepae requested a review from a team as a code owner December 31, 2024 13:04
@nalepae nalepae force-pushed the simplify-fork-creation branch 9 times, most recently from dd3bfcb to 84b3b43 Compare January 2, 2025 10:22
beacon-chain/blockchain/execution_engine.go Outdated Show resolved Hide resolved
beacon-chain/blockchain/execution_engine.go Outdated Show resolved Hide resolved
beacon-chain/blockchain/execution_engine.go Outdated Show resolved Hide resolved
}

return attr
log.WithField("version", st.Version()).Error("Could not get payload attribute due to unknown state version")
Copy link
Contributor

Choose a reason for hiding this comment

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

It is much more readable to use version.String() in logs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in cb41166.

}

err = errors.New("unknown state version")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add the version field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in cb41166.

})
}

return nil, fmt.Errorf("unknown execution block version for payload %d", bVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add version.String()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in Done in cb41166..

@nalepae nalepae force-pushed the simplify-fork-creation branch from 84b3b43 to 6a0f2aa Compare January 3, 2025 10:19
@nalepae nalepae force-pushed the simplify-fork-creation branch from b140ec5 to cb41166 Compare January 3, 2025 12:53
@nalepae nalepae force-pushed the simplify-fork-creation branch from cb41166 to d2abad7 Compare January 3, 2025 13:45
@nalepae nalepae enabled auto-merge January 3, 2025 13:48
@nalepae nalepae disabled auto-merge January 3, 2025 13:49
@nalepae nalepae enabled auto-merge January 3, 2025 13:52
@nalepae nalepae added this pull request to the merge queue Jan 3, 2025
Merged via the queue into develop with commit 8a439a6 Jan 3, 2025
15 checks passed
@nalepae nalepae deleted the simplify-fork-creation branch January 3, 2025 14:46
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.

2 participants