Skip to main content

ConfirmedBlockHeightExists

Assertion whether a block with the specified blockNumber is confirmed with additional data to compute the block production rate within a given time window.

Supported chains

  • BTC (Bitcoin)
  • DOGE (Dogecoin)
  • XRP (XRP Ledger)
  • Test networks: testBTC (Bitcoin Testnet v3), testDOGE, testXRP

Request

FieldSolidity TypeDescription
blockNumberuint64The block number to confirm.
queryWindowuint64The time period (in seconds) to calculate the block production rate.

Response

FieldSolidity TypeDescription
blockTimestampuint64The timestamp of the block at blockNumber.
numberOfConfirmationsuint64The required number of confirmations for the block to be considered confirmed (chain-specific).
lowestQueryWindowBlockNumberuint64The block number of the latest block with a timestamp strictly less than blockTimestamp - queryWindow.
lowestQueryWindowBlockTimestampuint64The timestamp of the block at lowestQueryWindowBlockNumber.

Verification process

  1. The function checks if the block with blockNumber is confirmed by at least the required numberOfConfirmations for the specified chain.
    • If the block does not meet this requirement, the request is rejected.
    • A block at the tip of the chain has exactly 1 confirmation.
  2. The lowestQueryWindowBlock` is identified, and its block number and timestamp are extracted.
  3. The required confirmations are defined based on chain-specific finality.
  4. The returned timestamp is:
    • mediantime for Bitcoin and Dogecoin.
    • close_time for XRPL.
Lowest used timestamp

For the lowestUsedTimestamp parameter, the value of lowestQueryWindowBlockTimestamp is used.

Finality

Blockchains have varying confirmation depths to consider blocks as final.

ChainchainIdConfirmations requiredConfirmation time
Bitcoin06≈60 mins
Dogecoin260≈60 mins
XRPL33≈12 seconds

Contract interface

Sourced from IConfirmedBlockHeightExists.sol on GitHub.

// SPDX-License-Identifier: MIT
pragma solidity >=0.7.6 <0.9;

/**
* @custom:name IConfirmedBlockHeightExists
* @custom:id 0x02
* @custom:supported BTC, DOGE, XRP
* @author Flare
* @notice An assertion that a block with `blockNumber` is confirmed.
* It also provides data to compute the block production rate in the given time range.
* @custom:verification It is checked that the block with `blockNumber` is confirmed by at
* least `numberOfConfirmations`.
* If it is not, the request is rejected. We note a block on the tip of the chain is confirmed by 1 block.
* Then `lowestQueryWindowBlock` is determined and its number and timestamp are extracted.
*
*
* Current confirmation heights consensus:
*
*
* | `Chain` | `chainId` | `numberOfConfirmations` | `timestamp ` |
* | ------- | --------- | ----------------------- | ------------ |
* | `BTC` | 0 | 6 | mediantime |
* | `DOGE` | 2 | 60 | mediantime |
* | `XRP` | 3 | 3 | close_time |
*
*
* @custom:lut `lowestQueryWindowBlockTimestamp`
* @custom:lutlimit `0x127500`, `0x127500`, `0x127500`
*/
interface IConfirmedBlockHeightExists {
/**
* @notice Toplevel request
* @param attestationType ID of the attestation type.
* @param sourceId ID of the data source.
* @param messageIntegrityCode `MessageIntegrityCode` that is derived from the expected response as defined.
* @param requestBody Data defining the request. Type and interpretation is determined by the `attestationType`.
*/
struct Request {
bytes32 attestationType;
bytes32 sourceId;
bytes32 messageIntegrityCode;
RequestBody requestBody;
}

/**
* @notice Toplevel response
* @param attestationType Extracted from the request.
* @param sourceId Extracted from the request.
* @param votingRound The ID of the State Connector round in which the request was considered.
* @param lowestUsedTimestamp The lowest timestamp used to generate the response.
* @param requestBody Extracted from the request.
* @param responseBody Data defining the response. The verification rules for the construction of the
* response body and the type are defined per specific `attestationType`.
*/
struct Response {
bytes32 attestationType;
bytes32 sourceId;
uint64 votingRound;
uint64 lowestUsedTimestamp;
RequestBody requestBody;
ResponseBody responseBody;
}

/**
* @notice Toplevel proof
* @param merkleProof Merkle proof corresponding to the attestation response.
* @param data Attestation response.
*/
struct Proof {
bytes32[] merkleProof;
Response data;
}

/**
* @notice Request body for ConfirmedBlockHeightExistsType attestation type
* @param blockNumber The number of the block the request wants a confirmation of.
* @param queryWindow The length of the period in which the block production rate is to be computed.
*/
struct RequestBody {
uint64 blockNumber;
uint64 queryWindow;
}

/**
* @notice Response body for ConfirmedBlockHeightExistsType attestation type
* @custom:below `blockNumber`, `lowestQueryWindowBlockNumber`, `blockTimestamp`, `lowestQueryWindowBlockTimestamp`
* can be used to compute the average block production time in the specified block range.
* @param blockTimestamp The timestamp of the block with `blockNumber`.
* @param numberOfConfirmations The depth at which a block is considered confirmed depending on the chain.
* All attestation providers must agree on this number.
* @param lowestQueryWindowBlockNumber The block number of the latest block that has a timestamp strictly smaller
* than `blockTimestamp` - `queryWindow`.
* @param lowestQueryWindowBlockTimestamp The timestamp of the block at height `lowestQueryWindowBlockNumber`.
*/
struct ResponseBody {
uint64 blockTimestamp;
uint64 numberOfConfirmations;
uint64 lowestQueryWindowBlockNumber;
uint64 lowestQueryWindowBlockTimestamp;
}
}