Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: Slashing, validator set, and governance simulation #1783

Merged
merged 80 commits into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
15a5cd5
Simulate time passing
cwgoes Jul 20, 2018
2a04c04
Print out final height & time
cwgoes Jul 20, 2018
79e870a
Simulate validator set changes
cwgoes Jul 20, 2018
a1ea7cc
Simulate different block loads
cwgoes Jul 20, 2018
727b7bd
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Jul 23, 2018
9c55ec5
Random SigningValidators
cwgoes Jul 23, 2018
782fcd7
Simple random Byzantine evidence
cwgoes Jul 23, 2018
e4d0b17
Option to skip RequestBeginBlock randomization
cwgoes Jul 23, 2018
0f85d6c
Initial genesis validator in simulation
cwgoes Jul 23, 2018
d2709e2
Helpful printouts
cwgoes Jul 23, 2018
6c07f4a
Better load simulation
cwgoes Jul 23, 2018
01264b9
Nicer logs
cwgoes Jul 23, 2018
d7f1553
Linter fixes; 'make format'
cwgoes Jul 23, 2018
738009c
Delay RequestBeginBlock.SigningValidators one block; nicer formatting
cwgoes Jul 24, 2018
b032b8e
Period invariant checks
cwgoes Jul 24, 2018
2bf2c9a
SimulateMsgUnrevoke
cwgoes Jul 24, 2018
e69f7fc
Simulated x/gov msgs, more initially bonded
cwgoes Jul 25, 2018
3a4aed5
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Jul 25, 2018
9a07c07
Linter fixes; 'make format'
cwgoes Jul 25, 2018
be70a21
Somehow nondeterministic
cwgoes Jul 25, 2018
d151988
Debugging contd.
cwgoes Jul 25, 2018
f0cff46
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Jul 25, 2018
5058379
Fix nondeterminism but now we found a bug!
cwgoes Jul 25, 2018
8cacb96
Debugging contd.
cwgoes Jul 26, 2018
d9000fb
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Jul 26, 2018
7a02762
More debugging
cwgoes Jul 26, 2018
ce52253
Debugging contd.
cwgoes Jul 27, 2018
d36d739
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Jul 27, 2018
529b93a
Remove debugging Printfs
cwgoes Jul 27, 2018
14c4642
Debugging contd.
cwgoes Jul 27, 2018
8ccde07
Merge PR #1842: simulation: Use transition matrices for simulating va…
ValarDragon Jul 28, 2018
a2ed2d1
Remove debug Printfs
cwgoes Jul 28, 2018
7fb08f8
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Jul 30, 2018
4036295
Governance simulation contd.
cwgoes Jul 30, 2018
e7a732d
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Jul 31, 2018
2a9061e
dep; make format
cwgoes Jul 31, 2018
462e0cc
NewInt64Coin
cwgoes Jul 31, 2018
afed984
Pass header correctly for slashing
cwgoes Jul 31, 2018
d69107c
Longer timeout; disable inflation
cwgoes Jul 31, 2018
c3b9818
Separate into 'test_sim_modules', 'test_sim_gaia_{fast,slow}'
cwgoes Jul 31, 2018
23d96f0
Misc fixes
cwgoes Jul 31, 2018
fd6594b
Fix teesny-tiny spelling mistake
cwgoes Jul 31, 2018
2163e96
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Jul 31, 2018
416e0d7
Past evidence; events for BeginBlock/EndBlock
cwgoes Aug 1, 2018
9a4a42b
Simplify simulation configuration
cwgoes Aug 1, 2018
dfb81f0
Add module simulation for x/gov
cwgoes Aug 1, 2018
6caaebc
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Aug 1, 2018
b1b7d9d
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Aug 3, 2018
ebd394c
Fix BeginBlock on existing deliverState.ctx
cwgoes Aug 3, 2018
03d9378
Minor cleanup
cwgoes Aug 3, 2018
36aa0af
Cleanup x/gov simulation msgs
cwgoes Aug 3, 2018
d9c1d67
Log proposal EndBlocker events
cwgoes Aug 3, 2018
fadfe87
Update PENDING.md
cwgoes Aug 3, 2018
7b2b989
Minor fixes
cwgoes Aug 3, 2018
73d5028
Correct evidence type
cwgoes Aug 3, 2018
a4c7fa7
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Aug 6, 2018
64a2e5b
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Aug 8, 2018
0a3f610
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Aug 8, 2018
bce3f5d
reduce unnecessarsy verbosity
ValarDragon Aug 9, 2018
75f8f15
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Aug 10, 2018
268c0ac
dep ensure -v -update
cwgoes Aug 10, 2018
f18c01d
Merge PR #1994: Delete install.md
zramsay Aug 13, 2018
1a64c87
Merge PR #1995: upgrading ledger goclient lib
jleni Aug 13, 2018
2b703c9
Merge branch 'develop' into cwgoes/slashing-simulation
cwgoes Aug 13, 2018
b40c9e8
Remove simulation from 'make test_cover'
cwgoes Aug 13, 2018
198f0f3
.ABCIValidator() includes address
cwgoes Aug 13, 2018
f172dd6
Minor fixes
cwgoes Aug 13, 2018
63762e9
Remove from CircleCI test_cover (why is this different)
cwgoes Aug 13, 2018
11ae0f3
Merge branch 'release/v0.24.0' into cwgoes/slashing-simulation
cwgoes Aug 15, 2018
70cc9bd
Update Gopkg.lock
cwgoes Aug 15, 2018
44c5ae7
Change timeout on 'make test_sim_gaia_fast'
cwgoes Aug 15, 2018
4bd01b0
testing...
cwgoes Aug 15, 2018
6e58500
Merge branch 'release/v0.24.0' into cwgoes/slashing-simulation
cwgoes Aug 15, 2018
1e1f337
Some logs for stake bug
cwgoes Aug 15, 2018
c13dd76
Add more debugging
cwgoes Aug 15, 2018
93060d7
Make randomized simulation deterministic from a given seed (#2059)
ValarDragon Aug 16, 2018
54ee496
Update Gopkg.lock
cwgoes Aug 16, 2018
617a503
Zero inflation on stake module test; additional event
cwgoes Aug 16, 2018
169260f
Remove accidental change from develop
cwgoes Aug 16, 2018
eb3e623
Remove printfs for merge into release/v0.24.0
cwgoes Aug 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/gaia/app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestFullGaiaSimulation(t *testing.T) {
},
[]simulation.RandSetup{},
[]simulation.Invariant{
allInvariants,
simulation.PeriodicInvariant(allInvariants, 100, 0),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to break up these invariants more? i.e. bank invariant every 100, staking/slashing every time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly! Currently optimized for ease of changing periodicity...

Copy link
Contributor

@ValarDragon ValarDragon Jul 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to what I previously suggested, maybe we should have a separate convenient debug full simulation function which takes in the seed and then run the invariants every time. (i.e. I'd prefer if we had a very easy way to see exactly what caused that randomized error once we've found an error)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can search by bisection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and also have a way to run the invariants every time, sure)

},
numKeys,
numBlocks,
Expand Down
9 changes: 3 additions & 6 deletions x/mock/simulation/random_simulate_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ func SimulateFromSeed(
}

