From 031ee12149d1edd4e399dd86dc974bf29993b206 Mon Sep 17 00:00:00 2001 From: thismars Date: Mon, 28 Jul 2025 14:34:10 +0900 Subject: [PATCH 1/7] feat: apply staking pool snapshot immediately on proposal submission --- modules/gov/handle_msg.go | 9 +++++++++ modules/gov/utils_proposal.go | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/modules/gov/handle_msg.go b/modules/gov/handle_msg.go index 09df71260..3729926b5 100644 --- a/modules/gov/handle_msg.go +++ b/modules/gov/handle_msg.go @@ -169,6 +169,15 @@ func (m *Module) handleSubmitProposalEvent(tx *juno.Transaction, proposer string return fmt.Errorf("error while saving proposal: %s", err) } + // Update staking pool snapshot immediately for the new proposal + err = m.UpdateSingleProposalStakingPoolSnapshot(int64(tx.Height), proposal.Id) + if err != nil { + log.Error().Err(err). + Uint64("proposal_id", proposal.Id). + Uint64("height", tx.Height). + Msg("failed to update staking pool snapshot for new proposal") + } + // Submit proposal must have a deposit event with depositor equal to the proposer return m.handleDepositEvent(tx, proposer, events) } diff --git a/modules/gov/utils_proposal.go b/modules/gov/utils_proposal.go index d24842750..b5d0da69b 100644 --- a/modules/gov/utils_proposal.go +++ b/modules/gov/utils_proposal.go @@ -100,6 +100,19 @@ func (m *Module) UpdateProposalStakingPoolSnapshot(height int64, proposalID uint ) } +// UpdateSingleProposalStakingPoolSnapshot updates the staking pool snapshot for a single proposal +// This is an optimized version of UpdateProposalStakingPoolSnapshot for handling newly created proposals +func (m *Module) UpdateSingleProposalStakingPoolSnapshot(height int64, proposalID uint64) error { + pool, err := m.stakingModule.GetStakingPoolSnapshot(height) + if err != nil { + return fmt.Errorf("error while getting staking pool: %s", err) + } + + return m.db.SaveProposalStakingPoolSnapshot( + types.NewProposalStakingPoolSnapshot(proposalID, pool), + ) +} + // updateDeletedProposalStatus updates the proposal having the given id by setting its status // to the one that represents a deleted proposal func (m *Module) updateDeletedProposalStatus(id uint64) error { From 066a808dd28640254c22b01dd1a19964fda91a24 Mon Sep 17 00:00:00 2001 From: Haryun Date: Mon, 28 Jul 2025 16:28:12 +0900 Subject: [PATCH 2/7] chore: update test.yml to use go v1.23 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e4180075..85c8627e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v2 with: - go-version: 1.15 + go-version: 1.23 - name: Test & Create coverage report run: make install test-unit stop-docker-test - name: Upload cove coverage From 84aefe09b6d75d76a5c9cfb3fdfd2da8d6b615da Mon Sep 17 00:00:00 2001 From: haryunio Date: Mon, 28 Jul 2025 16:36:48 +0900 Subject: [PATCH 3/7] test: update lint and test workflows to use latest action versions --- .github/workflows/lint.yml | 17 ++++++++--------- .github/workflows/test.yml | 12 ++++++------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 95b5f8999..5f6c1ec5a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,16 +14,15 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 6 steps: - - uses: actions/checkout@v2 - - uses: technote-space/get-diff-action@v4 + - uses: actions/checkout@v4 + - uses: technote-space/get-diff-action@v6 with: - SUFFIX_FILTER: | - .go - .mod - .sum - - uses: golangci/golangci-lint-action@v2 + PATTERNS: | + **/*.go + **/*.mod + **/*.sum + - uses: golangci/golangci-lint-action@v3 with: - version: v1.28 + version: v1.54 args: --timeout 10m - github-token: ${{ secrets.GITHUB_TOKEN }} if: "env.GIT_DIFF != ''" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 85c8627e7..e9aa543d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,21 +14,21 @@ jobs: - uses: rokroskar/workflow-run-cleanup-action@master env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" + if: '!startsWith(github.ref, ''refs/tags/'') && github.ref != ''refs/heads/master''' Unit-tests: runs-on: ubuntu-latest timeout-minutes: 10 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: - go-version: 1.23 + go-version: '1.23' - name: Test & Create coverage report run: make install test-unit stop-docker-test - - name: Upload cove coverage - uses: codecov/codecov-action@v1.0.7 + - name: Upload code coverage + uses: codecov/codecov-action@v3 with: file: ./coverage.txt From f9c5db5053f8d5b1f8308bc68cf845c2be7f51a0 Mon Sep 17 00:00:00 2001 From: haryunio Date: Mon, 28 Jul 2025 16:49:10 +0900 Subject: [PATCH 4/7] fix: bump golangci-lint and golangci-lint-action --- .github/workflows/lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5f6c1ec5a..7655fe984 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,8 +21,8 @@ jobs: **/*.go **/*.mod **/*.sum - - uses: golangci/golangci-lint-action@v3 + - uses: golangci/golangci-lint-action@v6 with: - version: v1.54 + version: v1.64.8 args: --timeout 10m if: "env.GIT_DIFF != ''" From 4dde4d43f0e2b668fc63236411e82edc212fb42e Mon Sep 17 00:00:00 2001 From: haryunio Date: Mon, 28 Jul 2025 17:03:13 +0900 Subject: [PATCH 5/7] chore: migrate golangci-lint configuration to v2 and workflow conditions --- .github/workflows/lint.yml | 2 +- .golangci.old.yaml | 70 +++++++++++++++++++++++++ .golangci.yaml | 103 ++++++++++++++++++------------------- 3 files changed, 122 insertions(+), 53 deletions(-) create mode 100644 .golangci.old.yaml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7655fe984..ae63fbe5a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,4 +25,4 @@ jobs: with: version: v1.64.8 args: --timeout 10m - if: "env.GIT_DIFF != ''" + if: env.GIT_DIFF != '' diff --git a/.golangci.old.yaml b/.golangci.old.yaml new file mode 100644 index 000000000..a9a80c2eb --- /dev/null +++ b/.golangci.old.yaml @@ -0,0 +1,70 @@ +run: + tests: false +# # timeout for analysis, e.g. 30s, 5m, default is 1m +# timeout: 5m + +linters: + disable-all: true + enable: + - bodyclose + - deadcode + - dogsled + - gocritic + - gofmt + - goimports + - golint + - gosec + - gosimple + - govet + - ineffassign + - maligned + - misspell + - nakedret + - scopelint + - staticcheck + - structcheck + - stylecheck + - typecheck + - unconvert + - unused + - unparam + - misspell + - nolintlint + +issues: + exclude-rules: + - text: "Use of weak random number generator" + linters: + - gosec + - text: "comment on exported var" + linters: + - golint + - text: "don't use an underscore in package name" + linters: + - golint + - text: "ST1003:" + linters: + - stylecheck + # FIXME: Disabled until golangci-lint updates stylecheck with this fix: + # https://github.com/dominikh/go-tools/issues/389 + - text: "ST1016:" + linters: + - stylecheck + # Disable until Msg-based gov proposals are fully implemented + - text: "SA1019:" + linters: + - staticcheck + max-issues-per-linter: 10000 + max-same-issues: 10000 + +linters-settings: + dogsled: + max-blank-identifiers: 3 + maligned: + # print struct with more effective memory layout or not, false by default + suggest-new: true + nolintlint: + allow-unused: false + allow-leading-space: true + require-explanation: false + require-specific: false diff --git a/.golangci.yaml b/.golangci.yaml index a9a80c2eb..3257cae5b 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,70 +1,69 @@ +version: "2" run: tests: false -# # timeout for analysis, e.g. 30s, 5m, default is 1m -# timeout: 5m - linters: - disable-all: true + default: none enable: - bodyclose - - deadcode - dogsled - gocritic - - gofmt - - goimports - - golint - gosec - - gosimple - govet - ineffassign - - maligned - misspell - nakedret - - scopelint + - nolintlint - staticcheck - - structcheck - - stylecheck - - typecheck - unconvert - - unused - unparam - - misspell - - nolintlint - + - unused + settings: + dogsled: + max-blank-identifiers: 3 + nolintlint: + require-explanation: false + require-specific: false + allow-unused: false + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - gosec + text: Use of weak random number generator + - linters: + - golint + text: comment on exported var + - linters: + - golint + text: don't use an underscore in package name + - linters: + - staticcheck + text: 'ST1003:' + - linters: + - staticcheck + text: 'ST1016:' + - linters: + - staticcheck + text: 'SA1019:' + paths: + - third_party$ + - builtin$ + - examples$ issues: - exclude-rules: - - text: "Use of weak random number generator" - linters: - - gosec - - text: "comment on exported var" - linters: - - golint - - text: "don't use an underscore in package name" - linters: - - golint - - text: "ST1003:" - linters: - - stylecheck - # FIXME: Disabled until golangci-lint updates stylecheck with this fix: - # https://github.com/dominikh/go-tools/issues/389 - - text: "ST1016:" - linters: - - stylecheck - # Disable until Msg-based gov proposals are fully implemented - - text: "SA1019:" - linters: - - staticcheck max-issues-per-linter: 10000 max-same-issues: 10000 - -linters-settings: - dogsled: - max-blank-identifiers: 3 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true - nolintlint: - allow-unused: false - allow-leading-space: true - require-explanation: false - require-specific: false +formatters: + enable: + - gofmt + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ From e1e6eaa42c9961639791ff8dbc09bd10be57fc97 Mon Sep 17 00:00:00 2001 From: haryunio Date: Mon, 28 Jul 2025 17:10:14 +0900 Subject: [PATCH 6/7] chore: update golangci-lint-action to version v2.3.0 --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ae63fbe5a..94adf561d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,6 +23,6 @@ jobs: **/*.sum - uses: golangci/golangci-lint-action@v6 with: - version: v1.64.8 + version: v2.3.0 args: --timeout 10m if: env.GIT_DIFF != '' From 08d62cd7481e8d5fbf541c90a2f43db853a5681f Mon Sep 17 00:00:00 2001 From: haryunio Date: Mon, 28 Jul 2025 17:14:11 +0900 Subject: [PATCH 7/7] chore: upgrade golangci-lint-action to version v7 --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 94adf561d..1f2f63502 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,7 +21,7 @@ jobs: **/*.go **/*.mod **/*.sum - - uses: golangci/golangci-lint-action@v6 + - uses: golangci/golangci-lint-action@v7 with: version: v2.3.0 args: --timeout 10m