Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(incentives): endorsement switch param #1802

Closed
wants to merge 67 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
7cf53ae
bumped ibc to v8
mtsitrin Jan 14, 2025
53ea151
go mod tidy passes
mtsitrin Jan 14, 2025
f9a7c2f
more deps. log and db
mtsitrin Jan 14, 2025
0439798
updating math dep
mtsitrin Jan 14, 2025
9d3eb5f
updating keepers
mtsitrin Jan 15, 2025
85d051e
updated expected keepers
mtsitrin Jan 17, 2025
2553c17
cleared some codecs
mtsitrin Jan 21, 2025
98026ba
updated math
mtsitrin Jan 21, 2025
cdf62d7
updated dymns
mtsitrin Jan 21, 2025
278cbb1
semi handled eibc
mtsitrin Jan 21, 2025
82e6f4d
updated module.go files
mtsitrin Jan 21, 2025
e08f28c
more support
mtsitrin Jan 21, 2025
14c25a6
done with streamer
mtsitrin Jan 21, 2025
e8dc18a
sponsorship
mtsitrin Jan 21, 2025
fc6a13b
cleaned legacyTx
mtsitrin Jan 21, 2025
c139df4
rollapp cleanup
mtsitrin Jan 21, 2025
3babcfd
cleanip
mtsitrin Jan 21, 2025
a7f6e52
removed unneeded deps
mtsitrin Jan 23, 2025
7f5ba05
disabled eth ante handlers
mtsitrin Jan 26, 2025
4b53251
fixed modules setup
mtsitrin Jan 26, 2025
5881dbf
app WIP
mtsitrin Jan 26, 2025
5fe77f7
keepers pass
mtsitrin Jan 26, 2025
2526ed1
app pass
mtsitrin Jan 26, 2025
36df3fe
updated proto files
mtsitrin Jan 26, 2025
4700e6c
generated proto files
mtsitrin Jan 26, 2025
a1a656e
updated half modules
mtsitrin Jan 27, 2025
6a0bde1
updated modules part 2
mtsitrin Jan 27, 2025
639d88e
handled dymd command:
mtsitrin Jan 27, 2025
e994396
ante handler WIP
mtsitrin Jan 27, 2025
fcb16a0
fixed minor in modules
mtsitrin Feb 11, 2025
cb7e81f
ante handler
mtsitrin Feb 11, 2025
48447a2
fixed config
mtsitrin Feb 12, 2025
fc2d1db
fixed account prefix
mtsitrin Feb 12, 2025
5891387
its alive
mtsitrin Feb 12, 2025
c4af894
fixed sponserhip ut
mtsitrin Feb 13, 2025
00925e2
fixing UT WIP
mtsitrin Feb 16, 2025
2dd8710
cleanup
mtsitrin Feb 16, 2025
daad521
cleanup
mtsitrin Feb 16, 2025
d0cc9bc
go.mod
mtsitrin Feb 16, 2025
82c8e94
fixed IBC light client initialization
mtsitrin Feb 16, 2025
e62c6ae
fixed coinbase bug
mtsitrin Feb 17, 2025
dddaa60
ibcetesting pass
mtsitrin Feb 17, 2025
12c2b5b
fixing modules UT
mtsitrin Feb 17, 2025
9f7ce56
fixing tests
mtsitrin Feb 18, 2025
2390a85
fixing more UT
mtsitrin Feb 18, 2025
c2947e5
fixed dymns UT
mtsitrin Feb 18, 2025
bb71530
fixed dym to adym denom
mtsitrin Feb 18, 2025
6e1f9e7
wip
mtsitrin Feb 18, 2025
90e409a
wip streamer UT
mtsitrin Feb 18, 2025
429095b
disabled broken tests
mtsitrin Feb 19, 2025
aa4b23a
Merge branch 'main' into upgrading_to_v50
mtsitrin Feb 19, 2025
df6d2e8
cleanup
mtsitrin Feb 19, 2025
1b191f5
more cleanup
mtsitrin Feb 19, 2025
8099a3f
minor fix
mtsitrin Feb 19, 2025
d7fbcb9
linter
mtsitrin Feb 19, 2025
f28df2f
linter fix
mtsitrin Feb 19, 2025
ae9c815
feat(sponsorship): added endorsement yeilding
keruch Feb 21, 2025
839f8e6
feat(sponsorship): proto files WRT ADR
keruch Feb 26, 2025
6777130
feat(sponsorship): proto files WRT ADR 2
keruch Feb 26, 2025
b378da7
feat(sponsorship): MsgClaimRewards
keruch Feb 27, 2025
ccca304
impl + start tests
keruch Feb 28, 2025
a9d696d
feat(sponsorship): unit tests
keruch Mar 5, 2025
5565b62
Merge branch 'main' into kirill/endorsement-yeild
keruch Mar 7, 2025
3c971c3
merge commit
keruch Mar 7, 2025
f5348cd
param switch for endorsement mode
zale144 Mar 26, 2025
71226a0
Merge branch 'main' into zale144/1729-endorsement-switch-param
zale144 Mar 26, 2025
c5c9471
merge leftover
zale144 Mar 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"cosmossdk.io/log"

