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>
  • Loading branch information
4 people committed Mar 12, 2024
1 parent 64f5651 commit ab7236d
Show file tree
Hide file tree
Showing 15 changed files with 1,851 additions and 195 deletions.
14 changes: 9 additions & 5 deletions app/provider/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

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

Expand Down Expand Up @@ -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()
Expand Down
14 changes: 13 additions & 1 deletion proto/interchain_security/ccv/provider/v1/provider.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -313,4 +315,14 @@ message ConsumerValidator {
int64 power = 2;
// public key the validator uses on the consumer chain during this epoch
tendermint.crypto.PublicKey consumer_public_key = 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 ab7236d

Please sign in to comment.