cronos icon indicating copy to clipboard operation
cronos copied to clipboard

create-vesting-account transaction doesn't work

Open AzulPretoBranco opened this issue 3 years ago • 4 comments

Describe the bug

create-vesting-account transaction doesn't work.

To Reproduce

  1. Configure and start a new blockchain node (can be a local test node)
  2. Try to send a new create-vesting-account transaction
.\cronosd.exe tx vesting create-vesting-account ADDRESS AMOUNT TIME --home ... --from ... --chain-id ...

Transaction will fail with error:

raw_log: 'failed to execute message; message index: 0: invalid account type; expected:
  BaseAccount, got: *types.EthAccount: invalid request'

Expected behavior The create-vesting-account should execute as expected and a new vesting account created

Screenshots

Screenshot 2022-05-11 154920

Desktop (please complete the following information):

  • OS: Windows 10 21H2

Additional context

Cronos version used: 0.7.0 (https://github.com/crypto-org-chain/cronos/releases/tag/v0.7.0)

After a quick analysis I think this problem is happening because of a conflict between the Cronos and Cosmos code regarding the base account data structure.

In Crono's app.go we register a custom AccountI constructor function using ethermint.ProtoAccount.

Screenshot 2022-05-11 155017

Because of that every time the Cosmos's NewAccountWithAddress method is called an account of type EthAccount will be created instead of the default BaseAccount.

The problem is that Cosmos's CreateVestingAccount is not expecting that and when it invokes NewAccountWithAddress it tries to cast AccountI to BaseAccount. The cast will fail and the transaction will not complete.

Screenshot 2022-05-11 155133

I'm not attaching logs because this an easy problem to replicate. I believe this is the problem but please double check my analysis.

Any questions please ask!

AzulPretoBranco avatar May 11 '22 15:05 AzulPretoBranco

yeah, I think you are right here. But I believe you can implement vesting logic in an EVM smart contract?

yihuang avatar May 19 '22 06:05 yihuang

There's a few advantages of using the native Cosmos's vesting accounts, for example:

  • Even though they cannot transfer coins to another account the owner of the vesting account is able to delegate and undelegate from validators.

I could be wrong but I don't see a way to implement this mechanic via an EVM smart contract.

AzulPretoBranco avatar May 20 '22 10:05 AzulPretoBranco

There's a few advantages of using the native Cosmos's vesting accounts, for example:

  • Even though they cannot transfer coins to another account the owner of the vesting account is able to delegate and undelegate from validators.

I could be wrong but I don't see a way to implement this mechanic via an EVM smart contract.

I see, maybe we can make it work under ethermint.

yihuang avatar May 20 '22 13:05 yihuang

it's fixed by upgrading to 0.46, and tested in https://github.com/crypto-org-chain/cronos/pull/648

yihuang avatar Aug 18 '22 03:08 yihuang