Custom staking hook registration #102
Unanswered
sabn2
asked this question in
Chain Builders (Cosmos SDK)
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to implement staking hooks(BeforeDelegationCreated) in a custom module. I have created a hooks.go file in my custom module keeper and added all methods implemented by staking hooks. I am registering custom hook in app.go. I can build the binary but it errors in run time as below:
si@sid:~/Downloads/DOWNLOADS_11_2_25/hooksa_ch/hooksach$ hooksachd start
panic: cannot set validator hooks twice
goroutine 1 [running]:
github.com/cosmos/cosmos-sdk/x/staking/keeper.(*Keeper).SetHooks(...)
/home/si/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.11/x/staking/keeper/keeper.go:97
hooksach/app.New({0x3f5b120, 0xc00154eaf0}, {0x3f72800, 0xc001494008}, {0x0, 0x0}, 0x1, {0x3f17d00, 0xc0006f0540}, {0xc000def110, ...})
/home/si/Downloads/DOWNLOADS_11_2_25/hooksa_ch/hooksach/app/app.go:255 +0x10f2
hooksach/cmd/hooksachd/cmd.newApp({0x3f5b120, 0xc00154eaf0}, {0x3f72800, 0xc001494008}, {0x0, 0x0}, {0x3f17d00, 0xc0006f0540})
/home/si/Downloads/DOWNLOADS_11_2_25/hooksa_ch/hooksach/cmd/hooksachd/cmd/commands.go:130 +0xaa
github.com/cosmos/cosmos-sdk/server.startApp(0xc001021780, 0x3ae19c8, {0x3ae2180, 0x0, 0x0, 0x0, 0x3ae2190})
/home/si/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.11/server/start.go:619 +0x223
github.com/cosmos/cosmos-sdk/server.start(_, {{0x0, 0x0, 0x0}, {0x3f78938, 0xc0015b3470}, 0x0, {0xc0015a0f68, 0x8}, {0x3f99b10, ...}, ...}, ...)
/home/si/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.11/server/start.go:225 +0x159
github.com/cosmos/cosmos-sdk/server.StartCmdWithOptions.func2.1()
/home/si/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.11/server/start.go:199 +0x63
github.com/cosmos/cosmos-sdk/server.wrapCPUProfile(0xc001021780, 0xc00008d9f8)
/home/si/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.11/server/start.go:571 +0x1b3
github.com/cosmos/cosmos-sdk/server.StartCmdWithOptions.func2(0xc00142f508, {0x5d13e20?, 0x0?, 0x0?})
/home/si/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.11/server/start.go:198 +0x212
github.com/spf13/cobra.(*Command).execute(0xc00142f508, {0x5d13e20, 0x0, 0x0})
/home/si/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:985 +0xaaa
github.com/spf13/cobra.(*Command).ExecuteC(0xc0010c0c08)
/home/si/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
/home/si/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041
github.com/spf13/cobra.(*Command).ExecuteContext(...)
/home/si/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1034
github.com/cosmos/cosmos-sdk/server/cmd.Execute(0xc0010c0c08, {0x32cef6a, 0x8}, {0xc000adb428, 0x12})
/home/si/go/pkg/mod/github.com/cosmos/cosmos-sdk@v0.50.11/server/cmd/execute.go:34 +0x187
main.main()
/home/si/Downloads/DOWNLOADS_11_2_25/hooksa_ch/hooksach/cmd/hooksachd/main.go:16 +0x3d
si@sid:~/Downloads/DOWNLOADS_11_2_25/hooksa_ch/hooksach$
=======
hook registration:
app.StakingKeeper.SetHooks(
stakingtypes.NewMultiStakingHooks(app.CustomhookKeeper.Hooks()),
)
I guess, the issue is custom hook registration during app initialization. Can any one help on this? I am struggling on this since 2 days. Thanks!!
@gjermundgaraba @julienrbrt @samricotta @tac0turtle
Beta Was this translation helpful? Give feedback.
All reactions