flags "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/flags"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
ethflags "github.com/evmos/ethermint/server/flags"

Expand Down Expand Up @@ -62,7 +62,6 @@ import (
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types"
appparams "github.com/dymensionxyz/dymension/v3/app/params"
"github.com/evmos/ethermint/x/evm"
evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
evmtypes "github.com/evmos/ethermint/x/evm/types"
Expand All @@ -79,6 +78,8 @@ import (
txfeestypes "github.com/osmosis-labs/osmosis/v15/x/txfees/types"
"github.com/spf13/cast"

appparams "github.com/dymensionxyz/dymension/v3/app/params"

"github.com/dymensionxyz/dymension/v3/x/bridgingfee"
delayedackmodule "github.com/dymensionxyz/dymension/v3/x/delayedack"
delayedackkeeper "github.com/dymensionxyz/dymension/v3/x/delayedack/keeper"
Expand Down Expand Up @@ -388,6 +389,7 @@ func (a *AppKeepers) InitKeepers(
a.EpochsKeeper,
a.TxFeesKeeper,
a.RollappKeeper,
a.IROKeeper,
)

a.IROKeeper = irokeeper.NewKeeper(
Expand Down
8 changes: 8 additions & 0 deletions proto/dymensionxyz/dymension/incentives/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ message Params {
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "cosmossdk.io/math.Int"
];

enum EndorsementMode {
EndorsementModeRollapp = 0;
EndorsementModeRollappAndIRO = 1;
}

// EndorsementMode switches between endorsing only active Rollapps and endorsing both active Rollapps and IROs
EndorsementMode endorsement_mode = 5;
}
8 changes: 8 additions & 0 deletions x/incentives/keeper/gauge_rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func (k Keeper) calculateRollappGaugeRewards(ctx sdk.Context, gauge types.Gauge,
if !found {
return sdk.Coins{}, fmt.Errorf("gauge %d: rollapp %s not found", gauge.Id, gauge.GetRollapp().RollappId)
}

_, isIRO := k.ik.GetPlanByRollapp(ctx, gauge.GetRollapp().RollappId)

if isIRO && k.EndorsementMode(ctx) != types.Params_EndorsementModeRollappAndIRO {
ctx.Logger().Debug("IROs are not currently endorsed")
return sdk.Coins{}, nil
}

// Ignore the error since the owner must always be valid in x/rollapp
owner := rollapp.Owner

Expand Down
13 changes: 12 additions & 1 deletion x/incentives/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,20 @@ type Keeper struct {
ek types.EpochKeeper
tk types.TxFeesKeeper
rk types.RollappKeeper
ik types.IROKeeper
}

// NewKeeper returns a new instance of the incentive module keeper struct.
func NewKeeper(storeKey storetypes.Key, paramSpace paramtypes.Subspace, bk types.BankKeeper, lk types.LockupKeeper, ek types.EpochKeeper, txfk types.TxFeesKeeper, rk types.RollappKeeper) *Keeper {
func NewKeeper(
storeKey storetypes.Key,
paramSpace paramtypes.Subspace,
bk types.BankKeeper,
lk types.LockupKeeper,
ek types.EpochKeeper,
txfk types.TxFeesKeeper,
rk types.RollappKeeper,
ik types.IROKeeper,
) *Keeper {
if !paramSpace.HasKeyTable() {
paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable())
}
Expand All @@ -40,6 +50,7 @@ func NewKeeper(storeKey storetypes.Key, paramSpace paramtypes.Subspace, bk types
ek: ek,
tk: txfk,
rk: rk,
ik: ik,
}
}

Expand Down
5 changes: 5 additions & 0 deletions x/incentives/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ func (k Keeper) DistrEpochIdentifier(ctx sdk.Context) (res string) {
k.paramSpace.Get(ctx, types.KeyDistrEpochIdentifier, &res)
return
}

func (k Keeper) EndorsementMode(ctx sdk.Context) (res types.Params_EndorsementMode) {
k.paramSpace.Get(ctx, types.KeyEndorsementMode, &res)
return
}
7 changes: 4 additions & 3 deletions x/incentives/types/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ var (
// DYM represents 1 DYM
DYM = math.NewIntWithDecimal(1, 18)

DefaultCreateGaugeFee = DYM.MulRaw(1) // 1 DYM
DefaultAddToGaugeFee = math.ZeroInt() // 0 DYM
DefaultAddDenomFee = DYM // 1 DYM
DefaultCreateGaugeFee = DYM.MulRaw(1) // 1 DYM
DefaultAddToGaugeFee = math.ZeroInt() // 0 DYM
DefaultAddDenomFee = DYM // 1 DYM
DefaultEndorsementMode = Params_EndorsementModeRollapp
)

const DefaultDistrEpochIdentifier = "week"
9 changes: 7 additions & 2 deletions x/incentives/types/expected_keepers.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package types

import (
context "context"
time "time"
"context"
"time"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
epochstypes "github.com/osmosis-labs/osmosis/v15/x/epochs/types"

irotypes "github.com/dymensionxyz/dymension/v3/x/iro/types"
lockuptypes "github.com/dymensionxyz/dymension/v3/x/lockup/types"
rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types"
)
Expand Down Expand Up @@ -42,3 +43,7 @@ type TxFeesKeeper interface {
type RollappKeeper interface {
GetRollapp(ctx sdk.Context, rollappId string) (rollapptypes.Rollapp, bool)
}

type IROKeeper interface {
GetPlanByRollapp(ctx sdk.Context, rollappId string) (irotypes.Plan, bool)
}
18 changes: 17 additions & 1 deletion x/incentives/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var (
KeyCreateGaugeFee = []byte("CreateGaugeFee")
KeyAddToGaugeFee = []byte("AddToGaugeFee")
KeyAddDenomFee = []byte("AddDenomFee")
KeyEndorsementMode = []byte("EndorsementMode")
)

// ParamKeyTable returns the key table for the incentive module's parameters.
Expand All @@ -24,12 +25,13 @@ func ParamKeyTable() paramtypes.KeyTable {
}

// NewParams takes an epoch distribution identifier, then returns an incentives Params struct.
func NewParams(distrEpochIdentifier string, createGaugeFee, addToGaugeFee, addDenomFee math.Int) Params {
func NewParams(distrEpochIdentifier string, createGaugeFee, addToGaugeFee, addDenomFee math.Int, endorsementMode Params_EndorsementMode) Params {
return Params{
DistrEpochIdentifier: distrEpochIdentifier,
CreateGaugeBaseFee: createGaugeFee,
AddToGaugeBaseFee: addToGaugeFee,
AddDenomFee: addDenomFee,
EndorsementMode: endorsementMode,
}
}

Expand All @@ -40,6 +42,7 @@ func DefaultParams() Params {
CreateGaugeBaseFee: DefaultCreateGaugeFee,
AddToGaugeBaseFee: DefaultAddToGaugeFee,
AddDenomFee: DefaultAddDenomFee,
EndorsementMode: DefaultEndorsementMode,
}
}

Expand All @@ -57,6 +60,9 @@ func (p Params) Validate() error {
if err := validateAddDenomFee(p.AddDenomFee); err != nil {
return err
}
if err := validateEndorsementMode(p.EndorsementMode); err != nil {
return err
}
return nil
}

Expand All @@ -67,6 +73,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
paramtypes.NewParamSetPair(KeyCreateGaugeFee, &p.CreateGaugeBaseFee, validateCreateGaugeFeeInterface),
paramtypes.NewParamSetPair(KeyAddToGaugeFee, &p.AddToGaugeBaseFee, validateAddToGaugeFeeInterface),
paramtypes.NewParamSetPair(KeyAddDenomFee, &p.AddDenomFee, validateAddDenomFee),
paramtypes.NewParamSetPair(KeyEndorsementMode, &p.EndorsementMode, validateEndorsementMode),
}
}

Expand Down Expand Up @@ -102,3 +109,12 @@ func validateAddDenomFee(i interface{}) error {
}
return nil
}

func validateEndorsementMode(i interface{}) error {
_, ok := i.(Params_EndorsementMode)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}

return nil
}
113 changes: 90 additions & 23 deletions x/incentives/types/params.pb.go

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

2 changes: 1 addition & 1 deletion x/sponsorship/types/expected_keepers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package types

import (
context "context"
"context"

sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
Expand Down
Loading