// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; /// @notice Records provenance, never asserts that the observation is factually true. contract RealityRegistry { uint256 public constant registryVersion = 1; uint256 public totalProofs; mapping(uint256 => uint256) public proofsByDay; mapping(address => uint256) public lastContribution; struct RealityProof { bytes32 contentHash; address contributor; uint256 generation; uint256 timestamp; uint8 proofType; } mapping(address => mapping(bytes32 => RealityProof)) public proofs; mapping(address => uint256) public proofCount; mapping(address => uint256) public checkpointCount; mapping(address => mapping(uint256 => bytes32)) public checkpoints; event RealitySubmitted(bytes32 indexed contentHash, address indexed contributor, uint256 generation, uint8 proofType, uint256 timestamp); event GenerationCheckpoint(address indexed contributor, uint256 indexed generation, bytes32 stateHash); function submitRealityProof(bytes32 contentHash, uint256 generation, uint8 proofType) external { require(contentHash != bytes32(0), 'EMPTY_HASH'); require(proofType <= 4, 'INVALID_TYPE'); require(proofs[msg.sender][contentHash].timestamp == 0, 'DUPLICATE_PROOF'); proofs[msg.sender][contentHash] = RealityProof(contentHash, msg.sender, generation, block.timestamp, proofType); proofCount[msg.sender]++; totalProofs++; proofsByDay[block.timestamp / 1 days]++; lastContribution[msg.sender] = generation; emit RealitySubmitted(contentHash, msg.sender, generation, proofType, block.timestamp); } /// @notice A checkpoint is an operator's attestation, not a privileged global state. function checkpointGeneration(uint256 generation, bytes32 stateHash) external { require(stateHash != bytes32(0), 'EMPTY_HASH'); require(checkpoints[msg.sender][generation] == bytes32(0), 'ALREADY_CHECKPOINTED'); checkpoints[msg.sender][generation] = stateHash; checkpointCount[msg.sender]++; emit GenerationCheckpoint(msg.sender, generation, stateHash); } }