Runs orchestrator processes that only relay specific messages that do not require a validator's signature. This mode is run alongside a non-validator injective node.
-
runRelayer
is the main entry point that starts the relayer loop running every 5 minutes. It checks if either valset or batch relaying is enabled in the config. -
The main relay flow happens in the
relay
method which:- Gets the latest Ethereum valset
- Runs valset and batch relaying in parallel if enabled (both have a config option)
-
Valset relaying (
relayValset
):- Fetches latest valsets from Injective chain
- Gets confirmations for each valset
- Checks if valset should be relayed using
shouldRelayValset
- Sends valset update to Ethereum if conditions are met
-
Batch relaying (
relayTokenBatch
):- Gets latest transaction batches from Injective chain
- Checks batch timeouts against Ethereum height
- Gets batch signatures
- Verifies if batch should be relayed using
shouldRelayBatch
- Sends transaction batch to Ethereum if conditions are met
-
Helper methods:
findLatestValsetOnEth
- Searches Ethereum events to find most recent valsetshouldRelayValset
- Checks nonce and time offset conditions for valset relayshouldRelayBatch
- Checks nonce and time offset conditions for batch relaycheckIfValsetsDiffer
- Validates consistency between Injective and Ethereum validator sets
-
Batching process that runs in parallel with relayer:
- See Batch Creator Process for more details.
This mode is specifically designed to run alongside a validator Injective node, as opposed to the more limited relayer mode which only runs the batch creator and relayer processes.
Runs 4 key parallel processes for orchestrating the Peggy bridge:
-
Oracle Process (
runOracle
):- Starts from
lastObservedEthHeight
height - Monitors and processes events from Ethereum
- See Oracle Process for more details.
- Starts from
-
Signer Process (
runSigner
):- Takes
peggyContractID
as input - Handles signing of validator messages and transactions
- See Signer Process for more details.
- Takes
-
Batch Creator Process (
runBatchCreator
):- Creates batches of transactions to be processed
- Manages transaction batching logic
- See Batch Creator Process for more details.
-
Relayer Process (
runRelayer
):- Handles relaying of messages between chains
- Manages cross-chain communication
- See Orchestrator's Relayer Mode for more details.
Retrieves Ethereum events from the Ethereum blockchain and brodcasts event claims to Injective where they're used to issue tokens or process batches.
ethBlockConfirmationDelay = 12
- Minimum confirmations needed for an Ethereum block to be considered validdefaultBlocksToSearch = 2000
- Maximum block range for Ethereum event queryresyncInterval = 24 hours
- Auto re-sync interval to catch up with validator's last observed event nonce
- Starts from
lastObservedEthBlock
height (fetched viagetLastClaimBlockHeight
from Injective) - Verifies validator is in the active set before making claims
- Ensures minimum block confirmations
- Retrieves and processes events in batches within defaultBlocksToSearch range
- Sorts events by nonce and filters out already processed ones
- Sends new event claims to Injective chain
- Legacy Deposit Events (
SendToCosmos
) - Deposit Events (
SendToInjective
) - Withdrawal Events (
TransactionBatchExecuted
) - ERC20 Deployment Events
- Valset Update Events
Implemented to handle cases where event nonce falls behind due to:
- Ethereum indexing delays
- Failed claims during validator UnBonding state
- Missed events due to infrastructure issues (e.g., Infura call failures)
getLastClaimBlockHeight
function is used to retrieve the last observed Eth event nonce from Cosmos.
- Ensures events are processed in sequence by checking nonce continuity
- Implements retry mechanisms for network operations
- Adds delays between event claims to ensure proper transaction ordering
- Maintains event order through sorting by nonce
- Checks for unsigned validator sets using OldestUnsignedValsets
- Signs off on any new validator set updates that haven't been signed yet
- Confirms valset updates on Injective chain with validator's signature
- Logs the confirmation with nonce and number of validators
- Looks for the oldest unsigned transaction batch using OldestUnsignedTransactionBatch
- Signs any new transaction batches that require signatures
- Confirms batches on Injective chain with validator's signature
- Logs confirmations with token contract, batch nonce, and number of transactions
- Runs on a default loop duration checking for items to sign
- Takes input directly from a trusted Injective node
- Assumes validity of batches and validator sets from the trusted node
- Uses retry mechanisms for reliability
- Requires both Ethereum address and Peggy ID for signing operations
- Reports metrics for monitoring and timing
- Operates as part of the main Orchestrator process
The BatchCreator runs as a loop with a default duration (60 seconds) checking for unbatched transactions
runBatchCreator
: Initializes and starts the batch creator looprequestTokenBatches
: Main loop function that processes unbatched tokensgetUnbatchedTokenFees
: Retrieves pending unbatched tokens with their feesrequestTokenBatch
: Handles individual token batch requestscheckMinBatchFee
: Validates if batch fees meet minimum USD threshold
- Monitors unbatched token withdrawals waiting to be processed
- Checks token prices against configured minimum batch fee in USD
- Supports custom ERC20 contract mapping to Injective denominations
- Uses price feeds to determine USD values of fees
- Implements retry logic for network operations
- Converts token amounts using proper decimals
- Multiplies by current token USD price (CoinGecko)
- Compares against minimum configured batch fee threshold
- Only processes batches that meet minimum fee requirements
- Reports function calls and timing
- Logs batch creation events and fee checks
- Provides debugging information for fee calculations
-
UpdatePeggyOrchestratorAddresses
- Allows validators to delegate voting responsibilities to a key
- Sets the Ethereum address that represents validators on the Ethereum side
- Validators must sign their Injective address using their submitted Ethereum address
-
SendValsetConfirm
- Used by validators to submit signatures over validator set at a given block height
- Requires validator to first set Ethereum address
- When 66% of voting power submits signatures, they can be used to update validator set on Ethereum
-
SendBatchConfirm
- Validators observe batch requests and form batches by ordering transactions by fee
- Includes validator's Ethereum signature over the batch
- Batches are cut off at max size or when transactions stop being profitable
-
SendToEth
- User-initiated message to bridge assets
- Removes tokens from user's balance immediately
- Has two layers of fees: bridge fee and chain fee
-
SendRequestBatch
- Anyone can request creation of a transaction batch
- Acts as coordination point for cross-chain transfers
- Handler generates batch from pending transactions
- Validators sign batch before relayer submits it
-
SendDepositClaim
- Claims deposits from Ethereum to Cosmos
- When >66% validators confirm seeing deposit, coins are issued on Injective side
- Includes event details like sender, receiver, amount and token contract
-
SendWithdrawalClaim
- Claims execution of withdrawal batch on Ethereum
- Confirms batch of withdrawal operations completed on bridge contract
-
SendValsetClaim
- Claims validator set updates on Ethereum
- Includes new validator powers and addresses
- Tracks reward distribution
-
SendERC20DeployedClaim
- Claims deployment of new ERC20 token contracts
- Records token details like name, symbol, decimals
- Maps Injective denoms to Ethereum token contracts