confio / tgrade

The Tgrade Blockchain Binary, based on the Cosmos SDK and wasmd
Apache License 2.0
31 stars 10 forks source link

Ensure Cosmos-SDK vesting accounts work with PoE #220

Closed ethanfrey closed 2 years ago

ethanfrey commented 2 years ago

After discussion with validators, we will use standard cosmos-sdk vesting accounts for them. We must ensure this works and test this in the 0.6 testnet.

  1. Example how to create such a vesting account in genesis
  2. Ensure such account can stake/unstake tokens to the PoE contract
  3. Ensure there is a simple command line tool to do so, eg. tgrade tx stake ...
  4. Ensure given account cannot send via bank, nor send tokens to contracts (Wasm/Execute,Instantiate,etc)

Questions:

ethanfrey commented 2 years ago

Looking at the Cosmos SDK a bit, it seems the bank has a separate call to delegate coins (rather than send/burn) that allows the use of vesting tokens: https://github.com/cosmos/cosmos-sdk/blob/c14b101a7a3ea6b126261a9e2d7b9a937140ceba/x/bank/keeper/keeper.go#L112-L118

We will likely need to modify this somehow (using staking adaptor?) to accept the poe staking via delegate.

This may also require larger architecture changes in the contracts as well... good to investigate more

alpe commented 2 years ago

There is some good doc .

ethanfrey commented 2 years ago

Kind of... it explains the account itself, not the interaction with bank: https://docs.cosmos.network/v0.42/modules/auth/05_vesting.html#delegating refers to "upstream caller" which would be bank I think.

So basically, we need to look at bank.

alpe commented 2 years ago

I have a spiked a solution that we can discuss.

alpe commented 2 years ago

Do vesting accounts explicitly enable staking module? Or explicitly disable bank module? (This has implications for using with wasm)

We discussed this already. Both modules work together. Staking module is not using default bank send but a delegate/ undelegate method

Do we need to pay fees in gentx? (eg global fee module)

With the global fee module enabled, Yes

Can a vesting account cover fees with the still-vesting tokens (likely not, but let's check)?

No, tx fails with insufficient funds

based on above, how to we make genesis vesting that can cover gentx to stake

The the total balance amount needs to be > vesting amount so that some liquid tokens are available. For example: tgrade add-genesis-account tgrade1... 200000000utgd --vesting-amount=100000000utgd ...

ethanfrey commented 2 years ago

Great work and report back.

I think this issue can be closed. It would be great to make the above comment more findable

alpe commented 2 years ago

Update:

based on above, how to we make genesis vesting that can cover gentx to stake

Sorry, I modified the system test to confirm the fees are working but commented before testing with genTx. When I tried this now with /contrib/local/ scripts then the account has no liquid tokens during gentx executen phase to pay the fees. Need to 👀 .

alpe commented 2 years ago

ok found the issue. and can confirm now it works as described earlier. 😅 https://github.com/confio/tgrade/blob/220_vesting-create-validator/contrib/local/setup_tgrade.sh#L53

alpe commented 2 years ago

Left to do:

alpe commented 2 years ago

All done on the backend side