From 39e79878155c6a2fbcbe4152f7f7c57300b1399f Mon Sep 17 00:00:00 2001 From: Paul Chen Date: Thu, 21 Mar 2024 20:15:57 +0800 Subject: [PATCH] fix: check submit event with voting start period attritube to gov handle block --- modules/gov/handle_block.go | 13 ++++++++++--- modules/gov/utils_proposal.go | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/gov/handle_block.go b/modules/gov/handle_block.go index b36c8ebce..1d6c05d51 100644 --- a/modules/gov/handle_block.go +++ b/modules/gov/handle_block.go @@ -38,12 +38,19 @@ func (m *Module) updateProposalsStatus(height int64, blockTime time.Time, txEven } ids = append(ids, endBlockIDs...) + // the proposal changes state from the submit to voting + idsInSubmitTxs, err := findProposalIDsInEvents(txEvents, govtypes.EventTypeSubmitProposal, govtypes.AttributeKeyVotingPeriodStart) + if err != nil { + return err + } + ids = append(ids, idsInSubmitTxs...) + // the proposal changes state from the deposit to voting - txIDs, err := findProposalIDsInEvents(txEvents, govtypes.EventTypeProposalDeposit, govtypes.AttributeKeyVotingPeriodStart) + idsInDepositTxs, err := findProposalIDsInEvents(txEvents, govtypes.EventTypeProposalDeposit, govtypes.AttributeKeyVotingPeriodStart) if err != nil { return err } - ids = append(ids, txIDs...) + ids = append(ids, idsInDepositTxs...) // update status for proposals IDs stored in ids array for _, id := range ids { @@ -57,7 +64,7 @@ func (m *Module) updateProposalsStatus(height int64, blockTime time.Time, txEven return fmt.Errorf("error while updating proposal validator statuses snapshots: %s", err) } - err = m.UpdateProposalStakingPoolSnapshot(height, blockVals, id) + err = m.UpdateProposalStakingPoolSnapshot(height, id) if err != nil { return fmt.Errorf("error while updating proposal validator statuses snapshots: %s", err) } diff --git a/modules/gov/utils_proposal.go b/modules/gov/utils_proposal.go index cecc8ffa2..92895d069 100644 --- a/modules/gov/utils_proposal.go +++ b/modules/gov/utils_proposal.go @@ -68,7 +68,7 @@ func (m *Module) UpdateProposalValidatorStatusesSnapshot(height int64, blockVals return nil } -func (m *Module) UpdateProposalStakingPoolSnapshot(height int64, blockVals *tmctypes.ResultValidators, id uint64) error { +func (m *Module) UpdateProposalStakingPoolSnapshot(height int64, id uint64) error { err := m.updateProposalStakingPoolSnapshot(height, id) if err != nil { return fmt.Errorf("error while updating proposal staking pool snapshot: %s", err)