Skip to content

Commit

Permalink
Merge PR #1783: Slashing, validator set, and governance simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
cwgoes authored Aug 16, 2018
1 parent c9358ec commit 3d50567
Show file tree
Hide file tree
Showing 28 changed files with 784 additions and 91 deletions.
30 changes: 24 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
export PATH="$GOBIN:$PATH"
make test_cli
test_sim:
test_sim_modules:
<<: *defaults
parallelism: 1
steps:
Expand All @@ -96,11 +96,26 @@ jobs:
- restore_cache:
key: v1-tree-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Test simulation
name: Test individual module simulations
command: |
export PATH="$GOBIN:$PATH"
export GAIA_SIMULATION_SEED=1531897442166404087
make test_sim
make test_sim_modules
test_sim_gaia_fast:
<<: *defaults
parallelism: 1
steps:
- attach_workspace:
at: /tmp/workspace
- restore_cache:
key: v1-pkg-cache
- restore_cache:
key: v1-tree-{{ .Environment.CIRCLE_SHA1 }}
- run:
name: Test full Gaia simulation
command: |
export PATH="$GOBIN:$PATH"
make test_sim_gaia_fast
test_cover:
<<: *defaults
Expand All @@ -118,7 +133,7 @@ jobs:
command: |
export PATH="$GOBIN:$PATH"
make install
for pkg in $(go list github.com/cosmos/cosmos-sdk/... | grep -v github.com/cosmos/cosmos-sdk/cmd/gaia/cli_test | circleci tests split --split-by=timings); do
for pkg in $(go list github.com/cosmos/cosmos-sdk/... | grep -v github.com/cosmos/cosmos-sdk/cmd/gaia/cli_test | grep -v '/simulation' | circleci tests split --split-by=timings); do
id=$(basename "$pkg")
GOCACHE=off go test -timeout 8m -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic "$pkg" | tee "/tmp/logs/$id-$RANDOM.log"
done
Expand Down Expand Up @@ -161,7 +176,10 @@ workflows:
- test_cli:
requires:
- setup_dependencies
- test_sim:
- test_sim_modules:
requires:
- setup_dependencies
- test_sim_gaia_fast:
requires:
- setup_dependencies
- test_cover:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ FEATURES
- Modules specify invariants and operations, preferably in an x/[module]/simulation package
- Modules can test random combinations of their own operations
- Applications can integrate operations and invariants from modules together for an integrated simulation
- Simulates Tendermint's algorithm for validator set updates
- Simulates validator signing/downtime with a Markov chain, and occaisional double-signatures
- Includes simulated operations & invariants for staking, slashing, governance, and bank modules
- [store] \#1481 Add transient store
- [baseapp] Initialize validator set on ResponseInitChain
- [baseapp] added BaseApp.Seal - ability to seal baseapp parameters once they've been set
Expand Down
51 changes: 26 additions & 25 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 12 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,17 @@ test_unit:
test_race:
@go test -race $(PACKAGES_NOSIMULATION)

test_sim:
@echo "Running individual module simulations."
@go test $(PACKAGES_SIMTEST) -v
@echo "Running full Gaia simulation. This may take several minutes."
@echo "Pass the flag 'SimulationSeed' to run with a constant seed."
@echo "Pass the flag 'SimulationNumKeys' to run with the specified number of keys."
@echo "Pass the flag 'SimulationNumBlocks' to run with the specified number of blocks."
@echo "Pass the flag 'SimulationBlockSize' to run with the specified block size (operations per block)."
@go test ./cmd/gaia/app -run TestFullGaiaSimulation -SimulationEnabled=true -SimulationBlockSize=200 -v
test_sim_modules:
@echo "Running individual module simulations..."
@go test $(PACKAGES_SIMTEST)

test_sim_gaia_fast:
@echo "Running full Gaia simulation. This may take several minutes..."
@go test ./cmd/gaia/app -run TestFullGaiaSimulation -SimulationEnabled=true -SimulationNumBlocks=1000 -v -timeout 24h

test_sim_gaia_slow:
@echo "Running full Gaia simulation. This may take several minutes..."
@go test ./cmd/gaia/app -run TestFullGaiaSimulation -SimulationEnabled=true -SimulationNumBlocks=1000 -SimulationVerbose=true -v -timeout 24h

test_cover:
@bash tests/test_cover.sh
Expand Down Expand Up @@ -204,4 +206,4 @@ localnet-stop:
check_tools check_dev_tools get_tools get_dev_tools get_vendor_deps draw_deps test test_cli test_unit \
test_cover test_lint benchmark devdoc_init devdoc devdoc_save devdoc_update \
build-linux build-docker-gaiadnode localnet-start localnet-stop \
format check-ledger test_sim update_tools update_dev_tools
format check-ledger test_sim_modules test_sim_gaia_fast test_sim_gaia_slow update_tools update_dev_tools
2 changes: 1 addition & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg
} else {
// In the first block, app.deliverState.ctx will already be initialized
// by InitChain. Context is now updated with Header information.
app.deliverState.ctx = app.deliverState.ctx.WithBlockHeader(req.Header)
app.deliverState.ctx = app.deliverState.ctx.WithBlockHeader(req.Header).WithBlockHeight(req.Header.Height)
}

if app.beginBlocker != nil {
Expand Down
Loading

0 comments on commit 3d50567

Please sign in to comment.