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

Issues with amino signing StakeAuthorization, or maybe outdated protobuff? #658

Open
wojciechowskip opened this issue Sep 26, 2024 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@wojciechowskip
Copy link

Hi, I've tested telescope today which basically solved my issues with FeeGrant (I wasnt able to amino sign these types of transactions with default converters from cosmjs and now I can - thats great). First impression - great tool you've provided to the community. Thank you!

But after getting rid of cosmjs amino converters and using my newly generated ones via telescope I've fixed one issue but something what was working before, now stopped :/

StakeAuthorization transaction with MsgGrant returns me:

Broadcasting transaction failed with code 4 (codespace: sdk). Log: signature verification failed; please verify account number (2815654), sequence (23) and chain-id (cosmoshub-4): unauthorized

Which is very generic error telling that 'Hey dude, your converters are shit!'. But I am wondering why. From what I was able to compare, before my msg looked like this (and was working):

{
      "type": "cosmos-sdk/MsgGrant",
      "value": {
        "grant": {
          "authorization": {
            "type": "cosmos-sdk/StakeAuthorization",
            "value": {
              "Validators": {
                "type": "cosmos-sdk/StakeAuthorization/AllowList",
                "value": {
                  "allow_list": {
                    "address": [
                      "xxx"
                    ]
                  }
                }
              },
              "authorization_type": 1,
              "max_tokens": {
                "amount": "28247",
                "denom": "uatom"
              }
            }
          },
          "expiration": "2027-09-27T10:30:33Z"
        },
        "grantee": "xxx",
        "granter": "xxx"
      }
    },

And now it looks like this (and doesnt work):

    {
      "type": "cosmos-sdk/MsgGrant",
      "value": {
        "grant": {
          "authorization": {
            "type": "cosmos-sdk/StakeAuthorization",
            "value": {
              "allow_list": {
                "address": [
                  "xxx"
                ]
              },
              "authorization_type": 1,
              "max_tokens": {
                "amount": "28247",
                "denom": "uatom"
              }
            }
          },
          "expiration": "2027-09-27T15:29:55Z"
        },
        "grantee": "xxx",
        "granter": "xxx"
      }
    },

I followed classic telescope guide from ur README, all works great except this. Looking at proto files and comparing the ones which were installed by telescope and the ones from cosmos-sdk I can say they are different for example for proto x/staking/proto/cosmos/staking/v1beta1/authz.proto

May this difference be an issue? That protobuffs for telescope are outdated? Or maybe something else?

@wojciechowskip wojciechowskip changed the title Issues with StakeAuthorization Issues with StakeAuthorization, or maybe outdated protobuff? Sep 26, 2024
@wojciechowskip wojciechowskip changed the title Issues with StakeAuthorization, or maybe outdated protobuff? Issues with amino signing StakeAuthorization, or maybe outdated protobuff? Sep 26, 2024
@pyramation
Copy link
Collaborator

Thanks @wojciechowskip —  can you share your telescope configuration? You likely need to enable interfaces, which should create the proper encoders for the accepts/implements Any interfaces such as authz

@wojciechowskip
Copy link
Author

Thanks @wojciechowskip —  can you share your telescope configuration? You likely need to enable interfaces, which should create the proper encoders for the accepts/implements Any interfaces such as authz

Sure thing, are you referring options in codegen.ts? If yes these are my options (default ones, cuz havent really changed em):

export const options: TelescopeInput = {
  protoDirs,
  outPath,
  options: {
    interfaces: {
      enabled: true,
      useUnionTypes: true
    },
    prototypes: {
      enabled: true,
      excluded: {
        packages: [
          'ibc.applications.fee.v1', // issue with parsing protos (LCD routes with nested objects in params)
          'cosmos.app.v1alpha1',
          'cosmos.app.v1beta1',
          'cosmos.base.kv.v1beta1',
          'cosmos.base.reflection.v1beta1',
          'cosmos.base.snapshots.v1beta1',
          'cosmos.base.store.v1beta1',
          'cosmos.base.tendermint.v1beta1',
          'cosmos.crisis.v1beta1',
          'cosmos.evidence.v1beta1',
          'cosmos.genutil.v1beta1',
          'cosmos.autocli.v1',
          'cosmos.msg.v1',
          'cosmos.nft.v1beta1',
          'cosmos.capability.v1beta1',
          'cosmos.orm.v1alpha1',
          'cosmos.orm.v1',
          'cosmos.slashing.v1beta1',
          'google.api',
          'ibc.core.port.v1',
          'ibc.core.types.v1'
        ]
      },
    },

    bundle: {
      enabled: true
    },

    tsDisable: {
      files: [],
      patterns: [],
      disableAll: true
    },

    eslintDisable: {
      files: [],
      patterns: [],
      disableAll: false
    },

    stargateClients: {
      enabled: true,
      includeCosmosDefaultTypes: true
    },

    aminoEncoding: {
      enabled: true,
      customTypes: {
        useCosmosSDKDec: false
      },
      exceptions: {
        ...AMINO_MAP
      },
    },
    lcdClients: {
      enabled: false
    },
    rpcClients: {
      type: 'tendermint',
      enabled: true
    },

    reactQuery: {
      enabled: false
    },

    mobx: {
      enabled: false
    },

    pinia: {
      enabled: false
    }
  }
};

After looking at I guess its enabled, right?

@wojciechowskip
Copy link
Author

wojciechowskip commented Sep 27, 2024

@pyramation is that something on telescope side? Matter of config or an issue? Since it does not work for me only for MsgGrant with StakeAuthorization. I was trying to put custom converter for this case but unfortunately it messes everything up :/ Any advice for a temporary workaround to speed things up?

Btw this is a way I am creating a message:

import { cosmos } from 'my-generated-lib'

const {
  MsgGrant,
  Grant,
} = cosmos.authz.v1beta1;

const {
  StakeAuthorization,
  AuthorizationType,
  StakeAuthorization_Validators,
} = cosmos.staking.v1beta1;

...
 
return {
    typeUrl: COSMOS_MESSAGE_TYPE_URL.GRANT,
    value: MsgGrant.fromPartial({
      granter: granterAddress,
      grantee: granteeAddress,
      grant: Grant.fromPartial({
        expiration: expiredDate, // date format
        authorization: {
          typeUrl: COSMOS_MESSAGE_TYPE_URL.STAKE_AUTHORIZATION, // '/cosmos.staking.v1beta1.StakeAuthorization'
          value: StakeAuthorization.encode(
            StakeAuthorization.fromPartial({
              maxTokens, // Coin
              authorizationType: AuthorizationType.AUTHORIZATION_TYPE_DELEGATE, // 1
              allowList: StakeAuthorization_Validators.fromPartial({
                address: validatorAddresses,
              }),
            })
          ).finish(),
        },
      }),
    }),
  };

and this is signing client creation:

import {
  cosmosAminoConverters, cosmosProtoRegistry,
} from 'my-generated-lib';

const protoRegistry: ReadonlyArray<[string, GeneratedType]> = [
  ...cosmosProtoRegistry,
];

const aminoConverters = {
  ...cosmosAminoConverters,
};

...

return SigningStargateClient.connectWithSigner(rpcEndpoint, offlineSigner, {
  registry,
  aminoTypes,
});

@pyramation
Copy link
Collaborator

https://github.com/cosmology-tech/create-cosmos-app/tree/main/examples/authz

checkout this example for now, we'll dig into these accepts/implements interface issues after Cosmoverse — hopefully this working demo can help! it has the StakeAuthorization in it

@pyramation pyramation added the help wanted Extra attention is needed label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants