atlas: evidence (#8561)

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
Marko 2021-02-15 13:51:42 +00:00 committed by GitHub
parent a534a960db
commit b4690d8ec6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 273 additions and 0 deletions

58
.github/workflows/atlas.yml vendored Normal file
View File

@ -0,0 +1,58 @@
name: Atlas
# Atlas checks if a modules atlas manifest has been touched, if so it publishes the updated version
on:
push:
branches:
- master
paths:
- "x/**/atlas/*"
pull_request:
paths:
- "x/**/atlas/*"
jobs:
auth:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
PATTERNS: |
x/auth/atlas/**
- uses: marbar3778/atlas_action@main
with:
token: ${{ secrets.ATLAS_TOKEN }}
path: ./x/auth/atlas/atlas.toml
dry-run: ${{ github.event_name != 'pull_request' }}
if: env.GIT_DIFF
bank:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
PATTERNS: |
x/bank/atlas/**
- uses: marbar3778/atlas_action@main
with:
token: ${{ secrets.ATLAS_TOKEN }}
path: ./x/bank/atlas/atlas.toml
dry-run: ${{ github.event_name != 'pull_request' }}
if: env.GIT_DIFF
evidence:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
PATTERNS: |
x/evidence/atlas/**
- uses: marbar3778/atlas_action@main
with:
token: ${{ secrets.ATLAS_TOKEN }}
path: ./x/evidence/atlas/manifest.toml
dry-run: ${{ github.event_name != 'pull_request' }}
if: env.GIT_DIFF

View File

@ -0,0 +1,167 @@
# x/evidence
The `x/evidence` module is responsible for handling multi-asset coin transfers between
accounts and tracking special-case pseudo-transfers which must work differently
with particular kinds of accounts.
## Usage
1. Import the module.
```go
import (
"github.com/cosmos/cosmos-sdk/x/evidence"
evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
)
```
2. Add `AppModuleBasic` to your `ModuleBasics`.
```go
var (
ModuleBasics = module.NewBasicManager(
// ...
evidence.AppModuleBasic{},
}
)
```
3. Add the evidence keeper to your apps struct.
```go
type app struct {
// ...
EvidenceKeeper evidencekeeper.Keeper
// ...
}
```
4. Add the evidence store key to the group of store keys.
```go
func NewApp(...) *App {
// ...
keys := sdk.NewKVStoreKeys(
evidencetypes.StoreKey,
)
// ...
}
```
5. Create the keeper. Note, the `x/evidence` module depends on the `x/staking` and `x/slashing` modules. Evidence has expected interfaces, these interfaces are linked to slashing and staking. You can find these interfaces [here](https://github.com/cosmos/cosmos-sdk/blob/v0.41.0/x/evidence/types/expected_keepers.go)
```go
func NewApp(...) *App {
// ...
// create evidence keeper with router
evidenceKeeper := evidencekeeper.NewKeeper(
appCodec, keys[evidencetypes.StoreKey], &app.StakingKeeper, app.SlashingKeeper,
)
}
```
6. Add the `x/evidence` module to the app's `ModuleManager`.
```go
func NewApp(...) *App {
// ...
app.mm = module.NewManager(
// ...
evidence.NewAppModule(app.EvidenceKeeper),
// ...
)
}
```
7. Set the `x/evidence` module begin blocker order.
```go
func NewApp(...) *App {
// ...
app.mm.SetOrderBeginBlockers(
// ...
evidencetypes.ModuleName,
// ...
)
}
```
8. Set the `x/evidence` module genesis order.
```go
func NewApp(...) *App {
// ...
app.mm.SetOrderInitGenesis(..., evidencetypes.ModuleName, ...)
}
```
9. Add the `x/evidence` module to the simulation manager (if you have one set).
```go
func NewApp(...) *App {
// ...
app.sm = module.NewSimulationManager(
// ...
evidence.NewAppModule(app.EvidenceKeeper),
// ...
)
}
## Genesis
The `x/evidence` module defines its genesis state as follows:
```proto
type GenesisState struct {
// evidence defines all the evidence at genesis.
Evidence []*types.Any `protobuf:"bytes,1,rep,name=evidence,proto3" json:"evidence,omitempty"`
}
```
## Messages
<!-- todo: change to v0.41 when its available -->
View supported messages at [docs.cosmos.network/v0.40/modules/evidence](https://docs.cosmos.network/v0.40/modules/evidence/03_messages.html)
## Client
Evidence supports querying of old evidence and submission of new evidence. There are two queries. One for all the evidence, and one for a specific piece of evidence.
### CLI
The evidence module supports the blow command to query evidence.
```sh
Usage:
app query evidence [flags]
Flags:
--count-total count total number of records in evidence to query for
--height int Use a specific height to query state at (this can error if the node is pruning state)
-h, --help help for evidence
--limit uint pagination limit of evidence to query for (default 100)
--node string <host>:<port> to Tendermint RPC interface for this chain (default "tcp://localhost:26657")
--offset uint pagination offset of evidence to query for
-o, --output string Output format (text|json) (default "text")
--page uint pagination page of evidence to query for. This sets offset to a multiple of limit (default 1)
--page-key string pagination page-key of evidence to query for
```
### REST
Evidence REST API supports only queries of evidence. To submit evidence please use gRPC or the cli.
### gRPC
Evidence supports both querying and submitting transactions via gRPC
#### Query
[gRPC query](https://docs.cosmos.network/master/core/proto-docs.html#cosmos/evidence/v1beta1/query.proto)
#### Tx
[gRPC Tx](https://docs.cosmos.network/master/core/proto-docs.html#cosmos-evidence-v1beta1-tx-proto)
View supported messages at [docs.cosmos.network/v0.40/modules/evidence](https://docs.cosmos.network/v0.40/modules/evidence/03_messages.html)

View File

@ -0,0 +1,48 @@
[module]
# Name of the module. (Required)
name = "x/evidence"
# Description of the module. (Optional)
description = "The evidence module is responsible for storing and handling evidence of misbeaviour."
# Link to where the module is located, it can also be a link to your project. (Optional)
homepage = "https://github.com/cosmos/cosmos-sdk"
#List of key words describing your module (Optional)
keywords = [
"evidence",
"misbeaviour",
"accountability"
]
[bug_tracker]
# A URL to a site that provides information or guidance on how to submit or deal
# with security vulnerabilities and bug reports.
url = "https://github.com/cosmos/cosmos-sdk/issues"
# To list multiple authors, multiple [[authors]] need to be created
[[authors]]
# Name of one of the authors. Typically their Github name. (Required)
name = "alexanderbez"
[[authors]]
name = "fedekunze"
[[authors]]
name = "aaronc"
[version]
# The repository field should be a URL to the source repository for your module.
# Typically, this will point to the specific GitHub repository release/tag for the
# module, although this is not enforced or required. (Required)
repo = "https://github.com/cosmos/cosmos-sdk"
# The documentation field specifies a URL to a website hosting the module's documentation. (Optional)
documentation = "https://raw.githubusercontent.com/cosmos/cosmos-sdk/master/x/evidence/atlas/atlas-v0.41.x.md"
# The module version to be published. (Required)
version = "v0.41"
# An optional Cosmos SDK version compatibility may be provided. (Optional)
sdk_compat = "v0.41"