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

Wire up grandpa decoder to babylon custom logic #360

Open
wants to merge 1 commit into
base: centauri-integration-ibc-v7-stable
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions x/zoneconcierge/extended-client-keeper/keeper.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package extended_client_keeper

import (
"bytes"

sdkerrors "cosmossdk.io/errors"
metrics "github.com/armon/go-metrics"
grandpa "github.com/babylonchain/babylon/x/zoneconcierge/types/grandpa"
"github.com/cometbft/cometbft/crypto/tmhash"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
Expand All @@ -13,6 +16,7 @@ import (
"github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
ibcwasm "github.com/cosmos/ibc-go/v7/modules/light-clients/08-wasm/types"
)

// ExtendedKeeper is same as the original clientkeeper.Keeper, except that
Expand All @@ -35,6 +39,25 @@ func GetHeaderInfo(ctx sdk.Context, m exported.ClientMessage) *HeaderInfo {
ChaindId: msg.Header.ChainID,
Height: uint64(msg.Header.Height),
}
case *ibcwasm.Header:
// try to decode wasm.data as a picasso header
gh, err := grandpa.DecodeHeader(grandpa.NewDecoder(bytes.NewReader(msg.Data)))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blasrodri just to be sure, does ibcwasm.Header.Data field contains only serialized picasso header or there is some other data here ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only contains grandpa light-client header

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh and how this header relates to the header parser that Eduardo implemented here - https://github.com/babylonchain/babylon/blob/centauri-integration-ibc-v7-stable/x/zoneconcierge/types/grandpa/header.go ?


if err == nil {
// this is header is unknown to babylon so we can't checkpoint it. Returning nil
// means that this light client will be frozen.
return nil
}

return &HeaderInfo{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you need any extra validation? Just asking, I'm totally new to it :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not need more validation as it is called only in our modified UpdateClient function after client message is already verified with VerifyClientMessage and CheckForMisbehaviour.

This function should probably be package private, but this just a detail :)

// For now use state root as consensus binding hash.
Hash: gh.StateRoot[:],
Height: uint64(gh.Number),
// TODO: it seems picasso headers doesn't have chain id. For now pass picasso string
// as we only checkpoint picasso chain.
ChaindId: "picasso",
}

default:
return nil
}
Expand Down