- 
                Notifications
    
You must be signed in to change notification settings  - Fork 116
 
feat(l2): allow paying fees with custom token #5024
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: fee_token_2
Are you sure you want to change the base?
Conversation
          Lines of code reportTotal lines added:  Detailed view | 
    
          Benchmark Results ComparisonBenchmark Results: Push
 Detailed ResultsBenchmark Results: BubbleSort
 Benchmark Results: ERC20Approval
 Benchmark Results: ERC20Mint
 Benchmark Results: ERC20Transfer
 Benchmark Results: Factorial
 Benchmark Results: FactorialRecursive
 Benchmark Results: Fibonacci
 Benchmark Results: FibonacciRecursive
 Benchmark Results: ManyHashes
 Benchmark Results: MstoreBench
 Benchmark Results: Push
 Benchmark Results: SstoreBench_no_opt
  | 
    
          
  | 
    
| ```rust | ||
| use ethrex_l2_sdk::{build_generic_tx, send_generic_transaction}; | ||
| use ethrex_rpc::clients::eth::Overrides; | ||
| use ethrex_common::types::TxType; | ||
| let mut tx = build_generic_tx( | ||
| l2_client, | ||
| TxType::FeeToken, | ||
| recipient, | ||
| origin, | ||
| ethrex_common::Bytes::default(), | ||
| Overrides { | ||
| fee_token: Some(fee_token), | ||
| value: Some(value), | ||
| ..Default::default() | ||
| }, | ||
| ) | ||
| .await; | ||
| 
               | 
          ||
| let tx_hash = send_generic_transaction(l2_client, tx, signer) | ||
| .await; | ||
| 
               | 
          ||
| ``` | 
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.
Can you add a complete example on how to do this.
It doesn't specify how to create l2_client and signer.
Maybe even deploying the fee_token if possible
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.
Right! Let me know what you think about this a6b20e3
        
          
                crates/l2/tests/tests.rs
              
                Outdated
          
        
      | "{test}: Priority fee mismatch" | ||
| ); | ||
| 
               | 
          ||
| if std::env::var("INTEGRATION_TEST_SKIP_FEE_VAULTS_CHECK").is_err() { | 
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.
The Operator and L1 vault balances must always be balance_before - balance_after = fee, as the fee will be 0 if it is not active. The only vault that should be under the env var is the base fee vault as it can be burn depending on the network configuration, but for that we have the INTEGRATION_TEST_SKIP_BASE_FEE_VAULT_CHECK already.
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 4c67d94
| ## Operator Workflow | ||
| 
               | 
          ||
| 1. Deploy or reuse an `IFeeToken` implementation and note its L2 address. | ||
| 2. Instantiate an `EthClient` and a signer (local or remote) that will send the transaction. | 
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.
Sending a transaction is not part of the Operator Workflow.
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.
Let's add a warning explaining what is missing.
Co-authored-by: Avila Gastón <[email protected]>
This reverts commit 452a134.
Motivation
This pull request introduces support for a new transaction type,
CustomFeeTransaction, we want to be able to pay fees with an ERC20 token instead of ETH.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