nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: decred/dcrd
Pull request #3057 (2023-02-15 00:27:10)

chaincfg: Enforce globally unique vote IDs.
~**This requires #3056**~.

The code currently supports reusing the same vote ID to refer to different agendas as long as they are in different agenda versions.

While there is nothing technically incorrect about this, and part of the design is to allow it, various other software in the ecosystem implicitly assumes the IDs are globally unique across all agendas.

Due to this, and also because supporting it makes the internal code more complex to deal with as well, there is currently a bit of an unwritten rule that the vote ID for every agenda across all versions should be unique.

This change effectively formalizes that unwritten rule by modifying the validation logic that happens at initialization time to reject deployments that have duplicate IDs across agenda versions.



Patch:
diff --git a/chaincfg/init.go b/chaincfg/init.go
index b7362cd8..afd34052 100644
--- a/chaincfg/init.go
+++ b/chaincfg/init.go
@@ -111,9 +111,9 @@ func validateChoices(mask uint16, choices []Choice) error {
 // there are no duplicate vote IDs and that all choices conform to the required
 // voting choice semantics.
 func validateDeployments(allDeployments map[uint32][]ConsensusDeployment) error {
+	// Ensure there are no duplicate vote IDs across all deployments.
+	dups := make(map[string]struct{})
 	for version, deployments := range allDeployments {
-		// Ensure there are no duplicate vote IDs across the deployment version.
-		dups := make(map[string]struct{})
 		for index, deployment := range deployments {
 			voteID := strings.ToLower(deployment.Vote.Id)
 			if _, found := dups[voteID]; found {


Test patch:
diff --git a/chaincfg/init_test.go b/chaincfg/init_test.go
index 880d12e1..006bf63a 100644
--- a/chaincfg/init_test.go
+++ b/chaincfg/init_test.go
@@ -151,8 +151,7 @@ func TestValidateChoices(t *testing.T) {
 }
 
 // TestRejectDuplicateVoteIDs ensures the validation logic for enforcing unique
-// deployment/vote IDs across the deployments for a given deployment version
-// works as intended.
+// deployment/vote IDs across all deployments works as intended.
 func TestRejectDuplicateVoteIDs(t *testing.T) {
 	tests := []struct {
 		name        string
@@ -168,12 +167,12 @@ func TestRejectDuplicateVoteIDs(t *testing.T) {
 		},
 		expected: errDuplicateVoteId,
 	}, {
-		name: "allow duplicate vote id in different versions",
+		name: "reject duplicate vote id in different versions",
 		deployments: map[uint32][]ConsensusDeployment{
 			1: {{Vote: mockVote()}},
 			2: {{Vote: mockVote()}},
 		},
-		expected: nil,
+		expected: errDuplicateVoteId,
 	}}
 
 	for _, test := range tests {
Repository: decred/dcrd
Pull request #3117 (2023-06-02 18:05:03)

build: golangci-lint v1.53.1


Patch:
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index 7cbe2687..d92989ba 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -16,9 +16,9 @@ jobs:
         with:
           go-version: ${{ matrix.go }}
       - name: Check out source
-        uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 #v3.5.0
+        uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab #v3.5.2
       - name: Install Linters
-        run: "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.2"
+        run: "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.53.1"
       - name: Build
         run: go build ./...
       - name: Test
diff --git a/.golangci.yml b/.golangci.yml
index 0897171f..c0e8fabf 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -1,10 +1,9 @@
 run:
   deadline: 10m
-
-linters:
   build-tags:
     - rpctest
 
+linters:
   disable-all: true
   enable:
     - asciicheck


Test patch:
diff --git a/internal/integration/rpctests/treasury_test.go b/internal/integration/rpctests/treasury_test.go
index 7861818f..7d46cea4 100644
--- a/internal/integration/rpctests/treasury_test.go
+++ b/internal/integration/rpctests/treasury_test.go
@@ -205,10 +205,11 @@ func assertTBaseAmount(t *testing.T, node *rpcclient.Client, amount int64) {
 // TestTreasury performs a test of treasury functionality across the entire
 // dcrd stack.
 func TestTreasury(t *testing.T) {
-	// TODO: Remove once the RPC test framework is updated to work with the
-	// latest simnet.
+	// TODO: Remove this comment and the nolint line below once the RPC
+	// test framework is updated to work with the latest simnet.
 	return
 
+	// nolint:govet
 	var handlers *rpcclient.NotificationHandlers
 	net := chaincfg.SimNetParams()