Skip to content

Commit

Permalink
Integration/capricorn (#172)
Browse files Browse the repository at this point in the history
* [capricorn] chores: bump wasmd to v0.20 and cosmos-sdk to temp v0.42.10 (#166)

* chores: bump wasmd to v0.20 and cosmos-sdk to temp v0.42.10

* chores: sort imports

* fix: add new iterator to wasmd supported features

* feat: add group module from regen/regen-ledger v1.0.0 (#167)

* [capricorn] Group module v2.0.0 (#169)

* feat: upgraded group module to v2.0.0

* fix: missing bank dependancy on group module

* fix: remove tests on unsupported variable length addresses

* fix: allow x/group router to route legacy messages

* chores: cleanup / deps update / typoz

* [capricorn] feat: group backport caelum changes (#170)

* feat: upgraded group module to v2.0.0

* fix: allow x/group router to route legacy messages

* chores: cleanup / deps update / typoz

* feat: backport proto changes

* chores: regenerate proto

* chores: go mod tidy

* feat: backport ./types changes

* feat: backport caelum changes + fix tests

* fix group v2.0.0. compatibility issues

* fix: adjust unused cosmos-sdk version to avoid confusion

Co-authored-by: kitty <[email protected]>

* docs: add draft of bls documentation (#150)

* chores: bump cosmos-sdk version to latest capricorn

* fix: group tx timeout (#173)

* feat: upgraded group module to v2.0.0

* fix: allow x/group router to route legacy messages

* fix: attempt to fix tx inclusion timeout

* fix: revert

* fix: non deterministic state on group vote & poll

Reworked TallyPoll to get rid of its internal map as maps are unordered
structures in go, making an inconsistent chain state when storing them.

Made sure to sort all the slices before storing them in state.

* chores: fix lint, codestyle, test speed

* chores: get rid of test cache on make test

* Update tx.go

Remove sort from MsgCreateGroupCmd and MsgUpdateGroupMembersCmd since the table structure will sort members automatically.

* chores: remove unused func

Co-authored-by: kitounliu <[email protected]>

* fix: hardcoded string checking for keys not found

* chores: delete unused starport config

* fix: better errors when bls validation fails (#174)

* fix: query group by creator wrong command name (#175)

* fix: remove unused poll.Status (#176)

* chores: remove Poll Status from proto file

* fix: add missing capability beginBlocker

* capricorn preps (#181)

* chores: remove group module

* chores: bump deps

- cosmos SDK to v0.42.11
- tendermint to v0.34.14
- wasmd to unreleased v0.22 (to get wasmvm v1.0.0-beta5)

* feat: add devgenesis.sh script (#183)

* fix: disable bls docs for now

* feat: add capricorn migration command (#182)

* feat: add capricorn-migrate command

removes stargatemigrate and gendelegations commands

* feat: initial wasm migration

add state validation before printing it

* feat: add removal of unused bridge contract code

* feat: set default gas prices in app.toml

When running migration command, this set a default gas price (specified
by --min-gas-price flag, with a default value of 500000000000afet), if
the config does not already contains any value.

* feat: add contract migration to capricorn-migrate

* feat: add list of codeIDs to be removed by migration

extend filtering to also remove potential contract instances

* feat: drop min-gas-prices migration step

* feat: add extra handy flags to migration command

* chores: add back genedelegations command

usefull for testing

* Update cmd/fetchd/cmd/capricornmigrate.go

Co-authored-by: Bryan White <[email protected]>

* fix: update usage

* fix: correct default amount of token to burn

* fix: correct number of default historical_entries

* fix: typo

* feat: add reconciliation contract v1 to removed contracts

* feat: update mobix contract configs unbonding_period (#186)

unbonding_period config was changed from nanoseconds to seconds,
so we update the config in the contract states (both staging and prod)
to reflect this change.

- before:

```
 $ jq -r '.app_state.wasm.contracts[]|select(.contract_info.code_id == "3").contract_state[]|select(.key == "636F6E666967").value' genesis_mainnet_orig.json  | base64 -d | jq
{
  "owner": "fetch1m3evl6dqkhmwtp597wq8hhr9vtdasaktaq6wlj",
  "chief_pausing_officer": "fetch1m9kf4s2gwpv07c6tndekxfc3vdjyup3zjggcgy",
  "denom": "nanomobx",
  "reward_rate": "8267196",
  "paused": false,
  "unbonding_period": "30000000000"
}
{
  "owner": "fetch1m3evl6dqkhmwtp597wq8hhr9vtdasaktaq6wlj",
  "chief_pausing_officer": "fetch1m9kf4s2gwpv07c6tndekxfc3vdjyup3zjggcgy",
  "denom": "nanomobx",
  "reward_rate": "8267196",
  "paused": false,
  "unbonding_period": "1814400000000000"
}
```

- after:

```
$ jq -r '.app_state.wasm.contracts[]|select(.contract_info.code_id == "3").contract_state[]|select(.key == "636F6E666967").value' genesis_migrated_mobix.json  | base64 -d | jq
    {
      "chief_pausing_officer": "fetch1m9kf4s2gwpv07c6tndekxfc3vdjyup3zjggcgy",
      "denom": "nanomobx",
      "owner": "fetch1m3evl6dqkhmwtp597wq8hhr9vtdasaktaq6wlj",
      "paused": false,
      "reward_rate": "8267196",
      "unbonding_period": "30"
    }
    {
      "chief_pausing_officer": "fetch1m9kf4s2gwpv07c6tndekxfc3vdjyup3zjggcgy",
      "denom": "nanomobx",
      "owner": "fetch1m3evl6dqkhmwtp597wq8hhr9vtdasaktaq6wlj",
      "paused": false,
      "reward_rate": "8267196",
      "unbonding_period": "1814400"
    }
```

* fix: only overwrite initial_height if actually given

* feat: add migration for new slashing double sign penalty value

* docs: update migrate cmd description

* fix: keep consensus_params evidence.max_bytes in sync with block.max_bytes

* fix: review comments

* feat: lift wasm upload and instantiate restrictions (#188)

Co-authored-by: Bryan White <[email protected]>

* docs: updated network information (#180)

* docs: updated network information

* fixed release version number

* removed references to v2 main-net

* removed more references to v2 ledger

* reverted prev change

* fix: add capricorn last minute infos

Co-authored-by: Flavien Binet <[email protected]>

* docs: update stargateworld url

* chores: set correct cosmos-sdk tag version

* feat: stake reconciliation migration CLI command (#187)

* chore: add package json for convenient installation of bats and supporting libs

* chore: add simple reconciliation migration test cases and fixtures

* feat: implement stake-reconciliation-migrate CLI command

Co-authored-by: Flavien Binet <[email protected]>

Co-authored-by: Flavien Binet <[email protected]>

Co-authored-by: kitty <[email protected]>
Co-authored-by: Joe <[email protected]>
Co-authored-by: kitounliu <[email protected]>
Co-authored-by: Bryan White <[email protected]>
Co-authored-by: Jonathan Ward <[email protected]>
  • Loading branch information
6 people authored Feb 2, 2022
1 parent 08ccbdc commit 6acfddc
Show file tree
Hide file tree
Showing 32 changed files with 2,714 additions and 324 deletions.
141 changes: 122 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#!/usr/bin/make -f

PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation')
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
VERSION := $(shell echo $(shell git describe --tags))
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
BINDIR ?= $(GOPATH)/bin
BUILDDIR ?= $(CURDIR)/build
APP_DIR = ./app
MOCKS_DIR = $(CURDIR)/tests/mocks
HTTPS_GIT := https://github.com/fetchai/fetchd.git
DOCKER_BUF := docker run -v $(shell pwd):/workspace --workdir /workspace bufbuild/buf
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)

export GO111MODULE = on

Expand Down Expand Up @@ -108,29 +115,68 @@ clean:
distclean: clean
rm -rf vendor/

########################################
### Testing


test: test-unit
test-all: check test-race test-cover
###############################################################################
### Tests & Simulation ###
###############################################################################

test: test-unit
test-all: test-unit test-ledger-mock test-race test-cover

TEST_PACKAGES=./...
TEST_TARGETS := test-unit test-unit-amino test-unit-proto test-ledger-mock test-race test-ledger test-race

# Test runs-specific rules. To add a new test target, just add
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
# append the new rule to the TEST_TARGETS list.
UNIT_TEST_ARGS = cgo ledger test_ledger_mock norace
AMINO_TEST_ARGS = ledger test_ledger_mock test_amino norace
LEDGER_TEST_ARGS = cgo ledger norace
LEDGER_MOCK_ARGS = ledger test_ledger_mock norace
TEST_RACE_ARGS = cgo ledger test_ledger_mock
ifeq ($(EXPERIMENTAL),true)
UNIT_TEST_ARGS += experimental
AMINO_TEST_ARGS += experimental
LEDGER_TEST_ARGS += experimental
LEDGER_MOCK_ARGS += experimental
TEST_RACE_ARGS += experimental
endif

test-unit:
@VERSION=$(VERSION) go test -mod=readonly -tags='ledger test_ledger_mock' ./...
test-unit: ARGS=-count=1 -tags='$(UNIT_TEST_ARGS)'
test-unit-amino: ARGS=-tags='${AMINO_TEST_ARGS}'
test-ledger: ARGS=-tags='${LEDGER_TEST_ARGS}'
test-ledger-mock: ARGS=-tags='${LEDGER_MOCK_ARGS}'
test-race: ARGS=-race -tags='${TEST_RACE_ARGS}'
test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION)

$(TEST_TARGETS): run-tests

SUB_MODULES = $(shell find . -type f -name 'go.mod' -print0 | xargs -0 -n1 dirname | sort)
CURRENT_DIR = $(shell pwd)
run-tests:
ifneq (,$(shell which tparse 2>/dev/null))
@echo "Unit tests"; \
for module in $(SUB_MODULES); do \
cd ${CURRENT_DIR}/$$module; \
go test -mod=readonly -json $(ARGS) $(TEST_PACKAGES) ./... | tparse; \
done
else
@echo "Unit tests"; \
for module in $(SUB_MODULES); do \
cd ${CURRENT_DIR}/$$module; \
go test -mod=readonly $(ARGS) $(TEST_PACKAGES) ./... ; \
done
endif

test-race:
@VERSION=$(VERSION) go test -mod=readonly -race -tags='ledger test_ledger_mock' ./...
.PHONY: run-tests test test-all $(TEST_TARGETS)

test-cover:
@go test -mod=readonly -timeout 30m -race -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock' ./...

format:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs goimports -w -local github.com/cosmos/cosmos-sdk
@export VERSION=$(VERSION);
@bash scripts/test_cover.sh
.PHONY: test-cover

benchmark:
@go test -mod=readonly -bench=. ./...
@go test -mod=readonly -bench=. $(PACKAGES_NOSIMULATION)
.PHONY: benchmark


########################################
Expand All @@ -151,3 +197,60 @@ localnet-stop:
.PHONY: all build-linux install install-debug \
go-mod-cache draw-deps clean build \
test test-all test-cover test-unit test-race


###############################################################################
### Protobuf ###
###############################################################################

containerProtoVer=v0.2
containerProtoImage=tendermintdev/sdk-proto-gen:$(containerProtoVer)
containerProtoGen=${PROJECT_NAME}-proto-gen-$(containerProtoVer)
containerProtoFmt=${PROJECT_NAME}-proto-fmt-$(containerProtoVer)
containerProtoGenSwagger=${PROJECT_NAME}-proto-gen-swagger-$(containerProtoVer)

proto-all: proto-gen proto-lint proto-check-breaking proto-format
.PHONY: proto-all proto-gen proto-gen-docker proto-lint proto-check-breaking proto-format

proto-gen:
@echo "Generating Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) sh ./scripts/protocgen.sh; fi

proto-format:
@echo "Formatting Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \
find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi

proto-format-direct:
find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \;

proto-lint:
@$(DOCKER_BUF) lint --error-format=json

proto-lint-direct:
@buf lint --error-format=json

proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=master

proto-check-breaking-direct:
@buf breaking --against '.git#branch=master'

GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
REGEN_COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master
COSMOS_PROTO_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/master/proto/cosmos

GOGO_PROTO_TYPES = third_party/proto/gogoproto
REGEN_COSMOS_PROTO_TYPES = third_party/proto/cosmos_proto
COSMOS_PROTO_TYPES = third_party/proto/cosmos

proto-update-deps:
@mkdir -p $(GOGO_PROTO_TYPES)
@curl -sSL $(GOGO_PROTO_URL)/gogoproto/gogo.proto > $(GOGO_PROTO_TYPES)/gogo.proto

@mkdir -p $(REGEN_COSMOS_PROTO_TYPES)
@curl -sSL $(REGEN_COSMOS_PROTO_URL)/cosmos.proto > $(REGEN_COSMOS_PROTO_TYPES)/cosmos.proto

@mkdir -p $(COSMOS_PROTO_TYPES)/base/query/v1beta1/
@curl -sSL $(COSMOS_PROTO_URL)/base/query/v1beta1/pagination.proto > $(COSMOS_PROTO_TYPES)/base/query/v1beta1/pagination.proto
@curl -sSL $(COSMOS_PROTO_URL)/base/v1beta1/coin.proto > $(COSMOS_PROTO_TYPES)/base/v1beta1/coin.proto
35 changes: 19 additions & 16 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,39 +1,34 @@
package app

import (
airdropkeeper "github.com/cosmos/cosmos-sdk/x/airdrop/keeper"
airdroptypes "github.com/cosmos/cosmos-sdk/x/airdrop/types"
"io"
"net/http"
"os"
"path/filepath"
"strings"

"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/spf13/cast"

abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

"strings"
"github.com/CosmWasm/wasmd/x/wasm"
wasmclient "github.com/CosmWasm/wasmd/x/wasm/client"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/airdrop"
airdropkeeper "github.com/cosmos/cosmos-sdk/x/airdrop/keeper"
airdroptypes "github.com/cosmos/cosmos-sdk/x/airdrop/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
Expand Down Expand Up @@ -89,9 +84,15 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
appparams "github.com/fetchai/fetchd/app/params"

abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

appparams "github.com/fetchai/fetchd/app/params"
)

const Name = "fetchd"
Expand Down Expand Up @@ -234,6 +235,8 @@ type App struct {

// the module manager
mm *module.Manager

configurator module.Configurator
}

// New returns a reference to an initialized Gaia.
Expand Down Expand Up @@ -363,7 +366,7 @@ func New(

// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
supportedFeatures := "staking,stargate"
supportedFeatures := "iterator,staking,stargate"
app.wasmKeeper = wasm.NewKeeper(
appCodec,
keys[wasm.StoreKey],
Expand Down Expand Up @@ -400,7 +403,6 @@ func New(
app.IBCKeeper.SetRouter(ibcRouter)

/**** Module Options ****/

// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
// we prefer to be more strict in what arguments the modules expect.
var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))
Expand Down Expand Up @@ -437,7 +439,7 @@ func New(
// CanWithdrawInvariant invariant.
// NOTE: staking module is required if HistoricalEntries param > 0
app.mm.SetOrderBeginBlockers(
upgradetypes.ModuleName, minttypes.ModuleName, airdroptypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, airdroptypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName,
)

Expand Down Expand Up @@ -468,7 +470,8 @@ func New(

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.mm.RegisterServices(module.NewConfigurator(app.MsgServiceRouter(), app.GRPCQueryRouter()))
app.configurator = module.NewConfigurator(app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)

// initialize stores
app.MountKVStores(keys)
Expand Down
Loading

0 comments on commit 6acfddc

Please sign in to comment.