Reviewing some (unrelated) sync code today I noticed that we are using a stategen accessor for the finalized state which copies the entire state object to look up validator balances to compute the custody_group_count. This excess memory allocation is likely causing GC pressure and increasing memory utilization. This PR avoids state copying for this purpose by making the following changes: - Adds a new method to the `ReadOnlyBalances` state interface: `EffectiveBalances([]primitives.ValidatorIndex) (uint64, []uint64, error)`. This method computes returns the sum of the effective balances of the given list of validator indices, a list with the individual effective balance of each requested index (where the i-th element in the return corresponds to the i-th element of the parameter), and an error - which is necessary due to index bounds checks and quirks of multi-value slice that can apparently result in the state being unusable for such lookups if not correctly initialized. - Adds a new method to the stategen interface `FinalizedReadOnlyBalances`, which returns the finalized state asserted to the `ReadOnlyBalances` interface. - Switches the peerdas code to use the sum given by `EffectiveBalances`. There was some existing nil checking code in the peerdas package that I didn't want to modify, so I added a new compound interface in stategen to allow the returned state to also expose the `IsNil` method. fixes https://github.com/OffchainLabs/prysm/issues/16354 --------- Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
Prysm: An Ethereum Consensus Implementation Written in Go
📖 Overview
This is the core repository for Prysm, a Golang implementation of the Ethereum Consensus specification, developed by Offchain Labs.
See the Changelog for details of the latest releases and upcoming breaking changes.
🚀 Getting Started
A detailed set of installation and usage instructions as well as breakdowns of each individual component are available in the official documentation portal.
💬 Need help? Join our Discord Community for support.
🏆 Staking on Mainnet
To participate in staking, you can join the official Ethereum launchpad. The launchpad is the only recommended way to become a validator on mainnet.
🔍 Explore validator rewards/penalties:
🤝 Contributing
🔥 Branches
Prysm maintains two permanent branches:
master- This points to the latest stable release. It is ideal for most users.develop- This is used for development and contains the latest PRs. Developers should base their PRs on this branch.
🛠 Contribution Guide
Want to get involved? Check out our Contribution Guide to learn more!
📜 License
This project is licensed under the GNU General Public License v3.0.
