cosmos / cosmos-sdk

:chains: A Framework for Building High Value Public Blockchains :sparkles:
https://cosmos.network/
Apache License 2.0
6.27k stars 3.63k forks source link

[Bug]: panic: failed to get executionContext from context #21924

Closed alpe closed 1 month ago

alpe commented 1 month ago

Is there an existing issue for this?

What happened?

This affects simdv2 only:

When starting a node from a state dump or using my sims branch, I run into this panic:

panic: failed to get executionContext from context

goroutine 128 [running]:
cosmossdk.io/server/v2/stf.eventService.EventManager(...)
        cosmossdk.io/server/v2/stf@v0.0.0-20240708142107-25e99c54bac1/core_event_service.go:27
cosmossdk.io/x/authz/keeper.Keeper.SaveGrant({{{0x14d04bce0, 0x14001522700}, {0x103554710, 0x105448380}, {0x103540aa0, 0x105448380}, {0x103554738, 0x105448380}, {0x1035409c0, 0x140015a8720}, ...}, ...}, ...)
        cosmossdk.io/x/authz@v0.0.0-00010101000000-000000000000/keeper/keeper.go:218 +0x3fc
cosmossdk.io/x/authz/keeper.Keeper.InitGenesis({{{0x14d04bce0, 0x14001522700}, {0x103554710, 0x105448380}, {0x103540aa0, 0x105448380}, {0x103554738, 0x105448380}, {0x1035409c0, 0x140015a8720}, ...}, ...}, ...)
        cosmossdk.io/x/authz@v0.0.0-00010101000000-000000000000/keeper/genesis.go:35 +0x224
cosmossdk.io/x/authz/module.AppModule.InitGenesis({{0x1035c5d68, 0x1400168ee50}, {{{0x14d04bce0, 0x14001522700}, {0x103554710, 0x105448380}, {0x103540aa0, 0x105448380}, {0x103554738, 0x105448380}, ...}, ...}, ...}, ...)
        cosmossdk.io/x/authz@v0.0.0-00010101000000-000000000000/module/module.go:132 +0xb0
cosmossdk.io/runtime/v2.(*MM[...]).InitGenesisJSON(0x0, {0x10357e3f0?, 0x14001668330}, 0x14001a0fef0, 0x14001a0fec0)
        cosmossdk.io/runtime/v2@v2.0.0-00010101000000-000000000000/manager.go:168 +0x50c
cosmossdk.io/runtime/v2.(*AppBuilder[...]).Build.func2.1()
        cosmossdk.io/runtime/v2@v2.0.0-00010101000000-000000000000/builder.go:186 +0x5c
cosmossdk.io/runtime/v2/services.(*genesisContext).Run(0x14001beb6c0, {0x10357e3f0?, 0x14001a0fe30?}, 0x14
002ea02a8)
        cosmossdk.io/runtime/v2@v2.0.0-00010101000000-000000000000/services/genesis.go:41 +0x5c
cosmossdk.io/runtime/v2.(*AppBuilder[...]).Build.func2({0x10353f008, 0x14001a0fe90}, 0x14001a0fec0?)
        cosmossdk.io/runtime/v2@v2.0.0-00010101000000-000000000000/builder.go:185 +0x21c
cosmossdk.io/server/v2/appmanager.AppManager[...].InitGenesis(0x10359f2c0, {0x10357e3f0, 0x14001a0fe30}, 0
x14001846b80, {0x140008cea80, 0x67cc, 0x6a80}, {0x103551720, 0x1400136ad90})
        cosmossdk.io/server/v2/appmanager@v0.0.0-20240802110823-cffeedff643d/appmanager.go:47 +0x140
cosmossdk.io/server/v2/cometbft.(*Consensus[...]).InitChain(0x1035daf00, {0x10357e4d0, 0x105448380}, 0x140
021b0b60)
        cosmossdk.io/server/v2/cometbft@v0.0.0-00010101000000-000000000000/abci.go:277 +0x434
github.com/cometbft/cometbft/abci/client.(*localClient).InitChain(0x12c368188?, {0x10357e4d0?, 0x105448380
?}, 0x1055b4108?)
        github.com/cometbft/cometbft@v1.0.0-rc1.0.20240908111210-ab0be101882f/abci/client/local_client.go:
125 +0xe4
github.com/cometbft/cometbft/proxy.(*appConnConsensus).InitChain(0x14001488c60, {0x10357e4d0, 0x105448380}
, 0x140021b0b60)

Cosmos SDK Version

main

How to reproduce?

It can be reproduced by exporting/importing grants for example. I have this system test to do so: https://github.com/cosmos/cosmos-sdk/pull/21913 You would find the stacktrace in the server logs

julienrbrt commented 1 month ago

We tried yesterday with latest main, but we were unable to reproduce. Export genesis works, but import genesis is blocked by https://github.com/cosmos/cosmos-sdk/pull/21678 That branch is giving https://github.com/cosmos/cosmos-sdk/actions/runs/11047632110/job/30689253949?pr=21678, but the tests are failing there, so I don't think we need to track it here, as it is happening only there.

alpe commented 1 month ago

Reopening the issue as the system test linked in #21913 is still failing.

21678 is addressing the valset but in the POC, I have used a different module to show that it is not valset only. I assume any module emitting events during genesis phase will run into this

julienrbrt commented 1 month ago

Yes, correct! It should indeed stay open. @kocubinski had a solution for it.

julienrbrt commented 1 month ago

Should be fixed with latest main @alpe. Could you retry?

alpe commented 1 month ago

It is still failing. Some more details: During depinject phase, the stf.EventService is wired into the appmodulev2.Environment. In genesis phase, the Environment.EventService.EventManager(ctx) is called in module like bank/send.go#283 and causes an error in stf/utils because it is not an executionContext type.

kocubinski commented 1 month ago

Looks fixed by https://github.com/cosmos/cosmos-sdk/pull/22192