Skip to content

Commit 1536d59

Browse files
authored
Remove unnecessary copy in Eth1DataHasEnoughSupport (#16118)
<!-- Thanks for sending a PR! Before submitting: 1. If this is your first PR, check out our contribution guide here https://docs.prylabs.network/docs/contribute/contribution-guidelines You will then need to sign our Contributor License Agreement (CLA), which will show up as a comment from a bot in this pull request after you open it. We cannot review code without a signed CLA. 2. Please file an associated tracking issue if this pull request is non-trivial and requires context for our team to understand. All features and most bug fixes should have an associated issue with a design discussed and decided upon. Small bug fixes and documentation improvements don't need issues. 3. New features and bug fixes must have tests. Documentation may need to be updated. If you're unsure what to update, send the PR, and we'll discuss in review. 4. Note that PRs updating dependencies and new Go versions are not accepted. Please file an issue instead. 5. A changelog entry is required for user facing issues. --> **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.
1 parent 11e46a4 commit 1536d59

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

beacon-chain/core/blocks/eth1_data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func Eth1DataHasEnoughSupport(beaconState state.ReadOnlyBeaconState, data *ethpb
6060
voteCount := uint64(0)
6161

6262
for _, vote := range beaconState.Eth1DataVotes() {
63-
if AreEth1DataEqual(vote, data.Copy()) {
63+
if AreEth1DataEqual(vote, data) {
6464
voteCount++
6565
}
6666
}

changelog/satushh-eth1copy.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Removed
2+
3+
- Unnecessary copy is removed from Eth1DataHasEnoughSupport

0 commit comments

Comments
 (0)