11// SPDX-License-Identifier: MIT
22pragma solidity ^ 0.8.28 ;
33
4+ import {BlockHeaderData} from "../libs/BlockHeader.sol " ;
45import {TxMerkleProof} from "../libs/TxMerkleProof.sol " ;
56
67/**
@@ -14,7 +15,7 @@ interface ISPVContract {
1415 * This error indicates that the provided block height is not valid for initialization
1516 * @param blockHeight The invalid block height
1617 */
17- error InvalidInitialBlockHeight (uint256 blockHeight );
18+ error InvalidInitialBlockHeight (uint64 blockHeight );
1819 /**
1920 * @notice Emitted when a previous block does not exist.
2021 * This error occurs when a block header references a previous block that is not found
@@ -66,15 +67,15 @@ interface ISPVContract {
6667 * @param newMainchainHead The hash of the new mainchain head
6768 */
6869 event MainchainHeadUpdated (
69- uint256 indexed newMainchainHeight ,
70+ uint64 indexed newMainchainHeight ,
7071 bytes32 indexed newMainchainHead
7172 );
7273 /**
7374 * @notice Emitted when a block header is successfully added
7475 * @param blockHeight The height of the added block
7576 * @param blockHash The hash of the added block
7677 */
77- event BlockHeaderAdded (uint256 indexed blockHeight , bytes32 indexed blockHash );
78+ event BlockHeaderAdded (uint64 indexed blockHeight , bytes32 indexed blockHash );
7879
7980 /**
8081 * @notice Represents the data of a block
@@ -138,27 +139,18 @@ interface ISPVContract {
138139 ) external view returns (bool );
139140
140141 /**
141- * @notice Returns the current status of a given block
142- * @param blockHash_ The hash of the block to check
143- * @return isInMainchain True if the block is in the mainchain, false otherwise
144- * @return confirmationsCount The number of blocks that have been mined on top of the given block
145- */
146- function getBlockStatus (bytes32 blockHash_ ) external view returns (bool , uint256 );
147-
148- /**
149- * @notice Returns the cumulative work of the last epoch.
150- * This represents the total difficulty accumulated up to the last epoch boundary
151- * @return The cumulative work of the last epoch
142+ * @notice Returns the hash of the current mainchain head.
143+ * This represents the highest block on the most accumulated work chain
144+ * @return The hash of the mainchain head
152145 */
153- function getLastEpochCumulativeWork () external view returns (uint256 );
146+ function getMainchainHead () external view returns (bytes32 );
154147
155148 /**
156- * @notice Returns the Merkle root of a given block hash.
157- * This function retrieves the Merkle root from the stored block header data
158- * @param blockHash_ The hash of the block
159- * @return The Merkle root of the block
149+ * @notice Returns the height of the current mainchain head.
150+ * This represents the highest block number on the most accumulated work chain
151+ * @return The height of the mainchain head
160152 */
161- function getBlockMerkleRoot ( bytes32 blockHash_ ) external view returns (bytes32 );
153+ function getMainchainHeight ( ) external view returns (uint64 );
162154
163155 /**
164156 * @notice Returns detailed information about a block.
@@ -169,26 +161,27 @@ interface ISPVContract {
169161 function getBlockInfo (bytes32 blockHash_ ) external view returns (BlockInfo memory blockInfo_ );
170162
171163 /**
172- * @notice Returns the basic block data for a given block hash.
173- * This includes the block header and its height
174- * @param blockHash_ The hash of the block
175- * @return The basic block data
164+ * @notice Returns the block header data for a given block hash.
165+ * @param blockHash The hash of the block
166+ * @return The block header data
176167 */
177- function getBlockData (bytes32 blockHash_ ) external view returns (BlockData memory );
168+ function getBlockHeader (bytes32 blockHash ) external view returns (BlockHeaderData memory );
178169
179170 /**
180- * @notice Returns the hash of the current mainchain head.
181- * This represents the highest block on the most accumulated work chain
182- * @return The hash of the mainchain head
171+ * @notice Returns the current status of a given block
172+ * @param blockHash_ The hash of the block to check
173+ * @return isInMainchain True if the block is in the mainchain, false otherwise
174+ * @return confirmationsCount The number of blocks that have been mined on top of the given block
183175 */
184- function getMainchainHead ( ) external view returns (bytes32 );
176+ function getBlockStatus ( bytes32 blockHash_ ) external view returns (bool , uint64 );
185177
186178 /**
187- * @notice Returns the height of the current mainchain head.
188- * This represents the highest block number on the most accumulated work chain
189- * @return The height of the mainchain head
179+ * @notice Returns the Merkle root of a given block hash.
180+ * This function retrieves the Merkle root from the stored block header data
181+ * @param blockHash_ The hash of the block
182+ * @return The Merkle root of the block
190183 */
191- function getMainchainHeight ( ) external view returns (uint256 );
184+ function getBlockMerkleRoot ( bytes32 blockHash_ ) external view returns (bytes32 );
192185
193186 /**
194187 * @notice Returns the block height for a given block hash
@@ -214,6 +207,13 @@ interface ISPVContract {
214207 */
215208 function getBlockTarget (bytes32 blockHash_ ) external view returns (bytes32 );
216209
210+ /**
211+ * @notice Returns the cumulative work of the last epoch.
212+ * This represents the total difficulty accumulated up to the last epoch boundary
213+ * @return The cumulative work of the last epoch
214+ */
215+ function getLastEpochCumulativeWork () external view returns (uint256 );
216+
217217 /**
218218 * @notice Checks if a block exists in the contract's storage.
219219 * This function verifies the presence of a block by its hash
0 commit comments