### Start Relayer Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Builds and starts the Generalised Relayer application. ```bash pnpm start ``` -------------------------------- ### Install Dependencies Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Installs project dependencies using pnpm. Includes a note about production environments requiring only production dependencies. ```bash pnpm install # For production environments: pnpm install --prod=false ``` -------------------------------- ### Environment Variables Configuration Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Example of the .env file used for Docker-specific configurations, such as enabling specific Docker Compose profiles. ```bash # .env COMPOSE_PROFILES=wormhole,layerzero ``` -------------------------------- ### Run with Docker Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Starts the Generalised Relayer using Docker Compose. The -d flag detaches the process to run in the background. ```bash docker compose up [-d] ``` -------------------------------- ### Run Redis Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Starts a Redis database container, exposing port 6379 for communication. This port must match the configuration in the .env file. ```bash docker container run -p 6379:6379 redis ``` -------------------------------- ### Typechain Type Generation Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Explains that the Relayer utilizes `ethers` types generated by the `typechain` package for contract interactions. These types are created from contract ABIs located in the `abis/` folder during `npm` package installation. If ABIs change, types must be regenerated via the `postinstall` script in `package.json`. ```javascript // package.json { "name": "generalised-relayer", "version": "1.0.0", "scripts": { "postinstall": "typechain --target=ethers-v5 'abis/**/*.json' --outDir='src/types/contracts'" // ... other scripts ... }, "devDependencies": { "@typechain/ethers-v5": "^10.0.0", "typechain": "^8.0.0", "ethers": "^5.0.0" // ... other dev dependencies ... } } ``` -------------------------------- ### Relayer Configuration Structure Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Illustrates the expected structure of the main relayer configuration file in YAML format, including global settings, AMB configurations, and chain-specific details. ```yaml # config.production.yaml global: privateKey: "0x..." monitor: interval: 5000 # ... other global configurations ambs: wormhole: incentivesAddress: "0x..." layerzero: incentivesAddress: "0x..." mock: incentivesAddress: "0x..." chains: ethereum: chainId: 1 rpc: "https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID" # overrides for monitor, getter, etc. monitor: interval: 10000 # overrides for AMB configuration amb: incentivesAddress: "0x..." polygon: chainId: 137 rpc: "https://polygon-rpc.com" # ... other chain configurations ``` -------------------------------- ### Pricing Service Configuration Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Configuration for the Pricing Service, including provider selection (fixed or coin-gecko) and cache duration. ```yaml pricingProvider: "fixed" | "coin-gecko" gasCoinId: "" # Required for coin-gecko provider cacheDuration: ``` -------------------------------- ### Low Balance Warning Configuration Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Configuration for the low balance warning threshold in Wei. ```yaml lowBalanceWarning: ``` -------------------------------- ### Docker Compose Configuration Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Recommends updating the `docker-compose.yaml` file to include any necessary images or services for a standalone AMB implementation when running the Relayer with Docker. It also suggests creating a dedicated Docker Compose profile for these new additions to allow for optional disabling. ```dockerfile version: '3.8' services: # ... other services ... your-amb-service: build: context: ./your-amb-service dockerfile: Dockerfile ports: - "3001:3001" depends_on: - redis environment: - AMB_CONFIG_PATH=./config.yaml profiles: - "your-amb-profile" # ... other services ... volumes: # ... volumes ... networks: # ... networks ... ``` -------------------------------- ### Collector Service Implementation Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Details the requirements for implementing a new collector service for an AMB. The service must be placed in a dedicated folder within `collector/`, named after the AMB. It should collect AMB proofs and submit them to Redis using the `store/store.lib.ts` library's `submitProof` helper. Crucially, the service must avoid blocking the main event loop, recommending the use of worker threads. ```typescript import { submitProof } from "./store/store.lib.ts"; // ... inside your AMB collector service ... async function collectAndSubmitProof(ambData) { // Collect AMB proofs const proofs = await collectProofs(ambData); // Submit proofs to Redis await submitProof(proofs); } // Example of using worker threads to avoid blocking import { Worker } from 'worker_threads'; function startProofCollectionWorker(ambData) { const worker = new Worker('./collector/your-amb/worker.ts', { workerData: ambData }); worker.on('message', (msg) => { console.log('Message from worker:', msg); }); worker.on('error', (err) => { console.error('Worker error:', err); }); worker.on('exit', (code) => { if (code !== 0) console.error(`Worker stopped with exit code ${code}`); }); } ``` -------------------------------- ### Store Library - Redis Interaction Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Abstraction layer for interacting with a Redis database, used for communication between Relayer services. ```typescript import { RedisClient } from 'redis'; class Store { private client: RedisClient; constructor(redisUrl: string) { this.client = new RedisClient({ url: redisUrl }); } async get(key: string): Promise { return this.client.get(key); } async set(key: string, value: string, ttl?: number): Promise { await this.client.set(key, value, { EX: ttl }); } async del(key: string): Promise { return this.client.del(key); } } export { Store }; ``` -------------------------------- ### Pricing Controller API Endpoints Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md API endpoints exposed by the Pricing controller for querying token prices. ```APIDOC GET /prices/{tokenAddress} Description: Retrieves the current price of a token. Parameters: - tokenAddress (path): The address of the token. Responses: 200 OK: content: application/json: schema: type: object properties: price: { type: number, description: "The price of the token." } currency: { type: string, description: "The currency of the price." } 404 Not Found: description: Token price not found. ``` -------------------------------- ### AMB Configuration in YAML Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Specifies how to add new AMB configurations to the `.yaml` configuration file. The configuration should be nested under the AMB's name and will be automatically passed to the service upon instantiation by the main Collector controller. ```yaml ambs: yourNewAMB: # AMB specific configuration parameters rpcUrl: "http://your-amb-rpc.com" contractAddress: "0x1234567890abcdef1234567890abcdef12345678" # ... other configuration ... ``` -------------------------------- ### Legacy Transaction Fee Configuration Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Configuration options for setting legacy transaction fees, including gas price adjustment factor and maximum allowed gas price. ```yaml gasPriceAdjustmentFactor: "" maxAllowedGasPrice: "" ``` -------------------------------- ### IncentivizedMessageEscrow Contract Interaction Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Demonstrates how the Submitter service interacts with the IncentivizedMessageEscrow contract to process packet submissions. This involves calling the `processPacket` method. ```solidity contract IncentivizedMessageEscrow { // ... other functions function processPacket( address _from, address _to, bytes calldata _data, uint256 _gasLimit, uint256 _gasPerUnit ) external { // Implementation details for processing a packet } // ... other functions } ``` -------------------------------- ### Transaction Repricing Configuration Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Configuration for repricing stuck transactions, including the maximum number of retries and the interval between retries. ```yaml maxTries: retryInterval: ``` -------------------------------- ### EIP-1559 Transaction Fee Configuration Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Configuration options for setting EIP-1559 transaction fees, including max fee per gas, priority fee adjustment, and maximum allowed priority fee. ```yaml maxFeePerGas: "" maxPriorityFeeAdjustmentFactor: "" maxAllowedPriorityFeePerGas: "" ``` -------------------------------- ### Relayer Integration - AMB Messages Endpoint Source: https://github.com/glacislabs/generalised-relayer/blob/main/README.md Endpoint for external services to query AMB messages corresponding to a transaction hash. ```APIDOC GET /relayer/ambs/{transactionHash} Description: Retrieves AMB messages for a given transaction hash. Parameters: - transactionHash (path): The hash of the transaction. Responses: 200 OK: content: application/json: schema: type: array items: type: object properties: message: { type: string, description: "The AMB message content." } timestamp: { type: string, format: date-time, description: "Timestamp of the message." } 404 Not Found: description: No AMB messages found for the transaction hash. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.