// Update the validator set
fmt.Printf("\nUpdates: %v\n", res.ValidatorUpdates)
fmt.Printf("Len before: %d\n", len(validators))
validators = UpdateValidators(t, validators, res.ValidatorUpdates)
fmt.Printf("Len after: %d\n", len(validators))
}

fmt.Printf("\nSimulation complete. Final height (blocks): %d, final time (seconds): %d\n", header.Height, header.Time)
Expand Down Expand Up @@ -162,10 +159,10 @@ func UpdateValidators(t *testing.T, current map[string]abci.Validator, updates [
for _, update := range updates {
switch {
case update.Power == 0:
require.NotNil(t, current[string(update.Address)], "tried to delete a nonexistent validator")
delete(current, string(update.Address))
require.NotNil(t, current[string(update.PubKey.Data)], "tried to delete a nonexistent validator")
delete(current, string(update.PubKey.Data))
default:
current[string(update.Address)] = update
current[string(update.PubKey.Data)] = update
}
}
return current
Expand Down
3 changes: 0 additions & 3 deletions x/stake/handler.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package stake

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/stake/keeper"
"github.com/cosmos/cosmos-sdk/x/stake/tags"
Expand All @@ -12,7 +10,6 @@ import (

func NewHandler(k keeper.Keeper) sdk.Handler {
return func(ctx sdk.Context, msg sdk.Msg) sdk.Result {
fmt.Printf("\nHandling msg %s\n", msg.GetSignBytes())
// NOTE msg already has validate basic run
switch msg := msg.(type) {
case types.MsgCreateValidator:
Expand Down
4 changes: 0 additions & 4 deletions x/stake/keeper/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,6 @@ func kickOutValidators(k Keeper, ctx sdk.Context, toKickOut map[string]byte) {
// perform all the store operations for when a validator status becomes unbonded
func (k Keeper) unbondValidator(ctx sdk.Context, validator types.Validator) types.Validator {

fmt.Printf("\nUnbonding validator: %s\n", validator.Owner)

store := ctx.KVStore(k.storeKey)
pool := k.GetPool(ctx)

Expand Down Expand Up @@ -508,8 +506,6 @@ func (k Keeper) unbondValidator(ctx sdk.Context, validator types.Validator) type
// perform all the store operations for when a validator status becomes bonded
func (k Keeper) bondValidator(ctx sdk.Context, validator types.Validator) types.Validator {

fmt.Printf("\nBonding validator: %s\n", validator.Owner)

store := ctx.KVStore(k.storeKey)
pool := k.GetPool(ctx)

Expand Down