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

R4R: implement meta transaction #2

Merged
merged 14 commits into from
Nov 17, 2023
Merged

R4R: implement meta transaction #2

merged 14 commits into from
Nov 17, 2023

Conversation

abelliumnt
Copy link

@abelliumnt abelliumnt commented Oct 31, 2023

This PR enable mantle-v2 to natively support meta transaction(gas less. transaction) in protocol.
There are other gasless transaction protocols which don't need any changes in protocol, such as
https://eips.ethereum.org/EIPS/eip-2771
https://eips.ethereum.org/EIPS/eip-2612
However, all above gas less transaction protocols have some limitations on either user accounts or assets contracts, which is not convenient.

Tools to build and broadcast meta tx:
metatx.zip

@abelliumnt abelliumnt force-pushed the feature/meta-tx branch 4 times, most recently from ef17bcb to b58bdaf Compare November 2, 2023 07:06
@abelliumnt abelliumnt changed the title WIP: implement meta transaction R4R: implement meta transaction Nov 2, 2023
core/txpool/txpool.go Show resolved Hide resolved
if metaTxParams == nil {
continue
}
if metaTxParams.ExpireHeight < currHeight {
Copy link

@wukongcheng wukongcheng Nov 2, 2023

Choose a reason for hiding this comment

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

What is the purpose of metaTxParams.ExpireHeight?

Copy link
Author

Choose a reason for hiding this comment

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

The gas fee sponsor have no idea about when the users will submit meta transactions. Suppose the gas fee sponsor don't want to sponsor gas fee any more, and want to use the wallet in the future, it would be possible that sponsor wallet will be deducted native token in the future, which will be very confusing. With the ExpireHeight, the sponsor can ensure that there will be no unconscious deduction after the highest ExpireHeight.
In summary, the ExpireHeight can bring more determinism for the fee sponsor.

if metaTxParams.ExpireHeight < pool.chain.CurrentBlock().Number.Uint64() {
return types.ErrExpiredMetaTx
}
balance = pool.currentState.GetBalance(metaTxParams.GasFeeSponsor)

Choose a reason for hiding this comment

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

What happens when there is not enough balance in st.msg. MetaTxParams. GasFeeSponsor

Copy link
Author

Choose a reason for hiding this comment

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

In line 706, balance will be checked against tx cost.

@abelliumnt abelliumnt force-pushed the feature/meta-tx branch 2 times, most recently from 44b716c to 07feb74 Compare November 7, 2023 05:47
@abelliumnt abelliumnt changed the title R4R: implement meta transaction WIP: implement meta transaction Nov 7, 2023
@abelliumnt
Copy link
Author

Try to support gas fee sponsor percent.

@abelliumnt abelliumnt force-pushed the feature/meta-tx branch 4 times, most recently from 18dc64c to 1d2aac1 Compare November 9, 2023 09:51
liuhaoyang added 4 commits November 9, 2023 17:52
add unittest in txpool to conver meta tx
improve unittests
add more tests

refactor util
@abelliumnt abelliumnt changed the title WIP: implement meta transaction R4R: implement meta transaction Nov 10, 2023
Copy link

@Tri-stone Tri-stone left a comment

Choose a reason for hiding this comment

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

LGTM

@abelliumnt abelliumnt merged commit 0502107 into develop Nov 17, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants