Skip to content

Commit

Permalink
Merge branch 'main' into zmanian-patch-3
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrit authored Jul 19, 2024
2 parents 60c9f66 + da76764 commit cf6132e
Show file tree
Hide file tree
Showing 32 changed files with 943 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ For more information you can check out the [Sommelier Documentation](https://som
We have active, helpful communities on Twitter, Discord, and Telegram.

* [Twitter](https://twitter.com/sommfinance)
* [Discord](https://discord.gg/gZzaPmDzUq)
* [Discord](https://discord.gg/sommfinance)
* [Telegram](https://t.me/getsomm)

## Sommelier
Expand Down
14 changes: 12 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (

"github.com/cosmos/cosmos-sdk/runtime"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
Expand All @@ -20,6 +22,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand Down Expand Up @@ -63,7 +66,6 @@ import (
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/mint"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
Expand Down Expand Up @@ -744,6 +746,14 @@ func NewSommelierApp(
app.MountTransientStores(tkeys)
app.MountMemoryStores(memKeys)

autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.mm.Modules))

reflectionSvc, err := runtimeservices.NewReflectionService()
if err != nil {
panic(err)
}
reflectionv1.RegisterReflectionServiceServer(app.GRPCQueryRouter(), reflectionSvc)

// initialize BaseApp
app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker)
Expand Down Expand Up @@ -966,7 +976,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypesv1.ParamKeyTable())
paramsKeeper.Subspace(govtypes.ModuleName)
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
paramsKeeper.Subspace(icaexported.ModuleName)
Expand Down
6 changes: 0 additions & 6 deletions integration_tests/auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,6 @@ func (s *IntegrationTestSuite) TestAuction() {
endedAuctionResponse, err := auctionQueryClient.QueryEndedAuction(context.Background(), &types.QueryEndedAuctionRequest{AuctionId: uint32(1)})
s.Require().NoError(err)

node, err = orchClientCtx.GetNode()
s.Require().NoError(err)
status, err = node.Status(context.Background())
s.Require().NoError(err)
currentBlockHeight = status.SyncInfo.LatestBlockHeight

expectedEndedAuction := types.Auction{
Id: uint32(1),
StartingTokensForSale: sdk.NewCoin("gravity0x3506424f91fd33084466f402d5d97f05f8e3b4af", sdk.NewInt(5000000000)),
Expand Down
23 changes: 16 additions & 7 deletions integration_tests/incentives_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,23 +210,32 @@ func (s *IntegrationTestSuite) queryValidatorRewards(ctx context.Context, valOpe
return rewardsRes.Rewards.Rewards.AmountOf(params.BaseCoinUnit)
}

func (s *IntegrationTestSuite) getCurrentHeight(clientCtx *client.Context) int64 {
func (s *IntegrationTestSuite) getCurrentHeight(clientCtx *client.Context) (int64, error) {
node, err := clientCtx.GetNode()
s.Require().NoError(err)
if err != nil {
return 0, err
}
status, err := node.Status(context.Background())
s.Require().NoError(err)

return status.SyncInfo.LatestBlockHeight
if err != nil {
return 0, err
}
return status.SyncInfo.LatestBlockHeight, nil
}

func (s *IntegrationTestSuite) getRewardAmountAndHeight(ctx context.Context, distQueryClient disttypes.QueryClient, operatorAddress string, clientCtx *client.Context) (sdk.Dec, int64) {
var amount sdk.Dec
var height int64

s.Require().Eventually(func() bool {
initialHeight := s.getCurrentHeight(clientCtx)
initialHeight, err := s.getCurrentHeight(clientCtx)
if err != nil {
return false
}
amount = s.queryValidatorRewards(ctx, operatorAddress, distQueryClient)
height = s.getCurrentHeight(clientCtx)
height, err = s.getCurrentHeight(clientCtx)
if err != nil {
return false
}
return initialHeight == height
}, time.Second*30, time.Second*1, "failed to reliably determine height of reward sample")

Expand Down
2 changes: 0 additions & 2 deletions integration_tests/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,6 @@ func (s *IntegrationTestSuite) initGenesis() {
distGenState := disttypes.DefaultGenesisState()
s.Require().NoError(cdc.UnmarshalJSON(appGenState[minttypes.ModuleName], &mintGenState))
distGenState.Params.CommunityTax = sdk.ZeroDec()
distGenState.Params.BaseProposerReward = sdk.ZeroDec()
distGenState.Params.BonusProposerReward = sdk.ZeroDec()
distGenState.FeePool.CommunityPool = sdk.NewDecCoins(sdk.NewDecCoin(params.BaseCoinUnit, sdk.NewInt(1000000000)))
bz, err = cdc.MarshalJSON(distGenState)
s.Require().NoError(err)
Expand Down
5 changes: 5 additions & 0 deletions prost_build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Rust Proto Bindings Build

## Notes

For some reason, the `type_attribute` config method is not working the the `CellarIdSet` type, therefore whenever `prost_build` gets run, we have to manually add the `serde::Deserialize` and `serde::Serialize` attributes to it.
4 changes: 4 additions & 0 deletions prost_build/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ fn compile_protos(out_dir: &Path, tmp_dir: &Path) {
config
.type_attribute("ScheduledCorkProposal", "#[derive(serde::Deserialize, serde::Serialize)]")
.type_attribute("AxelarScheduledCorkProposal", "#[derive(serde::Deserialize, serde::Serialize)]")
.type_attribute("AddPublisherProposal", "#[derive(serde::Deserialize, serde::Serialize)]")
.type_attribute("AddManagedCellarIDsProposalWithDeposit", "#[derive(serde::Deserialize, serde::Serialize)]")
.type_attribute("AddAxelarManagedCellarIDsProposalWithDeposit", "#[derive(serde::Deserialize, serde::Serialize)]")
.type_attribute("axelar_cork::CellarIdSet", "#[derive(serde::Deserialize, serde::Serialize)]")
.compile_protos(&protos, &proto_include_paths)
.unwrap();

Expand Down
4 changes: 4 additions & 0 deletions somm_proto/src/prost/auction.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ pub struct Params {
pub auction_price_decrease_acceleration_rate: ::prost::alloc::string::String,
#[prost(uint64, tag = "6")]
pub minimum_auction_height: u64,
/// value between 0 and 1 the determines the % of somm received from bids that
/// gets burned
#[prost(string, tag = "7")]
pub somm_burn_ratio: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryParamsRequest {}
Expand Down
4 changes: 2 additions & 2 deletions somm_proto/src/prost/axelarcork.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct AxelarCorkResults {
#[prost(message, repeated, tag = "1")]
pub cork_results: ::prost::alloc::vec::Vec<AxelarCorkResult>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq, ::prost::Message)]
pub struct CellarIdSet {
#[prost(uint64, tag = "1")]
pub chain_id: u64,
Expand Down Expand Up @@ -768,7 +768,7 @@ pub struct AddAxelarManagedCellarIDsProposal {
pub publisher_domain: ::prost::alloc::string::String,
}
/// AddAxelarManagedCellarIDsProposalWithDeposit is a specific definition for CLI commands
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq, ::prost::Message)]
pub struct AddAxelarManagedCellarIDsProposalWithDeposit {
#[prost(string, tag = "1")]
pub title: ::prost::alloc::string::String,
Expand Down
4 changes: 2 additions & 2 deletions somm_proto/src/prost/cork.v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct CorkResult {
#[prost(string, tag = "4")]
pub approval_percentage: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq, ::prost::Message)]
pub struct CellarIdSet {
#[prost(string, repeated, tag = "1")]
pub ids: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
Expand Down Expand Up @@ -402,7 +402,7 @@ pub struct AddManagedCellarIDsProposal {
pub publisher_domain: ::prost::alloc::string::String,
}
/// AddManagedCellarIDsProposalWithDeposit is a specific definition for CLI commands
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq, ::prost::Message)]
pub struct AddManagedCellarIDsProposalWithDeposit {
#[prost(string, tag = "1")]
pub title: ::prost::alloc::string::String,
Expand Down
1 change: 1 addition & 0 deletions somm_proto/src/prost/cosmos.msg.v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions somm_proto/src/prost/cosmos.query.v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions somm_proto/src/prost/cosmos_proto.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion somm_proto/src/prost/pubsub.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub struct DefaultSubscription {
}
/// governance proposal to add a publisher, with domain, adress, and ca_cert the same as the Publisher type
/// proof URL expected in the format: https://<domain>/<address>/cacert.pem and serving cacert.pem matching ca_cert
#[derive(Clone, PartialEq, ::prost::Message)]
#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq, ::prost::Message)]
pub struct AddPublisherProposal {
#[prost(string, tag = "1")]
pub title: ::prost::alloc::string::String,
Expand Down
4 changes: 4 additions & 0 deletions third_party/proto/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Third party vendored protos

The primary proto generation now uses buf and the buf schema registry, but some of these vendored protos are still necessary because the Rust code generator, found under `prost_build` in the root directory, needs them.

30 changes: 30 additions & 0 deletions third_party/proto/cosmos/msg/v1/msg.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
syntax = "proto3";

package cosmos.msg.v1;

import "google/protobuf/descriptor.proto";

// TODO(fdymylja): once we fully migrate to protov2 the go_package needs to be updated.
// We need this right now because gogoproto codegen needs to import the extension.
option go_package = "github.com/cosmos/cosmos-sdk/types/msgservice";

extend google.protobuf.ServiceOptions {
// service indicates that the service is a Msg service and that requests
// must be transported via blockchain transactions rather than gRPC.
// Tooling can use this annotation to distinguish between Msg services and
// other types of services via reflection.
bool service = 11110000;
}

extend google.protobuf.MessageOptions {
// signer must be used in cosmos messages in order
// to signal to external clients which fields in a
// given cosmos message must be filled with signer
// information (address).
// The field must be the protobuf name of the message
// field extended with this MessageOption.
// The field must either be of string kind, or of message
// kind in case the signer information is contained within
// a message inside the cosmos message.
repeated string signer = 11110000;
}
35 changes: 35 additions & 0 deletions third_party/proto/cosmos/query/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
syntax = "proto3";

package cosmos.query.v1;

import "google/protobuf/descriptor.proto";

// TODO: once we fully migrate to protov2 the go_package needs to be updated.
// We need this right now because gogoproto codegen needs to import the extension.
option go_package = "github.com/cosmos/cosmos-sdk/types/query";

extend google.protobuf.MethodOptions {
// module_query_safe is set to true when the query is safe to be called from
// within the state machine, for example from another module's Keeper, via
// ADR-033 calls or from CosmWasm contracts.
// Concretely, it means that the query is:
// 1. deterministic: given a block height, returns the exact same response
// upon multiple calls; and doesn't introduce any state-machine-breaking
// changes across SDK patch version.
// 2. consumes gas correctly.
//
// If you are a module developer and want to add this annotation to one of
// your own queries, please make sure that the corresponding query:
// 1. is deterministic and won't introduce state-machine-breaking changes
// without a coordinated upgrade path,
// 2. has its gas tracked, to avoid the attack vector where no gas is
// accounted for on potentially high-computation queries.
//
// For queries that potentially consume a large amount of gas (for example
// those with pagination, if the pagination field is incorrectly set), we
// also recommend adding Protobuf comments to warn module developers
// consuming these queries.
//
// When set to true, the query can safely be called
bool module_query_safe = 11110001;
}
16 changes: 16 additions & 0 deletions third_party/proto/cosmos_proto/cosmos.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package cosmos_proto;

import "google/protobuf/descriptor.proto";

option go_package = "github.com/regen-network/cosmos-proto";

extend google.protobuf.MessageOptions {
string interface_type = 93001;

string implements_interface = 93002;
}

extend google.protobuf.FieldOptions {
string accepts_interface = 93001;
}
Loading

0 comments on commit cf6132e

Please sign in to comment.