Skip to content

Commit

Permalink
Merge pull request #57 from regen-network/15-test_upgrade_module_on_t…
Browse files Browse the repository at this point in the history
…estnet

#15 test upgrade module on testnet
  • Loading branch information
aaronc authored Jun 4, 2019
2 parents af03558 + c7eac3d commit 9335cc3
Show file tree
Hide file tree
Showing 30 changed files with 616 additions and 1,663 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Changed
- [\#166185199](https://www.pivotaltracker.com/story/show/166185199) Temporarily disable all custom modules beside `geo` because they need to be integrated with the new app module setup and this can be a good test case for a coordinated tesnet upgrade
- [\#163156528](https://www.pivotaltracker.com/story/show/163156528) Use stored geo shape for ESP results
- [\#164056249](https://www.pivotaltracker.com/story/show/164056249) Rename `agent` -> `group` module, align structure of groups with specification document
- [\#16](https://github.com/regen-network/regen-ledger/issues/16) The on-chain store data command now only works with graphs defined by the graph package
- [\#166185199](https://www.pivotaltracker.com/story/show/166185199) Integrate Cosmos staking modules, temporarily disable all custom modules beside `geo` because they need to be integrated with the new app module setup and this can be a good test case for a coordinated tesnet upgrade
- [\#15](https://github.com/regen-network/regen-ledger/issues/15) Test and debug upgrade module in Cosmos PR [\#4233](https://github.com/cosmos/cosmos-sdk/pull/4233) against an
internal testnet

### Added

Expand All @@ -33,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [\#17](https://github.com/regen-network/regen-ledger/issues/17) Add define property schema support
- [\#18](https://github.com/regen-network/regen-ledger/issues/18) Graph package and binary serialization format
- [\#27](https://github.com/regen-network/regen-ledger/issues/27) Create claim module
- [\#166185199](https://www.pivotaltracker.com/story/show/166185199) Integrate Cosmos staking modules

## [0.3.0] - 2018-01-09

Expand Down
171 changes: 163 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,170 @@
export GO111MODULE=on
PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true

install:
go install ./cmd/xrnd
go install ./cmd/xrncli
export GO111MODULE = on

# process build tags

build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
endif
endif
endif

ifeq ($(WITH_CLEVELDB),yes)
build_tags += gcc
endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

whitespace :=
whitespace += $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))

# process linker flags

ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=xrn \
-X github.com/cosmos/cosmos-sdk/version.ServerName=xrnd \
-X github.com/cosmos/cosmos-sdk/version.ClientName=xrncli \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"

ifeq ($(WITH_CLEVELDB),yes)
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'

# The below include contains the tools target.
include contrib/devtools/Makefile

all: install lint check

build: go.sum
ifeq ($(OS),Windows_NT)
go build -mod=readonly $(BUILD_FLAGS) -o build/xrnd.exe ./cmd/xrnd
go build -mod=readonly $(BUILD_FLAGS) -o build/xrncli.exe ./cmd/xrncli
else
go build -mod=readonly $(BUILD_FLAGS) -o build/xrnd ./cmd/xrnd
go build -mod=readonly $(BUILD_FLAGS) -o build/xrncli ./cmd/xrncli
endif

build-linux: go.sum
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build

install: go.sum check-ledger
go install -mod=readonly $(BUILD_FLAGS) ./cmd/xrnd
go install -mod=readonly $(BUILD_FLAGS) ./cmd/xrncli

install-debug: go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/xrndebug


########################################
### Tools & dependencies

go-mod-cache: go.sum
@echo "--> Download go modules to local cache"
@go mod download

go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
@go mod verify

draw-deps:
@# requires brew install graphviz or apt-get install graphviz
go get github.com/RobotsAndPencils/goviz
@goviz -i ./cmd/xrnd -d 2 | dot -Tpng -o dependency-graph.png

clean:
rm -rf snapcraft-local.yaml build/

distclean: clean
rm -rf vendor/

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


check: check-unit check-build
check-all: check check-race check-cover

check-unit:
@VERSION=$(VERSION) go test -mod=readonly -tags='ledger test_ledger_mock' ./...

check-race:
@VERSION=$(VERSION) go test -mod=readonly -race -tags='ledger test_ledger_mock' ./...

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

check-build: build
@go test -mod=readonly -p 4 `go list ./cli_test/...` -tags=cli_test


lint: ci-lint
ci-lint:
golangci-lint run
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
go mod verify

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

benchmark:
@go test -mod=readonly -bench=. ./...


########################################
### Local validator nodes using docker and docker-compose

build-docker-xrndnode:
$(MAKE) -C networks/local

# Run a 4-node testnet locally
localnet-start: localnet-stop
@if ! [ -f build/node0/xrnd/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/xrnd:Z tendermint/xrndnode testnet --v 4 -o . --starting-ip-address 192.168.10.2 ; fi
docker-compose up -d

# Stop testnet
localnet-stop:
docker-compose down

# include simulations
include sims.mk

.PHONY: all build-linux install install-debug \
go-mod-cache draw-deps clean \
check check-all check-build check-cover check-ledger check-unit check-race

test:
go test ./...

test_cover:
bash -x tests/test_cover.sh

lint:
go get -u golang.org/x/lint/golint
${GOPATH}/bin/golint -set_exit_status ./...
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ can be controlled directly by ecological contracts.

## Testnet Status

See [testnets/](./testnets)
See https://github.com/regen-network/testnets.
<br />
<br />
<br />
Expand Down
19 changes: 12 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/upgrade"
"github.com/regen-network/regen-ledger/index/postgresql"
"github.com/regen-network/regen-ledger/x/geo"
"github.com/regen-network/regen-ledger/x/upgrade"
"github.com/spf13/viper"
"github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/log"
Expand Down Expand Up @@ -66,6 +66,7 @@ func init() {
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
geo.AppModuleBasic{},
upgrade.AppModuleBasic{},
)
}

Expand Down Expand Up @@ -98,13 +99,13 @@ type XrnApp struct {
keyFeeCollection *sdk.KVStoreKey
keyParams *sdk.KVStoreKey
tkeyParams *sdk.TransientStoreKey
upgradeStoreKey *sdk.KVStoreKey
//dataStoreKey *sdk.KVStoreKey
//schemaStoreKey *sdk.KVStoreKey
//espStoreKey *sdk.KVStoreKey
geoStoreKey *sdk.KVStoreKey
//agentStoreKey *sdk.KVStoreKey
//proposalStoreKey *sdk.KVStoreKey
//upgradeStoreKey *sdk.KVStoreKey
//consortiumStoreKey *sdk.KVStoreKey

// keepers
Expand All @@ -118,13 +119,13 @@ type XrnApp struct {
govKeeper gov.Keeper
crisisKeeper crisis.Keeper
paramsKeeper params.Keeper
upgradeKeeper upgrade.Keeper
//dataKeeper data.Keeper
//schemaKeeper schema.Keeper
//espKeeper esp.Keeper
geoKeeper geo.Keeper
//agentKeeper group.Keeper
//proposalKeeper proposal.Keeper
//upgradeKeeper upgrade.Keeper
//consortiumKeeper consortium.Keeper

// the module manager
Expand Down Expand Up @@ -162,13 +163,13 @@ func NewXrnApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bo
keyFeeCollection: sdk.NewKVStoreKey(auth.FeeStoreKey),
keyParams: sdk.NewKVStoreKey(params.StoreKey),
tkeyParams: sdk.NewTransientStoreKey(params.TStoreKey),
upgradeStoreKey: sdk.NewKVStoreKey(upgrade.StoreKey),
//dataStoreKey: sdk.NewKVStoreKey("data"),
//schemaStoreKey: sdk.NewKVStoreKey("schema"),
//espStoreKey: sdk.NewKVStoreKey("esp"),
geoStoreKey: sdk.NewKVStoreKey("geo"),
//agentStoreKey: sdk.NewKVStoreKey("group"),
//proposalStoreKey: sdk.NewKVStoreKey("proposal"),
//upgradeStoreKey: sdk.NewKVStoreKey("upgrade"),
txDecoder: txDecoder,
}

Expand Down Expand Up @@ -196,12 +197,14 @@ func NewXrnApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bo
slashingSubspace, slashing.DefaultCodespace)
app.crisisKeeper = crisis.NewKeeper(crisisSubspace, invCheckPeriod, app.distrKeeper,
app.bankKeeper, app.feeCollectionKeeper)
app.upgradeKeeper = upgrade.NewKeeper(app.upgradeStoreKey, app.cdc)

// register the proposal types
govRouter := gov.NewRouter()
govRouter.AddRoute(gov.RouterKey, gov.ProposalHandler).
AddRoute(params.RouterKey, params.NewParamChangeProposalHandler(app.paramsKeeper)).
AddRoute(distr.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.distrKeeper))
AddRoute(distr.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.distrKeeper)).
AddRoute(upgrade.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.upgradeKeeper))
app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.paramsKeeper, govSubspace,
app.bankKeeper, &stakingKeeper, gov.DefaultCodespace, govRouter)

Expand Down Expand Up @@ -239,12 +242,13 @@ func NewXrnApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bo
slashing.NewAppModule(app.slashingKeeper, app.stakingKeeper),
staking.NewAppModule(app.stakingKeeper, app.feeCollectionKeeper, app.distrKeeper, app.accountKeeper),
geo.NewAppModule(app.geoKeeper),
upgrade.NewAppModule(app.upgradeKeeper),
)

// During begin block slashing happens after distr.BeginBlocker so that
// there is nothing left over in the validator fee pool, so as to keep the
// CanWithdrawInvariant invariant.
app.mm.SetOrderBeginBlockers(mint.ModuleName, distr.ModuleName, slashing.ModuleName)
app.mm.SetOrderBeginBlockers(upgrade.ModuleName, mint.ModuleName, distr.ModuleName, slashing.ModuleName)

app.mm.SetOrderEndBlockers(gov.ModuleName, staking.ModuleName)

Expand All @@ -260,10 +264,11 @@ func NewXrnApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bo
app.MountStores(app.keyMain, app.keyAccount, app.keyStaking, app.keyMint,
app.keyDistr, app.keySlashing, app.keyGov, app.keyFeeCollection,
app.keyParams, app.tkeyParams, app.tkeyStaking, app.tkeyDistr,
app.upgradeStoreKey,
app.geoStoreKey,
//app.schemaStoreKey, app.dataStoreKey,
//app.espStoreKey, app.geoStoreKey, app.agentStoreKey,
//app.proposalStoreKey, app.upgradeStoreKey,
//app.proposalStoreKey,
)

// initialize BaseApp
Expand Down
18 changes: 13 additions & 5 deletions cmd/xrncli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ import (
//agentclient "github.com/regen-network/regen-ledger/x/group/client"
//claimclient "github.com/regen-network/regen-ledger/x/claim/client"
//proposalclient "github.com/regen-network/regen-ledger/x/proposal/client"
//upgraderest "github.com/regen-network/regen-ledger/x/upgrade/client/rest"
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradecli "github.com/cosmos/cosmos-sdk/x/upgrade/client/cli"
upgraderest "github.com/cosmos/cosmos-sdk/x/upgrade/client/rest"
)

const (
Expand All @@ -57,7 +60,6 @@ const (
storeData = "data"
storeAgent = "group"
storeProposal = "proposal"
storeUpgrade = "upgrade"
)

func main() {
Expand All @@ -72,14 +74,20 @@ func main() {
config.Seal()

mc := []sdk.ModuleClient{
govClient.NewModuleClient(gv.StoreKey, cdc, paramcli.GetCmdSubmitProposal(cdc), distrcli.GetCmdSubmitProposal(cdc)),
geoclient.NewModuleClient(cdc),
govClient.NewModuleClient(gv.StoreKey, cdc,
paramcli.GetCmdSubmitProposal(cdc),
distrcli.GetCmdSubmitProposal(cdc),
upgradecli.GetCmdSubmitUpgradeProposal(cdc),
upgradecli.GetCmdSubmitCancelUpgradeProposal(cdc),
),
distClient.NewModuleClient(distcmd.StoreKey, cdc),
stakingclient.NewModuleClient(st.StoreKey, cdc),
mintclient.NewModuleClient(mint.StoreKey, cdc),
slashingclient.NewModuleClient(sl.StoreKey, cdc),
crisisclient.NewModuleClient(sl.StoreKey, cdc),
upgradeclient.NewModuleClient(upgrade.StoreKey, cdc),
//proposalclient.NewModuleClient(storeProposal, cdc),
geoclient.NewModuleClient(cdc),
//dataclient.NewModuleClient(storeData, cdc),
//agentclient.NewModuleClient(storeAgent, cdc),
//claimclient.NewModuleClient(storeClaim, cdc),
Expand Down Expand Up @@ -182,9 +190,9 @@ func registerRoutes(rs *lcd.RestServer) {
staking.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase)
slashing.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, rs.KeyBase)
gov.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, paramsrest.ProposalRESTHandler(rs.CliCtx, rs.Cdc), dist.ProposalRESTHandler(rs.CliCtx, rs.Cdc))
upgraderest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, "upgrade-plan", upgrade.StoreKey)
mintrest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc)
//datarest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, storeData)
//upgraderest.RegisterRoutes(rs.CliCtx, rs.Mux, rs.Cdc, "upgrade-plan", storeUpgrade)
}

func initConfig(cmd *cobra.Command) error {
Expand Down
Loading

0 comments on commit 9335cc3

Please sign in to comment.