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

Chain simulations throws panic for certain seeds #156

Closed
javiersuweijie opened this issue Mar 23, 2023 · 1 comment · Fixed by #157
Closed

Chain simulations throws panic for certain seeds #156

javiersuweijie opened this issue Mar 23, 2023 · 1 comment · Fixed by #157
Assignees
Labels
bug Something isn't working

Comments

@javiersuweijie
Copy link
Member

javiersuweijie commented Mar 23, 2023

When take rate is set too high in simulations, asset.TotalTokens decay too quickly such that there isn't enough tokens to calculate reward distribution.

Stacktrace

Simulating... block 153/200, operation 0/16.panic: failed to rebalance assets in x/alliance module: there are no delegations yet

goroutine 866 [running]:
github.com/terra-money/alliance/x/alliance.EndBlocker({{0x106c93848, 0x14000128008}, {0x106ca3360, 0x140224193c0}, {{0x0, 0x0}, {0x105b70a86, 0xe}, 0x99, {0x0, ...}, ...}, ...}, ...)
        /Users/javiersuweijie/go/pkg/mod/github.com/terra-money/[email protected]/x/alliance/abci.go:31 +0x35c
github.com/terra-money/alliance/x/alliance.AppModule.EndBlock(...)
        /Users/javiersuweijie/go/pkg/mod/github.com/terra-money/[email protected]/x/alliance/module.go:103
github.com/cosmos/cosmos-sdk/types/module.(*Manager).EndBlock(_, {{0x106c93848, 0x14000128008}, {0x106ca3360, 0x140224193c0}, {{0x0, 0x0}, {0x105b70a86, 0xe}, 0x99, ...}, ...}, ...)
        /Users/javiersuweijie/go/pkg/mod/github.com/terra-money/[email protected]/types/module/module.go:505 +0x1a4
github.com/terra-money/core/v2/app.(*TerraApp).EndBlocker(...)
        /Users/javiersuweijie/Projects/core/app/app.go:876
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).EndBlock(0x14001098380, {0x14000128008?})
        /Users/javiersuweijie/go/pkg/mod/github.com/terra-money/[email protected]/baseapp/abci.go:206 +0x134
github.com/cosmos/cosmos-sdk/x/simulation.SimulateFromSeed({0x106ca8a00?, 0x1400013ca00}, {0x106c75640?, 0x14000126008}, 0x43e2cf?, 0x1090b63a0?, 0x106c65030, {0x140001e7180, 0x24, 0x28}, ...)
        /Users/javiersuweijie/go/pkg/mod/github.com/terra-money/[email protected]/x/simulation/simulate.go:188 +0x11b0
github.com/terra-money/core/v2/app_test.BenchmarkSimulation(0x1400013ca00)
        /Users/javiersuweijie/Projects/core/app/simulation_test.go:74 +0x420
testing.(*B).runN(0x1400013ca00, 0x1)
        /usr/local/go/src/testing/benchmark.go:193 +0x128
testing.(*B).run1.func1()
        /usr/local/go/src/testing/benchmark.go:233 +0x50
created by testing.(*B).run1
        /usr/local/go/src/testing/benchmark.go:226 +0x8c
exit status 2
FAIL    github.com/terra-money/core/v2/app      28.802s
FAIL
@javiersuweijie javiersuweijie added the bug Something isn't working label Mar 23, 2023
@javiersuweijie javiersuweijie self-assigned this Mar 23, 2023
@javiersuweijie javiersuweijie changed the title Chain simulations throws panic using Seed = 0 Chain simulations throws panic for certain seeds Mar 23, 2023
@javiersuweijie
Copy link
Member Author

Running simulations in feather-core

 https://github.com/AaronCQL/feather-core. Running simulations with --Seed=51:
go test ./app --benchmem --run='^$' --bench='^BenchmarkSimulation' --NumBlocks=200 --BlockSize=30 --InitialBlockHeight=1 --Seed=51

Results in error:
simulate.go:302: error on block  67/200, operation (14/27) from x/alliance:
failed to execute message; message index: 0: rpc error: code = InvalidArgument desc = Cannot redelegate to the same validator [terra-money/[email protected]/baseapp/baseapp.go:799]
Comment: unable to deliver tx

Running with a large enough --NumBlocks and --BlockSize may sometimes also cause errors:

// This passes:
go test ./app --benchmem --run='^$' --bench='^BenchmarkSimulation' --NumBlocks=200 --BlockSize=30 --InitialBlockHeight=1 --Seed=1 

// This fails:
go test ./app --benchmem --run='^$' --bench='^BenchmarkSimulation' --NumBlocks=400 --BlockSize=50 --InitialBlockHeight=1 --Seed=1

// With this error:
Simulating... block 169/400, operation 0/3.panic: failed to rebalance assets in x/alliance module: there are no delegations yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant