GithubHelp home page GithubHelp logo

cosmos-plugins's Introduction

cosmos-plugins

cosmos-sdk plugins for versions >= 0.50.x

storechanges (blockheader, KV store changes)

Implements ABCIListener.

Allows saving StoreKVPair and the cometBFT header to a file for further processing.

type ABCIListener interface {
  ListenFinalizeBlock(ctx context.Context, req abci.RequestFinalizeBlock, res abci.ResponseFinalizeBlock) error
  ListenCommit(ctx context.Context, res abci.ResponseCommit, changeSet []*StoreKVPair) error
}

This tool requires access to a cometBFT node via RPC. It cannot function without one.

Usage

You must compile the plugin before use and configure your cosmos-sdk node (simd or other) to use your plugin.

## build
cd cosmos-plugins
go build -o ./cmd/storechanges/storechanges ./cmd/storechanges/main.go

# move it if you want
# mv storechanges <path>

## export path to plugin so the chain app can find it
export COSMOS_SDK_ABCI="<abs_path_to_parent_dir>/cmd/storechanges/storechanges"

Configuring your node: In your app.toml add these sections:

[streaming]

[streaming.abci]

# List of kv store keys to stream out via gRPC.
# The store key names MUST match the module's StoreKey name.
#
# Example:
# ["acc", "bank", "gov", "staking", "mint"[,...]]
# ["*"] to expose all keys.
keys = ["bank", "transfer"]

plugin = "abci"

# stop-node-on-err specifies whether to stop the node on message delivery error.
stop-node-on-err = true

Plugin configuration

Plugin is configured using environment variables. Here are the available options:

# check .envexample
COMET_RPC_URL = "tcp://localhost:26657" # comet node used for fetching block data 
STREAMING_DIR = "~/.storechanges" # output files will be stored to this directory

The listed values are also used as defaults.

Start node and plugins

Create a an env file before starting your node and export the variables.

cp .env.example .env
# make changes

Export the variables before starting your node (in the same terminal session) and start your node.

set -a
. .env
set +a

simd start

App configuration

If your node does not register streaming listeners you will need to add this snippet to your app.go:

// app/app.go
func NewSimApp(
  logger log.Logger,
  db dbm.DB,
  traceStore io.Writer,
  loadLatest bool,
  appOpts servertypes.AppOptions,
  baseAppOptions ...func(*baseapp.BaseApp),
) *SimApp {
  // ...

  keys := storetypes.NewKVStoreKeys(
    authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, crisistypes.StoreKey,
    minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
    govtypes.StoreKey, paramstypes.StoreKey, consensusparamtypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
    evidencetypes.StoreKey, circuittypes.StoreKey,
    authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey,
)

+  // register streaming services
+  if err := bApp.RegisterStreamingServices(appOpts, keys); err != nil {
+    panic(err)
+  }
    
   // ...
}

cosmos-plugins's People

Contributors

msalopek avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.