Skip to content

Commit

Permalink
Fix Testnet3 by specifying the minimum vote version. (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
dajohi committed Jun 19, 2023
1 parent aed6a8a commit b2e8945
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions agenda.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ func agendasFromJSON(getVoteInfo types.GetVoteInfoResult) []Agenda {
return parsedAgendas
}

func agendasForVersions(ctx context.Context, dcrdClient *rpcclient.Client, maxVoteVersion uint32, currentHeight int64, svis StakeVersionIntervals) ([]Agenda, error) {
func agendasForVersions(ctx context.Context, dcrdClient *rpcclient.Client, currentHeight int64, svis StakeVersionIntervals) ([]Agenda, error) {
var allAgendas []Agenda
for version := uint32(0); version <= maxVoteVersion; version++ {
for version := svis.MinVoteVersion; version <= svis.MaxVoteVersion; version++ {
// Retrieve Agendas for this voting period
getVoteInfo, err := dcrdClient.GetVoteInfo(ctx, version)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func updatetemplateInformation(ctx context.Context, dcrdClient *rpcclient.Client
templateInformation.IsUpgrading = true
}

templateInformation.Agendas, err = agendasForVersions(ctx, dcrdClient, svis.MaxVoteVersion, height, svis)
templateInformation.Agendas, err = agendasForVersions(ctx, dcrdClient, height, svis)
if err != nil {
log.Printf("Error getting agendas: %v", err)
return
Expand Down
9 changes: 8 additions & 1 deletion stake_version_intervals.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
// StakeVersionIntervals wraps a set of types.VersionIntervals
type StakeVersionIntervals struct {
Intervals []types.VersionInterval
MinVoteVersion uint32
MaxVoteVersion uint32
}

Expand Down Expand Up @@ -82,7 +83,8 @@ func AllStakeVersionIntervals(ctx context.Context, dcrdClient *rpcclient.Client,
}

svis := StakeVersionIntervals{
Intervals: stakeVersionInfoResult.Intervals}
Intervals: stakeVersionInfoResult.Intervals,
}

// Reverse the slice of SVIs
// This makes traversing the set easier later on,
Expand All @@ -100,6 +102,11 @@ func AllStakeVersionIntervals(ctx context.Context, dcrdClient *rpcclient.Client,
}
}

min := activeNetParams.GenesisBlock.Header.StakeVersion
if min < 4 {
min = 4
}
svis.MinVoteVersion = min
svis.MaxVoteVersion = max

return svis, nil
Expand Down

0 comments on commit b2e8945

Please sign in to comment.