Skip to content

Commit

Permalink
fix: fix attestation
Browse files Browse the repository at this point in the history
  • Loading branch information
QEDK committed Oct 6, 2024
1 parent e8eebcb commit 98de9f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
9 changes: 6 additions & 3 deletions da-contracts/contracts/da-layers/AvailL1DAValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ import {IAvailBridge} from "../IAvailBridge.sol";
import {AvailAttestationLib} from "../lib/AvailAttestationLib.sol";

contract AvailL1DAValidator is IL1DAValidator, AvailAttestationLib {
error InvalidValidatorOutputHash();

constructor(IAvailBridge _availBridge) AvailAttestationLib(_availBridge) {}

function checkDA(
uint256, // _chainId
uint256, // _batchNumber
bytes32, // _l2DAValidatorOutputHash
bytes32 l2DAValidatorOutputHash, // _l2DAValidatorOutputHash
bytes calldata operatorDAInput,
uint256 maxBlobsSupported
) external returns (L1DAValidatorOutput memory output) {
IAvailBridge.MerkleProofInput memory input = abi.decode(operatorDAInput, (IAvailBridge.MerkleProofInput));
IAvailBridge.MerkleProofInput memory input = abi.decode(operatorDAInput[32:], (IAvailBridge.MerkleProofInput));
if (l2DAValidatorOutputHash != input.leaf) revert InvalidValidatorOutputHash();
_attest(input);

// The rest of the fields that relate to blobs are empty.
output.stateDiffHash = input.leaf;
output.stateDiffHash = bytes32(operatorDAInput[:32]);
output.blobsLinearHashes = new bytes32[](maxBlobsSupported);
output.blobsOpeningCommitments = new bytes32[](maxBlobsSupported);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@
pragma solidity 0.8.24;

import {IL2DAValidator} from "../../interfaces/IL2DAValidator.sol";
import {StateDiffL2DAValidator} from "../StateDiffL2DAValidator.sol";

/// Rollup DA validator. It will publish data that would allow to use either calldata or blobs.
contract AvailL2DAValidator is IL2DAValidator {
contract AvailL2DAValidator is IL2DAValidator, StateDiffL2DAValidator {
function validatePubdata(
// The rolling hash of the user L2->L1 logs.
bytes32,
// The root hash of the user L2->L1 logs.
bytes32,
// The chained hash of the L2->L1 messages
bytes32,
bytes32 _chainedMessagesHash,
// The chained hash of uncompressed bytecodes sent to L1
bytes32,
bytes32 _chainedBytecodesHash,
// Operator data, that is related to the DA itself
bytes calldata totalL2ToL1PubdataAndStateDiffs
bytes calldata _totalL2ToL1PubdataAndStateDiffs
) external returns (bytes32 outputHash) {
outputHash = keccak256(totalL2ToL1PubdataAndStateDiffs);
(bytes32 stateDiffHash, bytes calldata _totalPubdata, bytes calldata leftover) = _produceStateDiffPubdata(
_chainedMessagesHash,
_chainedBytecodesHash,
_totalL2ToL1PubdataAndStateDiffs
);
outputHash = keccak256(_totalPubdata);
}
}

0 comments on commit 98de9f8

Please sign in to comment.