Skip to content

Commit

Permalink
feat: implement mock attestation
Browse files Browse the repository at this point in the history
  • Loading branch information
QEDK committed Apr 9, 2024
1 parent f1aeb9e commit 0b963c0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/AvailAttestation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ abstract contract AvailAttestation is Initializable {
error InvalidAttestationProof();
event Attested(bytes32 indexed leaf, uint32 indexed blockNumber, uint128 indexed leafIndex);

function initialize(IAvailBridge _bridge) external initializer {
// slither-disable-next-line naming-convention,dead-code
function __AvailAttestation_init(IAvailBridge _bridge) internal virtual onlyInitializing {
bridge = _bridge;
vectorx = bridge.vectorx();
}

function _attest(IAvailBridge.MerkleProofInput calldata input) external {
function _attest(IAvailBridge.MerkleProofInput calldata input) internal virtual {
if (!bridge.verifyBlobLeaf(input)) revert InvalidAttestationProof();
attestations[input.leaf] = AttestationData(
vectorx.rangeStartBlocks(input.rangeHash) + uint32(input.dataRootIndex),
Expand Down
23 changes: 23 additions & 0 deletions src/mocks/AvailAttestationMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.25;

import {Initializable} from "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";
import {IAvailBridge} from "src/interfaces/IAvailBridge.sol";
import {AvailAttestation} from "src/AvailAttestation.sol";

/**
* @author @QEDK (Avail)
* @title AvailAttestationMock
* @notice An mock data attestation implementation for validiums, optimiums and generic rollup stacks
* @custom:security security@availproject.org
*/
contract AvailAttestationMock is Initializable, AvailAttestation {
function initialize(IAvailBridge _bridge) external initializer {
__AvailAttestation_init(_bridge);
}

// this function signature should differ based on rollup contract's expected function signature
function attest(IAvailBridge.MerkleProofInput calldata input) external {
_attest(input);
}
}

0 comments on commit 0b963c0

Please sign in to comment.