diff --git a/Makefile b/Makefile index bcc1db4fc80b..3c139f0daf3a 100644 --- a/Makefile +++ b/Makefile @@ -384,7 +384,7 @@ benchmark: ### Linting ### ############################################################################### -golangci_version=v1.55.0 +golangci_version=v1.56.2 #? setup-pre-commit: Set pre-commit git hook setup-pre-commit: diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index a4f254260bea..3fd7d86bb647 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -1804,7 +1804,10 @@ func TestABCI_PrepareProposal_VoteExtensions(t *testing.T) { // set up baseapp prepareOpt := func(bapp *baseapp.BaseApp) { bapp.SetPrepareProposal(func(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { - err := baseapp.ValidateVoteExtensions(ctx, valStore, req.Height, bapp.ChainID(), req.LocalLastCommit) + ctx = ctx.WithBlockHeight(req.Height).WithChainID(bapp.ChainID()) + _, info := extendedCommitToLastCommit(req.LocalLastCommit) + ctx = ctx.WithCometInfo(info) + err := baseapp.ValidateVoteExtensions(ctx, valStore, req.LocalLastCommit) if err != nil { return nil, err } @@ -2111,7 +2114,10 @@ func TestBaseApp_VoteExtensions(t *testing.T) { app.SetPrepareProposal(func(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { txs := [][]byte{} - if err := baseapp.ValidateVoteExtensions(ctx, valStore, req.Height, app.ChainID(), req.LocalLastCommit); err != nil { + ctx = ctx.WithBlockHeight(req.Height).WithChainID(app.ChainID()) + _, info := extendedCommitToLastCommit(req.LocalLastCommit) + ctx = ctx.WithCometInfo(info) + if err := baseapp.ValidateVoteExtensions(ctx, valStore, req.LocalLastCommit); err != nil { return nil, err } // add all VE as txs (in a real scenario we would need to check signatures too) diff --git a/baseapp/abci_utils.go b/baseapp/abci_utils.go index f31446d540b7..450f4c9b235c 100644 --- a/baseapp/abci_utils.go +++ b/baseapp/abci_utils.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + "slices" "github.com/cockroachdb/errors" abci "github.com/cometbft/cometbft/abci/types" @@ -14,6 +15,7 @@ import ( protoio "github.com/cosmos/gogoproto/io" "github.com/cosmos/gogoproto/proto" + "cosmossdk.io/core/comet" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/mempool" ) @@ -40,11 +42,19 @@ type ( func ValidateVoteExtensions( ctx sdk.Context, valStore ValidatorStore, - currentHeight int64, - chainID string, extCommit abci.ExtendedCommitInfo, ) error { + // Get values from context cp := ctx.ConsensusParams() + currentHeight := ctx.BlockHeight() + chainID := ctx.BlockHeader().ChainID + commitInfo := ctx.CometInfo().LastCommit + + // Check that both extCommit + commit are ordered in accordance with vp/address. + if err := validateExtendedCommitAgainstLastCommit(extCommit, commitInfo); err != nil { + return err + } + // Start checking vote extensions only **after** the vote extensions enable // height, because when `currentHeight == VoteExtensionsEnableHeight` // PrepareProposal doesn't get any vote extensions in its request. @@ -65,7 +75,6 @@ func ValidateVoteExtensions( sumVP int64 ) - cache := make(map[string]struct{}) for _, vote := range extCommit.Votes { totalVP += vote.Validator.Power @@ -90,12 +99,7 @@ func ValidateVoteExtensions( return fmt.Errorf("vote extensions enabled; received empty vote extension signature at height %d", currentHeight) } - // Ensure that the validator has not already submitted a vote extension. valConsAddr := sdk.ConsAddress(vote.Validator.Address) - if _, ok := cache[valConsAddr.String()]; ok { - return fmt.Errorf("duplicate validator; validator %s has already submitted a vote extension", valConsAddr.String()) - } - cache[valConsAddr.String()] = struct{}{} pubKeyProto, err := valStore.GetPubKeyByConsAddr(ctx, valConsAddr) if err != nil { @@ -141,6 +145,51 @@ func ValidateVoteExtensions( return nil } +// validateExtendedCommitAgainstLastCommit validates an ExtendedCommitInfo against a LastCommit. Specifically, +// it checks that the ExtendedCommit + LastCommit (for the same height), are consistent with each other + that +// they are ordered correctly (by voting power) in accordance with +// [comet](https://github.com/cometbft/cometbft/blob/4ce0277b35f31985bbf2c25d3806a184a4510010/types/validator_set.go#L784). +func validateExtendedCommitAgainstLastCommit(ec abci.ExtendedCommitInfo, lc comet.CommitInfo) error { + // check that the rounds are the same + if ec.Round != lc.Round { + return fmt.Errorf("extended commit round %d does not match last commit round %d", ec.Round, lc.Round) + } + + // check that the # of votes are the same + if len(ec.Votes) != len(lc.Votes) { + return fmt.Errorf("extended commit votes length %d does not match last commit votes length %d", len(ec.Votes), len(lc.Votes)) + } + + // check sort order of extended commit votes + if !slices.IsSortedFunc(ec.Votes, func(vote1, vote2 abci.ExtendedVoteInfo) int { + if vote1.Validator.Power == vote2.Validator.Power { + return bytes.Compare(vote1.Validator.Address, vote2.Validator.Address) // addresses sorted in ascending order (used to break vp conflicts) + } + return -int(vote1.Validator.Power - vote2.Validator.Power) // vp sorted in descending order + }) { + return fmt.Errorf("extended commit votes are not sorted by voting power") + } + + addressCache := make(map[string]struct{}, len(ec.Votes)) + // check consistency between LastCommit and ExtendedCommit + for i, vote := range ec.Votes { + // cache addresses to check for duplicates + if _, ok := addressCache[string(vote.Validator.Address)]; ok { + return fmt.Errorf("extended commit vote address %X is duplicated", vote.Validator.Address) + } + addressCache[string(vote.Validator.Address)] = struct{}{} + + if !bytes.Equal(vote.Validator.Address, lc.Votes[i].Validator.Address) { + return fmt.Errorf("extended commit vote address %X does not match last commit vote address %X", vote.Validator.Address, lc.Votes[i].Validator.Address) + } + if vote.Validator.Power != lc.Votes[i].Validator.Power { + return fmt.Errorf("extended commit vote power %d does not match last commit vote power %d", vote.Validator.Power, lc.Votes[i].Validator.Power) + } + } + + return nil +} + type ( // ProposalTxVerifier defines the interface that is implemented by BaseApp, // that any custom ABCI PrepareProposal and ProcessProposal handler can use diff --git a/baseapp/abci_utils_test.go b/baseapp/abci_utils_test.go index d0845c51040d..7157d3ac9cc3 100644 --- a/baseapp/abci_utils_test.go +++ b/baseapp/abci_utils_test.go @@ -2,6 +2,7 @@ package baseapp_test import ( "bytes" + "sort" "testing" abci "github.com/cometbft/cometbft/abci/types" @@ -19,6 +20,7 @@ import ( "cosmossdk.io/log" authtx "cosmossdk.io/x/auth/tx" + "cosmossdk.io/core/comet" "github.com/cosmos/cosmos-sdk/baseapp" baseapptestutil "github.com/cosmos/cosmos-sdk/baseapp/testutil" "github.com/cosmos/cosmos-sdk/baseapp/testutil/mock" @@ -64,6 +66,13 @@ func (t testValidator) toValidator(power int64) abci.Validator { } } +func (t testValidator) toSDKValidator(power int64) comet.Validator { + return comet.Validator{ + Address: t.consAddr.Bytes(), + Power: power, + } +} + type ABCIUtilsTestSuite struct { suite.Suite @@ -98,7 +107,9 @@ func NewABCIUtilsTestSuite(t *testing.T) *ABCIUtilsTestSuite { Abci: &cmtproto.ABCIParams{ VoteExtensionsEnableHeight: 2, }, - }) + }).WithBlockHeader(cmtproto.Header{ + ChainID: chainID, + }).WithLogger(log.NewTestLogger(t)) return s } @@ -128,6 +139,8 @@ func (s *ABCIUtilsTestSuite) TestValidateVoteExtensionsHappyPath() { extSig2, err := s.vals[2].privKey.Sign(bz) s.Require().NoError(err) + s.ctx = s.ctx.WithBlockHeight(3) // enable vote-extensions + llc := abci.ExtendedCommitInfo{ Round: 0, Votes: []abci.ExtendedVoteInfo{ @@ -151,8 +164,13 @@ func (s *ABCIUtilsTestSuite) TestValidateVoteExtensionsHappyPath() { }, }, } + + // order + convert to last commit + llc, info := extendedCommitToLastCommit(llc) + s.ctx = s.ctx.WithCometInfo(info) + // expect-pass (votes of height 2 are included in next block) - s.Require().NoError(baseapp.ValidateVoteExtensions(s.ctx, s.valStore, 3, chainID, llc)) + s.Require().NoError(baseapp.ValidateVoteExtensions(s.ctx, s.valStore, llc)) } // check ValidateVoteExtensions works when a single node has submitted a BlockID_Absent @@ -174,6 +192,8 @@ func (s *ABCIUtilsTestSuite) TestValidateVoteExtensionsSingleVoteAbsent() { extSig2, err := s.vals[2].privKey.Sign(bz) s.Require().NoError(err) + s.ctx = s.ctx.WithBlockHeight(3) // vote-extensions are enabled + llc := abci.ExtendedCommitInfo{ Round: 0, Votes: []abci.ExtendedVoteInfo{ @@ -196,8 +216,12 @@ func (s *ABCIUtilsTestSuite) TestValidateVoteExtensionsSingleVoteAbsent() { }, }, } + + llc, info := extendedCommitToLastCommit(llc) + s.ctx = s.ctx.WithCometInfo(info) + // expect-pass (votes of height 2 are included in next block) - s.Require().NoError(baseapp.ValidateVoteExtensions(s.ctx, s.valStore, 3, chainID, llc)) + s.Require().NoError(baseapp.ValidateVoteExtensions(s.ctx, s.valStore, llc)) } // check ValidateVoteExtensions works with duplicate votes @@ -223,15 +247,27 @@ func (s *ABCIUtilsTestSuite) TestValidateVoteExtensionsDuplicateVotes() { BlockIdFlag: cmtproto.BlockIDFlagCommit, } + ve2 := abci.ExtendedVoteInfo{ + Validator: s.vals[0].toValidator(334), // use diff voting-power to dupe + VoteExtension: ext, + ExtensionSignature: extSig0, + BlockIdFlag: cmtproto.BlockIDFlagCommit, + } + llc := abci.ExtendedCommitInfo{ Round: 0, Votes: []abci.ExtendedVoteInfo{ ve, - ve, + ve2, }, } + + s.ctx = s.ctx.WithBlockHeight(3) // vote-extensions are enabled + llc, info := extendedCommitToLastCommit(llc) + s.ctx = s.ctx.WithCometInfo(info) + // expect fail (duplicate votes) - s.Require().Error(baseapp.ValidateVoteExtensions(s.ctx, s.valStore, 3, chainID, llc)) + s.Require().Error(baseapp.ValidateVoteExtensions(s.ctx, s.valStore, llc)) } // check ValidateVoteExtensions works when a single node has submitted a BlockID_Nil @@ -275,8 +311,15 @@ func (s *ABCIUtilsTestSuite) TestValidateVoteExtensionsSingleVoteNil() { }, }, } + + s.ctx = s.ctx.WithBlockHeight(3) // vote-extensions are enabled + + // create last commit + llc, info := extendedCommitToLastCommit(llc) + s.ctx = s.ctx.WithCometInfo(info) + // expect-pass (votes of height 2 are included in next block) - s.Require().NoError(baseapp.ValidateVoteExtensions(s.ctx, s.valStore, 3, chainID, llc)) + s.Require().NoError(baseapp.ValidateVoteExtensions(s.ctx, s.valStore, llc)) } // check ValidateVoteExtensions works when two nodes have submitted a BlockID_Nil / BlockID_Absent @@ -317,8 +360,115 @@ func (s *ABCIUtilsTestSuite) TestValidateVoteExtensionsTwoVotesNilAbsent() { }, } + s.ctx = s.ctx.WithBlockHeight(3) // vote-extensions are enabled + + // create last commit + llc, info := extendedCommitToLastCommit(llc) + s.ctx = s.ctx.WithCometInfo(info) + // expect-pass (votes of height 2 are included in next block) - s.Require().Error(baseapp.ValidateVoteExtensions(s.ctx, s.valStore, 3, chainID, llc)) + s.Require().Error(baseapp.ValidateVoteExtensions(s.ctx, s.valStore, llc)) +} + +func (s *ABCIUtilsTestSuite) TestValidateVoteExtensionsIncorrectVotingPower() { + ext := []byte("vote-extension") + cve := cmtproto.CanonicalVoteExtension{ + Extension: ext, + Height: 2, + Round: int64(0), + ChainId: chainID, + } + + bz, err := marshalDelimitedFn(&cve) + s.Require().NoError(err) + + extSig0, err := s.vals[0].privKey.Sign(bz) + s.Require().NoError(err) + + llc := abci.ExtendedCommitInfo{ + Round: 0, + Votes: []abci.ExtendedVoteInfo{ + // validator of power >2/3 is missing, so commit-info should not be valid + { + Validator: s.vals[0].toValidator(333), + BlockIdFlag: cmtproto.BlockIDFlagCommit, + VoteExtension: ext, + ExtensionSignature: extSig0, + }, + { + Validator: s.vals[1].toValidator(333), + BlockIdFlag: cmtproto.BlockIDFlagNil, + }, + { + Validator: s.vals[2].toValidator(334), + VoteExtension: ext, + BlockIdFlag: cmtproto.BlockIDFlagAbsent, + }, + }, + } + + s.ctx = s.ctx.WithBlockHeight(3) // vote-extensions are enabled + + // create last commit + llc, info := extendedCommitToLastCommit(llc) + s.ctx = s.ctx.WithCometInfo(info) + + // modify voting powers to differ from the last-commit + llc.Votes[0].Validator.Power = 335 + llc.Votes[2].Validator.Power = 332 + + // expect-pass (votes of height 2 are included in next block) + s.Require().Error(baseapp.ValidateVoteExtensions(s.ctx, s.valStore, llc)) +} + +func (s *ABCIUtilsTestSuite) TestValidateVoteExtensionsIncorrecOrder() { + ext := []byte("vote-extension") + cve := cmtproto.CanonicalVoteExtension{ + Extension: ext, + Height: 2, + Round: int64(0), + ChainId: chainID, + } + + bz, err := marshalDelimitedFn(&cve) + s.Require().NoError(err) + + extSig0, err := s.vals[0].privKey.Sign(bz) + s.Require().NoError(err) + + llc := abci.ExtendedCommitInfo{ + Round: 0, + Votes: []abci.ExtendedVoteInfo{ + // validator of power >2/3 is missing, so commit-info should not be valid + { + Validator: s.vals[0].toValidator(333), + BlockIdFlag: cmtproto.BlockIDFlagCommit, + VoteExtension: ext, + ExtensionSignature: extSig0, + }, + { + Validator: s.vals[1].toValidator(333), + BlockIdFlag: cmtproto.BlockIDFlagNil, + }, + { + Validator: s.vals[2].toValidator(334), + VoteExtension: ext, + BlockIdFlag: cmtproto.BlockIDFlagAbsent, + }, + }, + } + + s.ctx = s.ctx.WithBlockHeight(3) // vote-extensions are enabled + + // create last commit + llc, info := extendedCommitToLastCommit(llc) + s.ctx = s.ctx.WithCometInfo(info) + + // modify voting powers to differ from the last-commit + llc.Votes[0], llc.Votes[2] = llc.Votes[2], llc.Votes[0] + + // expect-pass (votes of height 2 are included in next block) + s.Require().Error(baseapp.ValidateVoteExtensions(s.ctx, s.valStore, llc)) } func (s *ABCIUtilsTestSuite) TestDefaultProposalHandler_NoOpMempoolTxSelection() { @@ -603,3 +753,61 @@ func setTxSignatureWithSecret(t *testing.T, builder client.TxBuilder, signatures ) require.NoError(t, err) } + +func extendedCommitToLastCommit(ec abci.ExtendedCommitInfo) (abci.ExtendedCommitInfo, comet.Info) { + // sort the extended commit info + sort.Sort(extendedVoteInfos(ec.Votes)) + + // convert the extended commit info to last commit info + lastCommit := comet.CommitInfo{ + Round: ec.Round, + Votes: make([]comet.VoteInfo, len(ec.Votes)), + } + + for i, vote := range ec.Votes { + lastCommit.Votes[i] = comet.VoteInfo{ + Validator: comet.Validator{ + Address: vote.Validator.Address, + Power: vote.Validator.Power, + }, + } + } + + return ec, comet.Info{ + LastCommit: lastCommit, + } +} + +type voteInfos []comet.VoteInfo + +func (v voteInfos) Len() int { + return len(v) +} + +func (v voteInfos) Less(i, j int) bool { + if v[i].Validator.Power == v[j].Validator.Power { + return bytes.Compare(v[i].Validator.Address, v[j].Validator.Address) == -1 + } + return v[i].Validator.Power > v[j].Validator.Power +} + +func (v voteInfos) Swap(i, j int) { + v[i], v[j] = v[j], v[i] +} + +type extendedVoteInfos []abci.ExtendedVoteInfo + +func (v extendedVoteInfos) Len() int { + return len(v) +} + +func (v extendedVoteInfos) Less(i, j int) bool { + if v[i].Validator.Power == v[j].Validator.Power { + return bytes.Compare(v[i].Validator.Address, v[j].Validator.Address) == -1 + } + return v[i].Validator.Power > v[j].Validator.Power +} + +func (v extendedVoteInfos) Swap(i, j int) { + v[i], v[j] = v[j], v[i] +} diff --git a/client/cmd.go b/client/cmd.go index 739bc5c6340f..61412200fd5f 100644 --- a/client/cmd.go +++ b/client/cmd.go @@ -4,12 +4,12 @@ import ( "context" "crypto/tls" "fmt" + "slices" "strings" "github.com/cockroachdb/errors" "github.com/spf13/cobra" "github.com/spf13/pflag" - "golang.org/x/exp/slices" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" diff --git a/client/v2/autocli/testdata/msg-output.golden b/client/v2/autocli/testdata/msg-output.golden index 924f3eeee5d5..9d0cead403f9 100644 --- a/client/v2/autocli/testdata/msg-output.golden +++ b/client/v2/autocli/testdata/msg-output.golden @@ -1 +1 @@ -{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend","from_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk","to_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk","amount":[{"denom":"foo","amount":"1"}]}]},"auth_info":{"fee":{"gas_limit":"200000"}}} +{"body":{"messages":[{"@type":"/cosmos.bank.v1beta1.MsgSend", "from_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk", "to_address":"cosmos1y74p8wyy4enfhfn342njve6cjmj5c8dtl6emdk", "amount":[{"denom":"foo", "amount":"1"}]}]}, "auth_info":{"fee":{"gas_limit":"200000"}}} diff --git a/client/v2/go.mod b/client/v2/go.mod index 098366540535..571bc45f382a 100644 --- a/client/v2/go.mod +++ b/client/v2/go.mod @@ -122,9 +122,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/client/v2/go.sum b/client/v2/go.sum index e40c6900cbdc..9a13c73af234 100644 --- a/client/v2/go.sum +++ b/client/v2/go.sum @@ -585,8 +585,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -601,8 +601,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/collections/go.mod b/collections/go.mod index c9797e2cddb2..c03042f52630 100644 --- a/collections/go.mod +++ b/collections/go.mod @@ -35,9 +35,9 @@ require ( github.com/onsi/gomega v1.20.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/spf13/cast v1.6.0 // indirect diff --git a/collections/go.sum b/collections/go.sum index ef86ec23a917..128ded83395d 100644 --- a/collections/go.sum +++ b/collections/go.sum @@ -103,12 +103,12 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 27ee7b8be825..8dec182fa0c3 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -42,6 +42,17 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#18457](https://github.com/cosmos/cosmos-sdk/pull/18457) Add branch.ExecuteWithGasLimit. * [#19041](https://github.com/cosmos/cosmos-sdk/pull/19041) Add `appmodule.Environment` interface to fetch different services * [#19370](https://github.com/cosmos/cosmos-sdk/pull/19370) Add `appmodule.Migrations` interface to handle migrations +* [#19617](https://github.com/cosmos/cosmos-sdk/pull/19617) Add DataBaseService to store non-consensus data in a database + * Create V2 appmodule with v2 api for runtime/v2 + * Introduce `Transaction.Tx` for use in runtime/v2 + * Introduce `HasUpdateValidators` interface and `ValidatorUpdate` struct for validator updates + * Introduce `HasTxValidation` interface for modules to register tx validation handlers + * `HasGenesis` interface for modules to register import, export, validation and default genesis handlers. The new api works with `proto.Message` + * Add `PreMsghandler`and `PostMsgHandler` for pre and post message hooks + * Add `MsgHandler` as an alternative to grpc handlers + * Provide separate `MigrationRegistrar` instead of grouping with `RegisterServices` + +### Improvements ### API Breaking Changes diff --git a/core/appmodule/environment.go b/core/appmodule/environment.go index 17ab778191c0..93778e9e9bbe 100644 --- a/core/appmodule/environment.go +++ b/core/appmodule/environment.go @@ -1,21 +1,8 @@ package appmodule import ( - "cosmossdk.io/core/branch" - "cosmossdk.io/core/event" - "cosmossdk.io/core/gas" - "cosmossdk.io/core/header" - "cosmossdk.io/core/store" - "cosmossdk.io/log" + appmodule "cosmossdk.io/core/appmodule/v2" ) // Environment is used to get all services to their respective module -type Environment struct { - BranchService branch.Service - EventService event.Service - GasService gas.Service - HeaderService header.Service - KVStoreService store.KVStoreService - MemStoreService store.MemoryStoreService - Logger log.Logger -} +type Environment = appmodule.Environment diff --git a/core/appmodule/module.go b/core/appmodule/module.go index ac30c246fde8..7f352a28e7b6 100644 --- a/core/appmodule/module.go +++ b/core/appmodule/module.go @@ -5,20 +5,27 @@ import ( "google.golang.org/grpc" "google.golang.org/protobuf/runtime/protoiface" + + appmodule "cosmossdk.io/core/appmodule/v2" ) // AppModule is a tag interface for app module implementations to use as a basis // for extension interfaces. It provides no functionality itself, but is the // type that all valid app modules should provide so that they can be identified // by other modules (usually via depinject) as app modules. -type AppModule interface { - // IsAppModule is a dummy method to tag a struct as implementing an AppModule. - IsAppModule() +type AppModule = appmodule.AppModule + +// HasMigrations is the extension interface that modules should implement to register migrations. +type HasMigrations interface { + AppModule - // IsOnePerModuleType is a dummy method to help depinject resolve modules. - IsOnePerModuleType() + // RegisterMigrations registers the module's migrations with the app's migrator. + RegisterMigrations(MigrationRegistrar) error } +// HasConsensusVersion is the interface for declaring a module consensus version. +type HasConsensusVersion = appmodule.HasConsensusVersion + // HasServices is the extension interface that modules should implement to register // implementations of services defined in .proto files. type HasServices interface { @@ -39,14 +46,6 @@ type HasServices interface { RegisterServices(grpc.ServiceRegistrar) error } -// HasMigrations is the extension interface that modules should implement to register migrations. -type HasMigrations interface { - AppModule - - // RegisterMigrations registers the module's migrations with the app's migrator. - RegisterMigrations(MigrationRegistrar) error -} - // ResponsePreBlock represents the response from the PreBlock method. // It can modify consensus parameters in storage and signal the caller through the return value. // When it returns ConsensusParamsChanged=true, the caller must refresh the consensus parameter in the finalize context. @@ -65,23 +64,11 @@ type HasPreBlocker interface { // HasBeginBlocker is the extension interface that modules should implement to run // custom logic before transaction processing in a block. -type HasBeginBlocker interface { - AppModule - - // BeginBlock is a method that will be run before transactions are processed in - // a block. - BeginBlock(context.Context) error -} +type HasBeginBlocker = appmodule.HasBeginBlocker // HasEndBlocker is the extension interface that modules should implement to run // custom logic after transaction processing in a block. -type HasEndBlocker interface { - AppModule - - // EndBlock is a method that will be run after transactions are processed in - // a block. - EndBlock(context.Context) error -} +type HasEndBlocker = appmodule.HasEndBlocker // MsgHandlerRouter is implemented by the runtime provider. type MsgHandlerRouter interface { diff --git a/core/appmodule/v2/appmodule.go b/core/appmodule/v2/appmodule.go new file mode 100644 index 000000000000..eb44c9f513b8 --- /dev/null +++ b/core/appmodule/v2/appmodule.go @@ -0,0 +1,92 @@ +package appmodule + +import ( + "context" + + "cosmossdk.io/core/transaction" +) + +// AppModule is a tag interface for app module implementations to use as a basis +// for extension interfaces. It provides no functionality itself, but is the +// type that all valid app modules should provide so that they can be identified +// by other modules (usually via depinject) as app modules. +type AppModule interface { + // IsAppModule is a dummy method to tag a struct as implementing an AppModule. + IsAppModule() + + // IsOnePerModuleType is a dummy method to help depinject resolve modules. + IsOnePerModuleType() +} + +// HasBeginBlocker is the extension interface that modules should implement to run +// custom logic before transaction processing in a block. +type HasBeginBlocker interface { + AppModule + + // BeginBlock is a method that will be run before transactions are processed in + // a block. + BeginBlock(context.Context) error +} + +// HasEndBlocker is the extension interface that modules should implement to run +// custom logic after transaction processing in a block. +type HasEndBlocker interface { + AppModule + + // EndBlock is a method that will be run after transactions are processed in + // a block. + EndBlock(context.Context) error +} + +// HasTxValidation is the extension interface that modules should implement to run +// custom logic for validating transactions. +// It was previously known as AnteHandler/Decorator. +type HasTxValidation[T transaction.Tx] interface { + AppModule + + // TxValidator is a method that will be run on each transaction. + // If an error is returned: + // ,---. + // / | + // / | + // You shall not pass! / | + // / | + // \ ___,' | + // < -' : + // `-.__..--'``-,_\_ + // |o/ ` :,.)_`> + // :/ ` ||/) + // (_.).__,-` |\ + // /( `.`` `| : + // \'`-.) ` ; ; + // | ` /-< + // | ` / `. + // ,-_-..____ /| ` :__..-'\ + // /,'-.__\\ ``-./ :` ; \ + // `\ `\ `\\ \ : ( ` / , `. \ + // \` \ \\ | | ` : : .\ \ + // \ `\_ )) : ; | | ): : + // (`-.-'\ || |\ \ ` ; ; | | + // \-_ `;;._ ( ` / /_ | | + // `-.-.// ,'`-._\__/_,' ; | + // \:: : / ` , / | + // || | ( ,' / / | + // || ,' / | + TxValidator(ctx context.Context, tx T) error +} + +// HasUpdateValidators is an extension interface that contains information about the AppModule and UpdateValidators. +// It can be seen as the alternative of the Cosmos SDK' HasABCIEndBlocker. +// Both are still supported. +type HasUpdateValidators interface { + AppModule + + UpdateValidators(ctx context.Context) ([]ValidatorUpdate, error) +} + +// ValidatorUpdate defines a validator update. +type ValidatorUpdate struct { + PubKey []byte + PubKeyType string + Power int64 // updated power of the validtor +} diff --git a/core/appmodule/v2/environment.go b/core/appmodule/v2/environment.go new file mode 100644 index 000000000000..9badbddc2f73 --- /dev/null +++ b/core/appmodule/v2/environment.go @@ -0,0 +1,22 @@ +package appmodule + +import ( + "cosmossdk.io/core/branch" + "cosmossdk.io/core/event" + "cosmossdk.io/core/gas" + "cosmossdk.io/core/header" + "cosmossdk.io/core/store" + "cosmossdk.io/log" +) + +// Environment is used to get all services to their respective module +type Environment struct { + BranchService branch.Service + EventService event.Service + GasService gas.Service + HeaderService header.Service + KVStoreService store.KVStoreService + MemStoreService store.MemoryStoreService + DataBaseService store.DatabaseService + Logger log.Logger +} diff --git a/core/appmodule/v2/genesis.go b/core/appmodule/v2/genesis.go new file mode 100644 index 000000000000..d457ac89d8c3 --- /dev/null +++ b/core/appmodule/v2/genesis.go @@ -0,0 +1,17 @@ +package appmodule + +import ( + "context" + "encoding/json" +) + +// HasGenesis defines a custom genesis handling API implementation. +// WARNING: this API is meant as a short-term solution to allow for the +// migration of existing modules to the new app module API. It is intended to be replaced by collections +type HasGenesis interface { + AppModule + DefaultGenesis() Message + ValidateGenesis(data json.RawMessage) error + InitGenesis(ctx context.Context, data json.RawMessage) error + ExportGenesis(ctx context.Context) (json.RawMessage, error) +} diff --git a/core/appmodule/v2/handlers.go b/core/appmodule/v2/handlers.go new file mode 100644 index 000000000000..7bfc46bf24cf --- /dev/null +++ b/core/appmodule/v2/handlers.go @@ -0,0 +1,142 @@ +package appmodule + +import ( + "context" + "fmt" +) + +type ( + // PreMsgHandler is a handler that is executed before Handler. If it errors the execution reverts. + PreMsgHandler = func(ctx context.Context, msg Message) error + // Handler handles the state transition of the provided message. + Handler = func(ctx context.Context, msg Message) (msgResp Message, err error) + // PostMsgHandler runs after Handler, only if Handler does not error. If PostMsgHandler errors + // then the execution is reverted. + PostMsgHandler = func(ctx context.Context, msg, msgResp Message) error +) + +// RegisterHandler is a helper function that modules can use to not lose type safety when registering handlers to the +// QueryRouter or MsgRouter. Example usage: +// ```go +// +// func (k Keeper) QueryBalance(ctx context.Context, req *types.QueryBalanceRequest) (*types.QueryBalanceResponse, error) { +// ... query logic ... +// } +// +// func (m Module) RegisterQueryHandlers(router appmodule.QueryRouter) { +// appmodule.RegisterHandler(router, keeper.QueryBalance) +// } +// +// ``` +func RegisterHandler[R interface{ Register(string, Handler) }, Req, Resp Message]( + router R, + handler func(ctx context.Context, msg Req) (msgResp Resp, err error), +) { + untypedHandler := func(ctx context.Context, m Message) (Message, error) { + typed, ok := m.(Req) + if !ok { + return nil, fmt.Errorf("unexpected type %T, wanted: %T", m, *new(Req)) + } + return handler(ctx, typed) + } + router.Register(messageName[Req](), untypedHandler) +} + +// RegisterPreHandler is a helper function that modules can use to not lose type safety when registering PreMsgHandler to the +// PreMsgRouter. Example usage: +// ```go +// +// func (k Keeper) BeforeSend(ctx context.Context, req *types.MsgSend) (*types.QueryBalanceResponse, error) { +// ... before send logic ... +// } +// +// func (m Module) RegisterPreMsgHandlers(router appmodule.PreMsgRouter) { +// appmodule.RegisterPreHandler(router, keeper.BeforeSend) +// } +// +// ``` +func RegisterPreHandler[Req Message]( + router PreMsgRouter, + handler func(ctx context.Context, msg Req) error, +) { + untypedHandler := func(ctx context.Context, m Message) error { + typed, ok := m.(Req) + if !ok { + return fmt.Errorf("unexpected type %T, wanted: %T", m, *new(Req)) + } + return handler(ctx, typed) + } + router.Register(messageName[Req](), untypedHandler) +} + +// RegisterPostHandler is a helper function that modules can use to not lose type safety when registering handlers to the +// PostMsgRouter. Example usage: +// ```go +// +// func (k Keeper) AfterSend(ctx context.Context, req *types.MsgSend, resp *types.MsgSendResponse) error { +// ... query logic ... +// } +// +// func (m Module) RegisterPostMsgHandlers(router appmodule.PostMsgRouter) { +// appmodule.RegisterPostHandler(router, keeper.AfterSend) +// } +// +// ``` +func RegisterPostHandler[Req, Resp Message]( + router PostMsgRouter, + handler func(ctx context.Context, msg Req, msgResp Resp) error, +) { + untypedHandler := func(ctx context.Context, m, mResp Message) error { + typed, ok := m.(Req) + if !ok { + return fmt.Errorf("unexpected type %T, wanted: %T", m, *new(Req)) + } + typedResp, ok := mResp.(Resp) + if !ok { + return fmt.Errorf("unexpected type %T, wanted: %T", m, *new(Resp)) + } + return handler(ctx, typed, typedResp) + } + router.Register(messageName[Req](), untypedHandler) +} + +// msg handler + +type PreMsgRouter interface { + // Register will register a specific message handler hooking into the message with + // the provided name. + Register(msgName string, handler PreMsgHandler) + // RegisterGlobal will register a global message handler hooking into any message + // being executed. + RegisterGlobal(handler PreMsgHandler) +} + +type HasPreMsgHandlers interface { + RegisterPreMsgHandlers(router PreMsgRouter) +} + +type MsgRouter interface { + Register(msgName string, handler Handler) +} + +type HasMsgHandlers interface { + RegisterMsgHandlers(router MsgRouter) +} + +type PostMsgRouter interface { + // Register will register a specific message handler hooking after the execution of message with + // the provided name. + Register(msgName string, handler PostMsgHandler) + // RegisterGlobal will register a global message handler hooking after the execution of any message. + RegisterGlobal(handler PreMsgHandler) +} + +// query handler + +type QueryRouter interface { + Register(queryName string, handler Handler) +} + +type HasQueryHandlers interface { + RegisterQueryHandlers(router QueryRouter) +} diff --git a/core/appmodule/v2/message.go b/core/appmodule/v2/message.go new file mode 100644 index 000000000000..8a8753c9195e --- /dev/null +++ b/core/appmodule/v2/message.go @@ -0,0 +1,21 @@ +package appmodule + +import ( + gogoproto "github.com/cosmos/gogoproto/proto" + protov2 "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/runtime/protoiface" +) + +// Message aliases protoiface.MessageV1 for convenience. +type Message = protoiface.MessageV1 + +func messageName[M Message]() string { + switch m := any(*new(M)).(type) { + case protov2.Message: + return string(m.ProtoReflect().Descriptor().FullName()) + case gogoproto.Message: + return gogoproto.MessageName(m) + default: + panic("unknown message type") + } +} diff --git a/core/appmodule/v2/migrations.go b/core/appmodule/v2/migrations.go new file mode 100644 index 000000000000..794fb4a28cc8 --- /dev/null +++ b/core/appmodule/v2/migrations.go @@ -0,0 +1,41 @@ +package appmodule + +import "context" + +// HasConsensusVersion is the interface for declaring a module consensus version. +type HasConsensusVersion interface { + // ConsensusVersion is a sequence number for state-breaking change of the + // module. It should be incremented on each consensus-breaking change + // introduced by the module. To avoid wrong/empty versions, the initial version + // should be set to 1. + ConsensusVersion() uint64 +} + +// HasMigrations is implemented by a module which upgrades or has upgraded +// to a new consensus version. +type HasMigrations interface { + AppModule + HasConsensusVersion + + // RegisterMigrations registers the module's migrations with the app's migrator. + RegisterMigrations(MigrationRegistrar) error +} + +type MigrationRegistrar interface { + // Register registers an in-place store migration for a module. The + // handler is a migration script to perform in-place migrations from version + // `fromVersion` to version `fromVersion+1`. + // + // EACH TIME a module's ConsensusVersion increments, a new migration MUST + // be registered using this function. If a migration handler is missing for + // a particular function, the upgrade logic (see RunMigrations function) + // will panic. If the ConsensusVersion bump does not introduce any store + // changes, then a no-op function must be registered here. + Register(moduleName string, fromVersion uint64, handler MigrationHandler) error +} + +// MigrationHandler is the migration function that each module registers. +type MigrationHandler func(context.Context) error + +// VersionMap is a map of moduleName -> version +type VersionMap map[string]uint64 diff --git a/core/event/event.go b/core/event/event.go new file mode 100644 index 000000000000..4304e6e2b4af --- /dev/null +++ b/core/event/event.go @@ -0,0 +1,29 @@ +package event + +// Attribute is a kv-pair event attribute. +type Attribute struct { + Key, Value string +} + +func NewAttribute(key, value string) Attribute { + return Attribute{Key: key, Value: value} +} + +// Events represents a list of events. +type Events struct { + Events []Event +} + +func NewEvents(events ...Event) Events { + return Events{Events: events} +} + +// Event defines how an event will emitted +type Event struct { + Type string + Attributes []Attribute +} + +func NewEvent(ty string, attrs ...Attribute) Event { + return Event{Type: ty, Attributes: attrs} +} diff --git a/core/event/service.go b/core/event/service.go index 941f142db5f9..6668c1d5bfa8 100644 --- a/core/event/service.go +++ b/core/event/service.go @@ -36,12 +36,3 @@ type Manager interface { // not a state-machine breaking change. EmitNonConsensus(event protoiface.MessageV1) error } - -// KVEventAttribute is a kv-pair event attribute. -type Attribute struct { - Key, Value string -} - -func NewAttribute(key, value string) Attribute { - return Attribute{Key: key, Value: value} -} diff --git a/core/gas/meter.go b/core/gas/meter.go index 0774fd2a7733..9495201aa4c0 100644 --- a/core/gas/meter.go +++ b/core/gas/meter.go @@ -1,10 +1,25 @@ // Package gas provides a basic API for app modules to track gas usage. package gas -import "context" +import ( + "context" + "errors" + "math" +) +// ErrOutOfGas must be used by GasMeter implementers to signal +// that the state transition consumed all the allowed computational +// gas. +var ErrOutOfGas = errors.New("out of gas") + +// Gas defines type alias of uint64 for gas consumption. Gas is used +// to measure computational overhead when executing state transitions, +// it might be related to storage access and not only. type Gas = uint64 +// NoGasLimit signals that no gas limit must be applied. +const NoGasLimit Gas = math.MaxUint64 + // Service represents a gas service which can retrieve and set a gas meter in a context. // gas.Service is a core API type that should be provided by the runtime module being used to // build an app via depinject. diff --git a/core/go.mod b/core/go.mod index e7bf2f319d5e..e732129de93a 100644 --- a/core/go.mod +++ b/core/go.mod @@ -4,6 +4,7 @@ go 1.20 require ( cosmossdk.io/log v1.3.1 + github.com/cosmos/gogoproto v1.4.11 github.com/stretchr/testify v1.8.4 google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 @@ -12,6 +13,7 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/protobuf v1.5.3 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect @@ -19,6 +21,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rs/zerolog v1.32.0 // indirect + golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/core/go.sum b/core/go.sum index 105975b5b061..57133f587985 100644 --- a/core/go.sum +++ b/core/go.sum @@ -1,6 +1,8 @@ cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI= cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cosmos/gogoproto v1.4.11 h1:LZcMHrx4FjUgrqQSWeaGC1v/TeuVFqSLa43CC6aWR2g= +github.com/cosmos/gogoproto v1.4.11/go.mod h1:/g39Mh8m17X8Q/GDEs5zYTSNaNnInBSohtaxzQnYq1Y= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -10,6 +12,7 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -36,6 +39,8 @@ github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0= github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb h1:mIKbk8weKhSeLH2GmUTrvx8CjkyJmnU1wFmg59CUjFA= +golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/core/store/database.go b/core/store/database.go new file mode 100644 index 000000000000..551727a6342b --- /dev/null +++ b/core/store/database.go @@ -0,0 +1,23 @@ +package store + +// Database provides access to the underlying database for CRUD operations of non-consensus data. +// WARNING: using this api will make your module unprovable for fraud and validity proofs +type DatabaseService interface { + GetDatabase() NonConsensusStore +} + +// NonConsensusStore is a simple key-value store that is used to store non-consensus data. +// Note the non-consensus data is not committed to the blockchain and does not allow iteration +type NonConsensusStore interface { + // Get returns nil iff key doesn't exist. Errors on nil key. + Get(key []byte) ([]byte, error) + + // Has checks if a key exists. Errors on nil key. + Has(key []byte) (bool, error) + + // Set sets the key. Errors on nil key or value. + Set(key, value []byte) error + + // Delete deletes the key. Errors on nil key. + Delete(key []byte) error +} diff --git a/core/transaction/transaction.go b/core/transaction/transaction.go new file mode 100644 index 000000000000..be1e2960ad94 --- /dev/null +++ b/core/transaction/transaction.go @@ -0,0 +1,32 @@ +package transaction + +import ( + "google.golang.org/protobuf/proto" +) + +type ( + Type = proto.Message + Identity = []byte +) + +// Codec defines the TX codec, which converts a TX from bytes to its concrete representation. +type Codec[T Tx] interface { + // Decode decodes the tx bytes into a DecodedTx, containing + // both concrete and bytes representation of the tx. + Decode([]byte) (T, error) +} + +type Tx interface { + // Hash returns the unique identifier for the Tx. + Hash() [32]byte // TODO evaluate if 32 bytes is the right size & benchmark overhead of hashing instead of using identifier + // GetMessages returns the list of state transitions of the Tx. + GetMessages() []Type + // GetSenders returns the tx state transition sender. + GetSenders() []Identity // TODO reduce this to a single identity if accepted + // GetGasLimit returns the gas limit of the tx. Must return math.MaxUint64 for infinite gas + // txs. + GetGasLimit() uint64 + // Bytes returns the encoded version of this tx. Note: this is ideally cached + // from the first instance of the decoding of the tx. + Bytes() []byte +} diff --git a/docs/architecture/adr-069-gov-improvements.md b/docs/architecture/adr-069-gov-improvements.md index 6d5c80fad288..af5b12645205 100644 --- a/docs/architecture/adr-069-gov-improvements.md +++ b/docs/architecture/adr-069-gov-improvements.md @@ -164,19 +164,15 @@ Due to the vote option change, each proposal can have the same tallying method. However, chains may want to change the tallying function (weighted vote per voting power) of `x/gov` for a different algorithm (using a quadratic function on the voter stake, for instance). -The custom tallying function can be passed to the `x/gov` keeper with the following interface: +The custom tallying function can be passed to the `x/gov` keeper config: ```go -type Tally interface{ - // to be decided - - // Calculate calculates the tally result - Calculate(proposal v1.Proposal, govKeeper GovKeeper, stakingKeeper StakingKeeper) govv1.TallyResult - // IsAccepted returns true if the proposal passes/is accepted - IsAccepted() bool - // BurnDeposit returns true if the proposal deposit should be burned - BurnDeposit() bool -} +type CalculateVoteResultsAndVotingPowerFn func( + ctx context.Context, + keeper Keeper, + proposalID uint64, + validators map[string]v1.ValidatorGovInfo, +) (totalVoterPower math.LegacyDec, results map[v1.VoteOption]math.LegacyDec, err error) ``` ## Consequences diff --git a/go.mod b/go.mod index 6f3c80b7b3f1..24be15a14b4e 100644 --- a/go.mod +++ b/go.mod @@ -44,8 +44,8 @@ require ( github.com/mattn/go-isatty v0.0.20 github.com/mdp/qrterminal/v3 v3.2.0 github.com/muesli/termenv v0.15.2 - github.com/prometheus/client_golang v1.18.0 - github.com/prometheus/common v0.47.0 + github.com/prometheus/client_golang v1.19.0 + github.com/prometheus/common v0.49.0 github.com/rs/zerolog v1.32.0 github.com/spf13/cast v1.6.0 github.com/spf13/cobra v1.8.0 diff --git a/go.sum b/go.sum index efe6b82a5e1c..9d0dfeeef4e8 100644 --- a/go.sum +++ b/go.sum @@ -583,8 +583,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -599,8 +599,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/math/dec.go b/math/dec.go index 30d5ef464ff1..0ca1cfcb8c22 100644 --- a/math/dec.go +++ b/math/dec.go @@ -10,17 +10,17 @@ import ( "testing" ) -// NOTE: never use new(Dec) or else we will panic unmarshalling into the +// LegacyDec NOTE: never use new(Dec) or else we will panic unmarshalling into the // nil embedded big.Int type LegacyDec struct { i *big.Int } const ( - // number of decimal places + // LegacyPrecision number of decimal places LegacyPrecision = 18 - // bits required to represent the above precision + // LegacyDecimalPrecisionBits bits required to represent the above precision // Ceiling[Log2[10^Precision - 1]] LegacyDecimalPrecisionBits = 60 @@ -31,7 +31,7 @@ const ( maxDecBitLen = MaxBitLen + decimalTruncateBits - // max number of iterations in ApproxRoot function + // maxApproxRootIterations max number of iterations in ApproxRoot function maxApproxRootIterations = 300 ) @@ -94,12 +94,12 @@ func precisionMultiplier(prec int64) *big.Int { return precisionMultipliers[prec] } -// create a new Dec from integer assuming whole number +// LegacyNewDec create a new Dec from integer assuming whole number func LegacyNewDec(i int64) LegacyDec { return LegacyNewDecWithPrec(i, 0) } -// create a new Dec from integer with decimal place at prec +// LegacyNewDecWithPrec create a new Dec from integer with decimal place at prec // CONTRACT: prec <= Precision func LegacyNewDecWithPrec(i, prec int64) LegacyDec { bi := big.NewInt(i) @@ -108,13 +108,13 @@ func LegacyNewDecWithPrec(i, prec int64) LegacyDec { } } -// create a new Dec from big integer assuming whole numbers +// LegacyNewDecFromBigInt create a new Dec from big integer assuming whole numbers // CONTRACT: prec <= Precision func LegacyNewDecFromBigInt(i *big.Int) LegacyDec { return LegacyNewDecFromBigIntWithPrec(i, 0) } -// create a new Dec from big integer assuming whole numbers +// LegacyNewDecFromBigIntWithPrec create a new Dec from big integer assuming whole numbers // CONTRACT: prec <= Precision func LegacyNewDecFromBigIntWithPrec(i *big.Int, prec int64) LegacyDec { return LegacyDec{ @@ -122,13 +122,13 @@ func LegacyNewDecFromBigIntWithPrec(i *big.Int, prec int64) LegacyDec { } } -// create a new Dec from big integer assuming whole numbers +// LegacyNewDecFromInt create a new Dec from big integer assuming whole numbers // CONTRACT: prec <= Precision func LegacyNewDecFromInt(i Int) LegacyDec { return LegacyNewDecFromIntWithPrec(i, 0) } -// create a new Dec from big integer with decimal place at prec +// LegacyNewDecFromIntWithPrec create a new Dec from big integer with decimal place at prec // CONTRACT: prec <= Precision func LegacyNewDecFromIntWithPrec(i Int, prec int64) LegacyDec { return LegacyDec{ @@ -136,7 +136,7 @@ func LegacyNewDecFromIntWithPrec(i Int, prec int64) LegacyDec { } } -// create a decimal from an input decimal string. +// LegacyNewDecFromStr create a decimal from an input decimal string. // valid must come in the form: // // (-) whole integers (.) decimal integers @@ -201,7 +201,7 @@ func LegacyNewDecFromStr(str string) (LegacyDec, error) { return LegacyDec{combined}, nil } -// Decimal from string, panic on error +// LegacyMustNewDecFromStr Decimal from string, panic on error func LegacyMustNewDecFromStr(s string) LegacyDec { dec, err := LegacyNewDecFromStr(s) if err != nil { @@ -266,12 +266,12 @@ func (d LegacyDec) SetInt64(i int64) LegacyDec { return d } -// addition +// Add addition func (d LegacyDec) Add(d2 LegacyDec) LegacyDec { return d.ImmutOp(LegacyDec.AddMut, d2) } -// mutable addition +// AddMut mutable addition func (d LegacyDec) AddMut(d2 LegacyDec) LegacyDec { d.i.Add(d.i, d2.i) @@ -281,12 +281,12 @@ func (d LegacyDec) AddMut(d2 LegacyDec) LegacyDec { return d } -// subtraction +// Sub subtraction func (d LegacyDec) Sub(d2 LegacyDec) LegacyDec { return d.ImmutOp(LegacyDec.SubMut, d2) } -// mutable subtraction +// SubMut mutable subtraction func (d LegacyDec) SubMut(d2 LegacyDec) LegacyDec { d.i.Sub(d.i, d2.i) @@ -296,12 +296,12 @@ func (d LegacyDec) SubMut(d2 LegacyDec) LegacyDec { return d } -// multiplication +// Mul multiplication func (d LegacyDec) Mul(d2 LegacyDec) LegacyDec { return d.ImmutOp(LegacyDec.MulMut, d2) } -// mutable multiplication +// MulMut mutable multiplication func (d LegacyDec) MulMut(d2 LegacyDec) LegacyDec { d.i.Mul(d.i, d2.i) chopped := chopPrecisionAndRound(d.i) @@ -313,12 +313,12 @@ func (d LegacyDec) MulMut(d2 LegacyDec) LegacyDec { return d } -// multiplication truncate +// MulTruncate multiplication truncate func (d LegacyDec) MulTruncate(d2 LegacyDec) LegacyDec { return d.ImmutOp(LegacyDec.MulTruncateMut, d2) } -// mutable multiplication truncage +// MulTruncateMut mutable multiplication truncate func (d LegacyDec) MulTruncateMut(d2 LegacyDec) LegacyDec { d.i.Mul(d.i, d2.i) chopPrecisionAndTruncate(d.i) @@ -329,12 +329,12 @@ func (d LegacyDec) MulTruncateMut(d2 LegacyDec) LegacyDec { return d } -// multiplication round up at precision end. +// MulRoundUp multiplication round up at precision end. func (d LegacyDec) MulRoundUp(d2 LegacyDec) LegacyDec { return d.ImmutOp(LegacyDec.MulRoundUpMut, d2) } -// mutable multiplication with round up at precision end. +// MulRoundUpMut mutable multiplication with round up at precision end. func (d LegacyDec) MulRoundUpMut(d2 LegacyDec) LegacyDec { d.i.Mul(d.i, d2.i) chopPrecisionAndRoundUp(d.i) @@ -345,7 +345,7 @@ func (d LegacyDec) MulRoundUpMut(d2 LegacyDec) LegacyDec { return d } -// multiplication +// MulInt multiplication func (d LegacyDec) MulInt(i Int) LegacyDec { return d.ImmutOpInt(LegacyDec.MulIntMut, i) } @@ -358,7 +358,7 @@ func (d LegacyDec) MulIntMut(i Int) LegacyDec { return d } -// MulInt64 - multiplication with int64 +// MulInt64 multiplication with int64 func (d LegacyDec) MulInt64(i int64) LegacyDec { return d.ImmutOpInt64(LegacyDec.MulInt64Mut, i) } @@ -372,14 +372,14 @@ func (d LegacyDec) MulInt64Mut(i int64) LegacyDec { return d } -// quotient +// Quo quotient func (d LegacyDec) Quo(d2 LegacyDec) LegacyDec { return d.ImmutOp(LegacyDec.QuoMut, d2) } var squaredPrecisionReuse = new(big.Int).Mul(precisionReuse, precisionReuse) -// mutable quotient +// QuoMut mutable quotient func (d LegacyDec) QuoMut(d2 LegacyDec) LegacyDec { // multiply by precision twice d.i.Mul(d.i, squaredPrecisionReuse) @@ -392,12 +392,12 @@ func (d LegacyDec) QuoMut(d2 LegacyDec) LegacyDec { return d } -// quotient truncate +// QuoTruncate quotient truncate func (d LegacyDec) QuoTruncate(d2 LegacyDec) LegacyDec { return d.ImmutOp(LegacyDec.QuoTruncateMut, d2) } -// mutable quotient truncate +// QuoTruncateMut mutable quotient truncate func (d LegacyDec) QuoTruncateMut(d2 LegacyDec) LegacyDec { // multiply precision twice d.i.Mul(d.i, squaredPrecisionReuse) @@ -410,12 +410,12 @@ func (d LegacyDec) QuoTruncateMut(d2 LegacyDec) LegacyDec { return d } -// quotient, round up +// QuoRoundUp quotient, round up func (d LegacyDec) QuoRoundUp(d2 LegacyDec) LegacyDec { return d.ImmutOp(LegacyDec.QuoRoundupMut, d2) } -// mutable quotient, round up +// QuoRoundupMut mutable quotient, round up func (d LegacyDec) QuoRoundupMut(d2 LegacyDec) LegacyDec { // multiply precision twice d.i.Mul(d.i, squaredPrecisionReuse) @@ -428,7 +428,7 @@ func (d LegacyDec) QuoRoundupMut(d2 LegacyDec) LegacyDec { return d } -// quotient +// QuoInt quotient func (d LegacyDec) QuoInt(i Int) LegacyDec { return d.ImmutOpInt(LegacyDec.QuoIntMut, i) } @@ -438,7 +438,7 @@ func (d LegacyDec) QuoIntMut(i Int) LegacyDec { return d } -// QuoInt64 - quotient with int64 +// QuoInt64 quotient with int64 func (d LegacyDec) QuoInt64(i int64) LegacyDec { return d.ImmutOpInt64(LegacyDec.QuoInt64Mut, i) } @@ -528,12 +528,12 @@ func (d LegacyDec) ApproxSqrt() (LegacyDec, error) { return d.ApproxRoot(2) } -// is integer, e.g. decimals are zero +// IsInteger is integer, e.g. decimals are zero func (d LegacyDec) IsInteger() bool { return new(big.Int).Rem(d.i, precisionReuse).Sign() == 0 } -// format decimal state +// Format format decimal state func (d LegacyDec) Format(s fmt.State, verb rune) { _, err := s.Write([]byte(d.String())) if err != nil { @@ -756,14 +756,14 @@ func init() { LegacyMaxSortableDec = LegacyOneDec().Quo(LegacySmallestDec()) } -// ValidSortableDec ensures that a Dec is within the sortable bounds, +// LegacyValidSortableDec ensures that a Dec is within the sortable bounds, // a Dec can't have a precision of less than 10^-18. // Max sortable decimal was set to the reciprocal of SmallestDec. func LegacyValidSortableDec(dec LegacyDec) bool { return dec.Abs().LTE(LegacyMaxSortableDec) } -// SortableDecBytes returns a byte slice representation of a Dec that can be sorted. +// LegacySortableDecBytes returns a byte slice representation of a Dec that can be sorted. // Left and right pads with 0s so there are 18 digits to left and right of the decimal point. // For this reason, there is a maximum and minimum value for this, enforced by ValidSortableDec. func LegacySortableDecBytes(dec LegacyDec) []byte { @@ -888,7 +888,7 @@ func (d *LegacyDec) Size() int { return len(bz) } -// Override Amino binary serialization by proxying to protobuf. +// MarshalAmino Override Amino binary serialization by proxying to protobuf. func (d LegacyDec) MarshalAmino() ([]byte, error) { return d.Marshal() } func (d *LegacyDec) UnmarshalAmino(bz []byte) error { return d.Unmarshal(bz) } @@ -908,7 +908,7 @@ func LegacyDecsEqual(d1s, d2s []LegacyDec) bool { return true } -// minimum decimal between two +// LegacyMinDec minimum decimal between two func LegacyMinDec(d1, d2 LegacyDec) LegacyDec { if d1.LT(d2) { return d1 @@ -916,7 +916,7 @@ func LegacyMinDec(d1, d2 LegacyDec) LegacyDec { return d2 } -// maximum decimal between two +// LegacyMaxDec maximum decimal between two func LegacyMaxDec(d1, d2 LegacyDec) LegacyDec { if d1.LT(d2) { return d2 @@ -924,7 +924,7 @@ func LegacyMaxDec(d1, d2 LegacyDec) LegacyDec { return d1 } -// intended to be used with require/assert: require.True(DecEq(...)) +// LegacyDecEq intended to be used with require/assert: require.True(DecEq(...)) func LegacyDecEq(t *testing.T, exp, got LegacyDec) (*testing.T, bool, string, string, string) { t.Helper() return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String() diff --git a/math/int.go b/math/int.go index e08852fea8fd..fb4f63e15ab5 100644 --- a/math/int.go +++ b/math/int.go @@ -102,7 +102,7 @@ func (i Int) BigInt() *big.Int { return new(big.Int).Set(i.i) } -// BigInt converts Int to big.Int, mutative the input +// BigIntMut converts Int to big.Int, mutative the input func (i Int) BigIntMut() *big.Int { if i.IsNil() { return nil @@ -333,7 +333,7 @@ func (i Int) Mul(i2 Int) (res Int) { return x } -// MulRaw multipies Int and int64 +// MulRaw multiplies Int and int64 func (i Int) MulRaw(i2 int64) Int { return i.Mul(NewInt(i2)) } @@ -404,7 +404,7 @@ func (i Int) Abs() Int { return Int{abs(i.i)} } -// return the minimum of the ints +// MinInt return the minimum of the ints func MinInt(i1, i2 Int) Int { return Int{min(i1.BigInt(), i2.BigInt())} } @@ -414,7 +414,7 @@ func MaxInt(i, i2 Int) Int { return Int{max(i.BigInt(), i2.BigInt())} } -// Human readable string +// String returns human-readable string func (i Int) String() string { return i.i.String() } @@ -517,7 +517,7 @@ func (i *Int) Size() int { return len(bz) } -// Override Amino binary serialization by proxying to protobuf. +// MarshalAmino Override Amino binary serialization by proxying to protobuf. func (i Int) MarshalAmino() ([]byte, error) { return i.Marshal() } func (i *Int) UnmarshalAmino(bz []byte) error { return i.Unmarshal(bz) } diff --git a/math/uint.go b/math/uint.go index 6361694743b3..92f0453b1a35 100644 --- a/math/uint.go +++ b/math/uint.go @@ -21,7 +21,7 @@ func (u Uint) BigInt() *big.Int { return new(big.Int).Set(u.i) } -// BigInt converts Uint to big.Int, mutative the input +// BigIntMut converts Uint to big.Int, mutative the input func (u Uint) BigIntMut() *big.Int { if u.IsNil() { return nil @@ -99,7 +99,7 @@ func (u Uint) LTE(u2 Uint) bool { return !u.GT(u2) } // Add adds Uint from another func (u Uint) Add(u2 Uint) Uint { return NewUintFromBigInt(new(big.Int).Add(u.i, u2.i)) } -// Add convert uint64 and add it to Uint +// AddUint64 convert uint64 and add it to Uint func (u Uint) AddUint64(u2 uint64) Uint { return u.Add(NewUint(u2)) } // Sub adds Uint from another @@ -113,7 +113,7 @@ func (u Uint) Mul(u2 Uint) (res Uint) { return NewUintFromBigInt(new(big.Int).Mul(u.i, u2.i)) } -// Mul multiplies two Uints +// MulUint64 multiplies two Uints func (u Uint) MulUint64(u2 uint64) (res Uint) { return u.Mul(NewUint(u2)) } // Quo divides Uint with Uint @@ -139,16 +139,16 @@ func (u Uint) Decr() Uint { return u.Sub(OneUint()) } -// Quo divides Uint with uint64 +// QuoUint64 divides Uint with uint64 func (u Uint) QuoUint64(u2 uint64) Uint { return u.Quo(NewUint(u2)) } -// Return the minimum of the Uints +// MinUint returns the minimum of the Uints func MinUint(u1, u2 Uint) Uint { return NewUintFromBigInt(min(u1.i, u2.i)) } -// Return the maximum of the Uints +// MaxUint returns the maximum of the Uints func MaxUint(u1, u2 Uint) Uint { return NewUintFromBigInt(max(u1.i, u2.i)) } -// Human readable string +// String returns human-readable string func (u Uint) String() string { return u.i.String() } // MarshalJSON defines custom encoding scheme @@ -219,7 +219,7 @@ func (u *Uint) Size() int { return len(bz) } -// Override Amino binary serialization by proxying to protobuf. +// MarshalAmino override Amino binary serialization by proxying to protobuf. func (u Uint) MarshalAmino() ([]byte, error) { return u.Marshal() } func (u *Uint) UnmarshalAmino(bz []byte) error { return u.Unmarshal(bz) } diff --git a/orm/go.mod b/orm/go.mod index 329d2f8d775b..3e80e04a875b 100644 --- a/orm/go.mod +++ b/orm/go.mod @@ -52,9 +52,9 @@ require ( github.com/onsi/gomega v1.20.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/spf13/cast v1.6.0 // indirect diff --git a/orm/go.sum b/orm/go.sum index 2339cd6e4e2c..effb8fe59e9b 100644 --- a/orm/go.sum +++ b/orm/go.sum @@ -127,12 +127,12 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/regen-network/gocuke v1.1.0 h1:gxlkRTfpR9gJ0mwqQZIpoXHZGx+KPshKQpKE0jtUH5s= diff --git a/runtime/app.go b/runtime/app.go index c0f0e93e66d6..a224463fb806 100644 --- a/runtime/app.go +++ b/runtime/app.go @@ -3,9 +3,9 @@ package runtime import ( "encoding/json" "fmt" + "slices" abci "github.com/cometbft/cometbft/abci/types" - "golang.org/x/exp/slices" runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" diff --git a/simapp/app.go b/simapp/app.go index 510af074c4aa..2c1e47b95bf5 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -375,7 +375,7 @@ func NewSimApp( // by granting the governance module the right to execute the message. // See: https://docs.cosmos.network/main/modules/gov#proposal-messages govRouter := govv1beta1.NewRouter() - govConfig := govtypes.DefaultConfig() + govConfig := govkeeper.DefaultConfig() /* Example of setting gov params: govConfig.MaxMetadataLen = 10000 diff --git a/simapp/go.mod b/simapp/go.mod index 223989256736..6d72d11285eb 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -39,7 +39,7 @@ require ( cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 cosmossdk.io/x/authz v0.0.0-00010101000000-000000000000 cosmossdk.io/x/bank v0.0.0-00010101000000-000000000000 - cosmossdk.io/x/distribution v0.0.0-20230925135524-a1bc045b3190 + cosmossdk.io/x/distribution v0.0.0-20240227221813-a248d05f70f4 cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a cosmossdk.io/x/group v0.0.0-00010101000000-000000000000 cosmossdk.io/x/mint v0.0.0-00010101000000-000000000000 @@ -171,9 +171,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rivo/uniseg v0.2.0 // indirect @@ -206,7 +206,7 @@ require ( golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect - golang.org/x/oauth2 v0.16.0 // indirect + golang.org/x/oauth2 v0.17.0 // indirect golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.17.0 // indirect golang.org/x/term v0.17.0 // indirect diff --git a/simapp/go.sum b/simapp/go.sum index 6d24f3de1649..ef5f1c994b81 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -892,8 +892,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -908,8 +908,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -1230,8 +1230,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ= +golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/simapp/gomod2nix.toml b/simapp/gomod2nix.toml index 7bfcf6e89d35..f95900c88bce 100644 --- a/simapp/gomod2nix.toml +++ b/simapp/gomod2nix.toml @@ -396,14 +396,14 @@ schema = 3 version = "v1.0.1-0.20181226105442-5d4384ee4fb2" hash = "sha256-XA4Oj1gdmdV/F/+8kMI+DBxKPthZ768hbKsO3d9Gx90=" [mod."github.com/prometheus/client_golang"] - version = "v1.18.0" - hash = "sha256-kuC6WUg2j7A+9qnSp5VZSYo+oltgLvj/70TpqlCJIdE=" + version = "v1.19.0" + hash = "sha256-YV8sxMPR+xorTUCriTfcFsaV2b7PZfPJDQmOgUYOZJo=" [mod."github.com/prometheus/client_model"] version = "v0.6.0" hash = "sha256-TAD0mm7msYHo99yoNijeYzlDD0i1Vg3uTetpkDUWQo8=" [mod."github.com/prometheus/common"] - version = "v0.47.0" - hash = "sha256-zAfgbOSycgChcWT8x8oo5k1tq/y6Oay3gLdUEkt0NYk=" + version = "v0.49.0" + hash = "sha256-jDD8MAv4kervfJWlIX22ErjUrE5w8S7F8PQEO8/QN/w=" [mod."github.com/prometheus/procfs"] version = "v0.12.0" hash = "sha256-Y4ZZmxIpVCO67zN3pGwSk2TcI88zvmGJkgwq9DRTwFw=" @@ -517,8 +517,8 @@ schema = 3 version = "v0.21.0" hash = "sha256-LfiqMpPtqvW/eLkfx6Ebr5ksqKbQli6uq06c/+XrBsw=" [mod."golang.org/x/oauth2"] - version = "v0.16.0" - hash = "sha256-fJfS9dKaq82WaYSVWHMnxNLWH8+L4aip/C1AfJi4FFI=" + version = "v0.17.0" + hash = "sha256-M2ZZQZt449RJL18YpzGiAiqfGsDVMsr1IVWbYp/G/go=" [mod."golang.org/x/sync"] version = "v0.6.0" hash = "sha256-LLims/wjDZtIqlYCVHREewcUOX4hwRwplEuZKPOJ/HI=" diff --git a/simapp/sim_test.go b/simapp/sim_test.go index 1ea61de0235e..8001d48d0749 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -176,7 +176,6 @@ func TestAppImportExport(t *testing.T) { ctxA := app.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()}) ctxB := newApp.NewContextLegacy(true, cmtproto.Header{Height: app.LastBlockHeight()}) _, err = newApp.ModuleManager.InitGenesis(ctxB, app.AppCodec(), genesisState) - if err != nil { if strings.Contains(err.Error(), "validator set is empty after InitGenesis") { logger.Info("Skipping simulation as all validators have been unbonded") diff --git a/store/go.mod b/store/go.mod index 6dc0872e489a..733aad58cfd8 100644 --- a/store/go.mod +++ b/store/go.mod @@ -51,9 +51,9 @@ require ( github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/rs/zerolog v1.32.0 // indirect diff --git a/store/go.sum b/store/go.sum index f2c2c5faa61b..85707a574904 100644 --- a/store/go.sum +++ b/store/go.sum @@ -187,8 +187,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -196,8 +196,8 @@ github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZ github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= diff --git a/store/migration/manager_test.go b/store/migration/manager_test.go index b02ac5db94a9..c60a2376d4bd 100644 --- a/store/migration/manager_test.go +++ b/store/migration/manager_test.go @@ -31,7 +31,7 @@ func setupMigrationManager(t *testing.T) (*Manager, *commitment.CommitStore) { commitStore, err := commitment.NewCommitStore(multiTrees, db, nil, log.NewNopLogger()) require.NoError(t, err) - snapshotsStore, err := snapshots.NewStore(db, t.TempDir()) + snapshotsStore, err := snapshots.NewStore(t.TempDir()) require.NoError(t, err) snapshotsManager := snapshots.NewManager(snapshotsStore, snapshots.NewSnapshotOptions(1500, 2), commitStore, nil, nil, log.NewNopLogger()) diff --git a/store/snapshots/helpers_test.go b/store/snapshots/helpers_test.go index 8ed5d3d594b1..33dcc14fa6f4 100644 --- a/store/snapshots/helpers_test.go +++ b/store/snapshots/helpers_test.go @@ -17,7 +17,6 @@ import ( errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" "cosmossdk.io/store/v2" - dbm "cosmossdk.io/store/v2/db" "cosmossdk.io/store/v2/snapshots" snapshotstypes "cosmossdk.io/store/v2/snapshots/types" ) @@ -189,7 +188,7 @@ func (m *mockErrorCommitSnapshotter) SupportedFormats() []uint32 { // The snapshot will complete when the returned closer is called. func setupBusyManager(t *testing.T) *snapshots.Manager { t.Helper() - store, err := snapshots.NewStore(dbm.NewMemDB(), t.TempDir()) + store, err := snapshots.NewStore(t.TempDir()) require.NoError(t, err) hung := newHungCommitSnapshotter() mgr := snapshots.NewManager(store, opts, hung, &mockStorageSnapshotter{}, nil, log.NewNopLogger()) @@ -292,6 +291,7 @@ func (s *extSnapshotter) RestoreExtension(height uint64, format uint32, payloadR // GetTempDir returns a writable temporary director for the test to use. func GetTempDir(tb testing.TB) string { + //return "/tmp/snapshots" tb.Helper() // os.MkDir() is used instead of testing.T.TempDir() // see https://github.com/cosmos/cosmos-sdk/pull/8475 and diff --git a/store/snapshots/manager.go b/store/snapshots/manager.go index ad29da179671..b713da7134f4 100644 --- a/store/snapshots/manager.go +++ b/store/snapshots/manager.go @@ -599,7 +599,4 @@ func (m *Manager) snapshot(height int64) { } // Close the snapshot database. -func (m *Manager) Close() error { - m.logger.Info("snapshotManager Close Database") - return m.store.db.Close() -} +func (m *Manager) Close() error { return nil } diff --git a/store/snapshots/manager_test.go b/store/snapshots/manager_test.go index da598f7a6910..987d0c3b0e81 100644 --- a/store/snapshots/manager_test.go +++ b/store/snapshots/manager_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/require" "cosmossdk.io/log" - dbm "cosmossdk.io/store/v2/db" "cosmossdk.io/store/v2/snapshots" "cosmossdk.io/store/v2/snapshots/types" ) @@ -237,7 +236,7 @@ func TestManager_Restore(t *testing.T) { func TestManager_TakeError(t *testing.T) { snapshotter := &mockErrorCommitSnapshotter{} - store, err := snapshots.NewStore(dbm.NewMemDB(), GetTempDir(t)) + store, err := snapshots.NewStore(GetTempDir(t)) require.NoError(t, err) manager := snapshots.NewManager(store, opts, snapshotter, &mockStorageSnapshotter{}, nil, log.NewNopLogger()) diff --git a/store/snapshots/store.go b/store/snapshots/store.go index ad2179ddbac7..c7fef66bb424 100644 --- a/store/snapshots/store.go +++ b/store/snapshots/store.go @@ -3,12 +3,15 @@ package snapshots import ( "crypto/sha256" "encoding/binary" + "fmt" "hash" "io" "math" "os" "path/filepath" + "sort" "strconv" + "strings" "sync" "github.com/cosmos/gogoproto/proto" @@ -25,7 +28,6 @@ const ( // Store is a snapshot store, containing snapshot metadata and binary chunks. type Store struct { - db store.RawDB dir string mtx sync.Mutex @@ -33,7 +35,7 @@ type Store struct { } // NewStore creates a new snapshot store. -func NewStore(db store.RawDB, dir string) (*Store, error) { +func NewStore(dir string) (*Store, error) { if dir == "" { return nil, errors.Wrap(store.ErrLogic, "snapshot directory not given") } @@ -41,9 +43,12 @@ func NewStore(db store.RawDB, dir string) (*Store, error) { if err != nil { return nil, errors.Wrapf(err, "failed to create snapshot directory %q", dir) } + err = os.MkdirAll(filepath.Join(dir, "metadata"), 0o750) + if err != nil { + return nil, errors.Wrapf(err, "failed to create snapshot metadata directory %q", dir) + } return &Store{ - db: db, dir: dir, saving: make(map[uint64]bool), }, nil @@ -58,32 +63,25 @@ func (s *Store) Delete(height uint64, format uint32) error { return errors.Wrapf(store.ErrConflict, "snapshot for height %v format %v is currently being saved", height, format) } - b := s.db.NewBatch() - defer b.Close() - if err := b.Delete(encodeKey(height, format)); err != nil { - return errors.Wrapf(err, "failed to delete item in the batch") - } - if err := b.WriteSync(); err != nil { - return errors.Wrapf(err, "failed to delete snapshot for height %v format %v", - height, format) - } if err := os.RemoveAll(s.pathSnapshot(height, format)); err != nil { - return errors.Wrapf(err, "failed to delete snapshot chunks for height %v format %v", - height, format) + return errors.Wrapf(err, "failed to delete snapshot chunks for height %v format %v", height, format) + } + if err := os.RemoveAll(s.pathMetadata(height, format)); err != nil { + return errors.Wrapf(err, "failed to delete snapshot metadata for height %v format %v", height, format) } return nil } // Get fetches snapshot info from the database. func (s *Store) Get(height uint64, format uint32) (*types.Snapshot, error) { - bytes, err := s.db.Get(encodeKey(height, format)) + if _, err := os.Stat(s.pathMetadata(height, format)); os.IsNotExist(err) { + return nil, nil + } + bytes, err := os.ReadFile(s.pathMetadata(height, format)) if err != nil { return nil, errors.Wrapf(err, "failed to fetch snapshot metadata for height %v format %v", height, format) } - if bytes == nil { - return nil, nil - } snapshot := &types.Snapshot{} err = proto.Unmarshal(bytes, snapshot) if err != nil { @@ -96,44 +94,62 @@ func (s *Store) Get(height uint64, format uint32) (*types.Snapshot, error) { return snapshot, nil } -// Get fetches the latest snapshot from the database, if any. +// GetLatest fetches the latest snapshot from the database, if any. func (s *Store) GetLatest() (*types.Snapshot, error) { - iter, err := s.db.ReverseIterator(encodeKey(0, 0), encodeKey(uint64(math.MaxUint64), math.MaxUint32)) + metadata, err := os.ReadDir(s.pathMetadataDir()) if err != nil { - return nil, errors.Wrap(err, "failed to find latest snapshot") + return nil, errors.Wrap(err, "failed to list snapshot metadata") } - defer iter.Close() + if len(metadata) == 0 { + return nil, nil + } + // file system may not guarantee the order of the files, so we sort them lexically + sort.Slice(metadata, func(i, j int) bool { return metadata[i].Name() < metadata[j].Name() }) - var snapshot *types.Snapshot - if iter.Valid() { - snapshot = &types.Snapshot{} - err := proto.Unmarshal(iter.Value(), snapshot) - if err != nil { - return nil, errors.Wrap(err, "failed to decode latest snapshot") - } + path := filepath.Join(s.pathMetadataDir(), metadata[len(metadata)-1].Name()) + if err := s.validateMetadataPath(path); err != nil { + return nil, err + } + bz, err := os.ReadFile(path) + if err != nil { + return nil, errors.Wrapf(err, "failed to read latest snapshot metadata %s", path) } - err = iter.Error() - return snapshot, errors.Wrap(err, "failed to find latest snapshot") + + snapshot := &types.Snapshot{} + err = proto.Unmarshal(bz, snapshot) + if err != nil { + return nil, errors.Wrapf(err, "failed to decode latest snapshot metadata %s", path) + } + return snapshot, nil } // List lists snapshots, in reverse order (newest first). func (s *Store) List() ([]*types.Snapshot, error) { - iter, err := s.db.ReverseIterator(encodeKey(0, 0), encodeKey(uint64(math.MaxUint64), math.MaxUint32)) + metadata, err := os.ReadDir(s.pathMetadataDir()) if err != nil { - return nil, errors.Wrap(err, "failed to list snapshots") + return nil, errors.Wrap(err, "failed to list snapshot metadata") } - defer iter.Close() + // file system may not guarantee the order of the files, so we sort them lexically + sort.Slice(metadata, func(i, j int) bool { return metadata[i].Name() < metadata[j].Name() }) - snapshots := make([]*types.Snapshot, 0) - for ; iter.Valid(); iter.Next() { + snapshots := make([]*types.Snapshot, len(metadata)) + for i, entry := range metadata { + path := filepath.Join(s.pathMetadataDir(), entry.Name()) + if err := s.validateMetadataPath(path); err != nil { + return nil, err + } + bz, err := os.ReadFile(path) + if err != nil { + return nil, errors.Wrapf(err, "failed to read snapshot metadata %s", entry.Name()) + } snapshot := &types.Snapshot{} - err := proto.Unmarshal(iter.Value(), snapshot) + err = proto.Unmarshal(bz, snapshot) if err != nil { - return nil, errors.Wrap(err, "failed to decode snapshot info") + return nil, errors.Wrapf(err, "failed to decode snapshot metadata %s", entry.Name()) } - snapshots = append(snapshots, snapshot) + snapshots[len(metadata)-1-i] = snapshot } - return snapshots, iter.Error() + return snapshots, nil } // Load loads a snapshot (both metadata and binary chunks). The chunks must be consumed and closed. @@ -188,25 +204,25 @@ func (s *Store) loadChunkFile(height uint64, format, chunk uint32) (io.ReadClose // Prune removes old snapshots. The given number of most recent heights (regardless of format) are retained. func (s *Store) Prune(retain uint32) (uint64, error) { - iter, err := s.db.ReverseIterator(encodeKey(0, 0), encodeKey(uint64(math.MaxUint64), math.MaxUint32)) + metadata, err := os.ReadDir(s.pathMetadataDir()) if err != nil { - return 0, errors.Wrap(err, "failed to prune snapshots") + return 0, errors.Wrap(err, "failed to list snapshot metadata") } - defer iter.Close() pruned := uint64(0) prunedHeights := make(map[uint64]bool) skip := make(map[uint64]bool) - for ; iter.Valid(); iter.Next() { - height, format, err := decodeKey(iter.Key()) + for i := len(metadata) - 1; i >= 0; i-- { + height, format, err := s.parseMetadataFilename(metadata[i].Name()) if err != nil { - return 0, errors.Wrap(err, "failed to prune snapshots") + return 0, err } + if skip[height] || uint32(len(skip)) < retain { skip[height] = true continue } - err = s.Delete(height, format) + err = s.Delete(height, uint32(format)) if err != nil { return 0, errors.Wrap(err, "failed to prune snapshots") } @@ -223,7 +239,7 @@ func (s *Store) Prune(retain uint32) (uint64, error) { } } } - return pruned, iter.Error() + return pruned, nil } // Save saves a snapshot to disk, returning it. @@ -249,37 +265,24 @@ func (s *Store) Save( s.mtx.Unlock() }() - exists, err := s.db.Has(encodeKey(height, format)) - if err != nil { - return nil, err - } - if exists { - return nil, errors.Wrapf(store.ErrConflict, - "snapshot already exists for height %v format %v", height, format) - } - snapshot := &types.Snapshot{ Height: height, Format: format, } - dirCreated := false + // create height directory or do nothing + if err := os.MkdirAll(s.pathHeight(height), 0o750); err != nil { + return nil, errors.Wrapf(err, "failed to create snapshot directory for height %v", height) + } + // create format directory or fail (if for example the format directory already exists) + if err := os.Mkdir(s.pathSnapshot(height, format), 0o750); err != nil { + return nil, errors.Wrapf(err, "failed to create snapshot directory for height %v format %v", height, format) + } + index := uint32(0) snapshotHasher := sha256.New() chunkHasher := sha256.New() for chunkBody := range chunks { - // Only create the snapshot directory on encountering the first chunk. - // If the directory disappears during chunk saving, - // the whole operation will fail anyway. - if !dirCreated { - dir := s.pathSnapshot(height, format) - if err := os.MkdirAll(dir, 0o755); err != nil { - return nil, errors.Wrapf(err, "failed to create snapshot directory %q", dir) - } - - dirCreated = true - } - if err := s.saveChunk(chunkBody, index, snapshot, chunkHasher, snapshotHasher); err != nil { return nil, err } @@ -332,13 +335,9 @@ func (s *Store) saveSnapshot(snapshot *types.Snapshot) error { if err != nil { return errors.Wrap(err, "failed to encode snapshot metadata") } - b := s.db.NewBatch() - defer b.Close() - if err := b.Set(encodeKey(snapshot.Height, snapshot.Format), value); err != nil { - return errors.Wrap(err, "failed to set snapshot in batch") - } - if err := b.WriteSync(); err != nil { - return errors.Wrap(err, "failed to store snapshot") + err = os.WriteFile(s.pathMetadata(snapshot.Height, snapshot.Format), value, 0o600) + if err != nil { + return errors.Wrap(err, "failed to write snapshot metadata") } return nil } @@ -353,13 +352,52 @@ func (s *Store) pathSnapshot(height uint64, format uint32) string { return filepath.Join(s.pathHeight(height), strconv.FormatUint(uint64(format), 10)) } +func (s *Store) pathMetadataDir() string { + return filepath.Join(s.dir, "metadata") +} + +// pathMetadata generates a snapshot metadata path. +func (s *Store) pathMetadata(height uint64, format uint32) string { + return filepath.Join(s.pathMetadataDir(), fmt.Sprintf("%020d-%08d", height, format)) +} + // PathChunk generates a snapshot chunk path. func (s *Store) PathChunk(height uint64, format, chunk uint32) string { return filepath.Join(s.pathSnapshot(height, format), strconv.FormatUint(uint64(chunk), 10)) } -// decodeKey decodes a snapshot key. -func decodeKey(k []byte) (uint64, uint32, error) { +func (s *Store) parseMetadataFilename(filename string) (height uint64, format uint32, err error) { + parts := strings.Split(filename, "-") + if len(parts) != 2 { + return 0, 0, fmt.Errorf("invalid snapshot metadata filename %s", filename) + } + height, err = strconv.ParseUint(parts[0], 10, 64) + if err != nil { + return 0, 0, errors.Wrapf(err, "invalid snapshot metadata filename %s", filename) + } + var f uint64 + f, err = strconv.ParseUint(parts[1], 10, 32) + if err != nil { + return 0, 0, errors.Wrapf(err, "invalid snapshot metadata filename %s", filename) + } + format = uint32(f) + if filename != filepath.Base(s.pathMetadata(height, uint32(format))) { + return 0, 0, fmt.Errorf("invalid snapshot metadata filename %s", filename) + } + return height, format, nil +} + +func (s *Store) validateMetadataPath(path string) error { + dir, f := filepath.Split(path) + if dir != fmt.Sprintf("%s/", s.pathMetadataDir()) { + return fmt.Errorf("invalid snapshot metadata path %s", path) + } + _, _, err := s.parseMetadataFilename(f) + return err +} + +// legacyV1DecodeKey decodes a legacy snapshot key used in a raw kv store. +func legacyV1DecodeKey(k []byte) (uint64, uint32, error) { if len(k) != 13 { return 0, 0, errors.Wrapf(store.ErrLogic, "invalid snapshot key with length %v", len(k)) } @@ -372,11 +410,29 @@ func decodeKey(k []byte) (uint64, uint32, error) { return height, format, nil } -// encodeKey encodes a snapshot key. -func encodeKey(height uint64, format uint32) []byte { +// legacyV1EncodeKey encodes a snapshot key for use in a raw kv store. +func legacyV1EncodeKey(height uint64, format uint32) []byte { k := make([]byte, 13) k[0] = keyPrefixSnapshot binary.BigEndian.PutUint64(k[1:], height) binary.BigEndian.PutUint32(k[9:], format) return k } + +func (s *Store) MigrateFromV1(db store.RawDB) error { + itr, err := db.Iterator(legacyV1EncodeKey(0, 0), legacyV1EncodeKey(math.MaxUint64, math.MaxUint32)) + if err != nil { + return err + } + defer itr.Close() + for ; itr.Valid(); itr.Next() { + height, format, err := legacyV1DecodeKey(itr.Key()) + if err != nil { + return err + } + if err := os.WriteFile(s.pathMetadata(height, format), itr.Value(), 0o600); err != nil { + return errors.Wrapf(err, "failed to write snapshot metadata %q", s.pathMetadata(height, format)) + } + } + return nil +} diff --git a/store/snapshots/store_test.go b/store/snapshots/store_test.go index 07f4d4a6d515..c6708ec8d73c 100644 --- a/store/snapshots/store_test.go +++ b/store/snapshots/store_test.go @@ -10,14 +10,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - dbm "cosmossdk.io/store/v2/db" "cosmossdk.io/store/v2/snapshots" "cosmossdk.io/store/v2/snapshots/types" ) func setupStore(t *testing.T) *snapshots.Store { t.Helper() - store, err := snapshots.NewStore(dbm.NewMemDB(), GetTempDir(t)) + store, err := snapshots.NewStore(GetTempDir(t)) require.NoError(t, err) _, err = store.Save(1, 1, makeChunks([][]byte{ @@ -42,13 +41,13 @@ func setupStore(t *testing.T) *snapshots.Store { func TestNewStore(t *testing.T) { tempdir := GetTempDir(t) - _, err := snapshots.NewStore(dbm.NewMemDB(), tempdir) + _, err := snapshots.NewStore(tempdir) require.NoError(t, err) } func TestNewStore_ErrNoDir(t *testing.T) { - _, err := snapshots.NewStore(dbm.NewMemDB(), "") + _, err := snapshots.NewStore("") require.Error(t, err) } diff --git a/store/storage/rocksdb/db.go b/store/storage/rocksdb/db.go index b2525e3d8e81..440d26ccccce 100644 --- a/store/storage/rocksdb/db.go +++ b/store/storage/rocksdb/db.go @@ -9,7 +9,7 @@ import ( "fmt" "github.com/linxGnu/grocksdb" - "golang.org/x/exp/slices" + "slices" corestore "cosmossdk.io/core/store" "cosmossdk.io/store/v2" diff --git a/store/storage/sqlite/iterator.go b/store/storage/sqlite/iterator.go index e048e1f3cd27..3dd2875c1e18 100644 --- a/store/storage/sqlite/iterator.go +++ b/store/storage/sqlite/iterator.go @@ -4,10 +4,9 @@ import ( "bytes" "database/sql" "fmt" + "slices" "strings" - "golang.org/x/exp/slices" - corestore "cosmossdk.io/core/store" ) diff --git a/store/upgrade.go b/store/upgrade.go index 675e7e926303..b5de0e5443d4 100644 --- a/store/upgrade.go +++ b/store/upgrade.go @@ -1,6 +1,6 @@ package store -import "golang.org/x/exp/slices" +import "slices" // StoreUpgrades defines a series of transformations to apply the RootStore upon // loading a version. diff --git a/telemetry/metrics.go b/telemetry/metrics.go index c15720897972..502fdb611209 100644 --- a/telemetry/metrics.go +++ b/telemetry/metrics.go @@ -23,6 +23,7 @@ const ( FormatDefault = "" FormatPrometheus = "prometheus" FormatText = "text" + ContentTypeText = `text/plain; version=` + expfmt.TextVersion + `; charset=utf-8` MetricSinkInMem = "mem" MetricSinkStatsd = "statsd" @@ -192,7 +193,7 @@ func (m *Metrics) gatherPrometheus() (GatherResponse, error) { buf := &bytes.Buffer{} defer buf.Reset() - e := expfmt.NewEncoder(buf, expfmt.FmtText) + e := expfmt.NewEncoder(buf, expfmt.NewFormat(expfmt.TypeTextPlain)) for _, mf := range metricsFamilies { if err := e.Encode(mf); err != nil { @@ -200,7 +201,7 @@ func (m *Metrics) gatherPrometheus() (GatherResponse, error) { } } - return GatherResponse{ContentType: string(expfmt.FmtText), Metrics: buf.Bytes()}, nil + return GatherResponse{ContentType: ContentTypeText, Metrics: buf.Bytes()}, nil } // gatherGeneric collects generic metrics and returns a GatherResponse. diff --git a/telemetry/metrics_test.go b/telemetry/metrics_test.go index 1ce1103529c8..b18c33cac63e 100644 --- a/telemetry/metrics_test.go +++ b/telemetry/metrics_test.go @@ -7,7 +7,6 @@ import ( "time" "github.com/hashicorp/go-metrics" - "github.com/prometheus/common/expfmt" "github.com/stretchr/testify/require" ) @@ -58,7 +57,7 @@ func TestMetrics_Prom(t *testing.T) { gr, err := m.Gather(FormatPrometheus) require.NoError(t, err) - require.Equal(t, gr.ContentType, string(expfmt.FmtText)) + require.Equal(t, gr.ContentType, string(ContentTypeText)) require.True(t, strings.Contains(string(gr.Metrics), "test_dummy_counter 30")) } diff --git a/tests/go.mod b/tests/go.mod index bfbf6c21e60e..ae62c99accdb 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -40,7 +40,7 @@ require ( cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 cosmossdk.io/x/authz v0.0.0-00010101000000-000000000000 cosmossdk.io/x/bank v0.0.0-00010101000000-000000000000 - cosmossdk.io/x/distribution v0.0.0-20230925135524-a1bc045b3190 + cosmossdk.io/x/distribution v0.0.0-20240227221813-a248d05f70f4 cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a cosmossdk.io/x/group v0.0.0-00010101000000-000000000000 cosmossdk.io/x/mint v0.0.0-00010101000000-000000000000 @@ -167,9 +167,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect @@ -204,7 +204,7 @@ require ( golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect - golang.org/x/oauth2 v0.16.0 // indirect + golang.org/x/oauth2 v0.17.0 // indirect golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.17.0 // indirect golang.org/x/term v0.17.0 // indirect diff --git a/tests/go.sum b/tests/go.sum index 37047aad930a..fd33ab3213a5 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -876,8 +876,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -892,8 +892,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -1202,8 +1202,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ= +golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/tests/integration/gov/keeper/keeper_test.go b/tests/integration/gov/keeper/keeper_test.go index 39756b834f34..68561f4a7336 100644 --- a/tests/integration/gov/keeper/keeper_test.go +++ b/tests/integration/gov/keeper/keeper_test.go @@ -112,7 +112,7 @@ func initFixture(tb testing.TB) *fixture { stakingKeeper, poolKeeper, router, - types.DefaultConfig(), + keeper.DefaultConfig(), authority.String(), ) assert.NilError(tb, govKeeper.ProposalID.Set(newCtx, 1)) diff --git a/x/slashing/keeper/slash_redelegation_test.go b/tests/integration/slashing/keeper/slash_redelegation_test.go similarity index 81% rename from x/slashing/keeper/slash_redelegation_test.go rename to tests/integration/slashing/keeper/slash_redelegation_test.go index cc32f9ebdf2e..d50a012765e5 100644 --- a/x/slashing/keeper/slash_redelegation_test.go +++ b/tests/integration/slashing/keeper/slash_redelegation_test.go @@ -1,41 +1,52 @@ package keeper_test import ( + "context" "fmt" "testing" "time" + "github.com/stretchr/testify/require" + "cosmossdk.io/core/header" "cosmossdk.io/depinject" "cosmossdk.io/log" "cosmossdk.io/math" + authkeeper "cosmossdk.io/x/auth/keeper" bankkeeper "cosmossdk.io/x/bank/keeper" banktestutil "cosmossdk.io/x/bank/testutil" + distributionkeeper "cosmossdk.io/x/distribution/keeper" slashingkeeper "cosmossdk.io/x/slashing/keeper" - "cosmossdk.io/x/slashing/testutil" stakingkeeper "cosmossdk.io/x/staking/keeper" stakingtypes "cosmossdk.io/x/staking/types" - distributionkeeper "cosmossdk.io/x/distribution/keeper" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" - + "github.com/cosmos/cosmos-sdk/tests/integration/slashing" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + sdk "github.com/cosmos/cosmos-sdk/types" ) func TestSlashRedelegation(t *testing.T) { // setting up - var stakingKeeper *stakingkeeper.Keeper - var bankKeeper bankkeeper.Keeper - var slashKeeper slashingkeeper.Keeper - var distrKeeper distributionkeeper.Keeper - - app, err := simtestutil.Setup(depinject.Configs( - depinject.Supply(log.NewNopLogger()), - testutil.AppConfig, - ), &stakingKeeper, &bankKeeper, &slashKeeper, &distrKeeper) + var ( + authKeeper authkeeper.AccountKeeper + stakingKeeper *stakingkeeper.Keeper + bankKeeper bankkeeper.Keeper + slashKeeper slashingkeeper.Keeper + distrKeeper distributionkeeper.Keeper + ) + + app, err := simtestutil.Setup( + depinject.Configs( + depinject.Supply(log.NewNopLogger()), + slashing.AppConfig, + ), + &stakingKeeper, + &bankKeeper, + &slashKeeper, + &distrKeeper, + &authKeeper, + ) require.NoError(t, err) // get sdk context, staking msg server and bond denom @@ -56,8 +67,8 @@ func TestSlashRedelegation(t *testing.T) { // fund acc 1 and acc 2 testCoins := sdk.NewCoins(sdk.NewCoin(bondDenom, stakingKeeper.TokensFromConsensusPower(ctx, 10))) - banktestutil.FundAccount(ctx, bankKeeper, testAcc1, testCoins) - banktestutil.FundAccount(ctx, bankKeeper, testAcc2, testCoins) + fundAccount(t, ctx, bankKeeper, authKeeper, testAcc1, testCoins) + fundAccount(t, ctx, bankKeeper, authKeeper, testAcc2, testCoins) balance1Before := bankKeeper.GetBalance(ctx, testAcc1, bondDenom) balance2Before := bankKeeper.GetBalance(ctx, testAcc2, bondDenom) @@ -68,7 +79,7 @@ func TestSlashRedelegation(t *testing.T) { // creating evil val evilValAddr := sdk.ValAddress(evilValPubKey.Address()) - banktestutil.FundAccount(ctx, bankKeeper, sdk.AccAddress(evilValAddr), testCoins) + fundAccount(t, ctx, bankKeeper, authKeeper, sdk.AccAddress(evilValAddr), testCoins) createValMsg1, _ := stakingtypes.NewMsgCreateValidator( evilValAddr.String(), evilValPubKey, testCoins[0], stakingtypes.Description{Details: "test"}, stakingtypes.NewCommissionRates(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0)), math.OneInt()) _, err = stakingMsgServer.CreateValidator(ctx, createValMsg1) @@ -76,7 +87,7 @@ func TestSlashRedelegation(t *testing.T) { // creating good val goodValAddr := sdk.ValAddress(goodValPubKey.Address()) - banktestutil.FundAccount(ctx, bankKeeper, sdk.AccAddress(goodValAddr), testCoins) + fundAccount(t, ctx, bankKeeper, authKeeper, sdk.AccAddress(goodValAddr), testCoins) createValMsg2, _ := stakingtypes.NewMsgCreateValidator( goodValAddr.String(), goodValPubKey, testCoins[0], stakingtypes.Description{Details: "test"}, stakingtypes.NewCommissionRates(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0)), math.OneInt()) _, err = stakingMsgServer.CreateValidator(ctx, createValMsg2) @@ -99,7 +110,7 @@ func TestSlashRedelegation(t *testing.T) { require.NoError(t, err) // next block, commit height 2, move to height 3 - // with the new delegations, evil val increases in voting power and commit byzantine behaviour at height 3 consensus + // with the new delegations, evil val increases in voting power and commit byzantine behavior at height 3 consensus // at the same time, acc 1 and acc 2 withdraw delegation from evil val ctx, err = simtestutil.NextBlock(app, ctx, time.Duration(1)) require.NoError(t, err) @@ -126,9 +137,9 @@ func TestSlashRedelegation(t *testing.T) { require.NoError(t, err) // next block, commit height 3, move to height 4 - // Slash evil val for byzantine behaviour at height 3 consensus, + // Slash evil val for byzantine behavior at height 3 consensus, // at which acc 1 and acc 2 still contributed to evil val voting power - // even tho they undelegate at block 3, the valset update is applied after commited block 3 when height 3 consensus already passes + // even tho they undelegate at block 3, the valset update is applied after committed block 3 when height 3 consensus already passes ctx, err = simtestutil.NextBlock(app, ctx, time.Duration(1)) require.NoError(t, err) @@ -163,3 +174,14 @@ func TestSlashRedelegation(t *testing.T) { require.Equal(t, balance1AfterSlashing.Amount.Mul(math.NewIntFromUint64(10)).String(), balance1Before.Amount.String()) require.Equal(t, balance2AfterSlashing.Amount.Mul(math.NewIntFromUint64(10)).String(), balance2Before.Amount.String()) } + +func fundAccount(t *testing.T, ctx context.Context, bankKeeper bankkeeper.Keeper, authKeeper authkeeper.AccountKeeper, addr sdk.AccAddress, amount sdk.Coins) { + t.Helper() + + if authKeeper.GetAccount(ctx, addr) == nil { + addrAcc := authKeeper.NewAccountWithAddress(ctx, addr) + authKeeper.SetAccount(ctx, addrAcc) + } + + require.NoError(t, banktestutil.FundAccount(ctx, bankKeeper, addr, amount)) +} diff --git a/tests/starship/tests/go.mod b/tests/starship/tests/go.mod index 90bdee5473fb..244e26d1f67a 100644 --- a/tests/starship/tests/go.mod +++ b/tests/starship/tests/go.mod @@ -69,7 +69,7 @@ require ( cosmossdk.io/x/accounts v0.0.0-20240104091155-b729e981f130 // indirect cosmossdk.io/x/authz v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/circuit v0.0.0-20230613133644-0a778132a60f // indirect - cosmossdk.io/x/distribution v0.0.0-20230925135524-a1bc045b3190 // indirect + cosmossdk.io/x/distribution v0.0.0-20240227221813-a248d05f70f4 // indirect cosmossdk.io/x/evidence v0.0.0-20230613133644-0a778132a60f // indirect cosmossdk.io/x/feegrant v0.0.0-20230613133644-0a778132a60f // indirect cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a // indirect @@ -195,9 +195,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect @@ -234,7 +234,7 @@ require ( golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect - golang.org/x/oauth2 v0.16.0 // indirect + golang.org/x/oauth2 v0.17.0 // indirect golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.17.0 // indirect golang.org/x/term v0.17.0 // indirect diff --git a/tests/starship/tests/go.sum b/tests/starship/tests/go.sum index bb4c471af8ac..f3e4b8e20413 100644 --- a/tests/starship/tests/go.sum +++ b/tests/starship/tests/go.sum @@ -876,8 +876,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -892,8 +892,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -1202,8 +1202,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ= +golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/types/events.go b/types/events.go index 8d1f9d6cb44c..335fac3182c8 100644 --- a/types/events.go +++ b/types/events.go @@ -4,13 +4,13 @@ import ( "encoding/json" "fmt" "reflect" + "slices" "strings" abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/gogoproto/jsonpb" proto "github.com/cosmos/gogoproto/proto" "golang.org/x/exp/maps" - "golang.org/x/exp/slices" "github.com/cosmos/cosmos-sdk/codec" ) diff --git a/types/handler.go b/types/handler.go index 42774086c2e0..28873703bdea 100644 --- a/types/handler.go +++ b/types/handler.go @@ -6,23 +6,23 @@ package types // is required for the remainder of the AnteHandler execution, a new Context should // be created off of the provided Context and returned as . // -// The simulate argument is provided to indicate if the AnteHandler is being executed -// in simulation mode, which attempts to estimate a gas cost for the tx. Any state -// modifications made will be discarded if simulate is true. -type AnteHandler func(ctx Context, tx Tx, simulate bool) (newCtx Context, err error) +// When exec module is in simulation mode (ctx.ExecMode() == ExecModeSimulate), it indicates if the AnteHandler is +// being executed in simulation mode, which attempts to estimate a gas cost for the tx. +// Any state modifications made will be discarded in simulation mode. +type AnteHandler func(ctx Context, tx Tx, _ bool) (newCtx Context, err error) // PostHandler like AnteHandler but it executes after RunMsgs. Runs on success // or failure and enables use cases like gas refunding. -type PostHandler func(ctx Context, tx Tx, simulate, success bool) (newCtx Context, err error) +type PostHandler func(ctx Context, tx Tx, _, success bool) (newCtx Context, err error) // AnteDecorator wraps the next AnteHandler to perform custom pre-processing. type AnteDecorator interface { - AnteHandle(ctx Context, tx Tx, simulate bool, next AnteHandler) (newCtx Context, err error) + AnteHandle(ctx Context, tx Tx, _ bool, next AnteHandler) (newCtx Context, err error) } // PostDecorator wraps the next PostHandler to perform custom post-processing. type PostDecorator interface { - PostHandle(ctx Context, tx Tx, simulate, success bool, next PostHandler) (newCtx Context, err error) + PostHandle(ctx Context, tx Tx, _, success bool, next PostHandler) (newCtx Context, err error) } // ChainAnteDecorators ChainDecorator chains AnteDecorators together with each AnteDecorator @@ -46,13 +46,13 @@ func ChainAnteDecorators(chain ...AnteDecorator) AnteHandler { handlerChain := make([]AnteHandler, len(chain)+1) // set the terminal AnteHandler decorator - handlerChain[len(chain)] = func(ctx Context, tx Tx, simulate bool) (Context, error) { + handlerChain[len(chain)] = func(ctx Context, tx Tx, _ bool) (Context, error) { return ctx, nil } for i := 0; i < len(chain); i++ { ii := i - handlerChain[ii] = func(ctx Context, tx Tx, simulate bool) (Context, error) { - return chain[ii].AnteHandle(ctx, tx, simulate, handlerChain[ii+1]) + handlerChain[ii] = func(ctx Context, tx Tx, _ bool) (Context, error) { + return chain[ii].AnteHandle(ctx, tx, ctx.ExecMode() == ExecModeSimulate, handlerChain[ii+1]) } } @@ -74,13 +74,13 @@ func ChainPostDecorators(chain ...PostDecorator) PostHandler { handlerChain := make([]PostHandler, len(chain)+1) // set the terminal PostHandler decorator - handlerChain[len(chain)] = func(ctx Context, tx Tx, simulate, success bool) (Context, error) { + handlerChain[len(chain)] = func(ctx Context, tx Tx, _, success bool) (Context, error) { return ctx, nil } for i := 0; i < len(chain); i++ { ii := i - handlerChain[ii] = func(ctx Context, tx Tx, simulate, success bool) (Context, error) { - return chain[ii].PostHandle(ctx, tx, simulate, success, handlerChain[ii+1]) + handlerChain[ii] = func(ctx Context, tx Tx, _, success bool) (Context, error) { + return chain[ii].PostHandle(ctx, tx, ctx.ExecMode() == ExecModeSimulate, success, handlerChain[ii+1]) } } return handlerChain[0] diff --git a/types/handler_test.go b/types/handler_test.go index 3d20d3023d2d..21eba84a903c 100644 --- a/types/handler_test.go +++ b/types/handler_test.go @@ -14,7 +14,7 @@ func TestChainAnteDecorators(t *testing.T) { // test panic require.Nil(t, sdk.ChainAnteDecorators([]sdk.AnteDecorator{}...)) - ctx, tx := sdk.Context{}, sdk.Tx(nil) + ctx, tx := sdk.Context{}.WithExecMode(sdk.ExecModeSimulate), sdk.Tx(nil) mockCtrl := gomock.NewController(t) mockAnteDecorator1 := mock.NewMockAnteDecorator(mockCtrl) mockAnteDecorator1.EXPECT().AnteHandle(gomock.Eq(ctx), gomock.Eq(tx), true, gomock.Any()).Times(1) @@ -39,7 +39,7 @@ func TestChainPostDecorators(t *testing.T) { require.Nil(t, sdk.ChainPostDecorators([]sdk.PostDecorator{}...)) // Create empty context as well as transaction - ctx := sdk.Context{} + ctx := sdk.Context{}.WithExecMode(sdk.ExecModeSimulate) tx := sdk.Tx(nil) // Create mocks diff --git a/x/accounts/go.mod b/x/accounts/go.mod index 03d9bb17ca66..3e7745aba2a5 100644 --- a/x/accounts/go.mod +++ b/x/accounts/go.mod @@ -14,7 +14,6 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 github.com/spf13/cobra v1.8.0 github.com/stretchr/testify v1.8.4 - golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 ) @@ -118,9 +117,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect @@ -145,6 +144,7 @@ require ( go.etcd.io/bbolt v1.3.7 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.20.0 // indirect + golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.6.0 // indirect diff --git a/x/accounts/go.sum b/x/accounts/go.sum index d466a8159ee9..823fad196de8 100644 --- a/x/accounts/go.sum +++ b/x/accounts/go.sum @@ -577,8 +577,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -593,8 +593,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/accounts/v1/schema.go b/x/accounts/v1/schema.go index d4aef76353b6..6cebadb306f1 100644 --- a/x/accounts/v1/schema.go +++ b/x/accounts/v1/schema.go @@ -1,9 +1,9 @@ package v1 import ( + "slices" "strings" - "golang.org/x/exp/slices" "google.golang.org/grpc" "cosmossdk.io/x/accounts/internal/implementation" diff --git a/x/auth/ante/basic.go b/x/auth/ante/basic.go index b5d14d32bb13..59e9eca61ee1 100644 --- a/x/auth/ante/basic.go +++ b/x/auth/ante/basic.go @@ -24,10 +24,10 @@ func NewValidateBasicDecorator() ValidateBasicDecorator { return ValidateBasicDecorator{} } -func (vbd ValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { +func (vbd ValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (sdk.Context, error) { // no need to validate basic on recheck tx, call next antehandler if ctx.ExecMode() == sdk.ExecModeReCheck { - return next(ctx, tx, simulate) + return next(ctx, tx, false) } if validateBasic, ok := tx.(sdk.HasValidateBasic); ok { @@ -36,7 +36,7 @@ func (vbd ValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat } } - return next(ctx, tx, simulate) + return next(ctx, tx, ctx.ExecMode() == sdk.ExecModeSimulate) } // ValidateMemoDecorator will validate memo given the parameters passed in @@ -52,7 +52,7 @@ func NewValidateMemoDecorator(ak AccountKeeper) ValidateMemoDecorator { } } -func (vmd ValidateMemoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { +func (vmd ValidateMemoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (sdk.Context, error) { memoTx, ok := tx.(sdk.TxWithMemo) if !ok { return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") @@ -69,7 +69,7 @@ func (vmd ValidateMemoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate } } - return next(ctx, tx, simulate) + return next(ctx, tx, ctx.ExecMode() == sdk.ExecModeSimulate) } // ConsumeTxSizeGasDecorator will take in parameters and consume gas proportional @@ -77,7 +77,7 @@ func (vmd ValidateMemoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate // slightly over estimated due to the fact that any given signing account may need // to be retrieved from state. // -// CONTRACT: If simulate=true, then signatures must either be completely filled +// CONTRACT: If exec mode = simulate, then signatures must either be completely filled // in or empty. // CONTRACT: To use this decorator, signatures of transaction must be represented // as legacytx.StdSignature otherwise simulate mode will incorrectly estimate gas cost. @@ -91,7 +91,7 @@ func NewConsumeGasForTxSizeDecorator(ak AccountKeeper) ConsumeTxSizeGasDecorator } } -func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { +func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (sdk.Context, error) { sigTx, ok := tx.(authsigning.SigVerifiableTx) if !ok { return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid tx type") @@ -143,7 +143,7 @@ func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim } } - return next(ctx, tx, simulate) + return next(ctx, tx, ctx.ExecMode() == sdk.ExecModeSimulate) } // isIncompleteSignature tests whether SignatureData is fully filled in for simulation purposes @@ -193,7 +193,7 @@ func NewTxTimeoutHeightDecorator() TxTimeoutHeightDecorator { // type where the current block height is checked against the tx's height timeout. // If a height timeout is provided (non-zero) and is less than the current block // height, then an error is returned. -func (txh TxTimeoutHeightDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { +func (txh TxTimeoutHeightDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (sdk.Context, error) { timeoutTx, ok := tx.(TxWithTimeoutHeight) if !ok { return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "expected tx to implement TxWithTimeoutHeight") @@ -206,5 +206,5 @@ func (txh TxTimeoutHeightDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul ) } - return next(ctx, tx, simulate) + return next(ctx, tx, ctx.ExecMode() == sdk.ExecModeSimulate) } diff --git a/x/auth/ante/ext.go b/x/auth/ante/ext.go index 6a072526aa0f..92fefff3afff 100644 --- a/x/auth/ante/ext.go +++ b/x/auth/ante/ext.go @@ -43,13 +43,13 @@ func NewExtensionOptionsDecorator(checker ExtensionOptionChecker) sdk.AnteDecora var _ sdk.AnteDecorator = RejectExtensionOptionsDecorator{} // AnteHandle implements the AnteDecorator.AnteHandle method -func (r RejectExtensionOptionsDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { +func (r RejectExtensionOptionsDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { err = checkExtOpts(tx, r.checker) if err != nil { return ctx, err } - return next(ctx, tx, simulate) + return next(ctx, tx, ctx.ExecMode() == sdk.ExecModeSimulate) } func checkExtOpts(tx sdk.Tx, checker ExtensionOptionChecker) error { diff --git a/x/auth/ante/fee.go b/x/auth/ante/fee.go index 6da4ecc3b940..018b447c97e3 100644 --- a/x/auth/ante/fee.go +++ b/x/auth/ante/fee.go @@ -39,7 +39,7 @@ func NewDeductFeeDecorator(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKee } } -func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { +func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (sdk.Context, error) { feeTx, ok := tx.(sdk.FeeTx) if !ok { return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") @@ -67,7 +67,7 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo newCtx := ctx.WithPriority(priority) - return next(newCtx, tx, simulate) + return next(newCtx, tx, ctx.ExecMode() == sdk.ExecModeSimulate) } func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee sdk.Coins) error { diff --git a/x/auth/ante/setup.go b/x/auth/ante/setup.go index 4fbe8dac856e..6ab8fcd4c1d2 100644 --- a/x/auth/ante/setup.go +++ b/x/auth/ante/setup.go @@ -27,7 +27,7 @@ func NewSetUpContextDecorator() SetUpContextDecorator { return SetUpContextDecorator{} } -func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { +func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { // all transactions must implement GasTx gasTx, ok := tx.(GasTx) if !ok { @@ -67,7 +67,7 @@ func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate } }() - return next(newCtx, tx, simulate) + return next(newCtx, tx, ctx.ExecMode() == sdk.ExecModeSimulate) } // SetGasMeter returns a new context with a gas meter set from a given context. diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index e54a5964a6d5..facc160fcee3 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -149,7 +149,7 @@ func verifyIsOnCurve(pubKey cryptotypes.PubKey) (err error) { return nil } -func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { +func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { sigTx, ok := tx.(authsigning.Tx) if !ok { return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") @@ -215,7 +215,7 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul ctx.EventManager().EmitEvents(events) - return next(ctx, tx, simulate) + return next(ctx, tx, ctx.ExecMode() == sdk.ExecModeSimulate) } // authenticate the authentication of the TX for a specific tx signer. @@ -459,7 +459,7 @@ func NewValidateSigCountDecorator(ak AccountKeeper) ValidateSigCountDecorator { } } -func (vscd ValidateSigCountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { +func (vscd ValidateSigCountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (sdk.Context, error) { sigTx, ok := tx.(authsigning.SigVerifiableTx) if !ok { return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be a sigTx") @@ -479,7 +479,7 @@ func (vscd ValidateSigCountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim } } - return next(ctx, tx, simulate) + return next(ctx, tx, ctx.ExecMode() == sdk.ExecModeSimulate) } // DefaultSigVerificationGasConsumer is the default implementation of SignatureVerificationGasConsumer. It consumes gas diff --git a/x/auth/ante/unordered.go b/x/auth/ante/unordered.go index c110e63650ce..0394701ddf59 100644 --- a/x/auth/ante/unordered.go +++ b/x/auth/ante/unordered.go @@ -37,12 +37,12 @@ func NewUnorderedTxDecorator(maxTTL uint64, m *unorderedtx.Manager) *UnorderedTx } } -func (d *UnorderedTxDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { +func (d *UnorderedTxDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, _ bool, next sdk.AnteHandler) (sdk.Context, error) { unorderedTx, ok := tx.(sdk.TxWithUnordered) if !ok || !unorderedTx.GetUnordered() { // If the transaction does not implement unordered capabilities or has the // unordered value as false, we bypass. - return next(ctx, tx, simulate) + return next(ctx, tx, ctx.ExecMode() == sdk.ExecModeSimulate) } // TTL is defined as a specific block height at which this tx is no longer valid @@ -70,5 +70,5 @@ func (d *UnorderedTxDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate b d.txManager.Add(txHash, ttl) } - return next(ctx, tx, simulate) + return next(ctx, tx, ctx.ExecMode() == sdk.ExecModeSimulate) } diff --git a/x/auth/go.mod b/x/auth/go.mod index b93a40d79e81..fa4698cafb13 100644 --- a/x/auth/go.mod +++ b/x/auth/go.mod @@ -124,9 +124,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/auth/go.sum b/x/auth/go.sum index 95ac223a5b43..884ec3416ac7 100644 --- a/x/auth/go.sum +++ b/x/auth/go.sum @@ -577,8 +577,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -593,8 +593,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/authz/go.mod b/x/authz/go.mod index 740883699aed..a48bb4fe90f3 100644 --- a/x/authz/go.mod +++ b/x/authz/go.mod @@ -120,9 +120,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/authz/go.sum b/x/authz/go.sum index 95ac223a5b43..884ec3416ac7 100644 --- a/x/authz/go.sum +++ b/x/authz/go.sum @@ -577,8 +577,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -593,8 +593,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/bank/go.mod b/x/bank/go.mod index b467152ae2b0..9ebf12bdc141 100644 --- a/x/bank/go.mod +++ b/x/bank/go.mod @@ -119,9 +119,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/bank/go.sum b/x/bank/go.sum index 95ac223a5b43..884ec3416ac7 100644 --- a/x/bank/go.sum +++ b/x/bank/go.sum @@ -577,8 +577,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -593,8 +593,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/circuit/go.mod b/x/circuit/go.mod index 177d34780cbf..7a6982c45da9 100644 --- a/x/circuit/go.mod +++ b/x/circuit/go.mod @@ -118,9 +118,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/circuit/go.sum b/x/circuit/go.sum index 95ac223a5b43..884ec3416ac7 100644 --- a/x/circuit/go.sum +++ b/x/circuit/go.sum @@ -577,8 +577,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -593,8 +593,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/distribution/go.mod b/x/distribution/go.mod index deda10c2d3d9..a915abd43b1a 100644 --- a/x/distribution/go.mod +++ b/x/distribution/go.mod @@ -121,9 +121,9 @@ require ( github.com/pelletier/go-toml/v2 v2.1.1 // indirect github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/distribution/go.sum b/x/distribution/go.sum index 72cfb2e466bd..ba69099d417b 100644 --- a/x/distribution/go.sum +++ b/x/distribution/go.sum @@ -579,8 +579,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -595,8 +595,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/distribution/keeper/genesis.go b/x/distribution/keeper/genesis.go index 2abc1645615c..ce4a178401e4 100644 --- a/x/distribution/keeper/genesis.go +++ b/x/distribution/keeper/genesis.go @@ -121,7 +121,6 @@ func (k Keeper) InitGenesis(ctx context.Context, data types.GenesisState) { ), evt.ValidatorSlashEvent, ) - if err != nil { panic(err) } @@ -256,7 +255,6 @@ func (k Keeper) ExportGenesis(ctx context.Context) *types.GenesisState { return false, nil }, ) - if err != nil { panic(err) } diff --git a/x/distribution/keeper/grpc_query.go b/x/distribution/keeper/grpc_query.go index 16039f340f0f..38889665a0e4 100644 --- a/x/distribution/keeper/grpc_query.go +++ b/x/distribution/keeper/grpc_query.go @@ -330,7 +330,6 @@ func (k Querier) DelegatorValidators(ctx context.Context, req *types.QueryDelega return false }, ) - if err != nil { return nil, err } diff --git a/x/distribution/keeper/invariants.go b/x/distribution/keeper/invariants.go index 1bc6e23e4e58..04f3294320a0 100644 --- a/x/distribution/keeper/invariants.go +++ b/x/distribution/keeper/invariants.go @@ -153,7 +153,6 @@ func ReferenceCountInvariant(k Keeper) sdk.Invariant { return false, nil }, ) - if err != nil { panic(err) } @@ -168,7 +167,6 @@ func ReferenceCountInvariant(k Keeper) sdk.Invariant { return false, nil }, ) - if err != nil { panic(err) } diff --git a/x/evidence/go.mod b/x/evidence/go.mod index 955a36f7747b..12969d169dcf 100644 --- a/x/evidence/go.mod +++ b/x/evidence/go.mod @@ -120,9 +120,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/evidence/go.sum b/x/evidence/go.sum index 95ac223a5b43..884ec3416ac7 100644 --- a/x/evidence/go.sum +++ b/x/evidence/go.sum @@ -577,8 +577,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -593,8 +593,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/feegrant/go.mod b/x/feegrant/go.mod index 4ce5c25a4480..d8717b76e520 100644 --- a/x/feegrant/go.mod +++ b/x/feegrant/go.mod @@ -125,9 +125,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/feegrant/go.sum b/x/feegrant/go.sum index 5279853943fa..e2036bb174a4 100644 --- a/x/feegrant/go.sum +++ b/x/feegrant/go.sum @@ -587,8 +587,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -603,8 +603,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/gov/CHANGELOG.md b/x/gov/CHANGELOG.md index cc844666388d..0524fd23ff8b 100644 --- a/x/gov/CHANGELOG.md +++ b/x/gov/CHANGELOG.md @@ -27,6 +27,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* [#19592](https://github.com/cosmos/cosmos-sdk/pull/19592) Add custom tally function. * [#19304](https://github.com/cosmos/cosmos-sdk/pull/19304) Add `MsgSudoExec` for allowing executing any message as a sudo. * [#19101](https://github.com/cosmos/cosmos-sdk/pull/19101) Add message based params configuration. * [#18532](https://github.com/cosmos/cosmos-sdk/pull/18532) Add SPAM vote to proposals. @@ -59,6 +60,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking Changes +* [#19592](https://github.com/cosmos/cosmos-sdk/pull/19592) `types.Config` and `types.DefaultConfig` have been moved to the keeper package in order to support the custom tallying function. * [#19349](https://github.com/cosmos/cosmos-sdk/pull/19349) Simplify state management in `x/gov`. Note `k.VotingPeriodProposals` and `k.SetProposal` are no longer needed and have been removed. * [#18532](https://github.com/cosmos/cosmos-sdk/pull/18532) All functions that were taking an expedited bool parameter now take a `ProposalType` parameter instead. * [#17496](https://github.com/cosmos/cosmos-sdk/pull/17496) in `x/gov/types/v1beta1/vote.go` `NewVote` was removed, constructing the struct is required for this type. diff --git a/x/gov/depinject.go b/x/gov/depinject.go index 99bf5e3bf75e..3776ddf46025 100644 --- a/x/gov/depinject.go +++ b/x/gov/depinject.go @@ -2,11 +2,11 @@ package gov import ( "fmt" + "slices" "sort" "strings" "golang.org/x/exp/maps" - "golang.org/x/exp/slices" modulev1 "cosmossdk.io/api/cosmos/gov/module/v1" "cosmossdk.io/core/appmodule" @@ -60,7 +60,7 @@ type ModuleOutputs struct { } func ProvideModule(in ModuleInputs) ModuleOutputs { - defaultConfig := govtypes.DefaultConfig() + defaultConfig := keeper.DefaultConfig() if in.Config.MaxTitleLen != 0 { defaultConfig.MaxTitleLen = in.Config.MaxTitleLen } diff --git a/x/gov/go.mod b/x/gov/go.mod index 1b2c06e7efab..41fbd2a48f52 100644 --- a/x/gov/go.mod +++ b/x/gov/go.mod @@ -126,9 +126,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/gov/go.sum b/x/gov/go.sum index 5279853943fa..e2036bb174a4 100644 --- a/x/gov/go.sum +++ b/x/gov/go.sum @@ -587,8 +587,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -603,8 +603,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/gov/keeper/common_test.go b/x/gov/keeper/common_test.go index be8d44ea20c9..fb78f6fca0ca 100644 --- a/x/gov/keeper/common_test.go +++ b/x/gov/keeper/common_test.go @@ -130,7 +130,7 @@ func setupGovKeeper(t *testing.T, expectations ...func(sdk.Context, mocks)) ( // Gov keeper initializations - govKeeper := keeper.NewKeeper(encCfg.Codec, storeService, m.acctKeeper, m.bankKeeper, m.stakingKeeper, m.poolKeeper, baseApp.MsgServiceRouter(), types.DefaultConfig(), govAcct.String()) + govKeeper := keeper.NewKeeper(encCfg.Codec, storeService, m.acctKeeper, m.bankKeeper, m.stakingKeeper, m.poolKeeper, baseApp.MsgServiceRouter(), keeper.DefaultConfig(), govAcct.String()) require.NoError(t, govKeeper.ProposalID.Set(ctx, 1)) govRouter := v1beta1.NewRouter() // Also register legacy gov handlers to test them too. govRouter.AddRoute(types.RouterKey, v1beta1.ProposalHandler) diff --git a/x/gov/keeper/config.go b/x/gov/keeper/config.go new file mode 100644 index 000000000000..5e8f3a7d0c6a --- /dev/null +++ b/x/gov/keeper/config.go @@ -0,0 +1,42 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/math" + v1 "cosmossdk.io/x/gov/types/v1" +) + +// CalculateVoteResultsAndVotingPowerFn is a function signature for calculating vote results and voting power +// It can be overridden to customize the voting power calculation for proposals +// It gets the proposal tallied and the validators governance infos (bonded tokens, voting power, etc.) +// It must return the total voting power and the results of the vote +type CalculateVoteResultsAndVotingPowerFn func( + ctx context.Context, + keeper Keeper, + proposalID uint64, + validators map[string]v1.ValidatorGovInfo, +) (totalVoterPower math.LegacyDec, results map[v1.VoteOption]math.LegacyDec, err error) + +// Config is a config struct used for initializing the gov module to avoid using globals. +type Config struct { + // MaxTitleLen defines the amount of characters that can be used for proposal title + MaxTitleLen uint64 + // MaxMetadataLen defines the amount of characters that can be used for proposal metadata + MaxMetadataLen uint64 + // MaxSummaryLen defines the amount of characters that can be used for proposal summary + MaxSummaryLen uint64 + // CalculateVoteResultsAndVotingPowerFn is a function signature for calculating vote results and voting power + // Keeping it nil will use the default implementation + CalculateVoteResultsAndVotingPowerFn CalculateVoteResultsAndVotingPowerFn +} + +// DefaultConfig returns the default config for gov. +func DefaultConfig() Config { + return Config{ + MaxTitleLen: 255, + MaxMetadataLen: 255, + MaxSummaryLen: 10200, + CalculateVoteResultsAndVotingPowerFn: nil, + } +} diff --git a/x/gov/keeper/deposit.go b/x/gov/keeper/deposit.go index 34512ae253bf..ece9eac79059 100644 --- a/x/gov/keeper/deposit.go +++ b/x/gov/keeper/deposit.go @@ -98,7 +98,7 @@ func (k Keeper) AddDeposit(ctx context.Context, proposalID uint64, depositorAddr } // the deposit must only contain valid denoms (listed in the min deposit param) - if err := k.validateDepositDenom(ctx, params, depositAmount); err != nil { + if err := k.validateDepositDenom(params, depositAmount); err != nil { return false, err } @@ -280,7 +280,7 @@ func (k Keeper) ChargeDeposit(ctx context.Context, proposalID uint64, destAddres // validateInitialDeposit validates if initial deposit is greater than or equal to the minimum // required at the time of proposal submission. This threshold amount is determined by // the deposit parameters. Returns nil on success, error otherwise. -func (k Keeper) validateInitialDeposit(ctx context.Context, params v1.Params, initialDeposit sdk.Coins, proposalType v1.ProposalType) error { +func (k Keeper) validateInitialDeposit(params v1.Params, initialDeposit sdk.Coins, proposalType v1.ProposalType) error { if !initialDeposit.IsValid() || initialDeposit.IsAnyNegative() { return errors.Wrap(sdkerrors.ErrInvalidCoins, initialDeposit.String()) } @@ -311,7 +311,7 @@ func (k Keeper) validateInitialDeposit(ctx context.Context, params v1.Params, in } // validateDepositDenom validates if the deposit denom is accepted by the governance module. -func (k Keeper) validateDepositDenom(ctx context.Context, params v1.Params, depositAmount sdk.Coins) error { +func (k Keeper) validateDepositDenom(params v1.Params, depositAmount sdk.Coins) error { denoms := []string{} acceptedDenoms := make(map[string]bool, len(params.MinDeposit)) for _, coin := range params.MinDeposit { diff --git a/x/gov/keeper/export_test.go b/x/gov/keeper/export_test.go index 1421e96781d1..8294a34d95b7 100644 --- a/x/gov/keeper/export_test.go +++ b/x/gov/keeper/export_test.go @@ -14,5 +14,5 @@ func (k Keeper) ValidateInitialDeposit(ctx sdk.Context, initialDeposit sdk.Coins return err } - return k.validateInitialDeposit(ctx, params, initialDeposit, proposalType) + return k.validateInitialDeposit(params, initialDeposit, proposalType) } diff --git a/x/gov/keeper/keeper.go b/x/gov/keeper/keeper.go index 6a82442a401c..6ffa959c71c1 100644 --- a/x/gov/keeper/keeper.go +++ b/x/gov/keeper/keeper.go @@ -42,7 +42,8 @@ type Keeper struct { // Msg server router router baseapp.MessageRouter - config types.Config + // Config represent extra module configuration + config Config // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. @@ -88,7 +89,7 @@ func (k Keeper) GetAuthority() string { func NewKeeper( cdc codec.Codec, storeService corestoretypes.KVStoreService, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper, pk types.PoolKeeper, - router baseapp.MessageRouter, config types.Config, authority string, + router baseapp.MessageRouter, config Config, authority string, ) *Keeper { // ensure governance module account is set if addr := authKeeper.GetModuleAddress(types.ModuleName); addr == nil { @@ -99,7 +100,7 @@ func NewKeeper( panic(fmt.Sprintf("invalid authority address: %s", authority)) } - defaultConfig := types.DefaultConfig() + defaultConfig := DefaultConfig() // If MaxMetadataLen not set by app developer, set to default value. if config.MaxTitleLen == 0 { config.MaxTitleLen = defaultConfig.MaxTitleLen diff --git a/x/gov/keeper/msg_server.go b/x/gov/keeper/msg_server.go index 9fd9b8b6c86f..e6cc63a2b8f6 100644 --- a/x/gov/keeper/msg_server.go +++ b/x/gov/keeper/msg_server.go @@ -76,11 +76,11 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitPropos if msg.Expedited { // checking for backward compatibility msg.ProposalType = v1.ProposalType_PROPOSAL_TYPE_EXPEDITED } - if err := k.validateInitialDeposit(ctx, params, msg.GetInitialDeposit(), msg.ProposalType); err != nil { + if err := k.validateInitialDeposit(params, msg.GetInitialDeposit(), msg.ProposalType); err != nil { return nil, err } - if err := k.validateDepositDenom(ctx, params, msg.GetInitialDeposit()); err != nil { + if err := k.validateDepositDenom(params, msg.GetInitialDeposit()); err != nil { return nil, err } diff --git a/x/gov/keeper/proposal.go b/x/gov/keeper/proposal.go index 73d4566fa5a0..8e7801f8f520 100644 --- a/x/gov/keeper/proposal.go +++ b/x/gov/keeper/proposal.go @@ -264,7 +264,7 @@ func (k Keeper) ActivateVotingPeriod(ctx context.Context, proposal v1.Proposal) customMessageParams, err := k.MessageBasedParams.Get(ctx, sdk.MsgTypeURL(proposal.Messages[0])) if err == nil { votingPeriod = customMessageParams.VotingPeriod - } else if err != nil && !errors.Is(err, collections.ErrNotFound) { + } else if !errors.Is(err, collections.ErrNotFound) { return err } } diff --git a/x/gov/keeper/tally.go b/x/gov/keeper/tally.go index bf45e796e9c1..8f87ec3570d2 100644 --- a/x/gov/keeper/tally.go +++ b/x/gov/keeper/tally.go @@ -18,7 +18,11 @@ func (k Keeper) Tally(ctx context.Context, proposal v1.Proposal) (passes, burnDe return false, false, v1.TallyResult{}, err } - totalVoterPower, results, err := k.calculateVoteResultsAndVotingPower(ctx, proposal.Id, validators) + if k.config.CalculateVoteResultsAndVotingPowerFn == nil { + k.config.CalculateVoteResultsAndVotingPowerFn = defaultCalculateVoteResultsAndVotingPower + } + + totalVoterPower, results, err := k.config.CalculateVoteResultsAndVotingPowerFn(ctx, k, proposal.Id, validators) if err != nil { return false, false, v1.TallyResult{}, err } @@ -232,8 +236,9 @@ func (k Keeper) getCurrentValidators(ctx context.Context) (map[string]v1.Validat // calculateVoteResultsAndVotingPower iterate over all votes, tally up the voting power of each validator // and returns the votes results from voters -func (k Keeper) calculateVoteResultsAndVotingPower( +func defaultCalculateVoteResultsAndVotingPower( ctx context.Context, + k Keeper, proposalID uint64, validators map[string]v1.ValidatorGovInfo, ) (math.LegacyDec, map[v1.VoteOption]math.LegacyDec, error) { diff --git a/x/gov/types/config.go b/x/gov/types/config.go deleted file mode 100644 index 919d54e5b9ad..000000000000 --- a/x/gov/types/config.go +++ /dev/null @@ -1,20 +0,0 @@ -package types - -// Config is a config struct used for initializing the gov module to avoid using globals. -type Config struct { - // MaxTitleLen defines the amount of characters that can be used for proposal title - MaxTitleLen uint64 - // MaxMetadataLen defines the amount of characters that can be used for proposal metadata. - MaxMetadataLen uint64 - // MaxSummaryLen defines the amount of characters that can be used for proposal summary - MaxSummaryLen uint64 -} - -// DefaultConfig returns the default config for gov. -func DefaultConfig() Config { - return Config{ - MaxTitleLen: 255, - MaxMetadataLen: 255, - MaxSummaryLen: 10200, - } -} diff --git a/x/group/go.mod b/x/group/go.mod index d5621e4f3ff5..8332fc32b959 100644 --- a/x/group/go.mod +++ b/x/group/go.mod @@ -128,9 +128,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/group/go.sum b/x/group/go.sum index 8d2d0823d507..a7481d6bf0bf 100644 --- a/x/group/go.sum +++ b/x/group/go.sum @@ -587,8 +587,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -603,8 +603,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index ec84ccb60237..392ac9c27539 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -959,7 +959,6 @@ func SimulateMsgWithdrawProposal( } _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) - if err != nil { if strings.Contains(err.Error(), "group was modified") || strings.Contains(err.Error(), "group policy was modified") { return simtypes.NoOpMsg(group.ModuleName, sdk.MsgTypeURL(msg), "no-op:group/group-policy was modified"), nil, nil @@ -1067,7 +1066,6 @@ func SimulateMsgVote( } _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) - if err != nil { if strings.Contains(err.Error(), "group was modified") || strings.Contains(err.Error(), "group policy was modified") { return simtypes.NoOpMsg(group.ModuleName, sdk.MsgTypeURL(msg), "no-op:group/group-policy was modified"), nil, nil diff --git a/x/mint/go.mod b/x/mint/go.mod index 1eac687b2df1..b3ec0d3713ba 100644 --- a/x/mint/go.mod +++ b/x/mint/go.mod @@ -119,9 +119,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/mint/go.sum b/x/mint/go.sum index 95ac223a5b43..884ec3416ac7 100644 --- a/x/mint/go.sum +++ b/x/mint/go.sum @@ -577,8 +577,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -593,8 +593,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/nft/go.mod b/x/nft/go.mod index 61e5845833c5..c45f2500f1c3 100644 --- a/x/nft/go.mod +++ b/x/nft/go.mod @@ -118,9 +118,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/nft/go.sum b/x/nft/go.sum index 95ac223a5b43..884ec3416ac7 100644 --- a/x/nft/go.sum +++ b/x/nft/go.sum @@ -577,8 +577,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -593,8 +593,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/params/go.mod b/x/params/go.mod index 7eb74756b27b..16377d64e512 100644 --- a/x/params/go.mod +++ b/x/params/go.mod @@ -120,9 +120,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/params/go.sum b/x/params/go.sum index 95ac223a5b43..884ec3416ac7 100644 --- a/x/params/go.sum +++ b/x/params/go.sum @@ -577,8 +577,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -593,8 +593,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/protocolpool/go.mod b/x/protocolpool/go.mod index ae2a6d771d3a..6644b1071294 100644 --- a/x/protocolpool/go.mod +++ b/x/protocolpool/go.mod @@ -120,9 +120,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/protocolpool/go.sum b/x/protocolpool/go.sum index 95ac223a5b43..884ec3416ac7 100644 --- a/x/protocolpool/go.sum +++ b/x/protocolpool/go.sum @@ -577,8 +577,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -593,8 +593,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/slashing/go.mod b/x/slashing/go.mod index 7e03863235a1..37239d2a5af0 100644 --- a/x/slashing/go.mod +++ b/x/slashing/go.mod @@ -121,9 +121,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/slashing/go.sum b/x/slashing/go.sum index c1786f523dca..e4427810a9e4 100644 --- a/x/slashing/go.sum +++ b/x/slashing/go.sum @@ -579,8 +579,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -595,8 +595,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/staking/go.mod b/x/staking/go.mod index 9cf80ddfc703..7bf6ec71d2d2 100644 --- a/x/staking/go.mod +++ b/x/staking/go.mod @@ -122,9 +122,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect diff --git a/x/staking/go.sum b/x/staking/go.sum index 95ac223a5b43..884ec3416ac7 100644 --- a/x/staking/go.sum +++ b/x/staking/go.sum @@ -577,8 +577,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -593,8 +593,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index 6b70d5121a78..c5dea74ea009 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -431,7 +431,6 @@ func (k Keeper) GetRedelegations(ctx context.Context, delegator sdk.AccAddress, i++ return false, nil }) - if err != nil { return nil, err } diff --git a/x/staking/keeper/grpc_query.go b/x/staking/keeper/grpc_query.go index 942d29997358..5dd6f46d6932 100644 --- a/x/staking/keeper/grpc_query.go +++ b/x/staking/keeper/grpc_query.go @@ -118,7 +118,6 @@ func (k Querier) ValidatorDelegations(ctx context.Context, req *types.QueryValid return delegation, nil }, query.WithCollectionPaginationPairPrefix[sdk.ValAddress, sdk.AccAddress](valAddr), ) - if err != nil { delegations, pageResponse, err := k.getValidatorDelegationsLegacy(ctx, req) if err != nil { diff --git a/x/upgrade/go.mod b/x/upgrade/go.mod index 0abd37242c73..e0cd8b69260e 100644 --- a/x/upgrade/go.mod +++ b/x/upgrade/go.mod @@ -145,9 +145,9 @@ require ( github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/common v0.49.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect @@ -180,7 +180,7 @@ require ( golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect - golang.org/x/oauth2 v0.16.0 // indirect + golang.org/x/oauth2 v0.17.0 // indirect golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.17.0 // indirect golang.org/x/term v0.17.0 // indirect diff --git a/x/upgrade/go.sum b/x/upgrade/go.sum index 1ee818af771b..a9e0f3cc3350 100644 --- a/x/upgrade/go.sum +++ b/x/upgrade/go.sum @@ -874,8 +874,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= +github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -890,8 +890,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.49.0 h1:ToNTdK4zSnPVJmh698mGFkDor9wBI/iGaJy5dbH1EgI= +github.com/prometheus/common v0.49.0/go.mod h1:Kxm+EULxRbUkjGU6WFsQqo3ORzB4tyKvlWFOE9mB2sE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -1200,8 +1200,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= -golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= +golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ= +golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=