-
Couldn't load subscription status.
- Fork 114
feat(l2): use new approach for fee tokens instead of native tokens #5008
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
base: main
Are you sure you want to change the base?
Conversation
This reverts commit f6ccc00.
Lines of code reportTotal lines added: Detailed view |
| /// @notice The L1 token address that is treated as the one to be bridged to the L2. | ||
| /// @dev If set to address(0), ETH is considered the native token. | ||
| /// Otherwise, this address is used for native token deposits and withdrawals. | ||
| address public NATIVE_TOKEN_L1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we deprecate this var?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can safely this as we didn't deploy any L2 since this was added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR reverts the native token approach for L2, returning to ETH as the native balance while preparing for a future feature to allow fee payment with ERC20 tokens. The change simplifies the bridge implementation by removing the configurable native token support and standardizing on ETH.
Key changes:
- Removed native token configuration and related logic throughout the codebase
- Updated bridge contracts to use
ETH_TOKENconstant instead of configurableNATIVE_TOKEN_L1 - Simplified deposit/withdrawal flows to only handle ETH transfers
- Updated tests to remove native token conditionals
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| fixtures/contracts/ERC20/NativeTokenTest.bin | Removed test ERC20 token contract binary |
| docs/l2/fundamentals/native_tokens.md | Removed native token documentation |
| docs/l2/fundamentals/contracts.md | Updated constant name from NATIVE_TOKEN_L2 to ETH_TOKEN |
| crates/l2/tests/tests.rs | Removed native token parameters and conditional logic from test functions |
| crates/l2/sdk/src/sdk.rs | Updated default bridge address |
| crates/l2/docker-compose.yaml | Removed native token environment variable |
| crates/l2/contracts/src/l2/CommonBridgeL2.sol | Renamed constant and simplified withdrawal encoding |
| crates/l2/contracts/src/l1/interfaces/ICommonBridge.sol | Removed _amount parameter from deposit function signature |
| crates/l2/contracts/src/l1/CommonBridge.sol | Removed native token logic, simplified deposit/withdrawal to ETH-only |
| cmd/ethrex/l2/deployer.rs | Removed native token configuration and ERC20 approval logic from deployer |
| .github/workflows/pr-main_l2.yaml | Removed native token test workflow configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cmd/ethrex/l2/deployer.rs
Outdated
| const APPROVE_SIGNATURE: &str = "approve(address,uint256)"; | ||
|
|
||
| #[derive(Clone, Copy, Default)] | ||
| #[derive(Clone, Copy)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove Copy too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! a217eff
| _deposit(l2Recipient); | ||
| } | ||
|
|
||
| function _deposit(address l2Recipient) private { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can now have _deposit body directly in deposit and call deposit() on receive()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done it here a217eff
| /// @notice The L1 token address that is treated as the one to be bridged to the L2. | ||
| /// @dev If set to address(0), ETH is considered the native token. | ||
| /// Otherwise, this address is used for native token deposits and withdrawals. | ||
| address public NATIVE_TOKEN_L1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can safely this as we didn't deploy any L2 since this was added
Note
This PR needs #5024
Motivation
We want a new approach for having native tokens in the L2. We want to keep the balance of the accounts to remain being ETH but allow the fees of the transactions to be paid with an ERC20.
Description
CustomFeeTransactionas a new variant to theTransactionenum, and updated theTxTypeenum and its associated methods to recognize the new type.CustomFeeTransactionis not allowed in P2P transaction processing, returning an error if encountered.l2_hookto deduct and refund fees according to the ERC20 tokens desired as the user