Cross Chain

Usually, invariants are run on a single chain. However, Gate has the capability of getting some data sources from multiple chains.

circle-info

Even if you test invariants against a specific block, the cross-chain sources will always be evaluated against the head of the specified chain.

Syntax

For supported data sources, simply add the chainId parameter:

source usdtSymbol = Call {
    contract: 0xc2132D05D31c914a87C6611C10748AEb04B58e8F,
    signature: "function signature() returns (string)",
    chainId: 137
};

This source would run on Polygon, even if the rest of the gate file itself runs on Ethereum.

Most sources also support RPC URL as chainId parameter:

source usdtSymbol = Call {
    contract: 0xc2132D05D31c914a87C6611C10748AEb04B58e8F,
    signature: "function signature() returns (string)",
    chainId: "https://rpc.mock.com"
};

This source would make RPCs against the specified URL.

Additionally, some non-EVM chains (without a numerical chain ID) can be specified as follows:

  • Bitcoin Mainnet: chainId: "bitcoin"

  • Bitcoin Signet: chainId: "signet"

  • Starknet Mainnet: chainId: "starknet"

  • Babylon Mainnet: chainId: "babylon-mainnet"

  • Babylon Testnet: chainId: "babylon-testnet"

circle-info

The chainId parameter is not required for sources that are meant to run on the primary chain the invariants are running on.

Supported sources

Currently, the following sources are cross-chain compatible:

  • Balance

  • Call

  • HistoricalEvents*

  • HistoricalCalls*

  • ValidatorBalance*

  • Slashings*

  • StateRoot

  • BlockHash

  • StorageHash

* Does not support RPC URL

Last updated