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

feat(core): Implement gateway transaction fee methods in GasAdjuster #3552

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

VolodymyrBg
Copy link

What ❔

This PR implements the get_gateway_tx_base_fee() and get_gateway_tx_pubdata_price() methods in the GasAdjuster struct for handling gateway transactions in L2 mode. These methods were previously marked as todo!() and are now fully implemented.

The implementation follows the existing patterns for fee calculation while adapting them for L2-specific requirements:

  • Uses L2 pubdata price statistics for base fee calculations
  • Applies consistent price bounds and multipliers
  • Respects configuration overrides
  • Follows the same fee capping mechanisms as regular transactions

Why ❔

Gateway transactions in L2 mode require specific fee handling that differs from regular L1 transactions. This implementation:

  • Ensures proper fee calculation for gateway transactions using L2-specific metrics
  • Maintains consistency with the existing fee model architecture
  • Completes the implementation of the TxParamsProvider trait for GasAdjuster
  • Improves code maintainability by removing todo!() placeholders with proper implementations

The changes are necessary for proper operation of gateway transactions in L2 mode, which is a critical part of the zkSync Era infrastructure.

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • Code has been formatted via zkstack dev fmt and zkstack dev lint.

Implementation Details

The implementation:

  1. For get_gateway_tx_base_fee():

    • Uses L2 pubdata price statistics as the base metric
    • Applies the internal L1 pricing multiplier
    • Bounds the price using existing mechanisms
    • Respects enforced gas price configuration
  2. For get_gateway_tx_pubdata_price():

    • Uses L2 pubdata price statistics
    • Applies the same fee capping mechanism
    • Respects enforced pubdata price configuration

Both methods maintain consistency with existing patterns while adapting them for L2-specific requirements.

Implements get_gateway_tx_base_fee() and get_gateway_tx_pubdata_price() methods in the GasAdjuster's TxParamsProvider implementation. These methods handle fee calculation for gateway transactions in L2 mode by:

- Using L2 pubdata price statistics for base fee calculation
- Applying consistent price bounds and multipliers
- Respecting configuration overrides
- Following the same fee capping mechanisms as regular transactions

This implementation ensures proper fee handling for gateway transactions while maintaining consistency with the existing fee model architecture.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant