Skip to content

Commit

Permalink
Merge pull request #50 from tellor-io/tbr
Browse files Browse the repository at this point in the history
Tbr
  • Loading branch information
themandalore authored Jan 2, 2024
2 parents e0bd86d + 75dadaa commit 226b0f0
Show file tree
Hide file tree
Showing 47 changed files with 2,660 additions and 351 deletions.
14 changes: 6 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/group"
groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper"
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"
"github.com/cosmos/cosmos-sdk/x/mint"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
"github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
Expand Down Expand Up @@ -109,6 +106,9 @@ import (
solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
"github.com/spf13/cast"
"github.com/tellor-io/layer/x/mint"
mintkeeper "github.com/tellor-io/layer/x/mint/keeper"
minttypes "github.com/tellor-io/layer/x/mint/types"

oraclemodule "github.com/tellor-io/layer/x/oracle"
oraclemodulekeeper "github.com/tellor-io/layer/x/oracle/keeper"
Expand Down Expand Up @@ -197,6 +197,8 @@ var (
authtypes.FeeCollectorName: nil,
distrtypes.ModuleName: nil,
icatypes.ModuleName: nil,
minttypes.TimeBasedRewards: nil,
minttypes.MintToTeam: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
Expand Down Expand Up @@ -404,11 +406,8 @@ func New(
app.MintKeeper = mintkeeper.NewKeeper(
appCodec,
keys[minttypes.StoreKey],
app.StakingKeeper,
app.AccountKeeper,
app.BankKeeper,
authtypes.FeeCollectorName,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.DistrKeeper = distrkeeper.NewKeeper(
Expand Down Expand Up @@ -628,7 +627,7 @@ func New(
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)),
Expand Down Expand Up @@ -956,7 +955,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(authtypes.ModuleName)
paramsKeeper.Subspace(banktypes.ModuleName)
paramsKeeper.Subspace(stakingtypes.ModuleName)
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) //nolint:staticcheck
Expand Down
19 changes: 11 additions & 8 deletions app/default_overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ package app
import (
"encoding/json"

"cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/bank"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"

"github.com/cosmos/cosmos-sdk/x/distribution"

"github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
Expand Down Expand Up @@ -61,14 +64,14 @@ func (stakingModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
})
}

type mintModule struct {
mint.AppModuleBasic
type distrModule struct {
distribution.AppModuleBasic
}

// DefaultGenesis returns custom x/mint module genesis state.
func (mintModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
genState := minttypes.DefaultGenesisState()
genState.Params.MintDenom = BondDenom
// DefaultGenesis returns custom x/distribution module genesis state.
func (distrModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
genState := distrtypes.DefaultGenesisState()
genState.Params.CommunityTax = math.LegacyZeroDec() // 0% community tax on gas fees, inflation is minted to timeBasedRewards for reporters

return cdc.MustMarshalJSON(genState)
}
30 changes: 29 additions & 1 deletion mocks/AccountKeeper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions mocks/DistrKeeper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions proto/layer/mint/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = "proto3";
package layer.mint;

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

option go_package = "github.com/tellor-io/layer/x/mint/types";

// GenesisState defines the mint module's genesis state.
message GenesisState {
reserved 1; // 1 was previously used for the `Minter` field.

// BondDenom is the denomination of the token that should be minted.
string bond_denom = 2;

repeated cosmos.base.v1beta1.Coin initial_mint = 3 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}
18 changes: 18 additions & 0 deletions proto/layer/mint/mint.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";
package layer.mint;

option go_package = "github.com/tellor-io/layer/x/mint/types";

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "google/protobuf/timestamp.proto";

// Minter represents the mint state.
message Minter {
// PreviousBlockTime is the timestamp of the previous block.
google.protobuf.Timestamp previous_block_time = 1
[ (gogoproto.stdtime) = true ];

// BondDenom is the denomination of the token that should be minted.
string bond_denom = 2;
}
8 changes: 8 additions & 0 deletions proto/layer/mint/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";
package layer.mint;


option go_package = "github.com/tellor-io/layer/x/mint/types";

// Query defines the gRPC querier service.
service Query {}
1 change: 1 addition & 0 deletions proto/layer/oracle/aggregate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ message Aggregate {
repeated AggregateReporter reporters = 6;
bool flagged = 7;
int64 nonce = 8;
int64 aggregateReportIndex = 9;
}

message AvailableTimestamps {
Expand Down
18 changes: 18 additions & 0 deletions proto/layer/oracle/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import "layer/oracle/micro_report.proto";
import "layer/oracle/tips.proto";
import "layer/oracle/user_tip.proto";
import "layer/oracle/aggregate.proto";
import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/tellor-io/layer/x/oracle/types";

Expand Down Expand Up @@ -60,6 +62,12 @@ service Query {
option (google.api.http).get = "/tellor-io/layer/oracle/GetDataBefore/{queryId}/{timestamp}";

}

// Queries a list of GetTimeBasedRewards items.
rpc GetTimeBasedRewards (QueryGetTimeBasedRewardsRequest) returns (QueryGetTimeBasedRewardsResponse) {
option (google.api.http).get = "/tellor-io/layer/oracle/get_time_based_rewards";

}
}
// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}
Expand Down Expand Up @@ -122,3 +130,13 @@ message QueryGetDataBeforeRequest {
int64 timestamp = 2;
}

message QueryGetTimeBasedRewardsRequest {}

message QueryGetTimeBasedRewardsResponse {
cosmos.base.v1beta1.Coin reward = 1 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin",
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true
];
}

2 changes: 1 addition & 1 deletion tests/integration/dispute_keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (s *IntegrationTestSuite) TestProposeDisputeFromBond() {

bondedTokensBefore := val.GetBondedTokens()
onePercent := bondedTokensBefore.Mul(math.NewInt(1)).Quo(math.NewInt(100))
disputeFee := sdk.NewCoin("stake", onePercent)
disputeFee := sdk.NewCoin(s.denom, onePercent)
slashAmount := disputeFee.Amount
_, err := msgServer.ProposeDispute(ctx, &types.MsgProposeDispute{
Creator: sdk.AccAddress(valAddr).String(),
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func (s *IntegrationTestSuite) SetupTest() {
registry.AppWiringSetup()
dispute.AppWiringSetup()
oracle.AppWiringSetup()
sdk.DefaultBondDenom = "loya"
accountPubKeyPrefix := app.AccountAddressPrefix + "pub"
validatorAddressPrefix := app.AccountAddressPrefix + "valoper"
validatorPubKeyPrefix := app.AccountAddressPrefix + "valoperpub"
Expand Down Expand Up @@ -304,6 +305,10 @@ func (s *IntegrationTestSuite) createValidatorAccs(powers []int64) ([]sdk.AccAdd
s.stakingKeeper.SetValidatorByConsAddr(ctx, val)
s.stakingKeeper.SetNewValidatorByPowerIndex(ctx, val)
s.stakingKeeper.Delegate(ctx, addrs[i], s.stakingKeeper.TokensFromConsensusPower(ctx, powers[i]), stakingtypes.Unbonded, val, true)
// call hooks for distribution init
err = s.distrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())
err = s.distrKeeper.Hooks().BeforeDelegationCreated(ctx, addrs[i], val.GetOperator())
err = s.distrKeeper.Hooks().AfterDelegationModified(ctx, addrs[i], val.GetOperator())
}

_ = staking.EndBlocker(ctx, s.stakingKeeper)
Expand Down
Loading

0 comments on commit 226b0f0

Please sign in to comment.