Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ go.work.sum
# Depinject debug file
debug_container.dot

.DS_Store
.idea
/release/
**/node_modules
Expand Down
21 changes: 21 additions & 0 deletions proto/hyperlane/core/post_dispatch/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,27 @@ message EventCreateNoopHook {
string owner = 2;
}

// EventCreateAggregationHook ...
message EventCreateAggregationHook {

// id ...
string aggregation_hook_id = 1 [
(gogoproto.customtype) =
"github.com/bcp-innovations/hyperlane-cosmos/util.HexAddress",
(gogoproto.nullable) = false
];

// owner ...
string owner = 2;

// hooks ...
repeated string hooks = 3 [
(gogoproto.customtype) =
"github.com/bcp-innovations/hyperlane-cosmos/util.HexAddress",
(gogoproto.nullable) = false
];
}

// EventCreateIgp ...
message EventCreateIgp {
string igp_id = 1 [
Expand Down
4 changes: 3 additions & 1 deletion proto/hyperlane/core/post_dispatch/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ message GenesisState {
repeated MerkleTreeHook merkle_tree_hooks = 3
[ (gogoproto.nullable) = false ];
repeated NoopHook noop_hooks = 4 [ (gogoproto.nullable) = false ];
repeated AggregationHook aggregation_hooks = 5
[ (gogoproto.nullable) = false ];
}

// GenesisDestinationGasConfigWrapper ...
Expand All @@ -32,4 +34,4 @@ message GenesisDestinationGasConfigWrapper {

// igp_id is required for the Genesis handling.
uint64 igp_id = 4;
}
}
30 changes: 30 additions & 0 deletions proto/hyperlane/core/post_dispatch/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ service Query {
rpc NoopHook(QueryNoopHookRequest) returns (QueryNoopHookResponse) {
option (google.api.http).get = "/hyperlane/v1/noop_hooks/{id}";
}

// AggregationHooks ...
rpc AggregationHooks(QueryAggregationHooksRequest)
returns (QueryAggregationHooksResponse) {
option (google.api.http).get = "/hyperlane/v1/aggregation_hooks";
}

// AggregationHook ...
rpc AggregationHook(QueryAggregationHookRequest)
returns (QueryAggregationHookResponse) {
option (google.api.http).get = "/hyperlane/v1/aggregation_hooks/{id}";
}
}

// QueryIgpsRequest ...
Expand Down Expand Up @@ -174,3 +186,21 @@ message QueryNoopHooksResponse {
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryAggregationHookRequest ...
message QueryAggregationHookRequest { string id = 1; }

// QueryAggregationHookResponse ...
message QueryAggregationHookResponse { AggregationHook aggregation_hook = 1; }

// QueryAggregationHooksRequest ...
message QueryAggregationHooksRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

// QueryAggregationHooksResponse ...
message QueryAggregationHooksResponse {
repeated AggregationHook aggregation_hooks = 1
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
29 changes: 29 additions & 0 deletions proto/hyperlane/core/post_dispatch/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ service Msg {

// CreateNoopHook ...
rpc CreateNoopHook(MsgCreateNoopHook) returns (MsgCreateNoopHookResponse);

// CreateAggregationHook ...
rpc CreateAggregationHook(MsgCreateAggregationHook)
returns (MsgCreateAggregationHookResponse);
}

// MsgCreateIgp ...
Expand Down Expand Up @@ -205,3 +209,28 @@ message MsgCreateNoopHookResponse {
(gogoproto.nullable) = false
];
}

// MsgCreateAggregationHook ...
message MsgCreateAggregationHook {
option (cosmos.msg.v1.signer) = "owner";
option (amino.name) = "hyperlane/v1/MsgCreateAggregationHook";

// owner ...
string owner = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// hooks ...
repeated string hooks = 2 [
(gogoproto.customtype) =
"github.com/bcp-innovations/hyperlane-cosmos/util.HexAddress",
(gogoproto.nullable) = false
];
}

// MsgCreateAggregationHookResponse ...
message MsgCreateAggregationHookResponse {
string id = 1 [
(gogoproto.customtype) =
"github.com/bcp-innovations/hyperlane-cosmos/util.HexAddress",
(gogoproto.nullable) = false
];
}
22 changes: 21 additions & 1 deletion proto/hyperlane/core/post_dispatch/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,24 @@ message NoopHook {

// owner ...
string owner = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}
}

// AggregationHook ...
message AggregationHook {
// id ...
string id = 1 [
(gogoproto.customtype) =
"github.com/bcp-innovations/hyperlane-cosmos/util.HexAddress",
(gogoproto.nullable) = false
];

// owner ...
string owner = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// hooks ...
repeated string hooks = 3 [
(gogoproto.customtype) =
"github.com/bcp-innovations/hyperlane-cosmos/util.HexAddress",
(gogoproto.nullable) = false
];
}
69 changes: 69 additions & 0 deletions x/core/02_post_dispatch/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func GetQueryCmd() *cobra.Command {
CmdMerkleTreeHook(),
CmdNoopHooks(),
CmdNoopHook(),
CmdAggregationHooks(),
CmdAggregationHook(),
)
return cmd
}
Expand Down Expand Up @@ -303,3 +305,70 @@ func CmdNoopHook() *cobra.Command {

return cmd
}

