# RelayManager

### Description

Full node operators on the Bifrost Network must additionally operate the relayer program. Therefore, carefully managing and tracking the state of all relayers is crucial to maintaining the stability of the network. The core implementation for relayer management is defined in `pallet_relay_manager`.

###

### Extrinsics

**set\_storage\_cache\_lifetime(new: `u32`)**

* interface: `api.tx.relayManager.setStorageCacheLifetime`
* summary: Sets the `StorageCacheLifetime` round length. The origin should be the root.

**set\_heartbeat\_offence\_activation(is\_active: `bool`)**

* interface: `api.tx.relayManager.setHeartbeatOffenceActivation`
* summary: Sets the activation of relayer heartbeat management. The origin should be the root.

**set\_heartbeat\_slash\_fraction(new: `Perbill`)**

* interface: `api.tx.relayManager.setHeartbeatSlashFraction`
* summary: Sets a new slash fraction for heartbeat offences. The origin should be the root.

**set\_relayer(new: `AccountId`)**

* interface: `api.tx.relayManager.setRelayer`
* summary: (Re-)sets the bonded relayer account. The origin must be the bonded controller account. The state reflection will be immediately applied.

**heartbeat()**

* interface: `api.tx.relayManager.heartbeat`
* summary: Sends a new heartbeat to manage relayer liveness for the current session. The origin must be the registered relayer account, and only the selected relayers can request.

###

### Storage Values

**StorageCacheLifetime(): `u32`**

* interface: `api.query.relayManager.storageCacheLifetime`
* summary: The maximum storage lifetime for storage data to be cached.

**Round(): `RoundIndex`**

* interface: `api.query.relayManager.round`
* summary: The current round index.

**BondedController(`AccountId`): `Option<AccountId>`**

* interface: `api.query.relayManager.bondedController`
* summary: Mapped controller accounts to the relayer account.

**RelayerPool(): `Vec<Relayer<AccountId>>`**

* interface: `api.query.relayManager.relayerPool`
* summary: The pool of relayers of the current round (including selected and non-selected relayers).

**RelayerState(): `Option<RelayerMetadata<AccountId>>`**

* interface: `api.query.relayManager.relayerState`
* summary: The current state of a specific relayer.

**SelectedRelayers(): `Vec<AccountId>`**

* interface: `api.query.relayManager.selectedRelayers`
* summary: The active relayer set selected for the current round.

**InitialSelectedRelayers(): `Vec<AccountId>`**

* interface: `api.query.relayManager.initialSelectedRelayers`
* summary: The active relayer set selected at the beginning of the current round.

**CachedSelectedRelayers(): `Vec<(RoundIndex, Vec<AccountId>)>`**

* interface: `api.query.relayManager.cachedSelectedRelayers`
* summary: The cached active relayer set selected from previous rounds.

**CachedInitialSelectedRelayers(): `Vec<(RoundIndex, Vec<AccountId>)>`**

* interface: `api.query.relayManager.cachedInitialSelectedRelayers`
* summary: The cached active relayer set selected from the beginning of each previous round.

**Majority(): `u32`**

* interface: `api.query.relayManager.majority`
* summary: The majority of the current active relayer set.

**InitialMajority(): `u32`**

* interface: `api.query.relayManager.initialMajority`
* summary: The majority of the current active relayer set at the beginning of the current round.

**CachedMajority(): `Vec<(RoundIndex, u32)>`**

* interface: `api.query.relayManager.cachedMajority`
* summary: The cached majority based on the active relayer set selected from previous rounds.

**CachedInitialMajority(): `Vec<(RoundIndex, u32)>`**

* interface: `api.query.relayManager.cachedInitialMajority`
* summary: The cached majority based on the active relayer set selected from the beginning of each previous rounds.

**ReceivedHeartbeats(`AccountId`): `bool`**

* interface: `api.query.relayManager.receivedHeartbeats`
* summary: The received heartbeats of a specific relayer in the current session.

**IsHeartbeatOffenceActive(): `bool`**

* interface: `api.query.relayManager.isHeartbeatOffenceActive`
* summary: The activation of relayer heartbeat offence management.

**HeartbeatSlashFraction(): `Perbill`**

* interface: `api.query.relayManager.heartbeatSlashFraction`
* summary: The slash fraction for heartbeat offences.

###

### Constants

**StorageCacheLifetimeInRounds: `u32`**

* interface: `api.consts.relayManager.storageCacheLifetimeInRounds`
* summary: The maximum lifetime in rounds for storage data to be cached.

**IsHeartbeatOffenceActive: `bool`**

* interface: `api.consts.relayManager.isHeartbeatOffenceActive`
* summary: The activation of relayer heartbeat offence management.

**DefaultHeartbeatSlashFraction: `Perbill`**

* interface: `api.consts.relayManager.defaultHeartbeatSlashFraction`
* summary: The default slash fraction for heartbeat offences.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bifrostnetwork.com/bifrost-network/developer-documentations/pallet-interfaces/relaymanager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
