cosmjs icon indicating copy to clipboard operation
cosmjs copied to clipboard

EthSecp

Open zakarialounes opened this issue 3 years ago • 10 comments

Please also see: https://github.com/confio/cosmjs-types/pull/30

zakarialounes avatar Jun 06 '22 16:06 zakarialounes

cc: @fedekunze

zakarialounes avatar Jun 06 '22 22:06 zakarialounes

Hope we can merge it ASAP.

liangping avatar Jun 08 '22 02:06 liangping

Is tendermint/PubKeyEthSecp256k1 a type that exists in Tendermint? At least it uses a Tendermint namespace. But I don't see it in the codebase. I would like to avoid adding code for forked Tendermint/Cosmos SDK tech.

webmaster128 avatar Jun 08 '22 05:06 webmaster128

It's introduced By EVMOS, we need it if we want to integrate Evmos stuffs into Cosmjs.

For example:

export class EthereumLedgerSigner implements OfflineAminoSigner{
  app: Eth
  hdpath: string = "44'/60'/0'/0/0"

  public async getAccounts(): Promise<readonly AccountData[]> {

    return this.app.getAddress(this.hdpath).then(x => {
      const x1: AccountData = {
        pubkey: Secp256k1.compressPubkey(fromHex(x.publicKey)),
        address: x.address,
        algo: "secp256k1" // should set to 'ethsecp256k1'
      }
      const x2: AccountData = {
        pubkey: Secp256k1.compressPubkey(fromHex(x.publicKey)),
        address: ethToCosmos(x.address),
        algo: "secp256k1" // // should set to 'ethsecp256k1'
      }
      return [x1, x2]
    })
  };

There are many scenarios that we need to extend something like pubkey

liangping avatar Jun 08 '22 05:06 liangping

Is tendermint/PubKeyEthSecp256k1 a type that exists in Tendermint? At least it uses a Tendermint namespace. But I don't see it in the codebase. I would like to avoid adding code for forked Tendermint/Cosmos SDK tech.

@webmaster128 So this PR will not be accepted?

zakarialounes avatar Jun 08 '22 15:06 zakarialounes

I think the underlying problem is that comsjs currently can't be extended in Application Land to support this. In some way I think this is very special for the type of an Account. If it would be just messages, we could add them to the registry.

I think short term, it might make sense to support evmos accounts in cosmjs. If there are too many of those incidents, it might make more sense to allow users hooking into the account parsing.

StregoFren avatar Jun 08 '22 16:06 StregoFren

@StregoFren @webmaster128 In fact it is introduced by Ethermint: https://github.com/tharsis/ethermint

The open source library is used and maintained by the Evmos core team, in addition to being used in for a number of other chains; Cronos, Kava, GenesisL1, etc.

Supporting Ethermint types in cosmjs will ensure support for a growing number of chains in the Cosmos ecosystem that rely on Ethermint's EVM.

jolube avatar Jun 14 '22 07:06 jolube

I have no issue adding support for evmos types where this is possible in a clean way. But looking at the diffs people send for evmos support, it feels like big time hackery in the deepest core of CosmJS. If evmos changes those things, it is no surprise Cosmos SDK client libraries don't work anymore.

We'll certainly not add chain ID checks to change internal logic. There should also be a different Amino prefix for the different pubkey type. AccountData does not support the ethermint pubkey type, but this could be changed.

Adding ethermint types in cosmjs-types seems useful. But not in src/cosmos/crypto/ethsecp256k1/keys.ts as there is a separate ethermint protobuf package already.

webmaster128 avatar Jun 28 '22 09:06 webmaster128

So as dapp developers, how can we interact with evmos?

is there any hacky way to do that dAPP side instead of cosmjs side?

dimiandre avatar Jul 11 '22 10:07 dimiandre

As soon as I have some time I will update the code to import the ethermint types directly into cosmjs (without having to go through the chain-id, but via the coinType). Before that I'll update the code with my last changes (chain-id updated) and I'll publish the package on npm so that it's possible to take advantage of it now (since there is absolutely no chance that's the Amino prefix will be changed imho). I let you know.

zakarialounes avatar Oct 03 '22 00:10 zakarialounes

Thank you for this PR. It was a very helpful contribution to https://github.com/cosmos/cosmjs/issues/1351. For now it is undecided if Ethermint is in scope of this project.

webmaster128 avatar Dec 13 '22 10:12 webmaster128

Hey~ Im interested in the ethermint support too. Im willing to contribute and push this forward. So the blockers is how to ideal with the same prefix of secp256k1 and ethsecp256k1. And the chain-id issue can be solved by using the coin_type=60. Those are the blockers. Am I right?

vincentysc avatar Jul 31 '23 08:07 vincentysc