Перейти к содержимому
Проверенный контрактЧастичноеGPL-3.0-or-later WITH Classpath-exception-2.0

HeartbeatRepairValidation

Адрес0xe698fba85a5262c3dbf36cb6eaac8a2134ac03e7
Баланс

0 ETH

 

Транзакций

0

 

Компилятор

solc 0.8.38

 

Тот же код

Только этот контракт

 

Подробности

Компилятор
solc 0.8.38+commit.1835d247
Язык
solidity
Оптимизация
Да, 200 прогонов
Версия EVM
osaka
Через IR
да
Лицензия
GPL-3.0-or-later WITH Classpath-exception-2.0
Совпадение
Частичноекод создания: да, код в сети: да
Проверен на Sourcify
Создан в блоке
26 420 322
Транзакция создания
0xa17bd5debd…20fe133ef8

85 файлов

Исходный код большой: показывается один файл. Выберите файл в списке.

src/QueueHeartbeatIncidentRepair.sol

// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
pragma solidity ^0.8.37;

import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import {MessageQueue} from "src/MessageQueue.sol";
import {VaraQueueRootVerifier} from "src/VaraQueueRootVerifier.sol";
import {BeefyClient} from "src/beefy/BeefyClient.sol";

/// @notice One committed verifier replacement for the expired heartbeat-client incident.
/// @dev This candidate is not an approval. Review the actual deployed runtime (including this
/// commitment and both validation-helper immutables), layout, bootstrap and accepted anchor
/// before scheduling. ProxyAdmin itself does not enforce an implementation code hash.
/// No mutable storage is added; the old verifier/client and old implementation are never called.
contract QueueHeartbeatIncidentRepair is MessageQueue {
    struct RepairApproval {
        bytes32 incident;
        uint256 chainId;
        address proxy;
        bytes32 proxyCodeHash;
        address proxyAdmin;
        bytes32 proxyAdminCodeHash;
        address recoveryTimelock;
        address existingVerifier;
        uint256 maximumBlock;
        uint256 publicationFloor;
        uint256 nonceFloor;
        uint64 epoch;
        bool wasPaused;
        address replacementVerifier;
        bytes32 verifierCodeHash;
        address replacementClient;
        bytes32 clientCodeHash;
        bytes32 sourceDomain;
        uint64 historyStart;
        uint64 anchorBlock;
        bytes32 anchorRoot;
    }

    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    bytes32 public immutable repairApprovalHash;
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    HeartbeatRepairValidation public immutable heartbeatRepairValidation;

    error InvalidHeartbeatRepair();

    event HeartbeatIncidentRepaired(
        bytes32 indexed approvalHash, address indexed replacementVerifier, uint64 incidentEpoch
    );

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor(RepairApproval memory approval) {
        repairApprovalHash = keccak256(abi.encode(approval));
        heartbeatRepairValidation = new HeartbeatRepairValidation();
    }

    /// @dev Only the committed transparent ProxyAdmin may atomically install and initialize this
    /// implementation. Version 9 follows the release's version-8 migration; there is no reset lane.
    function initializeHeartbeatRepair(RepairApproval calldata approval) external onlyProxy reinitializer(9) {
        if (keccak256(abi.encode(approval)) != repairApprovalHash || ERC1967Utils.getAdmin() != approval.proxyAdmin) {
            revert InvalidHeartbeatRepair();
        }

        address existing;
        uint256 maximum;
        // Release layout: private verifier slot 5, maximum slot 9. Layout qualification is mandatory.
        assembly ("memory-safe") {
            existing := sload(5)
            maximum := sload(9)
        }
        if (
            existing != approval.existingVerifier || existing == address(0) || maximum != approval.maximumBlock
                || beefyRootMinimum != approval.publicationFloor || messageNonceMinimum != approval.nonceFloor
                || incidentEpoch[address(this)] != approval.epoch || paused() != approval.wasPaused
                || approval.replacementVerifier == existing
        ) revert InvalidHeartbeatRepair();
        heartbeatRepairValidation.validate(approval, msg.sender);

        address next = approval.replacementVerifier;
        assembly ("memory-safe") { sstore(5, next) }
        ++incidentEpoch[address(this)];
        if (!paused()) _pause();
        emit HeartbeatIncidentRepaired(repairApprovalHash, next, incidentEpoch[address(this)]);
    }
}

