Skip to content

Commit

Permalink
refactor(evm): adds comments to HashiProver fxs
Browse files Browse the repository at this point in the history
  • Loading branch information
allemanfredi committed Oct 31, 2024
1 parent c1c4a01 commit 2c98ae5
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/evm/contracts/prover/HashiProver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ contract HashiProver is IHashiProver {
SHOYU_BASHI = shoyuBashi;
}

/**
* @dev Verifies and retrieves a specific event from a transaction receipt in a foreign blockchain.
*
* @param proof A `ReceiptProof` struct containing proof details:
* - chainId: The chain ID of the foreign blockchain.
* - blockNumber: If ancestralBlockNumber is 0, then blockNumber represents the block where the transaction occurred and is available in Hashi.
* - blockHeader: The header of the specified block.
* - ancestralBlockNumber: If provided, this is the block number where the transaction took place. In this case, blockNumber is the block whose header is accessible in Hashi.
* - ancestralBlockHeaders: Array of block headers to prove the ancestry of the specified block.
* - receiptProof: Proof data for locating the receipt in the Merkle Trie.
* - transactionIndex: Index of the transaction within the block.
* - logIndex: The specific log index within the transaction receipt.
*
* @return bytes The RLP-encoded event corresponding to the specified `logIndex`.
*/
function verifyForeignEvent(ReceiptProof calldata proof) internal view returns (bytes memory) {
bytes memory blockHeader = _checkBlockHeaderAgainstHashi(
proof.chainId,
Expand All @@ -37,6 +52,23 @@ contract HashiProver is IHashiProver {
return logs[proof.logIndex].toRlpBytes();
}

/**
* @dev Verifies foreign storage data for a specified account on a foreign blockchain.
*
* @param proof An `AccountAndStorageProof` struct containing proof details:
* - chainId: The chain ID of the foreign blockchain.
* - blockNumber: If ancestralBlockNumber is 0, then blockNumber represents the block where the transaction occurred and is available in Hashi.
* - blockHeader: The header of the specified block.
* - ancestralBlockNumber: If provided, this is the block number where the transaction took place. In this case, blockNumber is the block whose header is accessible in Hashi.
* - ancestralBlockHeaders: Array of block headers proving ancestry of the specified block.
* - account: The account address whose storage is being verified.
* - accountProof: Proof data for locating the account in the state trie.
* - storageHash: Expected hash of the storage root for the account.
* - storageKeys: Array of storage keys for which data is being verified.
* - storageProof: Proof data for locating the storage values in the storage trie.
*
* @return bytes[] An array of storage values corresponding to the specified `storageKeys`.
*/
function verifyForeignStorage(AccountAndStorageProof calldata proof) internal view returns (bytes[] memory) {
bytes memory blockHeader = _checkBlockHeaderAgainstHashi(
proof.chainId,
Expand Down

0 comments on commit 2c98ae5

Please sign in to comment.