Skip to content

Commit

Permalink
Decode pub key for reducing message size
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Jun 17, 2024
1 parent c67eb8c commit b0ccc0b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/indexer/decode/handle/test/staking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,19 @@ func TestDecodeMsg_SuccessOnMsgCreateValidator(t *testing.T) {
},
}

data := structs.Map(m)
data["Pubkey"] = map[string]any{
"key": pk.PubKey().Bytes(),
"type": "ed25519",
}
msgExpected := storage.Message{
Id: 0,
Height: blob.Height,
Time: now,
Position: 0,
Type: storageTypes.MsgCreateValidator,
TxId: 0,
Data: structs.Map(m),
Data: data,
Size: 201,
Namespace: nil,
Addresses: addressesExpected,
Expand Down
10 changes: 10 additions & 0 deletions pkg/indexer/decode/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package decode
import (
"github.com/celenium-io/celestia-indexer/pkg/indexer/decode/context"
"github.com/celenium-io/celestia-indexer/pkg/indexer/decode/handle"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/x/authz"
crisisTypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
evidenceTypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
Expand Down Expand Up @@ -74,6 +75,15 @@ func Message(
// staking module
case *cosmosStakingTypes.MsgCreateValidator:
d.Msg.Type, d.Msg.Addresses, err = handle.MsgCreateValidator(ctx, status, typedMsg)
if err != nil {
return d, err
}
if pk, ok := typedMsg.Pubkey.GetCachedValue().(cryptotypes.PubKey); ok {
d.Msg.Data["Pubkey"] = map[string]any{
"key": pk.Bytes(),
"type": pk.Type(),
}
}
case *cosmosStakingTypes.MsgEditValidator:
d.Msg.Type, d.Msg.Addresses, err = handle.MsgEditValidator(ctx, status, typedMsg)
case *cosmosStakingTypes.MsgDelegate:
Expand Down

0 comments on commit b0ccc0b

Please sign in to comment.