Skip to content

Indexer

The TezosBridgeIndexer contract is designed to manage and retrieve signatures associated with specific signers and data identifiers. It allows signers to store signatures on-chain and enables users to read these signatures, facilitating secure and verifiable cross-chain operations.

Table of Contents

Overview

The TezosBridgeIndexer contract provides functionality to store and retrieve signatures. It is primarily used by signers to write signatures and by users to read these signatures. The contract maintains mappings of signatures and their timestamps to ensure data integrity and prevent replay attacks.

Key Features

  • Signature Management: Store and retrieve signatures using unique identifiers.
  • Timestamp Tracking: Users have the capability to monitor the performance and uptime of signers.
  • Batch Operations: Supports batch operations for setting multiple signatures at once.
  • Data Integrity: Ensures that each signature is unique.

Deployment

Getting Started

This section provides a quick guide to set up, test, and deploy the TezosBridgeIndexer contract.

1. Environment Setup

First, copy the environment template and configure your parameters:

cp .env.example .env

Edit .env with your specific values:

# Required for deployment
PRIVATE_KEY="0x..." # Deployer private key
 
# Network configuration
RPC_URL="http://localhost:8545" # For local testing
# RPC_URL="https://mainnet.infura.io/v3/YOUR_KEY" # For mainnet
 
# Optional: For contract verification
ETHERSCAN_API_KEY="your_api_key_here"

2. Install Dependencies

# Install Foundry if not already installed
curl -L https://foundry.paradigm.xyz | bash
foundryup
 
# Install project dependencies
forge install

3. Deploy and Verify

# Local testing
anvil
forge script script/TezosBridgeIndexer.s.sol:TezosBridgeIndexerScript --rpc-url http://localhost:8545 --private-key $PRIVATE_KEY --broadcast
 
# Testnet deployment
forge script script/TezosBridgeIndexer.s.sol:TezosBridgeIndexerScript --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast --verify

Production Deployment

For production deployment, ensure you follow these steps:

1. Security Checklist

  • Private keys stored securely (hardware wallet/secure key management)

2. Configure Production Environment

# Production configuration
PRIVATE_KEY="0x..." # Deployer key (preferably from hardware wallet)
RPC_URL="https://${NETWORK}.infura.io/v3/YOUR_INFURA_KEY"
ETHERSCAN_API_KEY="your_etherscan_api_key"

3. Deploy to Mainnet

# Deploy with verification
forge script script/TezosBridgeIndexer.s.sol:TezosBridgeIndexerScript --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast --verify
 
# Alternative: Use production deployment function
forge script script/TezosBridgeIndexer.s.sol:TezosBridgeIndexerScript --sig "runProduction()" --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast --verify

Monitoring

Users have the capability to monitor the performance and uptime of signers through the public functions provided by the TezosBridgeIndexer contract. By utilizing the timestamps associated with each signature, users can assess the responsiveness and reliability of the signers, ensuring the integrity of cross-chain operations.

Monitor Signer Performance

The TezosBridgeIndexer contract provides several public functions that allow users to monitor the performance and uptime of signers. By leveraging these functions, users can track signature timestamps, evaluate response times, and analyze signer activity. Here’s how users can effectively monitor signer performance:

1. Retrieve Signature Timestamps

Users can call the getTimestamp function to obtain the timestamp of the latest signature from a specific signer. This information is publicly accessible and can be used to evaluate how frequently and regularly signers are updating their signatures.

2. Evaluate Response Time

By comparing the timestamps of when a signature request was made and when the signature was recorded on-chain, users can measure the response time of signers. This helps in assessing how quickly signers are processing and signing transactions.

3. Check for Recent Signer Activity

Using the getSignersLastSignature function, users can check the most recent signatures from multiple signers. This function provides both the signature and its associated timestamp, allowing users to verify recent activity and ensure that signers are actively participating in the network.

4. Analyze Uptime and Performance Patterns

