-
Notifications
You must be signed in to change notification settings - Fork 176
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
base: centauri-integration-ibc-v7-stable
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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" | ||
|
@@ -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 | ||
|
@@ -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))) | ||
|
||
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{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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 | ||
} | ||
|
There was a problem hiding this comment.
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 ?There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 ?