/// @dev Read-only validation lives outside Q's runtime to stay within EIP-170.
contract HeartbeatRepairValidation {
    function validate(QueueHeartbeatIncidentRepair.RepairApproval calldata approval, address caller) external view {
        if (
            approval.incident == bytes32(0) || block.chainid != approval.chainId || msg.sender != approval.proxy
                || msg.sender.codehash != approval.proxyCodeHash || caller != approval.proxyAdmin
                || approval.proxyAdmin.code.length == 0 || approval.proxyAdmin.codehash != approval.proxyAdminCodeHash
                || approval.recoveryTimelock == address(0)
                || ProxyAdmin(approval.proxyAdmin).owner() != approval.recoveryTimelock
                || approval.replacementVerifier.code.length == 0
                || approval.replacementVerifier.codehash != approval.verifierCodeHash
                || approval.replacementClient.code.length == 0
                || approval.replacementClient.codehash != approval.clientCodeHash
        ) revert QueueHeartbeatIncidentRepair.InvalidHeartbeatRepair();

        VaraQueueRootVerifier replacement = VaraQueueRootVerifier(approval.replacementVerifier);
        BeefyClient client = BeefyClient(approval.replacementClient);
        if (
            replacement.messageQueue() != msg.sender || replacement.destinationChainId() != block.chainid
                || address(replacement.beefyClient()) != address(client) || client.destinationQueue() != msg.sender
                || client.destinationChainId() != block.chainid || approval.sourceDomain == bytes32(0)
                || client.sourceDomain() != approval.sourceDomain
                || client.bridgeDomain()
                    != keccak256(
                        abi.encodePacked(
                            "vara/gear-eth-bridge-domain/v2", approval.sourceDomain, bytes32(block.chainid), msg.sender
                        )
                    ) || approval.historyStart == 0 || client.mmrStartBlock() != approval.historyStart
                || approval.historyStart > approval.publicationFloor || !client.isLive()
                || client.lastAuthenticatedSourceTimestampMs() == 0 || approval.anchorRoot == bytes32(0)
                || approval.anchorBlock <= approval.maximumBlock || approval.anchorBlock <= approval.publicationFloor
                || !client.isAcceptedAnchor(approval.anchorBlock, approval.anchorRoot)
        ) revert QueueHeartbeatIncidentRepair.InvalidHeartbeatRepair();
    }
}
Настройки компилятораПоказать
{
  "debug": {
    "revertStrings": "strip"
  },
  "viaIR": true,
  "metadata": {
    "appendCBOR": false,
    "bytecodeHash": "none",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "viaSSACFG": false,
  "evmVersion": "osaka",
  "remappings": [
    "@openzeppelin-contracts-5.7.0/=dependencies/@openzeppelin-contracts-5.7.0/",
    "@openzeppelin-contracts-upgradeable-5.7.0/=dependencies/@openzeppelin-contracts-upgradeable-5.7.0/",
    "forge-std-1.17.0/=dependencies/forge-std-1.17.0/",
    "openzeppelin-foundry-upgrades-0.4.3/=dependencies/openzeppelin-foundry-upgrades-0.4.3/",
    "forge-std/=dependencies/forge-std-1.17.0/src/",
    "@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.7.0/",
    "@openzeppelin/contracts-upgradeable/=dependencies/@openzeppelin-contracts-upgradeable-5.7.0/",
    "openzeppelin-foundry-upgrades/=dependencies/openzeppelin-foundry-upgrades-0.4.3/src/"
  ],
  "experimental": false
}

Исходный код и метаданные: Sourcify.

Исходный код принадлежит авторам контракта.