Large Validator Sets/Rapid Validator Set Updates May Freeze the Bridge or Relayers
Submitted by nascent
In a similar vein to “Freeze The Bridge Via Large ERC20 Names/Symbols/Denoms”, a sufficiently large validator set or sufficiently rapid validator update, could cause both the eth_oracle_main_loop and relayer_main_loop to fall into a state of perpetual errors. In find_latest_valset, we call:
let mut all_valset_events = web3
.check_for_events(
end_search.clone(),
Some(current_block.clone()),
vec![gravity_contract_address],
vec![VALSET_UPDATED_EVENT_SIG],
)
.await?;
Which if the validator set is sufficiently large, or sufficiently rapidly updated, continuoussly return an error if the logs in a 5000 (see: const BLOCKS_TO_SEARCH: u128 = 5_000u128;) block range are in excess of 10mb. Cosmos hub says they will be pushing the number of validators up to 300 (currently 125). At 300, each log would produce 19328 bytes of data (432+64300). Given this, there must be below 517 updates per 5000 block range otherwise the node will fall out of sync.
This will freeze the bridge by disallowing attestations to take place.
This requires a patch to reenable the bridge.
Recommendation
Handle the error more concretely and check if you got a byte limit error. If you did, chunk the search size into 2 and try again. Repeat as necessary, and combine the results.
This is a solid report with detailed computations to back it up. I appreciate it and will take actions in our web3 library to prevent this exact scenario.
Context
Gravity Bridge is a bridge between Cosmos-based chains and Ethereum. Two off-chain components keep the bridge in sync with what happens on the Ethereum side: the orchestrator's eth_oracle_main_loop, which observes Ethereum events and turns them into attestations, and the relayer_main_loop, which relays validator set updates. Both depend on reading Ethereum event logs through a web3 library.
One of the functions involved is find_latest_valset, which searches recent blocks for validator set update events emitted by the Gravity contract. The report examines what happens to that search when the validator set grows large, or when validator set updates happen very rapidly.
Setup
The finding concerns the orchestrator's relayer component in the cosmos-gravity-bridge repository, at commit [redacted]. The relevant code is in orchestrator/relayer/src/find_latest_valset.rs. No special accounts, roles or tooling are described; the analysis is a code and arithmetic review of the event search logic.
The precondition is a validator set that is large, or that is updated rapidly enough, that the validator set update logs within a single search window exceed the size limit imposed by the Ethereum node.
Finding it
The researcher noticed that find_latest_valset performs a log search over a fixed block range and propagates any error from that search with ?. The search is issued like this:
let mut all_valset_events = web3
.check_for_events(
end_search.clone(),
Some(current_block.clone()),
vec![gravity_contract_address],
vec![VALSET_UPDATED_EVENT_SIG],
)
.await?;
The ? propagates any error out of the function. The search window is fixed by a constant:
const BLOCKS_TO_SEARCH: u128 = 5_000u128;
So every call searches a 5000-block range for VALSET_UPDATED_EVENT_SIG events from the Gravity contract address. If the logs returned for that range are in excess of 10mb, the node returns an error, and because the error is propagated, the search fails every time it is retried. The researcher frames this as similar in nature to the previously reported issue "Freeze The Bridge Via Large ERC20 Names/Symbols/Denoms": a data volume problem that turns into a permanent error state.
Exploitation
Step 1: Establish the size of a single log entry
Each validator set update log carries data proportional to the number of validators. The report gives the arithmetic for a set of 300 validators: each log produces 19328 bytes of data, calculated as 4*32+64*300.
Step 2: Compare against the node's response limit
The report states that Cosmos Hub intends to push the number of validators up to 300, from the current 125. With logs of that size, the total data returned for a 5000-block window exceeds the 10mb limit once there are too many updates in the window. The report derives the threshold: there must be below 517 updates per 5000-block range, otherwise the node will fall out of sync.
Step 3: Observe the loop behaviour
When the threshold is crossed, the log query returns a byte limit error. Because find_latest_valset propagates the error with ?, the call fails rather than returning partial results, and the next attempt uses the same 5000-block window and hits the same limit. The report describes the result as both eth_oracle_main_loop and relayer_main_loop falling into a state of perpetual errors.
Step 4: Consequence for the bridge
With the loops stuck in this error state, attestations cannot take place, which freezes the bridge. The report notes that this requires a patch to re-enable the bridge.
Root cause
The search window is fixed at 5000 blocks and the error from the log query is handled generically: any failure, including a response that exceeds the node's byte limit, aborts the function. There is no logic to detect a size-related failure and reduce the range being queried. Because the window never shrinks, a range whose logs exceed the limit will fail identically on every retry, so the loop cannot recover on its own. The search window is fixed, so growth in log volume from a larger validator set or more frequent updates is not accommodated.
Impact
If the validator set is sufficiently large, or validator set updates are sufficiently rapid, the validator set update logs in a 5000-block window can exceed the node's 10mb response limit. Both eth_oracle_main_loop and relayer_main_loop then fall into perpetual errors, attestations cannot take place, and the bridge is frozen until a patch is applied. The report's concrete figure is that at 300 validators there must be below 517 updates per 5000-block range to avoid this.
Fix
The recommendation is to handle the error more concretely: check whether the failure is a byte limit error, and if so, split the search size in two and try again, repeating as necessary and combining the results. This makes the search adaptive to log volume instead of failing permanently on a fixed window.
The Althea developer jkilpatr confirmed the report, describing it as solid with detailed computations to back it up, and stated that actions would be taken in the web3 library to prevent this exact scenario.
Variants to test
- Other fixed-window log searches. Look for any other
check_for_eventsstyle call with a hard-coded block range. A positive result is a range whose logs can be made to exceed the node's response limit, with the error propagated rather than handled. - Other event types with variable-size payloads. Events whose data grows with a configurable or attacker-influenced value, in the same way validator set update logs grow with the validator count. A positive result is a payload size calculation showing the limit can be crossed within the fixed window.
- Error handling around retries. Check whether a failing query is retried with the same parameters. A positive result is a loop that repeats an identical failing request indefinitely with no backoff or range reduction.
Hunting notes
This class of bug hides in off-chain components that poll a chain through a fixed query window and treat every error as fatal. During review, the signals are a hard-coded block range constant, a log query whose result size depends on on-chain state, and error propagation that leaves no path to recovery. The researcher showed impact by tying the payload size to Cosmos Hub's stated plan to raise the validator count, computing the per-log size and the resulting update threshold, and explaining that recovery requires a patch. That combination of arithmetic and a clear operational consequence is what the maintainer acknowledged.
What happened, in plain words
Gravity Bridge is a piece of software that lets two different blockchain networks, Cosmos-based chains and Ethereum, talk to each other and move value between them. To do that, some programs run off the blockchain (off-chain) and watch what happens on the Ethereum side. Two of these programs are called eth_oracle_main_loop and relayer_main_loop. The first one watches Ethereum for events and turns them into attestations, which are signed statements that something happened. The second one passes on updates about who the validators are.
A validator, in simple terms, is a computer that helps run a blockchain and confirm that transactions are genuine. The list of validators changes over time, and every change is written to Ethereum as an event log, a small record that says "the validator set was updated".
To find the most recent update, the bridge searches the last few thousand blocks of the Ethereum chain. A block is like a page in a ledger: a batch of transactions recorded together. The search is done through a web3 library, which is a helper program that lets other software talk to an Ethereum node (a server that holds a copy of the blockchain).
The problem in this report is about size. When there are many validators, each update log is bigger. When updates happen very often, there are more logs in the same search window. If the total amount of data returned for one search goes over a limit set by the Ethereum node (10mb in this case), the node refuses and returns an error. The bridge code propagates that error, so the search fails, and the loops fall into a state of perpetual errors. The result is that the bridge stops working: no attestations happen, and it stays frozen until someone patches the software.
Context
Gravity Bridge connects Cosmos-based chains and Ethereum. Two off-chain components keep the bridge in sync with what happens on the Ethereum side:
eth_oracle_main_loop, which observes Ethereum events and turns them into attestations.relayer_main_loop, which relays validator set updates.
Both depend on reading Ethereum event logs through a web3 library. One of the functions involved is find_latest_valset, which searches recent blocks for validator set update events emitted by the Gravity contract. A contract here is a program that lives on the blockchain and runs automatically. The report examines what happens to that search when the validator set grows large, or when validator set updates happen very rapidly.
Setup
The finding concerns the orchestrator's relayer component in the cosmos-gravity-bridge repository, at commit [redacted]. A commit is a saved snapshot of the code, identified by a long string of characters, so anyone can look at exactly the same version. The relevant code is in orchestrator/relayer/src/find_latest_valset.rs. No special accounts, roles or tooling are described; the analysis is a code and arithmetic review of the event search logic.
The precondition is a validator set that is large, or that is updated rapidly enough, that the validator set update logs within a single search window exceed the size limit imposed by the Ethereum node.
Finding it
The researcher noticed that find_latest_valset performs a log search over a fixed block range and treats any error from that search as fatal to the loop. The search is issued like this:
let mut all_valset_events = web3
.check_for_events(
end_search.clone(),
Some(current_block.clone()),
vec![gravity_contract_address],
vec![VALSET_UPDATED_EVENT_SIG],
)
.await?;
Line by line, in plain words:
let mut all_valset_events = web3starts a new variable calledall_valset_events, which will hold the list of events found.mutmeans the value can change later.web3is the helper library used to talk to the Ethereum node..check_for_events(calls a function in that library whose job is to look for events.end_search.clone(),passes the block where the search should stop..clone()makes a copy of the value so the original is not used up.Some(current_block.clone()),passes the current block as an optional value.Some(...)is how this language says "here is a value, not nothing".vec![gravity_contract_address],passes a list containing the address of the Gravity contract, so only events from that contract are considered.vec![...]builds a list.vec![VALSET_UPDATED_EVENT_SIG],passes a list containing the signature of the event we care about, meaning the label that identifies "validator set updated" events.)closes the call..await?;waits for the answer, and the?means: if the call returned an error, stop here and pass that error up to whoever called this function. This is the key detail: any error, including a "too much data" error, aborts the whole function.
The search window is fixed by a constant:
const BLOCKS_TO_SEARCH: u128 = 5_000u128;
This line defines a constant, a named value that never changes while the program runs. It is called BLOCKS_TO_SEARCH, has the type u128 (an unsigned whole number that can be very large), and its value is 5000. So every call searches a 5000-block range for VALSET_UPDATED_EVENT_SIG events from the Gravity contract address.
If the logs returned for that range are in excess of 10mb, the node returns an error, and because the error is propagated, the search fails every time it is retried. The researcher frames this as similar in nature to the previously reported issue "Freeze The Bridge Via Large ERC20 Names/Symbols/Denoms": a data volume problem that turns into a permanent error state.
Exploitation
Step 1: Establish the size of a single log entry
Each validator set update log carries data proportional to the number of validators. The report gives the arithmetic for a set of 300 validators: each log produces 19328 bytes of data, calculated as 4*32+64*300.
In plain words: 4 times 32 bytes is a fixed part of the record, and 64 bytes times 300 validators is the part that grows with the number of validators. Add them together and you get 19328 bytes for one log. A byte is a unit of digital information; roughly a million bytes make a megabyte (mb).
Step 2: Compare against the node's response limit
The report states that Cosmos Hub intends to push the number of validators up to 300, from the current 125. With logs of that size, the total data returned for a 5000-block window exceeds the 10mb limit once there are too many updates in the window. The report derives the threshold: there must be below 517 updates per 5000-block range, otherwise the node will fall out of sync.
In plain words: if more than 516 updates happen inside the same 5000-block window, the combined logs are too big for the node to return in one answer, and the bridge cannot keep up with the chain.
Step 3: Observe the loop behaviour
When the threshold is crossed, the log query returns a byte limit error. Because find_latest_valset propagates the error with ?, the call fails rather than returning partial results, and the next attempt uses the same 5000-block window and hits the same limit. The report describes the result as both eth_oracle_main_loop and relayer_main_loop falling into a state of perpetual errors.
A loop here is a piece of software that repeats the same job over and over. If every repetition ends in the same error, the loop never makes progress.
Step 4: Consequence for the bridge
With the loops stuck in this error state, attestations cannot take place, which freezes the bridge. The report notes that this requires a patch to re-enable the bridge. A patch is a small update to the software that fixes the problem.
Root cause
The search window is fixed at 5000 blocks and the error from the log query is handled generically: any failure, including a response that exceeds the node's byte limit, aborts the function. There is no logic to detect a size-related failure and reduce the range being queried. Because the window never shrinks, a range whose logs exceed the limit will fail identically on every retry, so the loop cannot recover on its own. The search window is fixed, so growth in log volume from a larger validator set or more frequent updates is not accommodated.
A useful comparison: imagine asking a librarian for every book on a shelf, and being told "too many, ask for fewer". If you keep asking for the whole shelf in exactly the same way, you will keep getting the same refusal. The fix is to ask for half the shelf, then a quarter, until the request is small enough to be answered.
Impact
If the validator set is sufficiently large, or validator set updates are sufficiently rapid, the validator set update logs in a 5000-block window can exceed the node's 10mb response limit. Both eth_oracle_main_loop and relayer_main_loop then fall into perpetual errors, attestations cannot take place, and the bridge is frozen until a patch is applied. The report's concrete figure is that at 300 validators there must be below 517 updates per 5000-block range to avoid this.
Fix
The recommendation is to handle the error more concretely: check whether the failure is a byte limit error, and if so, split the search size in two and try again, repeating as necessary and combining the results. This makes the search adaptive to log volume instead of failing permanently on a fixed window.
The Althea developer jkilpatr confirmed the report, describing it as solid with detailed computations to back it up, and stated that actions would be taken in the web3 library to prevent this exact scenario.
Variants to test
- Other fixed-window log searches. Look for any other
check_for_eventsstyle call with a hard-coded block range. A positive result is a range whose logs can be made to exceed the node's response limit, with the error propagated rather than handled. - Other event types with variable-size payloads. Events whose data grows with a configurable or attacker-influenced value, in the same way validator set update logs grow with the validator count. A positive result is a payload size calculation showing the limit can be crossed within the fixed window.
- Error handling around retries. Check whether a failing query is retried with the same parameters. A positive result is a loop that repeats an identical failing request indefinitely with no backoff or range reduction. Backoff means waiting longer between attempts; range reduction means asking for a smaller slice of blocks.
Hunting notes
This class of bug hides in off-chain components that poll a chain through a fixed query window and treat every error as fatal. Polling means asking the same question again and again at intervals. During review, the signals are a hard-coded block range constant, a log query whose result size depends on on-chain state, and error propagation that leaves no path to recovery. The researcher showed impact by tying the payload size to Cosmos Hub's stated plan to raise the validator count, computing the per-log size and the resulting update threshold, and explaining that recovery requires a patch. That combination of arithmetic and a clear operational consequence is what the maintainer acknowledged.
Glossary
- Attestation: a signed statement produced by the bridge software confirming that something happened on a blockchain.
- Backoff: waiting longer between repeated attempts after a failure.
- Block: a batch of transactions recorded together on a blockchain, like a page in a ledger.
- Blockchain: a shared, append-only record of transactions kept by many computers.
- Bridge: software that lets two separate blockchains exchange information or value.
- Byte: a unit of digital information; about a million bytes make a megabyte (mb).
- Commit: a saved snapshot of a code repository, identified by a long string of characters.
- Constant: a named value in a program that does not change while the program runs.
- Contract: a program that lives on a blockchain and runs automatically.
- Cosmos Hub: a blockchain in the Cosmos family of networks.
- Error propagation: passing an error up from the function where it happened to the code that called it, instead of handling it locally.
- Event log: a small record written to a blockchain when something notable happens, such as a validator set update.
- Fixed window: a search range that always covers the same number of blocks, regardless of how much data it returns.
- Loop: a piece of software that repeats the same job over and over.
- Off-chain: running outside the blockchain itself, on ordinary servers or computers.
- Orchestrator: the part of the bridge software that coordinates the off-chain components.
- Patch: a small update to software that fixes a problem.
- Payload: the data carried inside a message or record.
- Polling: asking the same question again and again at intervals.
- Relayer: the component that passes validator set updates from one side of the bridge to the other.
- Signature (event): the label that identifies a particular kind of event on a blockchain.
- Unsigned integer (u128): a whole number that cannot be negative and can hold very large values.
- Validator: a computer that helps run a blockchain and confirm that transactions are genuine.
- Validator set: the current list of validators taking part in a blockchain.
- Web3 library: a helper program that lets other software talk to an Ethereum node.
- Ethereum node: a server that holds a copy of the Ethereum blockchain and answers queries about it.