confio / tgrade

The Tgrade Blockchain Binary, based on the Cosmos SDK and wasmd
Apache License 2.0
31 stars 10 forks source link

Fix simulations #400

Closed ethanfrey closed 2 years ago

ethanfrey commented 2 years ago

A bit of banging around here to get simulations to pass a bit more consistently.

I tried ensuring all new validators had sufficient stake and EP. Then made them more likely to bond. Finally, I realized that huge numbers (up to 100%) get slashed every block and this is hardcoded in the sdk. So I just reduced number of blocks to 20 as a workaround to get some coverage with less fails.


I have been digging deep into simulations to figure out why they keep fail in tgrade. It seems this is build it deep to the sdk.

We use RandomParams when creating a simulation run, with no way of overriding them https://github.com/cosmos/cosmos-sdk/blob/ad9e5620fb3445c716e9de45cfcdb56e8f1745bf/x/simulation/simulate.go/#L68-L69

This uses a random value between 0 and 1.0 for what percentage of validators will double sign in a given block: https://github.com/cosmos/cosmos-sdk/blob/ad9e5620fb3445c716e9de45cfcdb56e8f1745bf/x/simulation/params.go/#L83-L84

Which does mean each validator has this chance (may be 99%) of being slashed https://github.com/cosmos/cosmos-sdk/blob/ad9e5620fb3445c716e9de45cfcdb56e8f1745bf/x/simulation/mock_tendermint.go/#L179-L210