Skip to content

Bridge

Bridge is a cross-chain message passing contract that enables secure asset transfers between Layer 1 (Ethereum) and Layer 2 (Taiko Alethia). The bridge allows users to send, process, retry, and recall messages between chains, leveraging the Signal Service for proof verification.

The contract also supports quota management to prevent excessive withdrawals and is designed to work efficiently in rollup environments.


Features

  • Cross-chain message transfers: Facilitates message passing and asset transfers between L1 and L2.
  • Signal verification: Uses Merkle proofs to validate messages.
  • Gas-optimized execution: Implements EIP-1559-based fee calculations for processing efficiency.
  • Quota management: Ensures rate-limited withdrawals via the QuotaManager contract.
  • Relayer-friendly architecture: Allows relayers to submit transactions and earn fees.

Contract Methods

sendMessage

Sends a cross-chain message and takes custody of Ether or tokens.

ParameterTypeDescription
_messageMessageThe message struct containing message details.

Returns:

Return ValueTypeDescription
msgHash_bytes32The hash of the sent message.
message_MessageThe updated message details.

Mechanism:

  • Stores the message hash and emits a MessageSent event.
  • Sends a signal to the SignalService for proof verification.

processMessage

Processes a bridge message on the destination chain.

ParameterTypeDescription
_messageMessageThe message to process.
_proofbytesMerkle proof verifying the message.

Returns:

Return ValueTypeDescription
status_StatusThe final status of the message (e.g., DONE, RETRIABLE).
reason_StatusReasonReason for status change.

Mechanism:

  • Verifies message authenticity using Merkle proofs.
  • Checks if the relayer is eligible for fees.
  • Processes the message call on the destination chain.
  • Refunds excess Ether to the destOwner.

retryMessage

Retries processing a failed message.

ParameterTypeDescription
_messageMessageThe message to retry.
_isLastAttemptboolIf true, marks the message as failed if retry fails.

Mechanism:

  • Checks message status before retrying.
  • Attempts re-execution on the destination chain.
  • Marks the message as DONE if successful, otherwise FAILED.

failMessage

Marks a message as failed if it’s in a retriable state.

ParameterTypeDescription
_messageMessageThe message to mark as failed.

Mechanism:

  • Updates message status to FAILED.
  • Sends a failure signal via the SignalService.

recallMessage

Recalls a failed message on the source chain and refunds associated assets.

ParameterTypeDescription
_messageMessageThe message to recall.
_proofbytesMerkle proof proving message failure.

Mechanism:

  • Validates Merkle proof to confirm failure.
  • Refunds Ether or calls the sender’s recall function.

isMessageSent

Checks whether a message has been sent.

ParameterTypeDescription
_messageMessageThe message to check.

Returns:

Return ValueTypeDescription
boolboolReturns true if the message was sent.

isMessageReceived

Checks whether a message has been received.

ParameterTypeDescription
_messageMessageThe message to check.
_proofbytesMerkle proof verifying the message.

Returns:

Return ValueTypeDescription
boolboolReturns true if the message was received.

Events

MessageSent

Emitted when a message is sent.

ParameterTypeDescription
msgHashbytes32Hash of the message.
messageMessageThe message details.

MessageStatusChanged

Emitted when a message’s status changes.

ParameterTypeDescription
msgHashbytes32Hash of the message.
statusStatusNew status of the message.

MessageProcessed

Emitted when a message is successfully processed.

ParameterTypeDescription
msgHashbytes32Hash of the processed message.
messageMessageThe message details.
statsProcessingStatsGas usage and relayer stats.

Important Data Structures

Message

A message represents a cross-chain transaction.

FieldTypeDescription
iduint64Unique ID assigned to the message.
feeuint64Maximum processing fee for relayers.
gasLimituint32Gas limit required for processing.
fromaddressSender’s address.
srcChainIduint64Source chain ID.
srcOwneraddressOwner of the message on the source chain.
destChainIduint64Destination chain ID.
destOwneraddressOwner of the message on the destination chain.
toaddressRecipient address on the destination chain.
valueuint256Ether amount to send.
databytesCall data for execution.

Status

Represents the current state of a message.

StatusDescription
NEWMessage is pending processing.
RETRIABLEMessage failed but can be retried.
DONEMessage processed successfully.
FAILEDMessage failed permanently.
RECALLEDMessage was recalled by the sender.

StatusReason

Represents the reason for a message’s status change.

ReasonDescription
INVOCATION_OKMessage executed successfully.
INVOCATION_PROHIBITEDMessage execution was blocked.
INVOCATION_FAILEDMessage execution failed.
OUT_OF_ETH_QUOTAInsufficient quota for message execution.

Gas Considerations

ParameterValueDescription
GAS_RESERVE800,000Reserved gas for processing.
GAS_OVERHEAD120,000Overhead for message execution.
RELAYER_MAX_PROOF_BYTES200,000Max proof size relayers can process.
_GAS_REFUND_PER_CACHE_OPERATION20,000Gas refund per cache operation.
_SEND_ETHER_GAS_LIMIT35,000Gas limit for sending Ether.