Users can analyze historical data of signature timestamps to identify patterns in signer uptime and performance. This analysis can help in detecting periods of inactivity or potential issues with specific signers.

Example Monitoring Process

Step 1: Retrieve Timestamps

Call getTimestamp for each signer to get the latest signature timestamps.

Step 2: Compare Timestamps

Compare these timestamps to determine the time elapsed since the last signature update. Frequent updates indicate active and reliable signers.

Step 3: Set Up Alerts

Although the contract itself does not provide alerting mechanisms, users can set up external monitoring tools to alert them when the time between signature updates exceeds expected thresholds.

Step 4: Visualize Data

Users can create dashboards or visualizations using off-chain tools to represent signer performance metrics, such as signature frequency and response times.


By leveraging these public functions and the transparency of the blockchain, users can effectively monitor the performance and uptime of signers, contributing to the overall reliability and trustworthiness of the cross-chain bridge.

Contract Functions

The TezosBridgeIndexer contract provides several functions for managing signatures. Below is a detailed description of each function.

setSignature

Allows a signer to set a signature for a specific identifier.

function setSignature(
    string calldata id,
    string calldata data,
    string calldata signature
) public;
Parameters:
  • id: The unique identifier for the signature.
  • data: The data associated with the signature.
  • signature: The signature to be stored.

setSignatures

Allows a signer to set multiple signatures at once.

function setSignatures(
    string[] calldata ids,
    string[] calldata datas,
    string[] calldata signatures
) external;
Parameters:
  • ids: An array of unique identifiers for the signatures.
  • datas: An array of data associated with the signatures.
  • signatures: An array of signatures to be stored.

getSignature

Retrieves a signature for a specific identifier and signer.

function getSignature(
    address signer,
    string calldata id
) external view returns (Signature memory);
Parameters:
  • signer: The address of the signer.
  • id: The unique identifier for the signature.
Returns:
  • Signature: The signature associated with the identifier and signer.

getTimestamp

Retrieves the timestamp for a specific signature and signer.

function getTimestamp(
    address signer,
    string calldata signature
) external view returns (uint256);
Parameters:
  • signer: The address of the signer.
  • signature: The signature to retrieve the timestamp for.
Returns:
  • uint256: The timestamp of the signature.

getSignatureAndTimestamp

Retrieves both the signature and its timestamp for a specific identifier and signer.

function getSignatureAndTimestamp(
    address signer,
    string calldata id
) external view returns (Signature memory, uint256);
Parameters:
  • signer: The address of the signer.
  • id: The unique identifier for the signature.
Returns:
  • Signature: The signature associated with the identifier and signer.
  • uint256: The timestamp of the signature.

getSignersLastSignature

Retrieves the last signatures and their timestamps for multiple signers and a specific identifier.

function getSignersLastSignature(
    address[] calldata signers,
    string calldata id
) external view returns (Signature[] memory, uint256[] memory);
Parameters:
  • signers: An array of signer addresses.
  • id: The unique identifier for the signatures.
Returns:
  • Signature[]: An array of signatures associated with the identifier and signers.
  • uint256[]: An array of timestamps for the signatures.

Usage

Writing Signatures

Signers can use the setSignature or setSignatures functions to store signatures on-chain. Ensure that each signature is unique and associated with the correct data identifier.

Reading Signatures

Users can retrieve signatures and their timestamps using the getSignature, getTimestamp, getSignatureAndTimestamp, and getSignersLastSignature functions. These functions provide flexibility in accessing the stored signatures and their metadata.

Troubleshooting

Common Issues

1. Signature already exists

  • Ensure that each signature is unique and has not been previously stored.
  • Verify that the timestamp for the signature has not already been set.

2. Invalid input

  • Ensure that the input arrays for setSignatures are of the same length.
  • Verify that the data and identifiers are correctly formatted and provided.

3. Access denied

  • Verify that the contract address and function signatures are correct.
Copyright © 2025 RAID Square.