Skip to content

Commit

Permalink
feat!: add PSS reward distribution spike (#1632)
Browse files Browse the repository at this point in the history
* PSS reward distribution

* "add optin mapping to test"

* Update app/provider/app.go

Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com>

* docs

* add TODO

* fix Dos vector in IBCMiddlewarea

* add reformat

* fix DOS issue and make integration tests pass

* doc

* add integration test

* doc

* Compute total vp per consumer

* add comments

* remove opt-in comments and add TODOs

* format

* Update x/ccv/provider/keeper/distribution.go

Co-authored-by: insumity <karolos@informal.systems>

* add UT + doc

* Update tests/integration/distribution.go

Co-authored-by: insumity <karolos@informal.systems>

* Update tests/integration/distribution.go

Co-authored-by: insumity <karolos@informal.systems>

* nits

* Update x/ccv/provider/ibc_middleware.go

Co-authored-by: Marius Poke <marius.poke@posteo.de>

* add panics in IBC Middleware ICS4wrapper funcs

* address comments

---------

Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com>
Co-authored-by: insumity <karolos@informal.systems>
Co-authored-by: Marius Poke <marius.poke@posteo.de>
4 people committed Mar 8, 2024
1 parent 400c9a0 commit a70d162
Showing 15 changed files with 1,845 additions and 190 deletions.
14 changes: 9 additions & 5 deletions app/provider/app.go
Original file line number Diff line number Diff line change
@@ -102,6 +102,7 @@ import (

appencoding "github.com/cosmos/interchain-security/v4/app/encoding"
testutil "github.com/cosmos/interchain-security/v4/testutil/integration"
"github.com/cosmos/interchain-security/v4/x/ccv/provider"
ibcprovider "github.com/cosmos/interchain-security/v4/x/ccv/provider"
ibcproviderclient "github.com/cosmos/interchain-security/v4/x/ccv/provider/client"
ibcproviderkeeper "github.com/cosmos/interchain-security/v4/x/ccv/provider/keeper"
@@ -470,12 +471,15 @@ func New(
app.BankKeeper,
scopedTransferKeeper,
)
transferModule := transfer.NewAppModule(app.TransferKeeper)
ibcmodule := transfer.NewIBCModule(app.TransferKeeper)

// Add an IBC middleware callback to track the consumer rewards
var transferStack porttypes.IBCModule
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = provider.NewIBCMiddleware(transferStack, app.ProviderKeeper)

// create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, ibcmodule)
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferStack)
ibcRouter.AddRoute(providertypes.ModuleName, providerModule)
app.IBCKeeper.SetRouter(ibcRouter)

@@ -514,7 +518,7 @@ func New(
evidence.NewAppModule(app.EvidenceKeeper),
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
transferModule,
transfer.NewAppModule(app.TransferKeeper),
providerModule,
)

@@ -610,7 +614,7 @@ func New(
params.NewAppModule(app.ParamsKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
ibc.NewAppModule(app.IBCKeeper),
transferModule,
transfer.NewAppModule(app.TransferKeeper),
)

app.sm.RegisterStoreDecoders()
13 changes: 13 additions & 0 deletions proto/interchain_security/ccv/provider/v1/provider.proto
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@ import "ibc/lightclients/tendermint/v1/tendermint.proto";
import "tendermint/crypto/keys.proto";
import "cosmos/evidence/v1beta1/evidence.proto";
import "cosmos/base/v1beta1/coin.proto";
import "amino/amino.proto";


//
// Note any type defined in this file is ONLY used internally to the provider CCV module.
@@ -300,3 +302,14 @@ message ConsumerAddrsToPrune {
uint64 vsc_id = 2;
AddressList consumer_addrs = 3;
}

// ConsumerRewardsAllocation stores the rewards allocated by a consumer chain
// to the consumer rewards pool. It is used to allocate the tokens to the consumer
// opted-in validators and the community pool during BeginBlock.
message ConsumerRewardsAllocation {
repeated cosmos.base.v1beta1.DecCoin rewards = 1 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"
];
}
Loading

0 comments on commit a70d162

Please sign in to comment.