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

Revert "Revert "feat(hub-genesis): Relayer triggered genesis transfer"" #61

Merged
Merged
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
18 changes: 18 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Here are our instructions:

We want you to play the role of an expert software developer, who has particular expertise in Golang and all its nuances, as well as the Cosmos SDK, IBC protocol, Tendermint/CometBFT algorithms and light clients, and also knowledge of the wider blockchain technology space.

Please be terse, and follow all the coding guidelines. Pay particular attention to importing packages correctly, and the visibility of methods, functions, types and fields. Do not write lines longer than 80 characters wide, you should split them according to golang formatting rules. If writing code, try to reuse existing code, and suggest refactors for how to keep the code DRY.

Also pay particular attention to security, and to make sure that the code is deterministic. Make sure to look at the context of the code to use the right library versions and import aliases, and to follow typical Cosmos SDK practices like using the SDK math, coin and error handling libraries. Remember that Cosmos SDK blockchains have a single logical thread of execution and execute transactions in sequence, there are no 'race' conditions, and failed transactions have no effect. Be wary of any paths that can lead to a panic from BeginBlocker or EndBlocker. Don't worry about what ifs or improbably scenarios based on future code changes. Just evaluate the code as it is, and find bugs that definitely exist.

These additional resources are useful
- https://github.com/dymensionxyz/dymension/blob/main/Contributing.md (also at ../Contributing.md)
- https://github.com/cosmos/ibc/tree/main/spec/core
- https://github.com/cosmos/ibc-go/tree/v7.5.1/modules/core
- https://github.com/cosmos/ibc-go/tree/v7.5.1/modules/light-clients/07-tendermint
- https://github.com/cosmos/cosmos-sdk/tree/v0.47.13/docs
- https://github.com/dymensionxyz/dymint
- https://github.com/dymensionxyz/rollapp-evm
- https://github.com/dymensionxyz/rollapp-wasm
- https://github.com/dymensionxyz/go-relayer
42 changes: 42 additions & 0 deletions cmd/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Most of these commands take a [path] argument. Make sure:
upgradeClientsCmd(a),
createConnectionCmd(a),
createChannelCmd(a),
sendGenesisTransfer(a),
closeChannelCmd(a),
lineBreakCommand(),
registerCounterpartyCmd(a),
Expand Down Expand Up @@ -596,6 +597,47 @@ $ %s tx chan demo-path --timeout 5s --max-retries 10`,
return cmd
}

func sendGenesisTransfer(a *appState) *cobra.Command {
cmd := &cobra.Command{
Use: "rollapp-send-genesis-transfer <path>",
Aliases: []string{},
Short: "Send a genesis transfer from the rollapp to the hub.",
Long: "Send a genesis transfer from the rollapp to the hub - intended for recovery/retry. Relayer will try automatically the first time during channel creation.",
Args: withUsage(cobra.ExactArgs(1)),
RunE: func(cmd *cobra.Command, args []string) error {
pathName := args[0]

c, src, dst, err := a.config.ChainsFromPath(pathName)
if err != nil {
return err
}

// ensure that keys exist
if exists := c[src].ChainProvider.KeyExists(c[src].ChainProvider.Key()); !exists {
return fmt.Errorf("key %s not found on src chain %s", c[src].ChainProvider.Key(), c[src].ChainID())
}

if exists := c[dst].ChainProvider.KeyExists(c[dst].ChainProvider.Key()); !exists {
return fmt.Errorf("key %s not found on dst chain %s", c[dst].ChainProvider.Key(), c[dst].ChainID())
}

// create channel if it isn't already created
return processor.SendGenesisTransfer(
cmd.Context(),
c[src].ChainProvider, // must be hub
c[dst].ChainProvider, // must be rollapp
)
},
}

cmd = timeoutFlag(a.viper, cmd)
cmd = retryFlag(a.viper, cmd)
cmd = overrideFlag(a.viper, cmd)
cmd = channelParameterFlags(a.viper, cmd)
cmd = memoFlag(a.viper, cmd)
return cmd
}

func isRollapp(src, dst *relayer.Chain) bool {
srcP, ok := src.ChainProvider.ProviderConfig().(cosmos.CosmosProviderConfig)
if !ok {
Expand Down
28 changes: 28 additions & 0 deletions proto/dymensionxyz/dymension/lightclient/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
syntax = "proto3";
package dymensionxyz.dymension.lightclient;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/cosmos/relayer/relayer/chains/cosmos/dym/lightclient/types";



// Query defines the gRPC querier service.
service Query {
rpc RollappCanonChannel(QueryRollappCanonChannelRequest) returns (QueryRollappCanonChannelResponse) {
option (google.api.http).get = "/dymensionxyz/dymension/lightclient/canon_channel/{rollappId}";
}
}

message QueryRollappCanonChannelRequest {
string rollappId = 1;
}

message QueryRollappCanonChannelResponse {
// hub side
string hub_channel_id = 1;
// rollapp side ('counterparty')
string rollapp_channel_id = 2;
}
24 changes: 24 additions & 0 deletions proto/rollapp/hub_genesis/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
syntax = "proto3";
package rollapp.hub_genesis;

import "cosmos/msg/v1/msg.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/cosmos/relayer/relayer/chains/cosmos/rollapp/rdk/hub-genesis/types";


service Msg {
rpc SendTransfer(MsgSendTransfer) returns (MsgSendTransferResponse);
}

// Try to send the genesis transfer
// Must be whitelisted relayer, and channel must be open
// Must have tokens available to send
message MsgSendTransfer {
option (cosmos.msg.v1.signer) = "signer";
string signer = 1;
// ID of the canonical channel, as queried from the hub
string channel_id = 2;
}

message MsgSendTransferResponse {}
5 changes: 5 additions & 0 deletions relayer/chains/cosmos/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

dymtypes "github.com/cosmos/relayer/v2/relayer/chains/cosmos/dym/lightclient/types"
cosmosmodule "github.com/cosmos/relayer/v2/relayer/chains/cosmos/module"
rdktypes "github.com/cosmos/relayer/v2/relayer/chains/cosmos/rollapp/rdk/hub-genesis/types"
"github.com/cosmos/relayer/v2/relayer/chains/cosmos/stride"
ethermintcodecs "github.com/cosmos/relayer/v2/relayer/codecs/ethermint"
injectivecodecs "github.com/cosmos/relayer/v2/relayer/codecs/injective"
Expand Down Expand Up @@ -91,8 +92,12 @@ func MakeCodec(moduleBasics []module.AppModuleBasic, extraCodecs []string, accBe
}
{
// DYMENSION
// hub
dymtypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)
encodingConfig.Amino.RegisterConcrete(&dymtypes.MsgSetCanonicalClient{}, "/lightclient.SetCanonicalClient", nil)
// rollapp TODO: finish
rdktypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)
// encodingConfig.Amino.RegisterConcrete(&rdktypes.MsgSendTransfer{}, "/lightclient.SetCanonicalClient", nil)
}

return encodingConfig
Expand Down
Loading
Loading