Skip to content

Commit

Permalink
Merge pull request #76 from notional-labs/hot-fix
Browse files Browse the repository at this point in the history
Hot fix
  • Loading branch information
faddat authored May 8, 2023
2 parents 0a65bef + c312e93 commit 8a39536
Show file tree
Hide file tree
Showing 12 changed files with 1,845 additions and 21 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ require (
cosmossdk.io/simapp v0.0.0-20230320103358-f4a6feb9d4ee
github.com/armon/go-metrics v0.4.1
github.com/cometbft/cometbft v0.37.1
github.com/cometbft/cometbft-db v0.7.0
github.com/cometbft/cometbft-db v0.8.0
github.com/cosmos/cosmos-proto v1.0.0-beta.3
github.com/cosmos/cosmos-sdk v0.47.2
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.9
github.com/cosmos/gogoproto v1.4.8
github.com/gogo/protobuf v1.3.2
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.3
Expand All @@ -37,6 +37,7 @@ require (
github.com/gin-gonic/gin v1.8.1 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/linxGnu/grocksdb v1.7.16 // indirect
)

require (
Expand Down Expand Up @@ -141,7 +142,6 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tidwall/btree v1.6.0 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
Expand Down
15 changes: 6 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZ
github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M=
github.com/cometbft/cometbft v0.37.1 h1:KLxkQTK2hICXYq21U2hn1W5hOVYUdQgDQ1uB+90xPIg=
github.com/cometbft/cometbft v0.37.1/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs=
github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo=
github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0=
github.com/cometbft/cometbft-db v0.8.0 h1:vUMDaH3ApkX8m0KZvOFFy9b5DZHBAjsnEuo9AKVZpjo=
github.com/cometbft/cometbft-db v0.8.0/go.mod h1:6ASCP4pfhmrCBpfk01/9E1SI29nD3HfVHrY4PG8x5c0=
github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4=
github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak=
github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ=
Expand All @@ -386,8 +386,8 @@ github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4x
github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE=
github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ4GUkT+tbFI=
github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU=
github.com/cosmos/gogoproto v1.4.9 h1:MjVmV6F1yk1rJLWtKeYdGQcTbE880t+VlRcayEBqUKQ=
github.com/cosmos/gogoproto v1.4.9/go.mod h1:c0ysUnwvnlR+RmCUvqqii7pp8kHBB/DBcp/5VLA/nQk=
github.com/cosmos/gogoproto v1.4.8 h1:BrHKc6WFZt8+jRV71vKSQE+JrfF+JAnzrKo2VP7wIZ4=
github.com/cosmos/gogoproto v1.4.8/go.mod h1:hnb0DIEWTv+wdNzNcqus5xCQXq5+CXauq1FJuurRfVY=
github.com/cosmos/iavl v0.20.0 h1:fTVznVlepH0KK8NyKq8w+U7c2L6jofa27aFX6YGlm38=
github.com/cosmos/iavl v0.20.0/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A=
github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo=
Expand Down Expand Up @@ -467,9 +467,6 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0=
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0=
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A=
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
Expand Down Expand Up @@ -835,6 +832,8 @@ github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6
github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
github.com/linxGnu/grocksdb v1.7.16 h1:Q2co1xrpdkr5Hx3Fp+f+f7fRGhQFQhvi/+226dtLmA8=
github.com/linxGnu/grocksdb v1.7.16/go.mod h1:JkS7pl5qWpGpuVb3bPqTz8nC12X3YtPZT+Xq7+QfQo4=
github.com/lucasjones/reggen v0.0.0-20180717132126-cdb49ff09d77/go.mod h1:5ELEyG+X8f+meRWHuqUOewBOhvHkl7M76pdGEansxW4=
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
Expand Down Expand Up @@ -1111,8 +1110,6 @@ github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNG
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs=
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48=
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok=
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8=
github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E=
github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg=
Expand Down
167 changes: 167 additions & 0 deletions proto/liquidstaking/distribution/v1/distribution.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
syntax = "proto3";
package liquidstaking.distribution.v1;

option go_package = "github.com/iqlusioninc/liquidity-staking-module/x/distribution/types";
option (gogoproto.equal_all) = true;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";

// Params defines the set of params for the distribution module.
message Params {
option (gogoproto.goproto_stringer) = false;
string community_tax = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string base_proposer_reward = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string bonus_proposer_reward = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
bool withdraw_addr_enabled = 4;
}

// ValidatorHistoricalRewards represents historical rewards for a validator.
// Height is implicit within the store key.
// Cumulative reward ratio is the sum from the zeroeth period
// until this period of rewards / tokens, per the spec.
// The reference count indicates the number of objects
// which might need to reference this historical entry at any point.
// ReferenceCount =
// number of outstanding delegations which ended the associated period (and
// might need to read that record)
// + number of slashes which ended the associated period (and might need to
// read that record)
// + one per validator for the zeroeth period, set on initialization
message ValidatorHistoricalRewards {
repeated cosmos.base.v1beta1.DecCoin cumulative_reward_ratio = 1
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false];
uint32 reference_count = 2;
}

// ValidatorCurrentRewards represents current rewards and current
// period for a validator kept as a running counter and incremented
// each block as long as the validator's tokens remain constant.
message ValidatorCurrentRewards {
repeated cosmos.base.v1beta1.DecCoin rewards = 1
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false];
uint64 period = 2;
}

