From b66785576f32cadc365ff24ef9f262fcaf4cd76c Mon Sep 17 00:00:00 2001 From: Clockwork Date: Mon, 26 Feb 2024 09:40:09 +0200 Subject: [PATCH] feat: Support custom govgen gov module --- cmd/parse/gov/proposal.go | 2 +- database/gov.go | 4 +--- go.mod | 4 +--- go.sum | 13 ++----------- modules/gov/handle_genesis.go | 2 +- modules/gov/handle_msg.go | 5 ++--- modules/gov/source/remote/source.go | 6 ++---- modules/gov/source/source.go | 2 +- modules/gov/utils_proposal.go | 4 ++-- modules/types/sources.go | 2 +- types/gov.go | 16 +++++++++++++--- 11 files changed, 27 insertions(+), 33 deletions(-) diff --git a/cmd/parse/gov/proposal.go b/cmd/parse/gov/proposal.go index f8f58fdbc..f72baa7ad 100644 --- a/cmd/parse/gov/proposal.go +++ b/cmd/parse/gov/proposal.go @@ -9,7 +9,7 @@ import ( modulestypes "github.com/forbole/bdjuno/v4/modules/types" "github.com/rs/zerolog/log" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govtypes "github.com/atomone-hub/govgen/x/gov/types" parsecmdtypes "github.com/forbole/juno/v5/cmd/parse/types" "github.com/forbole/juno/v5/types/config" "github.com/spf13/cobra" diff --git a/database/gov.go b/database/gov.go index 136837d56..f8c22ea5d 100644 --- a/database/gov.go +++ b/database/gov.go @@ -5,8 +5,8 @@ import ( "fmt" "time" + govtypes "github.com/atomone-hub/govgen/x/gov/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/gogo/protobuf/proto" @@ -19,7 +19,6 @@ import ( // SaveGovParams saves the given x/gov parameters inside the database func (db *Db) SaveGovParams(params *types.GovParams) error { - depositParamsBz, err := json.Marshal(¶ms.DepositParams) if err != nil { return fmt.Errorf("error while marshaling deposit params: %s", err) @@ -412,7 +411,6 @@ WHERE proposal_validator_status_snapshot.height <= excluded.height` // SaveSoftwareUpgradePlan allows to save the given software upgrade plan with its proposal id func (db *Db) SaveSoftwareUpgradePlan(proposalID uint64, plan upgradetypes.Plan, height int64) error { - stmt := ` INSERT INTO software_upgrade_plan(proposal_id, plan_name, upgrade_height, info, height) VALUES ($1, $2, $3, $4, $5) diff --git a/go.mod b/go.mod index b69b257d6..0ea17188f 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/forbole/bdjuno/v4 go 1.19 require ( - github.com/atomone-hub/govgen v0.0.0-20240216125422-eb7bce76c600 + github.com/atomone-hub/govgen v1.0.0 github.com/cometbft/cometbft v0.37.2 github.com/cosmos/cosmos-sdk v0.45.16 github.com/cosmos/go-bip39 v1.0.0 // indirect @@ -86,7 +86,6 @@ require ( github.com/cosmos/gogoproto v1.4.11 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/cosmos/iavl v0.19.5 // indirect - github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.1.1 // indirect github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/daixiang0/gci v0.11.2 // indirect @@ -158,7 +157,6 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect - github.com/iancoleman/orderedmap v0.2.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jgautheron/goconst v1.6.0 // indirect github.com/jingyugao/rowserrcheck v1.1.1 // indirect diff --git a/go.sum b/go.sum index 1808fdf0c..211561e61 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ github.com/ashanbrown/forbidigo v1.6.0 h1:D3aewfM37Yb3pxHujIPSpTf6oQk9sc9WZi8ger github.com/ashanbrown/forbidigo v1.6.0/go.mod h1:Y8j9jy9ZYAEHXdu723cUlraTqbzjKF1MUyfOKL+AjcU= github.com/ashanbrown/makezero v1.1.1 h1:iCQ87C0V0vSyO+M9E/FZYbu65auqH0lnsOkf5FcB28s= github.com/ashanbrown/makezero v1.1.1/go.mod h1:i1bJLCRSCHOcOa9Y6MyF2FTfMZMFdHvxKHxgO5Z1axI= -github.com/atomone-hub/govgen v0.0.0-20240216125422-eb7bce76c600 h1:aLy3ieeJ8+1R169gQgj7y9sOLfSlYPk29SYEV35n+XU= -github.com/atomone-hub/govgen v0.0.0-20240216125422-eb7bce76c600/go.mod h1:3HvxM7XDgCAXnAPTIuRQVD3o1XYSdlhtx/+e784jdBI= +github.com/atomone-hub/govgen v1.0.0 h1:IRRoCflROmdKqSBjdZePBLziyb/yswg3rp7fMLZAJlQ= +github.com/atomone-hub/govgen v1.0.0/go.mod h1:y6BIlaIfVoloBw+rHtvsbeEJ+GiScUVdwFda1czL/+4= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -183,8 +183,6 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/clockworkgr/govgen v0.0.0-20240216093636-431a6f0d0500 h1:nxCgYT1jrLn2oFkYb0pAK1thKcM/zLHbwCyJ9GR6O4Y= -github.com/clockworkgr/govgen v0.0.0-20240216093636-431a6f0d0500/go.mod h1:3HvxM7XDgCAXnAPTIuRQVD3o1XYSdlhtx/+e784jdBI= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -226,8 +224,6 @@ github.com/cosmos/cosmos-proto v1.0.0-beta.1 h1:iDL5qh++NoXxG8hSy93FdYJut4XfgbSh github.com/cosmos/cosmos-proto v1.0.0-beta.1/go.mod h1:8k2GNZghi5sDRFw/scPL8gMSowT1vDA+5ouxL8GjaUE= github.com/cosmos/cosmos-sdk v0.45.16-ics-lsm h1:Cld5lg+lXvqT8plyy0l5Aytir4PdxWMHNLyFbOE3iMs= github.com/cosmos/cosmos-sdk v0.45.16-ics-lsm/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= -github.com/cosmos/gaia/v14 v14.1.0 h1:aETug4HFGdc2n3GhAEUFQq22JwvkYMdFIXx1uIRtQF4= -github.com/cosmos/gaia/v14 v14.1.0/go.mod h1:W1BE1sGsKudo/Igt+ttz1/ouWS6/1TuaHpA0xelQeew= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= @@ -237,8 +233,6 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4 github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.19.5 h1:rGA3hOrgNxgRM5wYcSCxgQBap7fW82WZgY78V9po/iY= github.com/cosmos/iavl v0.19.5/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= -github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.1.1 h1:TeiMKG56Kg+lqw/+08dfusInebjVagr9v75sP2GJo6w= -github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.1.1/go.mod h1:mFk2qfXAm7ndXQQuXUGm9tlC2OM9jxPQb5PRKEHNU5I= github.com/cosmos/ibc-go/v4 v4.5.1 h1:+P73X7aIikGAXBUJ9vP9rEbvdSuekt3KGXmAWCSYets= github.com/cosmos/ibc-go/v4 v4.5.1/go.mod h1:2EOi40Bx/j6rJrtP1ui8k8yUAMpGybmL1EjakYqYv5U= github.com/cosmos/interchain-security/v2 v2.4.0-lsm h1:1BQ94GQD4TVOLfL2/jJn2Vgro6ph+tVgChk5ziy/JOA= @@ -570,8 +564,6 @@ github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSo github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hydrogen18/memlistener v0.0.0-20141126152155-54553eb933fb/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= -github.com/iancoleman/orderedmap v0.2.0 h1:sq1N/TFpYH++aViPcaKjys3bDClUEU7s5B+z6jq8pNA= -github.com/iancoleman/orderedmap v0.2.0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= @@ -783,7 +775,6 @@ github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJ github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= -github.com/oxyno-zeta/gomock-extra-matcher v1.1.0 h1:Yyk5ov0ZPKBXtVEeIWtc4J2XVrHuNoIK+0F2BUJgtsc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= diff --git a/modules/gov/handle_genesis.go b/modules/gov/handle_genesis.go index 73e29fa3f..a8354a451 100644 --- a/modules/gov/handle_genesis.go +++ b/modules/gov/handle_genesis.go @@ -8,7 +8,7 @@ import ( "github.com/forbole/bdjuno/v4/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govtypes "github.com/atomone-hub/govgen/x/gov/types" "github.com/rs/zerolog/log" ) diff --git a/modules/gov/handle_msg.go b/modules/gov/handle_msg.go index f3865a079..e9a4f6084 100644 --- a/modules/gov/handle_msg.go +++ b/modules/gov/handle_msg.go @@ -2,16 +2,15 @@ package gov import ( "fmt" - "time" - "strconv" + "time" "github.com/cosmos/cosmos-sdk/x/authz" "github.com/forbole/bdjuno/v4/types" + govtypes "github.com/atomone-hub/govgen/x/gov/types" sdk "github.com/cosmos/cosmos-sdk/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" juno "github.com/forbole/juno/v5/types" ) diff --git a/modules/gov/source/remote/source.go b/modules/gov/source/remote/source.go index 5e226d0f6..eafe620cd 100644 --- a/modules/gov/source/remote/source.go +++ b/modules/gov/source/remote/source.go @@ -1,15 +1,13 @@ package remote import ( - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govtypes "github.com/atomone-hub/govgen/x/gov/types" "github.com/forbole/juno/v5/node/remote" govsource "github.com/forbole/bdjuno/v4/modules/gov/source" ) -var ( - _ govsource.Source = &Source{} -) +var _ govsource.Source = &Source{} // Source implements govsource.Source using a remote node type Source struct { diff --git a/modules/gov/source/source.go b/modules/gov/source/source.go index 3acdea56e..1fecdc013 100644 --- a/modules/gov/source/source.go +++ b/modules/gov/source/source.go @@ -1,6 +1,6 @@ package source -import govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" +import govtypes "github.com/atomone-hub/govgen/x/gov/types" type Source interface { Proposal(height int64, id uint64) (govtypes.Proposal, error) diff --git a/modules/gov/utils_proposal.go b/modules/gov/utils_proposal.go index 3f1ad00a6..956702525 100644 --- a/modules/gov/utils_proposal.go +++ b/modules/gov/utils_proposal.go @@ -19,7 +19,7 @@ import ( distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" ccvprovidertypes "github.com/cosmos/interchain-security/v2/x/ccv/provider/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govtypes "github.com/atomone-hub/govgen/x/gov/types" ) func (m *Module) UpdateProposal(height int64, blockTime time.Time, id uint64) error { @@ -227,7 +227,7 @@ func (m *Module) updateProposalValidatorStatusesSnapshot( return fmt.Errorf("error while getting validator statuses: %s", err) } - var snapshots = make([]types.ProposalValidatorStatusSnapshot, len(validators)) + snapshots := make([]types.ProposalValidatorStatusSnapshot, len(validators)) for index, validator := range validators { consAddr, err := validator.GetConsAddr() if err != nil { diff --git a/modules/types/sources.go b/modules/types/sources.go index 2b8d395a3..f0242b03f 100644 --- a/modules/types/sources.go +++ b/modules/types/sources.go @@ -6,9 +6,9 @@ import ( "github.com/cosmos/cosmos-sdk/simapp/params" "github.com/forbole/juno/v5/node/remote" + govtypes "github.com/atomone-hub/govgen/x/gov/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" diff --git a/types/gov.go b/types/gov.go index 2591a5ade..bc6b6856d 100644 --- a/types/gov.go +++ b/types/gov.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govtypes "github.com/atomone-hub/govgen/x/gov/types" ) const ( @@ -28,13 +28,23 @@ func NewDepositParam(d govtypes.DepositParams) DepositParams { // VotingParams contains the voting parameters of the x/gov module type VotingParams struct { - VotingPeriod int64 `json:"voting_period,omitempty" yaml:"voting_period"` + VotingPeriodDefault int64 `json:"voting_period_default,omitempty" yaml:"voting_period_default"` + // Length of the voting period for parameter change proposal. + VotingPeriodParameterChange int64 `json:"voting_period_parameter_change,omitempty" yaml:"voting_period_parameter_change"` + // Length of the voting period for software upgrade and cancel software + // upgrade proposal. + VotingPeriodSoftwareUpgrade int64 `json:"voting_period_software_upgrade,omitempty" yaml:"voting_period_software_upgrade"` + // Length of the voting period for text proposal. + VotingPeriodText int64 `json:"voting_period_text,omitempty" yaml:"voting_period_text"` } // NewVotingParams allows to build a new VotingParams instance func NewVotingParams(v govtypes.VotingParams) VotingParams { return VotingParams{ - VotingPeriod: v.VotingPeriod.Nanoseconds(), + VotingPeriodDefault: v.VotingPeriodDefault.Nanoseconds(), + VotingPeriodParameterChange: v.VotingPeriodParameterChange.Nanoseconds(), + VotingPeriodSoftwareUpgrade: v.VotingPeriodSoftwareUpgrade.Nanoseconds(), + VotingPeriodText: v.VotingPeriodText.Nanoseconds(), } }