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

EIP-3009: transferWithAuthorization - Gas-Abstracted ERC20 transactions #3009

Merged
merged 4 commits into from
Oct 1, 2020

Conversation

petejkim
Copy link
Contributor

@petejkim petejkim commented Sep 30, 2020

An EIP for transferWithAuthorization, as used by the USD Coin (USDC) smart contract, alongside EIP-2612.

Discussions

@petejkim petejkim changed the title transferWithAuthorization - Gas-Abstracted ERC20 transactions EIP-3009: transferWithAuthorization - Gas-Abstracted ERC20 transactions Sep 30, 2020
Copy link
Member

@lightclient lightclient left a comment

Choose a reason for hiding this comment

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

Thank you for your proposal, @petejkim. I've left a few suggestions on your EIP.

EIPS/eip-3009.md Outdated Show resolved Hide resolved
EIPS/eip-3009.md Show resolved Hide resolved
EIPS/eip-3009.md Outdated Show resolved Hide resolved
EIPS/eip-3009.md Outdated Show resolved Hide resolved
EIPS/eip-3009.md Outdated Show resolved Hide resolved
EIPS/eip-3009.md Outdated Show resolved Hide resolved
EIPS/eip-3009.md Outdated Show resolved Hide resolved
EIPS/eip-3009.md Outdated Show resolved Hide resolved
EIPS/eip-3009.md Outdated Show resolved Hide resolved
EIPS/eip-3009.md Outdated Show resolved Hide resolved
EIPS/eip-3009.md Show resolved Hide resolved
EIPS/eip-3009.md Show resolved Hide resolved
EIPS/eip-3009.md Outdated Show resolved Hide resolved
Copy link
Contributor

@MicahZoltu MicahZoltu left a comment

Choose a reason for hiding this comment

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

Looks good enough to merge as a draft. Recommend addressing the feedback I have provided prior to moving to the next phase though.

Comment on lines +21 to +29
This enables the user to:

- delegate the gas payment to someone else,
- pay for gas in the token itself rather than in ETH,
- perform one or more token transfers and other operations in a single atomic transaction,
- transfer ERC-20 tokens to another address, and have the recipient submit the transaction,
- batch multiple transactions with minimal overhead, and
- create and perform multiple transactions without having to worry about them failing due to accidental nonce-reuse or improper ordering by the miner.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This enables the user to:
- delegate the gas payment to someone else,
- pay for gas in the token itself rather than in ETH,
- perform one or more token transfers and other operations in a single atomic transaction,
- transfer ERC-20 tokens to another address, and have the recipient submit the transaction,
- batch multiple transactions with minimal overhead, and
- create and perform multiple transactions without having to worry about them failing due to accidental nonce-reuse or improper ordering by the miner.

Please move this text to the motivation section. Abstract should be a human readable version of the specification while motivation section is where you talk about why someone would want to implement this specification.

Comment on lines +30 to +31
The popular USD-backed stablecoin [USDC v2](https://etherscan.io/token/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48) implements an expanded form of this spec. This can also be adopted alongside the [EIP-2612](./eip-2612) spec for maximum compatibility with existing applications.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The popular USD-backed stablecoin [USDC v2](https://etherscan.io/token/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48) implements an expanded form of this spec. This can also be adopted alongside the [EIP-2612](./eip-2612) spec for maximum compatibility with existing applications.

The first sentence isn't really appropriate for an EIP. Mentioning one token that already implements this standard isn't relevant to the standardization process. The second sentence could be retained, though should probably be moved into motivation.


This is especially problematic now that gas prices have become very high and transactions often get queued up and remain unconfirmed for a long time. Non-sequential nonces allow users to create as many transactions as they want at the same time.

The ERC-20 allowance mechanism is susceptible to the [multiple withdrawal attack](https://blockchain-projects.readthedocs.io/multiple_withdrawal.html)/[SWC-114](https://swcregistry.io/docs/SWC-114), and encourages antipatterns such as the use of the "infinite" allowance. The wide-prevalence of upgradeable contracts have made the conditions favorable for these attacks to happen in the wild.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it reasonable to inline a description of the multiple withdrawal attack? External links are very likely to break one day and we would like EIPs to stand on their own with minimal or no external references.

Comment on lines +55 to +56
mapping(address => mapping(bytes32 => bool)) authorizationStates;

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mapping(address => mapping(bytes32 => bool)) authorizationStates;

This is an internal implementation detail, which isn't appropriate for a standard.

) external view returns (bool);
```

This mapping keeps track of the nonces of the authorizations that have been used (`false` = Unused, `true` = Used). Nonces are randomly generated `bytes32` unique to the token holder's address.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This mapping keeps track of the nonces of the authorizations that have been used (`false` = Unused, `true` = Used). Nonces are randomly generated `bytes32` unique to the token holder's address.
This function will return `true` if the given nonce has already been used by the authorizer, and `false` otherwise.

Whether this is backed by a mapping or not is not relevant to the interface definition.

Comment on lines +52 to +53
### Storage

Copy link
Contributor

Choose a reason for hiding this comment

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

Storage is an implementation detail. Move the contents of this section into Methods.

) external;
```

The arguments `v`, `r`, and `s` can be obtained using the [EIP-712](./eip-712) typed message signing spec.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The arguments `v`, `r`, and `s` can be obtained using the [EIP-712](./eip-712) typed message signing spec.
The arguments `v`, `r`, and `s` **MUST** be obtained using the [EIP-712](./eip-712) typed message signing spec.

- However, for meta-transactions, when a transaction containing a sequential nonce value that is too high is submitted, instead of staying pending, it will revert and fail immediately, resulting in wasted gas.
- The fact that miners can also reorder transactions and include them in the block in the order they want (assuming each transaction was submitted to the network by different meta-transaction relayers) also makes it possible for the meta-transactions to fail even if the nonces used were correct. (e.g. User submits nonces 3, 4 and 5, but miner ends up including them in the block as 4,5,3, resulting in only 3 succeeding)
- Lastly, when using different applications simultaneously, in absence of some sort of an off-chain nonce-tracker, it is not possible to determine what the correct next nonce value is if there exists nonces that are used but haven't been submitted and confirmed by the network.
- This is especially problematic now that high gas price fluctuations often cause transactions to "get stuck" in the pool for a long time. Today, if you make a meta-transaction that uses a sequential nonce from one app, and switch to another app to make another meta-transaction before the previous one confirms, the same nonce will be used twice, resulting in one of the transactions failing.
Copy link
Contributor

Choose a reason for hiding this comment

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

now that high gas price fluctuations often cause transactions to "get stuck" in the pool for a long time

EIPs should be worded for a target audience reading it in 5+ years. Since we have no idea what gas prices will be like at that time, we shouldn't discuss their state (e.g., volatility) as an invariant or really even mention anything about the "current" situation.

@MicahZoltu MicahZoltu merged commit c9c0052 into ethereum:master Oct 1, 2020
tkstanczak pushed a commit to tkstanczak/EIPs that referenced this pull request Nov 7, 2020
…ns (ethereum#3009)

A contract interface that enables transferring of fungible assets via a signed authorization.
Arachnid pushed a commit to Arachnid/EIPs that referenced this pull request Mar 6, 2021
…ns (ethereum#3009)

A contract interface that enables transferring of fungible assets via a signed authorization.
@grantmike
Copy link

@petejkim @MicahZoltu @lightclient @Arachnid @tkstanczak I have an EIP which adds 13 lines of functionality to this EIP, would love your thoughts 😄 (from Circle engineering team!) #5987

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.

4 participants