-
Notifications
You must be signed in to change notification settings - Fork 12
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
docs: add integrate docs #190
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
53368c5
impl template doc
neitdung caca548
Merge branch 'main' of https://github.com/osmosis-labs/mesh-security-…
neitdung 4a46fb4
add integrate guide for mesh security module
neitdung 82a281b
add integrate guide for mesh security provider module
neitdung f8bebde
add integrate guide for all mesh security modules
neitdung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,152 @@ | ||
# Meshi-security | ||
# Mesh-security | ||
Cosmos module implementation | ||
|
||
# Integrate the mesh security module | ||
|
||
## Prerequisites | ||
Projects that want to integrate the meshsecurity module onto their Cosmos SDK chain must enable the following modules: | ||
- [x/staking](https://github.com/cosmos/cosmos-sdk/tree/main/x/staking) | ||
- [x/auth](https://github.com/cosmos/cosmos-sdk/tree/main/x/auth) | ||
- [x/bank](https://github.com/cosmos/cosmos-sdk/tree/main/x/bank) | ||
- [x/wasm](github.com/CosmWasm/wasmd/x/wasm) | ||
|
||
## Configuring and Adding Module | ||
1. Add the mesh security package to the go.mod and install it. | ||
``` | ||
require ( | ||
... | ||
github.com/osmosis-labs/mesh-security | ||
... | ||
) | ||
``` | ||
|
||
2. Add the following modules to `app.go` | ||
``` | ||
import ( | ||
... | ||
"github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity" | ||
meshseckeeper "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/keeper" | ||
meshsectypes "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" | ||
... | ||
) | ||
``` | ||
3. In `app.go`: Register the AppModule for the mesh security module. | ||
``` | ||
ModuleBasics = module.NewBasicManager( | ||
... | ||
meshsecurity.AppModuleBasic{}, | ||
... | ||
) | ||
``` | ||
4. In `app.go`: Add module account permissions: | ||
``` | ||
maccPerms = map[string][]string{ | ||
... | ||
meshsectypes.ModuleName: {authtypes.Minter, authtypes.Burner} | ||
} | ||
``` | ||
5. In `app.go`: Add mesh security keeper. | ||
``` | ||
type App struct { | ||
... | ||
MeshSecKeeper *meshseckeeper.Keeper | ||
... | ||
} | ||
``` | ||
6. In `app.go`: Add mesh security store key. | ||
``` | ||
keys := sdk.NewKVStoreKeys( | ||
... | ||
meshsectypes.StoreKey, | ||
... | ||
) | ||
``` | ||
7. In `app.go`: Instantiate mesh security keeper | ||
``` | ||
app.MeshSecKeeper = meshseckeeper.NewKeeper( | ||
app.appCodec, | ||
keys[meshsectypes.StoreKey], | ||
memKeys[meshsectypes.MemStoreKey], | ||
app.BankKeeper, | ||
app.StakingKeeper, | ||
&app.WasmKeeper, // ensure this is a pointer as we instantiate the keeper a bit later | ||
authtypes.NewModuleAddress(govtypes.ModuleName).String(), | ||
) | ||
``` | ||
8. In `app.go`: Add the mesh security module to the app manager instantiation. | ||
``` | ||
app.mm = module.NewManager( | ||
... | ||
meshsecurity.NewAppModule(appCodec, app.MeshSecKeeper), | ||
... | ||
) | ||
``` | ||
9. In `app.go`: Add the module as the final element to the following: | ||
- SetOrderBeginBlockers | ||
- SetOrderEndBlockers | ||
- SetOrderInitGenesis | ||
``` | ||
// Add mesh security to begin blocker logic | ||
app.moduleManager.SetOrderBeginBlockers( | ||
... | ||
meshsectypes.ModuleName, | ||
... | ||
) | ||
|
||
// Add mesh security to end blocker logic | ||
app.moduleManager.SetOrderEndBlockers( | ||
... | ||
meshsectypes.ModuleName, | ||
... | ||
) | ||
|
||
// Add mesh security to init genesis logic | ||
app.moduleManager.SetOrderInitGenesis( | ||
... | ||
meshsectypes.ModuleName, | ||
... | ||
) | ||
``` | ||
10. In `app.go`: Add the mesh security staking decorator to the slashing module. | ||
``` | ||
app.SlashingKeeper = slashingkeeper.NewKeeper( | ||
appCodec, | ||
legacyAmino, | ||
keys[slashingtypes.StoreKey], | ||
// decorate the sdk keeper to capture all jail/ unjail events for MS | ||
meshseckeeper.NewStakingDecorator(app.StakingKeeper, app.MeshSecKeeper), | ||
authtypes.NewModuleAddress(govtypes.ModuleName).String(), | ||
) | ||
``` | ||
11. In `app.go`: Add the mesh security hooks to the staking module. | ||
``` | ||
app.StakingKeeper.SetHooks( | ||
stakingtypes.NewMultiStakingHooks( | ||
... | ||
// register hook to capture valset updates | ||
app.MeshSecKeeper.Hooks() | ||
), | ||
) | ||
``` | ||
12. In `app.go`: Add the mesh security hooks to the evidence module. | ||
``` | ||
evidenceKeeper := evidencekeeper.NewKeeper( | ||
... | ||
// decorate the SlashingKeeper to capture the tombstone event | ||
meshseckeeper.CaptureTombstoneDecorator(app.MeshSecKeeper, app.SlashingKeeper, app.StakingKeeper), | ||
) | ||
``` | ||
13. In `app.go`: Add the mesh security wasm message handler decorator to the wasm module. | ||
``` | ||
meshMessageHandler := wasmkeeper.WithMessageHandlerDecorator(func(nested wasmkeeper.Messenger) wasmkeeper.Messenger { | ||
return wasmkeeper.NewMessageHandlerChain( | ||
meshseckeeper.NewIntegrityHandler(app.MeshSecKeeper), | ||
nested, | ||
meshseckeeper.NewDefaultCustomMsgHandler(app.MeshSecKeeper), | ||
) | ||
}) | ||
wasmOpts = append(wasmOpts, meshMessageHandler, | ||
// add support for the mesh-security queries | ||
wasmkeeper.WithQueryHandlerDecorator(meshseckeeper.NewQueryDecorator(app.MeshSecKeeper, app.SlashingKeeper)), | ||
) | ||
``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be both provider and consumer