func CmdAggregationHooks() *cobra.Command {
cmd := &cobra.Command{
Use: "aggregation-hooks",
Short: "List all aggregation hooks",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}

params := &types.QueryAggregationHooksRequest{
Pagination: pageReq,
}

res, err := queryClient.AggregationHooks(cmd.Context(), params)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)
flags.AddPaginationFlagsToCmd(cmd, "aggregation-hooks")

return cmd
}

func CmdAggregationHook() *cobra.Command {
cmd := &cobra.Command{
Use: "aggregation-hook [id]",
Short: "Get details for a specific aggregation hook",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)

params := &types.QueryAggregationHookRequest{
Id: args[0],
}

res, err := queryClient.AggregationHook(cmd.Context(), params)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}
1 change: 1 addition & 0 deletions x/core/02_post_dispatch/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func GetTxCmd() *cobra.Command {
NewIgpCmd(),
NewMerkleCmd(),
NewNoopHookCmd(),
NewAggregationHookCmd(),
)

return txCmd
Expand Down
65 changes: 65 additions & 0 deletions x/core/02_post_dispatch/client/cli/tx_aggregation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package cli

import (
"fmt"

"github.com/bcp-innovations/hyperlane-cosmos/util"
"github.com/bcp-innovations/hyperlane-cosmos/x/core/02_post_dispatch/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/cobra"
)

func NewAggregationHookCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "aggregation",
Short: "Hyperlane Aggregation Hook commands",
}

cmd.AddCommand(
CmdCreateAggregationHook(),
)

return cmd
}

func CmdCreateAggregationHook() *cobra.Command {
cmd := &cobra.Command{
Use: "create [hook-id...]",
Short: "Create a new aggregation hook with the given ordered child hook ids",
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

hooks := make([]util.HexAddress, len(args))
for i, arg := range args {
hookId, err := util.DecodeHexAddress(arg)
if err != nil {
return err
}
hooks[i] = hookId
}

msg := types.MsgCreateAggregationHook{
Owner: clientCtx.GetFromAddress().String(),
Hooks: hooks,
}

_, err = sdk.AccAddressFromBech32(msg.Owner)
if err != nil {
panic(fmt.Errorf("invalid sender address (%s)", msg.Owner))
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
28 changes: 24 additions & 4 deletions x/core/02_post_dispatch/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ func InitGenesis(ctx sdk.Context, k Keeper, data *types.GenesisState) {
panic(err)
}
}

for _, aggregationHook := range data.AggregationHooks {
if err := k.validateAggregationHooks(ctx, aggregationHook.Hooks); err != nil {
panic(err)
}
if err := k.aggregationHooks.Set(ctx, aggregationHook.Id.GetInternalId(), aggregationHook); err != nil {
panic(err)
}
}
}

func ExportGenesis(ctx sdk.Context, k Keeper) *types.GenesisState {
Expand Down Expand Up @@ -95,10 +104,21 @@ func ExportGenesis(ctx sdk.Context, k Keeper) *types.GenesisState {
panic(err)
}

iterAggregationHooks, err := k.aggregationHooks.Iterate(ctx, nil)
if err != nil {
panic(err)
}

aggregationHooks, err := iterAggregationHooks.Values()
if err != nil {
panic(err)
}

return &types.GenesisState{
Igps: igps,
IgpGasConfigs: gasConfigs,
MerkleTreeHooks: merkleTreeHooks,
NoopHooks: noopHooks,
Igps: igps,
IgpGasConfigs: gasConfigs,
MerkleTreeHooks: merkleTreeHooks,
NoopHooks: noopHooks,
AggregationHooks: aggregationHooks,
}
}
Loading
Loading