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

(fix) allow full EVM access to unlocked tokens #1268

Merged
merged 53 commits into from
Feb 14, 2023
Merged

Conversation

0a1c
Copy link
Contributor

@0a1c 0a1c commented Jan 23, 2023

Description

Grant full EVM access to unlocked tokens, which by definition have no restrictions—and enable a user to make full use of their spendable balance.

By removing the AnteHandler locked token check, we allow the bank module to apply its accounting logic to every EVM state-change. See the spec for more details on how this solution works.

We include additional AnteHandler checks to make sure that if a transaction would fail because it attempts to spend unlocked tokens, we reject it and don't process it.

Edits

  • Updated spec to clarify context and solution
  • Updated description

Closes #XXX

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

PR review checkboxes:

I have...

  • added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • included the correct type prefix in the PR title
  • targeted the correct branch (see PR Targeting)
  • provided a link in the PR description to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all required CI checks have passed

Code maintenance:

I have...

  • written unit and integration tests
  • added relevant godoc and code comments.
  • updated relevant documentation (docs/) or specification (x/<module>/spec/)

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • confirmed that this PR does not change production code

-->

@0a1c 0a1c requested review from ramacarlucho and a team as code owners January 23, 2023 16:42
@0a1c 0a1c requested review from Vvaradinov and removed request for a team January 23, 2023 16:42
@linear
Copy link

linear bot commented Jan 23, 2023

ENG-1117 EVM transactions fail on vesting account for unlocked tokens when account has locked tokens

Impact

On a vesting account, unlocked tokens can't be used on the EVM at all, meaning

  1. MetaMask users can't send funds on a vesting account (with and without ledger)
  2. MetaMask users can't do any contract interactions like LPing, lending, or providing liquidity on a vesting account.
  3. MetaMask users with a vesting account have to migrate their funds off of their wallet to use those unlocked tokens on the EVM, via a non EVM tx, which is possible through dashboards like Disperze.Network.

Since vesting accounts are still increasing in adoption and we have a vesting UI being worked on, we should consider working on a fix soon to improve the vesting accounts implementation and fix all of its bugs.

What should be happening instead

Unlocked tokens that are vested, those are free to do whatever and shouldn't be bound by the EVM or restricted.

Why it happens

Currently, EVM transactions are blocked on Evmos if the account has any locked tokens, rather than if the tokens in question are locked. This is problematic because it delays access to unlocked tokens for much longer than is necessary (in many cases, this means multiple years).

Possible Solution

  • Look into using SpendableCoins, which should maintain a balance of unlocked tokens

Slack thread for context:

https://evmos.slack.com/archives/C02QAFZFSTA/p1669682548184549?thread_ts=1669594767.974709&cid=C02QAFZFSTA

@0a1c 0a1c marked this pull request as draft January 23, 2023 16:43
@0a1c 0a1c marked this pull request as ready for review January 24, 2023 03:51
app/ante/vesting.go Outdated Show resolved Hide resolved
x/vesting/keeper/integration_test.go Outdated Show resolved Hide resolved
@0a1c 0a1c changed the title Allow full EVM access to unlocked tokens (fix) allow full EVM access to unlocked tokens Jan 25, 2023
@0a1c 0a1c requested a review from danburck January 25, 2023 00:59
app/ante/vesting.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jan 25, 2023

Codecov Report

Merging #1268 (40ab7a8) into main (8aa1736) will increase coverage by 0.10%.
The diff coverage is 85.96%.

❗ Current head 40ab7a8 differs from pull request most recent head 047d53a. Consider uploading reports for the commit 047d53a to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1268      +/-   ##
==========================================
+ Coverage   72.27%   72.38%   +0.10%     
==========================================
  Files         259      259              
  Lines       17640    17658      +18     
==========================================
+ Hits        12750    12781      +31     
+ Misses       4321     4308      -13     
  Partials      569      569              
Impacted Files Coverage Δ
app/ante/handler_options.go 30.52% <0.00%> (ø)
x/vesting/types/clawback_vesting_account.go 96.74% <ø> (ø)
app/ante/evm/vesting.go 88.46% <87.50%> (+53.16%) ⬆️
x/claims/keeper/msg_server.go 66.66% <0.00%> (-24.51%) ⬇️
x/claims/keeper/keeper.go 84.61% <0.00%> (-0.57%) ⬇️
x/evm/types/errors.go 0.00% <0.00%> (ø)
ethereum/eip712/encoding.go 76.68% <0.00%> (ø)
x/claims/keeper/ibc_callbacks.go 97.76% <0.00%> (ø)

app/ante/vesting.go Outdated Show resolved Hide resolved
@fedekunze fedekunze marked this pull request as draft January 25, 2023 15:02
app/ante/vesting.go Outdated Show resolved Hide resolved
app/ante/vesting.go Outdated Show resolved Hide resolved
app/ante/vesting.go Outdated Show resolved Hide resolved
app/ante/vesting.go Outdated Show resolved Hide resolved
app/ante/vesting.go Outdated Show resolved Hide resolved
Copy link
Contributor

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there are a lot of duplicated test utils. Please reuse existing functions

x/vesting/keeper/integration_test.go Outdated Show resolved Hide resolved
x/vesting/keeper/integration_test.go Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the docs label Feb 13, 2023
@github-actions github-actions bot added the tests label Feb 13, 2023
tests/signer.go Outdated Show resolved Hide resolved
testutil/integration.go Outdated Show resolved Hide resolved
x/vesting/keeper/integration_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@fedekunze fedekunze enabled auto-merge (squash) February 14, 2023 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants