diff --git a/.policy.yml b/.policy.yml index 4f76e4865d5a..5fed6dc23393 100644 --- a/.policy.yml +++ b/.policy.yml @@ -26,7 +26,6 @@ approval_rules: only_changed_files: paths: - "*pb.go" - - "*pb.gw.go" - "*.bazel" options: ignore_commits_by: @@ -69,7 +68,6 @@ approval_rules: changed_files: ignore: - "*pb.go" - - "*pb.gw.go" - "*.bazel" options: ignore_commits_by: diff --git a/CHANGELOG.md b/CHANGELOG.md index 3378558c2a60..5d391264f3c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,9 +60,10 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve - validator registration log changed to debug, and the frequency of validator registration calls are reduced - Core: Fix process effective balance update to safe copy validator for Electra. - `== nil` checks before calling `IsNil()` on interfaces to prevent panics. -- Core: Fixed slash processing causing extra hashing -- Core: Fixed extra allocations when processing slashings +- Core: Fixed slash processing causing extra hashing. +- Core: Fixed extra allocations when processing slashings. - remove unneeded container in blob sidecar ssz response +- Testing: added custom matcher for better push settings testing. ### Security diff --git a/hack/README.md b/hack/README.md index 6720654d82f4..5cf3ec3b0350 100644 --- a/hack/README.md +++ b/hack/README.md @@ -5,6 +5,6 @@ This subproject contains useful bash scripts for working with our repository. We ## update-go-pbs.sh -This script generates the *.pb.go and *.pb.gw.go files from the *.proto files. -After running `update-go-pbs.sh` keep only the *.pb.go and *pb.gw.go for the protos that have changed before checking in. +This script generates the *.pb.go files from the *.proto files. +After running `update-go-pbs.sh` keep only the *.pb.go for the protos that have changed before checking in. *Note*: the generated files may not have imports correctly linted and will need to be fixed to remote associated errors. \ No newline at end of file diff --git a/hack/common.sh b/hack/common.sh index c4f1bf32c19d..06a70ed7a16d 100644 --- a/hack/common.sh +++ b/hack/common.sh @@ -19,7 +19,7 @@ cygwin*) system="windows" ;; esac readonly system -# Get locations of pb.go and pb.gw.go files. +# Get locations of pb.go files. findutil="find" # On OSX `find` is not GNU find compatible, so require "findutils" package. if [ "$system" == "darwin" ]; then diff --git a/hack/update-go-pbs.sh b/hack/update-go-pbs.sh index 47a009eb9b10..6ab61ba22539 100755 --- a/hack/update-go-pbs.sh +++ b/hack/update-go-pbs.sh @@ -9,7 +9,7 @@ bazel query 'attr(testonly, 0, //proto/...)' | xargs bazel build $@ file_list=() while IFS= read -d $'\0' -r file; do file_list=("${file_list[@]}" "$file") -done < <($findutil -L "$(bazel info bazel-bin)"/proto -type f -regextype sed -regex ".*pb\.\(gw\.\)\?go$" -print0) +done < <($findutil -L "$(bazel info bazel-bin)"/proto -type f -regextype sed -regex ".*pb\.go$" -print0) arraylength=${#file_list[@]} searchstring="prysmaticlabs/prysm/v5/" diff --git a/proto/eth/v1/attestation.pb.gw.go b/proto/eth/v1/attestation.pb.gw.go deleted file mode 100755 index cdd03643f0c7..000000000000 --- a/proto/eth/v1/attestation.pb.gw.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build ignore -// +build ignore - -package ignore diff --git a/proto/eth/v1/beacon_block.pb.gw.go b/proto/eth/v1/beacon_block.pb.gw.go deleted file mode 100755 index cdd03643f0c7..000000000000 --- a/proto/eth/v1/beacon_block.pb.gw.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build ignore -// +build ignore - -package ignore diff --git a/proto/eth/v1/beacon_chain.pb.gw.go b/proto/eth/v1/beacon_chain.pb.gw.go deleted file mode 100755 index cdd03643f0c7..000000000000 --- a/proto/eth/v1/beacon_chain.pb.gw.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build ignore -// +build ignore - -package ignore diff --git a/proto/eth/v1/events.pb.gw.go b/proto/eth/v1/events.pb.gw.go deleted file mode 100755 index cdd03643f0c7..000000000000 --- a/proto/eth/v1/events.pb.gw.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build ignore -// +build ignore - -package ignore diff --git a/proto/eth/v1/node.pb.gw.go b/proto/eth/v1/node.pb.gw.go deleted file mode 100755 index cdd03643f0c7..000000000000 --- a/proto/eth/v1/node.pb.gw.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build ignore -// +build ignore - -package ignore diff --git a/proto/eth/v1/validator.pb.gw.go b/proto/eth/v1/validator.pb.gw.go deleted file mode 100755 index cdd03643f0c7..000000000000 --- a/proto/eth/v1/validator.pb.gw.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build ignore -// +build ignore - -package ignore diff --git a/proto/eth/v2/beacon_block.pb.gw.go b/proto/eth/v2/beacon_block.pb.gw.go deleted file mode 100755 index cdd03643f0c7..000000000000 --- a/proto/eth/v2/beacon_block.pb.gw.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build ignore -// +build ignore - -package ignore diff --git a/proto/eth/v2/beacon_chain.pb.gw.go b/proto/eth/v2/beacon_chain.pb.gw.go deleted file mode 100755 index cdd03643f0c7..000000000000 --- a/proto/eth/v2/beacon_chain.pb.gw.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build ignore -// +build ignore - -package ignore diff --git a/proto/eth/v2/beacon_lightclient.pb.gw.go b/proto/eth/v2/beacon_lightclient.pb.gw.go deleted file mode 100755 index cdd03643f0c7..000000000000 --- a/proto/eth/v2/beacon_lightclient.pb.gw.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build ignore -// +build ignore - -package ignore diff --git a/proto/eth/v2/custom.go b/proto/eth/v2/custom.go index f61e764614fa..678b71a39ff5 100644 --- a/proto/eth/v2/custom.go +++ b/proto/eth/v2/custom.go @@ -3,9 +3,10 @@ package eth import ( "bytes" "fmt" - enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" "math/bits" + enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" + v1 "github.com/prysmaticlabs/prysm/v5/proto/eth/v1" ) diff --git a/proto/eth/v2/ssz.pb.gw.go b/proto/eth/v2/ssz.pb.gw.go deleted file mode 100755 index cdd03643f0c7..000000000000 --- a/proto/eth/v2/ssz.pb.gw.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build ignore -// +build ignore - -package ignore diff --git a/proto/eth/v2/sync_committee.pb.gw.go b/proto/eth/v2/sync_committee.pb.gw.go deleted file mode 100755 index cdd03643f0c7..000000000000 --- a/proto/eth/v2/sync_committee.pb.gw.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build ignore -// +build ignore - -package ignore diff --git a/proto/eth/v2/validator.pb.gw.go b/proto/eth/v2/validator.pb.gw.go deleted file mode 100755 index cdd03643f0c7..000000000000 --- a/proto/eth/v2/validator.pb.gw.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build ignore -// +build ignore - -package ignore diff --git a/proto/eth/v2/version.pb.gw.go b/proto/eth/v2/version.pb.gw.go deleted file mode 100755 index cdd03643f0c7..000000000000 --- a/proto/eth/v2/version.pb.gw.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build ignore -// +build ignore - -package ignore diff --git a/proto/eth/v2/withdrawals.pb.gw.go b/proto/eth/v2/withdrawals.pb.gw.go deleted file mode 100755 index cdd03643f0c7..000000000000 --- a/proto/eth/v2/withdrawals.pb.gw.go +++ /dev/null @@ -1,4 +0,0 @@ -//go:build ignore -// +build ignore - -package ignore diff --git a/validator/client/validator_test.go b/validator/client/validator_test.go index 679a2add8425..56abfd651b6b 100644 --- a/validator/client/validator_test.go +++ b/validator/client/validator_test.go @@ -1,6 +1,7 @@ package client import ( + "bytes" "context" "errors" "flag" @@ -1456,6 +1457,40 @@ func TestValidator_WaitForKeymanagerInitialization_Interop(t *testing.T) { } } +type PrepareBeaconProposerRequestMatcher struct { + expectedRecipients []*ethpb.PrepareBeaconProposerRequest_FeeRecipientContainer +} + +func (m *PrepareBeaconProposerRequestMatcher) Matches(x interface{}) bool { + req, ok := x.(*ethpb.PrepareBeaconProposerRequest) + if !ok { + return false + } + + if len(req.Recipients) != len(m.expectedRecipients) { + return false + } + + // Build maps for efficient comparison + expectedMap := make(map[primitives.ValidatorIndex][]byte) + for _, recipient := range m.expectedRecipients { + expectedMap[recipient.ValidatorIndex] = recipient.FeeRecipient + } + + // Compare the maps + for _, fc := range req.Recipients { + expectedFeeRecipient, exists := expectedMap[fc.ValidatorIndex] + if !exists || !bytes.Equal(expectedFeeRecipient, fc.FeeRecipient) { + return false + } + } + return true +} + +func (m *PrepareBeaconProposerRequestMatcher) String() string { + return fmt.Sprintf("matches PrepareBeaconProposerRequest with Recipients: %v", m.expectedRecipients) +} + func TestValidator_PushSettings(t *testing.T) { for _, isSlashingProtectionMinimal := range [...]bool{false, true} { ctrl := gomock.NewController(t) @@ -1525,8 +1560,8 @@ func TestValidator_PushSettings(t *testing.T) { PublicKeys: [][]byte{keys[0][:], keys[1][:]}, Indices: []primitives.ValidatorIndex{1, 2}, }, nil) - client.EXPECT().PrepareBeaconProposer(gomock.Any(), ðpb.PrepareBeaconProposerRequest{ - Recipients: []*ethpb.PrepareBeaconProposerRequest_FeeRecipientContainer{ + client.EXPECT().PrepareBeaconProposer(gomock.Any(), &PrepareBeaconProposerRequestMatcher{ + expectedRecipients: []*ethpb.PrepareBeaconProposerRequest_FeeRecipientContainer{ {FeeRecipient: common.HexToAddress("0x055Fb65722E7b2455043BFEBf6177F1D2e9738D9").Bytes(), ValidatorIndex: 1}, {FeeRecipient: common.HexToAddress(defaultFeeHex).Bytes(), ValidatorIndex: 2}, }, @@ -1616,8 +1651,8 @@ func TestValidator_PushSettings(t *testing.T) { PublicKeys: [][]byte{keys[0][:], keys[1][:]}, Indices: []primitives.ValidatorIndex{1, 2}, }, nil) - client.EXPECT().PrepareBeaconProposer(gomock.Any(), ðpb.PrepareBeaconProposerRequest{ - Recipients: []*ethpb.PrepareBeaconProposerRequest_FeeRecipientContainer{ + client.EXPECT().PrepareBeaconProposer(gomock.Any(), &PrepareBeaconProposerRequestMatcher{ + expectedRecipients: []*ethpb.PrepareBeaconProposerRequest_FeeRecipientContainer{ {FeeRecipient: common.HexToAddress("0x055Fb65722E7b2455043BFEBf6177F1D2e9738D9").Bytes(), ValidatorIndex: 1}, {FeeRecipient: common.HexToAddress(defaultFeeHex).Bytes(), ValidatorIndex: 2}, }, @@ -1702,8 +1737,8 @@ func TestValidator_PushSettings(t *testing.T) { PublicKeys: [][]byte{keys[0][:], keys[1][:]}, Indices: []primitives.ValidatorIndex{1, 2}, }, nil) - client.EXPECT().PrepareBeaconProposer(gomock.Any(), ðpb.PrepareBeaconProposerRequest{ - Recipients: []*ethpb.PrepareBeaconProposerRequest_FeeRecipientContainer{ + client.EXPECT().PrepareBeaconProposer(gomock.Any(), &PrepareBeaconProposerRequestMatcher{ + expectedRecipients: []*ethpb.PrepareBeaconProposerRequest_FeeRecipientContainer{ {FeeRecipient: common.HexToAddress("0x055Fb65722E7b2455043BFEBf6177F1D2e9738D9").Bytes(), ValidatorIndex: 1}, {FeeRecipient: common.HexToAddress(defaultFeeHex).Bytes(), ValidatorIndex: 2}, },