From cc1172ed24d44b93cc1f5fb6192970f9dfcd5559 Mon Sep 17 00:00:00 2001 From: Aaron <76254323+huichiaotsou@users.noreply.github.com> Date: Mon, 29 Aug 2022 16:28:47 +0800 Subject: [PATCH] fix: parse gov genesis with `doc.InitialHeight` instead of height 1 (#461) ## Description Closes: #XXXX jira: https://forbole.atlassian.net/browse/BDU-544 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch - [ ] provided a link to the relevant issue or specification - [x] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) --- CHANGELOG.md | 2 ++ modules/gov/handle_genesis.go | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 710d62144..6dc9bbff7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - ([\#443](https://github.com/forbole/bdjuno/pull/443)) Remove tombstone status from staking module(already stored in slashing module) - ([\#455](https://github.com/forbole/bdjuno/pull/455)) Added `unbonding_tokens` and `staked_not_bonded_tokens` values to staking pool table +#### Gov Module +- ([\#461](https://github.com/forbole/bdjuno/pull/461)) Parse `x/gov` genesis with `genesisDoc.InitialHeight` instead of the hard-coded height 1 #### Daily refetch - ([\#454](https://github.com/forbole/bdjuno/pull/454)) Added `daily refetch` module to refetch missing blocks every day diff --git a/modules/gov/handle_genesis.go b/modules/gov/handle_genesis.go index a299ee25f..a0e74e1d7 100644 --- a/modules/gov/handle_genesis.go +++ b/modules/gov/handle_genesis.go @@ -24,7 +24,7 @@ func (m *Module) HandleGenesis(doc *tmtypes.GenesisDoc, appState map[string]json } // Save the proposals - err = m.saveProposals(genState.Proposals) + err = m.saveProposals(genState.Proposals, doc.InitialHeight) if err != nil { return fmt.Errorf("error while storing genesis governance proposals: %s", err) } @@ -44,7 +44,7 @@ func (m *Module) HandleGenesis(doc *tmtypes.GenesisDoc, appState map[string]json } // saveProposals save proposals from genesis file -func (m *Module) saveProposals(slice govtypes.Proposals) error { +func (m *Module) saveProposals(slice govtypes.Proposals, genHeight int64) error { proposals := make([]types.Proposal, len(slice)) tallyResults := make([]types.TallyResult, len(slice)) deposits := make([]types.Deposit, len(slice)) @@ -70,14 +70,14 @@ func (m *Module) saveProposals(slice govtypes.Proposals) error { proposal.FinalTallyResult.Abstain.String(), proposal.FinalTallyResult.No.String(), proposal.FinalTallyResult.NoWithVeto.String(), - 1, + genHeight, ) deposits[index] = types.NewDeposit( proposal.ProposalId, "", proposal.TotalDeposit, - 1, + genHeight, ) }