Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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@v7
with:
version: v1.28
version: v2.3.0
args: --timeout 10m
github-token: ${{ secrets.GITHUB_TOKEN }}
if: "env.GIT_DIFF != ''"
if: env.GIT_DIFF != ''
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.15
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
70 changes: 70 additions & 0 deletions .golangci.old.yaml
Original file line number Diff line number Diff line change
@@ -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
103 changes: 51 additions & 52 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -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$
9 changes: 9 additions & 0 deletions modules/gov/handle_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
13 changes: 13 additions & 0 deletions modules/gov/utils_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading