Skip to main content

Mass exit API and CLI reference

This topic summarizes key CLI commands, Rell queries, and EVM contract calls used throughout the mass exit flow.

EVM contract functions

Trigger mass exit

function triggerMassExit(
bytes memory blockHeader, // Recent, verified block header
bytes[] memory sigs, // Validator signatures endorsing the header
address[] memory signers, // Validator addresses corresponding to the signatures
Data.ExtraProofData memory extraProof // Additional proof data if needed

Trigger with historical validators

function triggerMassExitWithHistoricalValidators(
bytes memory blockHeader, // Recent, verified block header
bytes[] memory sigs, // Validator signatures endorsing the header
address[] memory signers, // Validator addresses corresponding to the signatures
Data.ExtraProofData memory extraProof, // Additional proof data if needed
address[] memory historicalValidators // Historical validator addresses used for verification
)

Withdraw via snapshot

function withdrawBySnapshot(
bytes calldata snapshot, // Snapshot data capturing the account state
Data.Proof memory stateProof // Merkle proof validating the snapshot
)

Complete in-progress withdrawal

function completeWithdrawalBySnapshot(
bytes calldata _stateRecord, // Account state record data (header and withdrawal event hashes)
uint64 n, // Index of the specific withdrawal event in the record
bytes memory _event, // Withdrawal event data
Data.Proof memory stateProof // Merkle proof for the account state record
)

Chromia CLI and queries

Get account state proof

chr query -brid $BRIDGE get_account_state_merkle_proof \
-- blockHeight=$BLOCK_HEIGHT \
accountNumber=$ACCOUNT_STATE_SLOT_ID

Get state slot IDs for user balance

val state_slot_ids = hbridge.get_state_slot_ids_for_address(
beneficiary, // EVM address of the user
network_id // Identifier of the EVM network
);

Get state slot IDs for withdrawal

val slot_ids = hbridge.get_withdrawal_state_slot_ids_for_address(
beneficiary, // EVM address of the user
network_id // Identifier of the EVM network
);

Get withdrawal by tx + op index

val withdrawal = hbridge.get_erc20_withdrawal_by_tx(
tx_rid, // Rell transaction RID
op_index // Operation index within the transaction
);

Get withdrawal event proof

chr query -brid $BRIDGE get_event_merkle_proof \
-- eventHash=$WITHDRAWAL_EVENT_HASH

Cross-Chain recovery

Deploy recovery contract

npx hardhat deploy:recovery --network <network> \
--validator-address <VALIDATOR_CONTRACT_ADDRESS>

Set recovery contract RID

npx hardhat setBlockchainRid:recovery \
--network <network> \
--address <RECOVERY_CONTRACT_ADDRESS> \
--blockchain-rid <DOWNSTREAM_CHAIN_RID>

Register recovery contract on downstream

chr tx -brid $DOWNSTREAM_CHAIN_RID register_recovery_contract \
-- $NETWORK_ID x"'$RECOVERY_CONTRACT_ADDRESS'"

Register it upstream via ICCF on Bridge Chain

chr tx -brid $BRIDGE --iccf-tx $ICCF_TX_RID \
--iccf-source $DOWNSTREAM_CHAIN_RID \
register_recovery_contract -- 0