This repository has been archived by the owner on Mar 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
IAxiomV1Verifier.sol
47 lines (42 loc) · 2.95 KB
/
IAxiomV1Verifier.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import {BLOCK_BATCH_DEPTH} from "../../libraries/configuration/AxiomV1Configuration.sol";
interface IAxiomV1Verifier {
/// @notice A merkle proof to verify a block against the verified blocks cached by Axiom
/// @dev `BLOCK_BATCH_DEPTH = 10`
struct BlockHashWitness {
uint32 blockNumber;
bytes32 claimedBlockHash;
bytes32 prevHash;
uint32 numFinal;
bytes32[BLOCK_BATCH_DEPTH] merkleProof;
}
/// @notice Verify the blockhash of block blockNumber equals claimedBlockHash. Assumes that blockNumber is within the last 256 most recent blocks.
/// @param blockNumber The block number to verify
/// @param claimedBlockHash The claimed blockhash of block blockNumber
function isRecentBlockHashValid(uint32 blockNumber, bytes32 claimedBlockHash) external view returns (bool);
/// @notice Verify the blockhash of block witness.blockNumber equals witness.claimedBlockHash by checking against Axiom's cache of #historicalRoots.
/// @dev For block numbers within the last 256, use #isRecentBlockHashValid instead.
/// @param witness The block hash to verify and the Merkle proof to verify it
/// witness.blockNumber is the block number to verify
/// witness.claimedBlockHash is the claimed blockhash of block witness.blockNumber
/// witness.prevHash is the prevHash stored in #historicalRoots(witness.blockNumber - witness.blockNumber % 1024)
/// witness.numFinal is the numFinal stored in #historicalRoots(witness.blockNumber - witness.blockNumber % 1024)
/// witness.merkleProof is the Merkle inclusion proof of witness.claimedBlockHash to the root stored in #historicalRoots(witness.blockNumber - witness.blockNumber % 1024)
/// witness.merkleProof[i] is the sibling of the Merkle node at depth 10 - i, for i = 0, ..., 10
function isBlockHashValid(BlockHashWitness calldata witness) external view returns (bool);
/// @notice Verify the blockhash of block blockNumber equals claimedBlockHash by checking against Axiom's cache of historical Merkle mountain ranges in #mmrRingBuffer.
/// @dev Use event logs to determine the correct bufferId and get the MMR at that index in the ring buffer.
/// @param mmr The Merkle mountain range commited to in #mmrRingBuffer(bufferId), must be correct length
/// @param bufferId The index in the ring buffer of #mmrRingBuffer
/// @param blockNumber The block number to verify
/// @param claimedBlockHash The claimed blockhash of block blockNumber
/// @param merkleProof The Merkle inclusion proof of claimedBlockHash to the corresponding peak in mmr. The correct peak is calculated from mmr.length and blockNumber.
function mmrVerifyBlockHash(
bytes32[] calldata mmr,
uint8 bufferId,
uint32 blockNumber,
bytes32 claimedBlockHash,
bytes32[] calldata merkleProof
) external view;
}