Skip to content

SignalService

SignalService is a cross-chain signaling contract that enables secure message passing Taiko Alethia. It allows applications to send signals, synchronize chain data, and verify signals using Merkle proofs. The contract ensures that cross-chain messages are securely persisted and verifiable without introducing additional trust assumptions.

Features

  • Cross-chain message synchronization: Facilitates Merkle-proof-based message verification.
  • State root and signal caching: Stores and verifies state roots and signal roots for cross-layer communication.
  • Efficient storage: Uses slot-based storage for optimized signal retrieval.
  • Authorization mechanism: Controls who can sync chain data to prevent unauthorized updates.

Contract Methods

sendSignal

Stores a signal in contract storage for cross-chain message passing.

ParameterTypeDescription
_signalbytes32The signal (message) to store.

Returns:

Return ValueTypeDescription
slot_bytes32The storage slot where the signal is stored.

syncChainData

Synchronizes state roots and signal roots from other chains.

ParameterTypeDescription
_chainIduint64Identifier of the source chain.
_kindbytes32Type of data being synced (e.g., state root, signal root).
_blockIduint64Block ID from which the data is sourced.
_chainDatabytes32Data to be stored as the signal.

Returns:

Return ValueTypeDescription
signal_bytes32The signal corresponding to the stored chain data.

proveSignalReceived

Verifies that a signal has been received on the target chain using Merkle proofs.

ParameterTypeDescription
_chainIduint64Source chain identifier.
_appaddressAddress that sent the signal.
_signalbytes32The signal being verified.
_proofbytesMerkle proof that the signal was persisted on the source chain.

Returns:

Return ValueTypeDescription
numCacheOps_uint256The number of newly cached items.

Mechanism:

  • Uses _verifySignalReceived() to validate the proof.
  • Caches state roots and signal roots for future verification.

verifySignalReceived

Read-only version of proveSignalReceived, verifying without modifying state.

ParameterTypeDescription
_chainIduint64Source chain identifier.
_appaddressAddress that sent the signal.
_signalbytes32The signal being verified.
_proofbytesMerkle proof that the signal was persisted on the source chain.

Technical Note:

  • Uses _verifySignalReceived() for validation.
  • Does not cache or modify contract state.

isSignalSent

Checks whether a given signal has been sent.

ParameterTypeDescription
_appaddressAddress that sent the signal.
_signalbytes32The signal to check.

Returns:

Return ValueTypeDescription
boolboolReturns true if the signal has been sent, otherwise false.

isChainDataSynced

Checks if a given chain data has been successfully synced.

ParameterTypeDescription
_chainIduint64Source chain identifier.
_kindbytes32Data type identifier.
_blockIduint64Block ID from which the data is sourced.
_chainDatabytes32Data to check for synchronization.

Returns:

Return ValueTypeDescription
boolboolReturns true if the data is synced, otherwise false.

getSyncedChainData

Fetches the latest synchronized chain data.

ParameterTypeDescription
_chainIduint64Source chain identifier.
_kindbytes32Data type identifier.
_blockIduint64Block ID (if 0, retrieves the most recent).

Returns:

Return ValueTypeDescription
blockId_uint64Block ID of the synced data.
chainData_bytes32Synchronized data from the source chain.

signalForChainData

Derives a unique signal for given chain data.

ParameterTypeDescription
_chainIduint64Source chain identifier.
_kindbytes32Data type identifier.
_blockIduint64Block ID from which the data is sourced.

Returns:

Return ValueTypeDescription
signal_bytes32Unique signal hash representing the chain data.

getSignalSlot

Computes the storage slot where a signal is stored.

ParameterTypeDescription
_chainIduint64Chain ID of the signal.
_appaddressAddress that initiated the signal.
_signalbytes32Signal message to retrieve.

Returns:

Return ValueTypeDescription
slot_bytes32Storage slot where the signal is stored.

Events

SignalSent

Emitted when a signal is sent.

ParameterTypeDescription
appaddressAddress that initiated the signal.
signalbytes32The signal (message) that was sent.
slotbytes32Storage slot of the signal.
valuebytes32The signal’s value.

ChainDataSynced

Emitted when state or signal roots are synced from another chain.

ParameterTypeDescription
chainIduint64Source chain identifier.
blockIduint64Block ID associated with the data.
kindbytes32Data type identifier (state root or signal root).
databytes32The synchronized chain data.
signalbytes32Signal associated with the chain data.

Authorized

Emitted when an address is authorized or deauthorized for syncing chain data.

ParameterTypeDescription
addraddressThe address being authorized or deauthorized.
authorizedbooltrue if authorized, false otherwise.

State Variables

VariableTypeDescription
topBlockIdmapping(uint64 => mapping(bytes32 => uint64))Tracks the highest synced block ID for each chain and data type.
isAuthorizedmapping(address => bool)Stores addresses authorized to sync chain data.