Files
linea-monorepo/contracts/docs/inheriting-main-contracts.md
The Dark Jester e66abc64fd Feat/1076 refactor and allow overriding (#1079)
* allow tokenbridge overrides

* add L1MessageService overrides

* refactor L2 MessageService

* refactor L2 MessageService V1

* use correct modifier

* refactor LineaRollup for overriding

* allow other overrides

* reinstate general in pause on tokenbridge

* add missing NatSpec

* sample overrides

* add generic bridge and document placeholder

* documentation and folder placement

* documentation cleanup

* use imported references

* use variable pragma for inherited contracts

* reset pragmas for some

* use base abstract contracts with version overrides

* use TokenBridgeBase as abstract

* Update contracts/src/bridging/token/TokenBridgeBase.sol

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* Update contracts/src/bridging/token/TokenBridgeBase.sol

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* Update contracts/src/bridging/token/TokenBridgeBase.sol

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* Update contracts/src/bridging/token/interfaces/ITokenBridge.sol

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* Update contracts/src/messaging/l2/L2MessageServiceBase.sol

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* Update contracts/src/messaging/l2/v1/interfaces/IL2MessageServiceV1.sol

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* Update contracts/src/rollup/interfaces/ILineaRollup.sol

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* Update contracts/src/rollup/LineaRollupBase.sol

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* Update contracts/src/_testing/unit/bridging/InheritingTokenBridge.sol

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* Update contracts/src/verifiers/PlonkVerifierDev.sol

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* Update contracts/src/verifiers/PlonkVerifierForDataAggregation.sol

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* Update contracts/src/verifiers/PlonkVerifierForMultiTypeDataAggregation.sol

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* Update contracts/src/verifiers/PlonkVerifierMainnetFull.sol

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* Update contracts/src/verifiers/PlonkVerifierSepoliaFull.sol

Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* linting

* allow submitDataAsCalldata overriding

* address missing test coverage

* adjust gap name for storage clarity

---------

Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>
Co-authored-by: Victorien Gauch <85494462+VGau@users.noreply.github.com>
2025-06-17 09:26:24 -07:00

3.3 KiB

Customizing Linea Rollup, Messaging, and Bridging Components

This guide explains how to customize core rollup, messaging, and bridging functionality by overriding virtual functions in the Linea protocol contracts. Several examples are provided to help you get started. Please note, these are just illustrative samples.

Note: It is recommended that any overrides or modifications from the original audited code should be independently audited for conflicting behavior.

🧩 Customizing Contract Versions

To modify the ABI version returned, the CONTRACT_VERSION() must be overriden with your specific string value. The default is the base version.

🧱 Customizing Linea Rollup Behavior

To modify the behavior of the rollup mechanism itself (e.g. blob submission for finalization), you can override virtual functions in LineaRollup.sol.

✉️ Customizing Message Sending Behavior

The MessageService contract handles L1 ↔ L2 message passing. If you want to adjust how messages are sent or verified (e.g. adding rules, changing fee logic), you can override its virtual functions.

See InheritingLineaRollup.sol for an example where MessageService functionality is customized within the rollup context.

The example provided prevents fee and value from being directly sent to the message service, but instead relies on the samples for the generic Ether bridge - sample are found links below.

🔁 Overriding Token Bridge Behavior

To implement custom behavior for token bridging (e.g., additional validation, whitelisting, alternative transfer mechanisms), override functions in the TokenBridge contract.

A reference implementation is available in InheritingTokenBridge.sol, demonstrating how to override core bridge functions for ERC20 tokens.

The example creates a generic way move specific funds to alternate escrow accounts when bridging. This could be done for various reasons - e.g. independently controlled asset types.

📨 Overriding L2 Message Service Behavior

If you need to modify how messages are processed or validated on the L2 side, override functions in the L2MessageService contract.

Check out InheritingL2MessageService.sol for a practical example of extending L2 message processing behavior.

This is modified in line with the customized L1MessageService behavior to work with the custom Ether bridges.

🪙 Custom Ether Bridge Examples

For more advanced use cases involving Ether transfers—such as delayed withdrawals or multi-phase bridging—you can extend and override the send/receive logic in:

These sample files serve as a foundation for creating fully custom Ether bridging flows tailored to your application needs.


By leveraging inheritance and Solidity's virtual/override keywords, you can safely extend and adapt Linea's modular bridge and rollup system.

Additionally, it is worth noting that all the inherited contracts now contain an additional 50 storage slots of padded space for future Linea expansion without breaking the underlying inheritors layouts.