// ValidatorAccumulatedCommission represents accumulated commission
// for a validator kept as a running counter, can be withdrawn at any time.
message ValidatorAccumulatedCommission {
repeated cosmos.base.v1beta1.DecCoin commission = 1
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false];
}

// ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards
// for a validator inexpensive to track, allows simple sanity checks.
message ValidatorOutstandingRewards {
repeated cosmos.base.v1beta1.DecCoin rewards = 1
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false];
}

// ValidatorSlashEvent represents a validator slash event.
// Height is implicit within the store key.
// This is needed to calculate appropriate amount of staking tokens
// for delegations which are withdrawn after a slash has occurred.
message ValidatorSlashEvent {
uint64 validator_period = 1;
string fraction = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

// ValidatorSlashEvents is a collection of ValidatorSlashEvent messages.
message ValidatorSlashEvents {
option (gogoproto.goproto_stringer) = false;
repeated ValidatorSlashEvent validator_slash_events = 1 [(gogoproto.nullable) = false];
}

// FeePool is the global fee pool for distribution.
message FeePool {
repeated cosmos.base.v1beta1.DecCoin community_pool = 1
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"];
}

// CommunityPoolSpendProposal details a proposal for use of community funds,
// together with how many coins are proposed to be spent, and to which
// recipient account.
message CommunityPoolSpendProposal {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";

string title = 1;
string description = 2;
string recipient = 3;
repeated cosmos.base.v1beta1.Coin amount = 4
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
}

// DelegatorStartingInfo represents the starting info for a delegator reward
// period. It tracks the previous validator period, the delegation's amount of
// staking token, and the creation height (to check later on if any slashes have
// occurred). NOTE: Even though validators are slashed to whole staking tokens,
// the delegators within the validator may be left with less than a full token,
// thus sdk.Dec is used.
message DelegatorStartingInfo {
uint64 previous_period = 1;
string stake = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
uint64 height = 3 [(gogoproto.jsontag) = "creation_height"];
}

// DelegationDelegatorReward represents the properties
// of a delegator's delegation reward.
message DelegationDelegatorReward {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = true;

string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

repeated cosmos.base.v1beta1.DecCoin reward = 2
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false];
}

// TokenizeShareRecordReward represents the properties of tokenize share
message TokenizeShareRecordReward {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = true;

uint64 recordId = 1;

repeated cosmos.base.v1beta1.DecCoin reward = 2 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
(gogoproto.nullable) = false
];
}

// CommunityPoolSpendProposalWithDeposit defines a CommunityPoolSpendProposal
// with a deposit
message CommunityPoolSpendProposalWithDeposit {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = true;
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";

string title = 1;
string description = 2;
string recipient = 3;
string amount = 4;
string deposit = 5;
}
144 changes: 144 additions & 0 deletions proto/liquidstaking/distribution/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
syntax = "proto3";
package liquidstaking.distribution.v1;

option go_package = "github.com/iqlusioninc/liquidity-staking-module/x/distribution/types";
option (gogoproto.equal_all) = true;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "liquidstaking/distribution/v1/distribution.proto";
import "cosmos_proto/cosmos.proto";

// DelegatorWithdrawInfo is the address for where distributions rewards are
// withdrawn to by default this struct is only used at genesis to feed in
// default withdraw addresses.
message DelegatorWithdrawInfo {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// delegator_address is the address of the delegator.
string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// withdraw_address is the address to withdraw the delegation rewards to.
string withdraw_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// ValidatorOutstandingRewardsRecord is used for import/export via genesis json.
message ValidatorOutstandingRewardsRecord {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// validator_address is the address of the validator.
string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// outstanding_rewards represents the oustanding rewards of a validator.
repeated cosmos.base.v1beta1.DecCoin outstanding_rewards = 2
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false];
}

// ValidatorAccumulatedCommissionRecord is used for import / export via genesis
// json.
message ValidatorAccumulatedCommissionRecord {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// validator_address is the address of the validator.
string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// accumulated is the accumulated commission of a validator.
ValidatorAccumulatedCommission accumulated = 2 [(gogoproto.nullable) = false];
}

// ValidatorHistoricalRewardsRecord is used for import / export via genesis
// json.
message ValidatorHistoricalRewardsRecord {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// validator_address is the address of the validator.
string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// period defines the period the historical rewards apply to.
uint64 period = 2;

// rewards defines the historical rewards of a validator.
ValidatorHistoricalRewards rewards = 3 [(gogoproto.nullable) = false];
}

// ValidatorCurrentRewardsRecord is used for import / export via genesis json.
message ValidatorCurrentRewardsRecord {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// validator_address is the address of the validator.
string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// rewards defines the current rewards of a validator.
ValidatorCurrentRewards rewards = 2 [(gogoproto.nullable) = false];
}

// DelegatorStartingInfoRecord used for import / export via genesis json.
message DelegatorStartingInfoRecord {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// delegator_address is the address of the delegator.
string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// validator_address is the address of the validator.
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// starting_info defines the starting info of a delegator.
DelegatorStartingInfo starting_info = 3 [(gogoproto.nullable) = false];
}

// ValidatorSlashEventRecord is used for import / export via genesis json.
message ValidatorSlashEventRecord {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// validator_address is the address of the validator.
string validator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// height defines the block height at which the slash event occured.
uint64 height = 2;
// period is the period of the slash event.
uint64 period = 3;
// validator_slash_event describes the slash event.
ValidatorSlashEvent validator_slash_event = 4 [(gogoproto.nullable) = false];
}

// GenesisState defines the distribution module's genesis state.
message GenesisState {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// params defines all the paramaters of the module.
Params params = 1 [(gogoproto.nullable) = false];

// fee_pool defines the fee pool at genesis.
FeePool fee_pool = 2 [(gogoproto.nullable) = false];

// fee_pool defines the delegator withdraw infos at genesis.
repeated DelegatorWithdrawInfo delegator_withdraw_infos = 3 [(gogoproto.nullable) = false];

// fee_pool defines the previous proposer at genesis.
string previous_proposer = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// fee_pool defines the outstanding rewards of all validators at genesis.
repeated ValidatorOutstandingRewardsRecord outstanding_rewards = 5 [(gogoproto.nullable) = false];

// fee_pool defines the accumulated commisions of all validators at genesis.
repeated ValidatorAccumulatedCommissionRecord validator_accumulated_commissions = 6 [(gogoproto.nullable) = false];

// fee_pool defines the historical rewards of all validators at genesis.
repeated ValidatorHistoricalRewardsRecord validator_historical_rewards = 7 [(gogoproto.nullable) = false];

// fee_pool defines the current rewards of all validators at genesis.
repeated ValidatorCurrentRewardsRecord validator_current_rewards = 8 [(gogoproto.nullable) = false];

// fee_pool defines the delegator starting infos at genesis.
repeated DelegatorStartingInfoRecord delegator_starting_infos = 9 [(gogoproto.nullable) = false];

// fee_pool defines the validator slash events at genesis.
repeated ValidatorSlashEventRecord validator_slash_events = 10 [(gogoproto.nullable) = false];
}
Loading

0 comments on commit 8a39536

Please sign in to comment.