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: add null addresses checks in creditGasFees #302

Merged
merged 6 commits into from
Nov 23, 2023

Conversation

nvtaveras
Copy link
Collaborator

Description

While testing MU04 on Baklava we noticed that gas payment with stables was broken and after some digging we realized that this is due to a slight change in the implementation details of the creditGasFees function after switching to the StableTokenV2 implementation.

TL;DR is that there were checks for the null address in the v1 implementation that were removed in v2, which makes the tx fail when the node attempts to include it in a block due to the gatewayFeeRecipient address being 0x and the underlying call to _transfer(from, 0x, amount) failing.

This change adds a null address check for each recipient addresses and it also keeps track of any amount that can't be transferred to recipients so that it's burned at the end of the function for proper accounting purposes.

Other changes

Fixed a slight typo of conmunityFund which was repeated throughout the code.

Tested

  • Wrote unit tests passing null addresses for each recipient
  • Existing tests pass as expected

Backwards compatibility

This is actually backwards compatible with the original V1 implementation that has proper null checks before the balances of the different accounts are manipulated https://github.com/mento-protocol/mento-core/blob/develop/contracts/legacy/StableToken.sol#L581-L587

@nvtaveras nvtaveras changed the base branch from develop to v2.2.1-creditGasFeeFix November 22, 2023 13:52
@nvtaveras nvtaveras changed the title fix: check for 0x addresses in creditGasFees fix: add null addresses checks in creditGasFees Nov 22, 2023
contracts/tokens/StableTokenV2.sol Outdated Show resolved Hide resolved
contracts/tokens/StableTokenV2.sol Show resolved Hide resolved
test/tokens/StableTokenV2.t.sol Show resolved Hide resolved
contracts/tokens/StableTokenV2.sol Show resolved Hide resolved
Copy link
Contributor

@philbow61 philbow61 left a comment

Choose a reason for hiding this comment

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

LGTM ⛷️

@nvtaveras nvtaveras merged commit 0e467d1 into v2.2.1-creditGasFeeFix Nov 23, 2023
@chapati23 chapati23 deleted the fix/MU04Hotfix branch November 30, 2023 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants