NibiruChain / nibiru

Nibiru Chain: The breakthrough smart contract platform ushering in the next era of money. Nibiru powers an ecosystem of dApps including perps, RWAs, and more.
https://nibiru.fi
Apache License 2.0
182 stars 200 forks source link

bug(simulation): TestAppStateDeterminism with empty validator set #1848

Open Unique-Divine opened 4 months ago

Unique-Divine commented 4 months ago

Summary

The GitHub action for TestAppStateDeterminism can fail when the random state results in an empty validator set. We should make this impossible to remove the false positive in the test results .

Error Log:

--- FAIL: TestAppStateDeterminism (0.58s) panic: validator set is empty after InitGenesis, please ensure at least one validator is initialized with a delegation greater than or equal to the DefaultPowerReduction ({824639684576}) [recovered] panic: validator set is empty after InitGenesis, please ensure at least one validator is initialized with a delegation greater than or equal to the DefaultPowerReduction ({824639684576})

goroutine 34 [running]: testing.tRunner.func1.2({0x2283ac0, 0xc0019591a0}) /opt/hostedtoolcache/go/1.21.9/x64/src/testing/testing.go:1545 +0x238 testing.tRunner.func1() /opt/hostedtoolcache/go/1.21.9/x64/src/testing/testing.go:1548 +0x397 panic({0x2283ac0?, 0xc0019591a0?}) /opt/hostedtoolcache/go/1.21.9/x64/src/runtime/panic.go:914 +0x21f github.com/cosmos/cosmos-sdk/types/module.(Manager).InitGenesis(_, {{0x32f5b90, 0x498a260}, {0x330b0d0, 0xc001202040}, {{0x0, 0x0}, {0x2725c8b, 0xe}, 0x0, ...}, ...}, ...) /home/runner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.47.10/types/module/module.go:372 +0x479 github.com/NibiruChain/nibiru/app.(NibiruApp).InitChainer(, {{0x32f5b90, 0x498a260}, {0x330b0d0, 0xc001202040}, {{0x0, 0x0}, {0x2725c8b, 0xe}, 0x0, ...}, ...}, ...) /home/runner/work/nibiru/nibiru/app/app.go:264 +0x195 github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).InitChain(0xc0007e6d20, {{0x0, 0x1047311641, 0x494d920}, {0x2725c8b, 0xe}, 0xc0001c8620, {0x0, 0x0, 0x0}, ...}) /home/runner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.47.10/baseapp/abci.go:78 +0x515 github.com/cosmos/cosmos-sdk/x/simulation.initChain(0x3?, {0x3fd4e7b2f5caff38, , , {, , }, {, }, {, ...}}, ...) /home/runner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.47.10/x/simulation/simulate.go:46 +0x2a5 github.com/cosmos/cosmos-sdk/x/simulation.SimulateFromSeed({0x3317f40?, 0xc000ed7860?}, {, }, , , , {0xc0001f8c00, 0x31, 0x58}, ...) /home/runner/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.47.10/x/simulation/simulate.go:80 +0x4cf github.com/NibiruChain/nibiru/simapp_test.TestAppStateDeterminism(0xc000ed7860) /home/runner/work/nibiru/nibiru/simapp/sim_test.go:146 +0x988 testing.tRunner(0xc000ed7860, 0x2de2ac8) /opt/hostedtoolcache/go/1.21.9/x64/src/testing/testing.go:1595 +0xff created by testing.(*T).Run in goroutine 1 /opt/hostedtoolcache/go/1.21.9/x64/src/testing/testing.go:1648 +0x3ad FAIL github.com/NibiruChain/nibiru/simapp 0.660s FAIL make: *** [contrib/make/simulation.mk:6: test-sim-nondeterminism] Error 1

Unique-Divine commented 4 months ago

@k-yang: Likely not possible in production, but we should improve the test case to make it impossible to ahve an empty validator set.