interchain-security

module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2022 License: Apache-2.0

README

Interchain Security

Go Report Card Security Rating Vulnerabilities Bugs Lines of Code Coverage

interchain-security houses the code for implementing Interchain Security. The repo is currently a WIP and targetting v1 of Interchain Security. For more details on the Interchain Security protocol, take a look at the specification.

CCV stands for cross chain validation and refers to the subset of Interchain Security related to the staking and slashing communication between the provider and consumer blockchains. The provider blockchain communicates staking changes to consumer blockchain(s), while the consumer blockchain may communicate slashing evidence to the provider blockchain.

The code for CCV is housed under x/ccv. The types folder contains types and related functions that are used by both provider and consumer chains, while the consumer module contains the code run by consumer chains and the provider module contains the code run by provider chain.

NOTE: At the moment the testing app may not be functional, please rely on the IBC testing suite to write unit tests for the moment.

Instructions

Prerequisites

## For OSX or Linux

# go 1.18 (https://formulae.brew.sh/formula/go)
brew install go@1.18
# jq (optional, for testnet) (https://formulae.brew.sh/formula/jq)
brew install jq
# docker (optional, for integration tests, testnet) (https://docs.docker.com/get-docker/)

Installing and running binaries

# install interchain-security-pd and interchain-security-cd binaries
make install
# run provider
interchain-security-pd
# run consumer
interchain-security-cd
# (if the above fail, ensure ~/go/bin on $PATH)
export PATH=$PATH:$(go env GOPATH)/bin

Inspect the Makefile if curious.

Running tests

# run all unit tests using make
make test
# run all unit tests using go
go test ./...
# run all unit tests with verbose output
go test -v ./..
# run all unit tests with coverage stats
go test -cover ./..
# run a single unit test
go test -run <test-suite-name>/<test-name> ./...
# example: run a single unit test
go test -run TestProviderTestSuite/TestPacketRoundtrip ./...
# run the integration tests
go run ./integration-tests/...
# run golang native fuzz tests (https://go.dev/doc/tutorial/fuzz)
go test -fuzz=<regex-to-match-test-name>

Linters and static analysis

Several analyzers are used on the code including CodeQL, SonarCloud, golangci-lint and gosec. Some of these are run on github when committing to PRs ect, but some tools are also applicable locally, and are built into golang.

# gofmt to format and simplify code (https://pkg.go.dev/cmd/gofmt)
gofmt -w -s -e .
# go vet to search for suspicious code (https://pkg.go.dev/cmd/vet)
go vet ./...

Some useful tools are included in the repository using pre-commit. pre-commit lets you run developer tools either on every git commit, or manually with pre-commit run --all-files. See the config for details. In this repo the hooks are not installed to git, as that can be cumbersome, but it is still possible to benefit from them.

## Prerequisites

# pre-commit
brew install pre-commit
# goimports (https://pkg.go.dev/golang.org/x/tools/cmd/goimports)
go install golang.org/x/tools/cmd/goimports@latest
# gocyclo (https://github.com/fzipp/gocyclo)
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
# go-critic https://github.com/go-critic/go-critic
go install github.com/go-critic/go-critic/cmd/gocritic@latest

## Run the tools

pre-commit run --all-files

Debugging

If using VSCode, see vscode-go/wiki/debugging to debug unit tests or go binaries.

More

More instructions will be added soon, in time for the testnet.

Learn more

Directories

Path Synopsis
app
cmd
testutil
x
ccv/provider/types
Package types is a reverse proxy.
Package types is a reverse proxy.
ccv/staking
Package staking defines a "wrapper" module around the Cosmos SDK's native x/staking module.
Package staking defines a "wrapper" module around the Cosmos SDK's native x/staking module.
types Module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL