From 1536d59e30694caafe422eca67623a8e67d3b18e Mon Sep 17 00:00:00 2001 From: satushh Date: Tue, 9 Dec 2025 19:02:36 +0000 Subject: [PATCH] Remove unnecessary copy in Eth1DataHasEnoughSupport (#16118) **What type of PR is this?** Other **What does this PR do? Why is it needed?** - Remove unnecessary `Copy()` call in `Eth1DataHasEnoughSupport` - `data.Copy()` was called on every iteration of the vote counting loop, even though `AreEth1DataEqual` only reads the data and never mutates it. - Additionally, `Eth1DataVotes()` already returns copies of all votes, so state is protected regardless. **Which issues(s) does this PR fix?** Fixes # **Other notes for review** **Acknowledgements** - [x] I have read [CONTRIBUTING.md](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md). - [x] I have included a uniquely named [changelog fragment file](https://github.com/prysmaticlabs/prysm/blob/develop/CONTRIBUTING.md#maintaining-changelogmd). - [x] I have added a description to this PR with sufficient context for reviewers to understand this PR. --- beacon-chain/core/blocks/eth1_data.go | 2 +- changelog/satushh-eth1copy.md | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelog/satushh-eth1copy.md diff --git a/beacon-chain/core/blocks/eth1_data.go b/beacon-chain/core/blocks/eth1_data.go index d8953e947e..a9195aac71 100644 --- a/beacon-chain/core/blocks/eth1_data.go +++ b/beacon-chain/core/blocks/eth1_data.go @@ -60,7 +60,7 @@ func Eth1DataHasEnoughSupport(beaconState state.ReadOnlyBeaconState, data *ethpb voteCount := uint64(0) for _, vote := range beaconState.Eth1DataVotes() { - if AreEth1DataEqual(vote, data.Copy()) { + if AreEth1DataEqual(vote, data) { voteCount++ } } diff --git a/changelog/satushh-eth1copy.md b/changelog/satushh-eth1copy.md new file mode 100644 index 0000000000..6a92fd751c --- /dev/null +++ b/changelog/satushh-eth1copy.md @@ -0,0 +1,3 @@ +### Removed + +- Unnecessary copy is removed from Eth1DataHasEnoughSupport \ No newline at end of file