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

Support for custom modules in Atomkraft #195

Open
dalmirel opened this issue Nov 24, 2022 · 1 comment
Open

Support for custom modules in Atomkraft #195

dalmirel opened this issue Nov 24, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@dalmirel
Copy link
Contributor

Currently Atomkraft is having implemented GRPC broadcasting only for Cosmos SDK modules and x/wasmd module trough terra_sdk. That is, the mechanism of easily creating tx and broadcasting them to the chain works only for modules covered in this package.

In audits, we will mostly have the need to audit and create and execute tests with Atomkraft for custom built modules and will need the fastest way to cover some module with tests. If an auditor could think only of parsing the traces and creating test assertions during the Atomkraft adaptation for a project, it would be great (we need to be as fast as possible).

Currently the audit team will use the CLI binary in order to create and execute tests for custom modules build for other chains, but it would be nice if there is a way to:

  • easily define new Msg type or query and use the existing GRPC broadcasting or
  • use CLI, but without the need to worry about details around building the commands that will be sent to the chain.
@dalmirel dalmirel added the enhancement New feature or request label Nov 24, 2022
@rnbguy
Copy link
Member

rnbguy commented Feb 17, 2023

Cosmos GRPC supports reflections. One can leverage it to load proto files from live GRPC endpoints without access to source protobufs.

The following examples uses grpculrl on CLI. We need to find a library to do the same programmatically during Atomkraft runtime.

Describing a query

$ grpcurl -plaintext <GRPC_IP:PORT> describe cosmos.staking.v1beta1.Query.Validator
cosmos.staking.v1beta1.Query.Validator is a method:
rpc Validator ( .cosmos.staking.v1beta1.QueryValidatorRequest ) returns ( .cosmos.staking.v1beta1.QueryValidatorResponse ) {
  option (.google.api.http) = { get:"/cosmos/staking/v1beta1/validators/{validator_addr}"  };
}

Performing the query

$ grpcurl -plaintext -d '{"validator_addr": "cosmosvaloper16k579jk6yt2cwmqx9dz5xvq9fug2tekvlu9qdv"}' <GRPC_IP:PORT> cosmos.staking.v1beta1.Query.Validator
{
  "validator": {
    "operatorAddress": "cosmosvaloper16k579jk6yt2cwmqx9dz5xvq9fug2tekvlu9qdv",
    "consensusPubkey": {"@type":"/cosmos.crypto.ed25519.PubKey","key":"pTcg/QVBC+LzpR0BuynDpMkNh4tajyeKCOtmWMfkvFU="},
    "status": "BOND_STATUS_BONDED",
    "tokens": "3217496887306",
    "delegatorShares": "3217818666723387338143077808531",
    "description": {
      "moniker": "Informal Systems",
...

The type_urls and proto files for Msg types can be retrieved from cosmos.base.reflection.v1beta1.ReflectionService and cosmos.base.reflection.v2alpha1.ReflectionService.

Listing all tx msg types

$ grpcurl -plaintext <GRPC_IP:PORT> cosmos.base.reflection.v2alpha1.ReflectionService.GetTxDescriptor
{
  "tx": {
    "fullname": "cosmos.tx.v1beta1.Tx",
    "msgs": [
      {
        "msgTypeUrl": "/ibc.core.channel.v1.MsgChannelOpenInit"
      },
      {
        "msgTypeUrl": "/ibc.core.channel.v1.MsgChannelCloseConfirm"
...

Describing a tx msg type

$ grpcurl -plaintext <GRPC_IP:PORT> describe ibc.core.channel.v1.MsgChannelOpenInit
ibc.core.channel.v1.MsgChannelOpenInit is a message:
message MsgChannelOpenInit {
  option (.gogoproto.equal) = false;
  option (.gogoproto.goproto_getters) = false;
  string port_id = 1 [(.gogoproto.moretags) = "yaml:\port_id\"];
  .ibc.core.channel.v1.Channel channel = 2 [(.gogoproto.nullable) = false];
  string signer = 3;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants