false
true
0

Contract Address Details

0x85Fbe4C5f7992Fbd97a8E4dafc821FAD3b0D20F3

Contract Name
BeaconForkGate
Creator
0xf71cba–f75eac at 0xb1a640–189ea2
Balance
0 tPLS
Tokens
Fetching tokens...
Transactions
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
26048816
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
BeaconForkGate




Optimization enabled
false
Compiler version
v0.8.28+commit.7893614a




EVM Version




Verified at
2026-11-19T13:50:59.402901Z

Constructor Arguments

000000000000000000000000000f3df6d732807ef1319fb7b8bb8522d0beac0200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000064377651000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000020d81664ba97279a6fa0832041b4aee6009172b4750a99467ff670a9faf3a34e640000000000000000000000000f094a965f280599b41f57a5182955f4afad063f

Arg [0] (address) : 0x000f3df6d732807ef1319fb7b8bb8522d0beac02
Arg [1] (uint8) : 4
Arg [2] (uint64) : 1681356369
Arg [3] (uint64) : 10
Arg [4] (uint64) : 32
Arg [5] (bytes32) : d81664ba97279a6fa0832041b4aee6009172b4750a99467ff670a9faf3a34e64
Arg [6] (address) : 0x0f094a965f280599b41f57a5182955f4afad063f

              

src/hardened/BeaconForkGate.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

import {IDepositGate} from "./IDepositGate.sol";
import {IForkRegistry} from "./IForkRegistry.sol";
import {BeaconClock} from "./BeaconClock.sol";
import {BeaconBlockHeader, SSZ} from "./SSZ.sol";
import {ForkShape} from "./ForkShape.sol";

/// @title BeaconForkGate
/// @notice Refuses a deposit unless the chain's state has a shape that the route can read (hole HB-02, window 1).
/// The rule is the same on both chains: accept any fork version whose state proof has an allowed shape, with the genesis validators root branch
/// proving `genesis_validators_root` at that shape under the same state root. Seal only on a shape outside the allowed
/// set. The shape judging lives in `ForkShape`, one library for the EIP-4788 path and for the registry path. The gate
/// holds no list of fork version names.
/// @dev Two paths bring the evidence. On Ethereum the gate reads the chain's own recent beacon block roots through
/// EIP-4788 and requires a proof of `state.fork.current_version` and a proof of `genesis_validators_root`, both under
/// the state root of a header of the current epoch. A fork version changes only at an epoch boundary, so a proof from the
/// current epoch covers the block that the deposit lands in. PulseChain has no EIP-4788, so its evidence is the fork
/// observation registry: the observation program proves the shape, and the registry stores it next to each version.
/// After a state of a shape that the route cannot read, no accepted proof exists and deposits revert with the tokens
/// still in the wallet of the user.
///
/// Trade-off, on both chains: judging the shape gives up the check that would catch a fork that reorders fields at the
/// same depth. Such a fork passes the gate. The light client then fails closed.
///
/// Three modes, chosen at deployment from an enum. `Enforcing` (Ethereum) applies the rules from the first call.
/// `DetectBeaconRoots` probes the beacon roots contract on each call and admits every deposit while the contract is
/// absent. The first call that sees a root switches the gate to enforcing for good. There is no owner and no key: only
/// the protocol writes roots, through the system address, so the probe cannot be spoofed. A replay of the keyless
/// deployment of the genuine code on a chain without EIP-4788 leaves its storage empty, so every read reverts and the
/// gate stays in detection mode.
///
/// The generalized indices are computed in `ForkShape` from the shape, never taken from the caller. If the caller could
/// choose them, a proof of `Fork.previous_version` would pass for the current version.
///
/// The gate holds `genesisValidatorsRoot` as an immutable. The deploy script checks it against the chain that the route
/// follows.
///
/// `DetectBeaconRootsAndRegistry` (PulseChain) adds two things to detection. First, execution
/// canaries: one tiny probe contract that runs one new opcode per call (`TSTORE`, `MCOPY`, `BLOBBASEFEE`, `CLZ`, chosen
/// by the first byte of the calldata), and a call to the first BLS12-381 precompile. A PulseChain consensus fork almost
/// always arrives with an execution fork, and the first canary that works switches the gate to enforcing for good.
/// Second, a fork observation registry: while its latest observed shape is not allowed, every deposit is refused, and
/// `seal()` with empty evidence closes the gate for good. The canaries and the EIP-4788 probe decide when the gate starts
/// to enforce. They do not decide what it accepts.
///
/// Two seal-only modes (decision of 2026-11-10, "no proof writing on the deposit"): `SealOnly` (Ethereum) and
/// `SealOnlyWithRegistry` (PulseChain). `admit` reads the seal and nothing else: a send is admitted unless the gate is
/// sealed. There is no epoch, no evidence, no probe and no canary on a send, and the gate applies this rule from the
/// first call. `seal` is the same code as in the other modes: a proof of a shape outside the allowed set, by EIP-4788
/// evidence, or (with a registry) empty evidence when the registry shows such a shape. `confirm` still runs its checks,
/// and a confirmation only raises the floor of a seal proof (`SealEvidenceTooOld`); `admit` never reads it. The gap that
/// remains: a send between the activation of an unsupported fork and the seal is admitted.
///
/// The runtime code of the gate avoids `MCOPY`, `TSTORE` and `TLOAD`, because PulseChain rejects them. The probe holds
/// those opcodes on purpose, as a separate contract that the constructor deploys from raw bytes.
contract BeaconForkGate is IDepositGate {
    /// @notice The behavior of the gate before it has seen a beacon root.
    enum GateMode {
        /// @dev The rules apply from the first call (Ethereum).
        Enforcing,
        /// @dev The gate admits every deposit until the beacon roots contract answers with a root (PulseChain).
        /// Execution canaries also switch it to enforcing.
        DetectBeaconRoots,
        /// @dev As `DetectBeaconRoots`, and the gate also refuses while the fork registry shows an unsupported version.
        DetectBeaconRootsAndRegistry,
        /// @dev A send is admitted unless the gate is sealed. Seals by EIP-4788 evidence (Ethereum).
        SealOnly,
        /// @dev As `SealOnly`, and `seal("")` also seals when the fork registry shows a shape outside the allowed set
        /// (PulseChain). A send does not read the registry.
        SealOnlyWithRegistry
    }

    /// @notice The execution canaries, in the order the gate tries them.
    enum Canary {
        TransientStorage,
        MemoryCopy,
        BlobBaseFee,
        CountLeadingZeros,
        Bls12381Precompile
    }

    /// @notice The proof that the chain is in a given fork version.
    /// @param timestamp The timestamp key of the beacon roots contract. It holds the parent beacon block root.
    /// @param header A beacon block header whose root the beacon roots contract returns for `timestamp`.
    /// @param version The claimed `Fork.current_version` of the state of that header. The gate does not judge its name.
    /// @param branch The branch from the version leaf to `header.stateRoot`, deepest first.
    /// @param genesisValidatorsRootBranch The branch from `genesis_validators_root` (field 1 of the state) to `header.stateRoot`,
    /// deepest first. It pins the shape. A seal proof of a shape outside the allowed set needs no genesis validators root branch.
    struct ForkEvidence {
        uint256 timestamp;
        BeaconBlockHeader header;
        bytes4 version;
        bytes32[] branch;
        bytes32[] genesisValidatorsRootBranch;
    }

    /// @dev One storage slot: the gate reads it once for the cheapest deposit.
    struct GateState {
        uint64 confirmedEpoch;
        bool hasConfirmedEpoch;
        bool isSealed;
        bool enforcing;
        uint64 highestConfirmedSlot;
    }

    /// @notice The gas forwarded to each call of the opcode probe. The costliest path (`TSTORE`, which costs 100 gas by
    /// itself) needs 167, measured, and the others need 97 to 126. The cap leaves room for a later repricing of a
    /// cheap opcode. A call
    /// whose opcode is not valid burns all its gas, so this is also the most that one canary can cost.
    uint256 public constant PROBE_GAS = 400;
    /// @notice The gas forwarded to the BLS12-381 precompile canary. `BLS12_G1ADD` costs 375 gas (EIP-2537). The cap
    /// leaves room for a later repricing and still bounds a mock that burns gas.
    uint256 public constant PRECOMPILE_GAS = 2_000;
    /// @notice The address of `BLS12_G1ADD` (EIP-2537, "Specification": G1ADD is 0x0b, G1MSM 0x0c, G2ADD 0x0d,
    /// G2MSM 0x0e, PAIRING_CHECK 0x0f, MAP_FP_TO_G1 0x10, MAP_FP2_TO_G2 0x11).
    address public constant BLS_G1_ADD = address(0x0b);
    /// @notice The word the probe returns when its opcode ran.
    uint256 public constant PROBE_WORD = 1;

    /// @dev The runtime code of the opcode probe. It reads the first byte of the calldata as a selector, from 1 to 4
    /// in the order of the `Canary` enum (selector = index + 1). Each selector jumps to its own path. A path runs
    /// exactly one new opcode and then returns the word 1. Any other selector, and empty calldata, reverts. `PUSH0`
    /// (0x5f) is EIP-3855, live in Shanghai. The jump targets are byte offsets in this code, and a test fails if one
    /// is wrong.
    ///
    ///   00  5f 35 60f8 1c        PUSH0 CALLDATALOAD PUSH1 0xf8 SHR       selector on the stack
    ///   05  80 6001 14 6024 57   DUP1 PUSH1 1 EQ PUSH1 0x24 JUMPI        selector 1: TSTORE path
    ///   0c  80 6002 14 602c 57   selector 2: MCOPY path
    ///   13  80 6003 14 6035 57   selector 3: BLOBBASEFEE path
    ///   1a  80 6004 14 603b 57   selector 4: CLZ path
    ///   21  5f 5f fd             PUSH0 PUSH0 REVERT                      unknown selector
    ///   24  5b 6001 5f 5d 603f 56        JUMPDEST, key 0 value 1 TSTORE, jump to the return
    ///   2c  5b 6020 5f 5f 5e 603f 56     JUMPDEST, copy 32 bytes from 0 to 0 (MCOPY), jump to the return
    ///   35  5b 4a 50 603f 56             JUMPDEST BLOBBASEFEE POP, jump to the return
    ///   3b  5b 5f 1e 50                  JUMPDEST PUSH0 CLZ POP, falls into the return
    ///   3f  5b 6001 5f52 60205f f3       JUMPDEST, store 1 in memory, RETURN 32 bytes
    /// Opcode values: TSTORE 0x5d (EIP-1153), MCOPY 0x5e (EIP-5656), BLOBBASEFEE 0x4a (EIP-7516), CLZ 0x1e (EIP-7939).
    bytes private constant PROBE_RUNTIME = hex"5f3560f81c" hex"80600114" hex"602457" hex"80600214" hex"602c57"
        hex"80600314" hex"603557" hex"80600414" hex"603b57" hex"5f5ffd" hex"5b60015f5d603f56" hex"5b60205f5f5e603f56"
        hex"5b4a50603f56" hex"5b5f1e50" hex"5b60015f5260205ff3";
    /// @dev The generator of G1 on BLS12-381 (EIP-2537 encoding: each field element is 64 bytes, big endian, with 16
    /// leading zero bytes). Source: the BLS12-381 parameters; the point satisfies y^2 = x^3 + 4 modulo the field prime.
    /// Adding the point at infinity (128 zero bytes) to it must return it unchanged. Held as 32 byte words so that the
    /// bytes are push data in the runtime code, never a data section.
    bytes32 private constant BLS_G1_X_HIGH = 0x0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0f;
    bytes32 private constant BLS_G1_X_LOW = 0xc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb;
    bytes32 private constant BLS_G1_Y_HIGH = 0x0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4;
    bytes32 private constant BLS_G1_Y_LOW = 0xfcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1;

    /// @notice A constructor argument is zero or empty.
    error ZeroValue(string name);
    /// @notice The gate is sealed. No deposit passes, and the seal never clears.
    error GateSealed();
    /// @notice The epoch has no confirmation and the deposit brought no evidence.
    error ForkNotConfirmed(uint256 epoch);
    /// @notice Detection mode only: the beacon roots contract returns no root, so the gate cannot confirm or seal.
    error BeaconRootsAbsent();
    /// @notice The beacon roots contract returned no root for the timestamp (out of its ring buffer, or empty).
    error BeaconRootUnavailable(uint256 timestamp);
    /// @notice The header does not hash to the beacon root of the timestamp.
    error HeaderRootMismatch(bytes32 expected, bytes32 actual);
    /// @notice The header is not from the current epoch.
    error HeaderNotInCurrentEpoch(uint256 headerEpoch, uint256 currentEpoch);
    /// @notice The version branch has a length that fits no allowed shape. `depth` is the tree depth that the length
    /// implies.
    error ShapeNotAllowed(uint256 depth);
    /// @notice A seal needs a shape outside the allowed set, and the proof shows an allowed one.
    error ShapeIsAllowed(uint8 shape);
    /// @notice The version branch is valid for an allowed shape, but the genesis validators root branch of `genesis_validators_root`
    /// is not valid at that shape under the same state root.
    error GenesisValidatorsRootBranchInvalid();
    /// @notice The branch of a seal proof implies a tree depth below `ForkShape.MIN_SEAL_DEPTH` or above
    /// `ForkShape.MAX_SEAL_DEPTH`.
    error SealDepthNotAllowed(uint256 depth);
    /// @notice The branch does not lead from the version to the state root.
    error ForkProofInvalid();
    /// @notice A registry address is set in a mode that has no registry, or missing in the mode that needs one.
    error ForkRegistryMismatch(GateMode mode, address forkRegistry);
    /// @notice The fork registry address holds no code.
    error ForkRegistryHasNoCode(address forkRegistry);
    /// @notice The opcode probe contract did not deploy.
    error ProbeDeploymentFailed();
    /// @notice The fork registry shows an observed state shape that the route does not allow.
    error ObservedShapeNotAllowed(bytes4 version, uint8 shape, uint64 slot);
    /// @notice `seal` with empty evidence needs an observed shape outside the allowed set in the registry, and there is
    /// none.
    error NoDisallowedObservedShape();
    /// @notice The block time is before the genesis time of the chain.
    error BeforeGenesis(uint256 timestamp, uint64 genesisTime);
    /// @notice A seal proof is older than the newest evidence that the gate trusts.
    error SealEvidenceTooOld(uint64 slot, uint64 minimumSlot);

    /// @notice Emitted once, when detection mode first reads a beacon root and the gate becomes enforcing.
    event BeaconRootsDetected();
    /// @notice Emitted when a proof of an allowed shape confirms the fork version for an epoch.
    event ForkConfirmed(uint256 indexed epoch, bytes4 version);
    /// @notice Emitted once, when an execution canary first works and the gate becomes enforcing.
    event ExecutionCanaryFired(Canary canary);
    /// @notice Emitted when a proof of a shape outside the allowed set seals the gate for good. The registry path
    /// reports the observed version and slot.
    event GateSealedByFork(bytes4 version, uint64 slot);

    /// @notice The beacon roots contract (EIP-4788): 0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02.
    address public immutable beaconRoots;
    /// @notice Whether the gate starts enforcing or starts in detection mode.
    GateMode public immutable mode;
    /// @notice The fork observation registry. Zero except in `DetectBeaconRootsAndRegistry` and `SealOnlyWithRegistry`
    /// mode.
    IForkRegistry public immutable forkRegistry;
    /// @notice The one probe contract for the four opcode canaries (`TSTORE`, `MCOPY`, `BLOBBASEFEE`, `CLZ`). The
    /// first byte of the calldata picks the opcode.
    address public immutable opcodeProbe;
    /// @notice The `genesis_validators_root` of the beacon chain that the route follows. The genesis validators root leaf must equal it.
    bytes32 public immutable genesisValidatorsRoot;
    /// @notice The genesis time of the beacon chain of this chain, in seconds.
    uint64 public immutable genesisTime;
    /// @notice Seconds per slot (12 on Ethereum, 10 on PulseChain).
    uint64 public immutable secondsPerSlot;
    /// @notice Slots per epoch (32 on both).
    uint64 public immutable slotsPerEpoch;
    /// @notice The slot of the block that deployed the gate (zero when that block is before genesis). A seal proof
    /// from an earlier slot is refused.
    uint64 public immutable deploymentSlot;

    GateState private _state;

    /// @param beaconRoots_ The EIP-4788 contract address.
    /// @param mode_ `Enforcing`, `DetectBeaconRoots`, `DetectBeaconRootsAndRegistry`, `SealOnly` or
    /// `SealOnlyWithRegistry`.
    /// @param genesisTime_ Genesis time of the beacon chain.
    /// @param secondsPerSlot_ Seconds per slot.
    /// @param slotsPerEpoch_ Slots per epoch.
    /// @param genesisValidatorsRoot_ The `genesis_validators_root` of the beacon chain that the route follows. The
    /// deploy script checks it against the chain.
    /// @param forkRegistry_ The fork observation registry. It must hold code in `DetectBeaconRootsAndRegistry` and
    /// `SealOnlyWithRegistry` mode and must be zero in every other mode.
    constructor(
        address beaconRoots_,
        GateMode mode_,
        uint64 genesisTime_,
        uint64 secondsPerSlot_,
        uint64 slotsPerEpoch_,
        bytes32 genesisValidatorsRoot_,
        address forkRegistry_
    ) {
        if (beaconRoots_ == address(0)) revert ZeroValue("beaconRoots");
        if (genesisTime_ == 0) revert ZeroValue("genesisTime");
        if (secondsPerSlot_ == 0) revert ZeroValue("secondsPerSlot");
        if (slotsPerEpoch_ == 0) revert ZeroValue("slotsPerEpoch");
        if (genesisValidatorsRoot_ == bytes32(0)) revert ZeroValue("genesisValidatorsRoot");
        bool needsRegistry = mode_ == GateMode.DetectBeaconRootsAndRegistry || mode_ == GateMode.SealOnlyWithRegistry;
        if (needsRegistry != (forkRegistry_ != address(0))) {
            revert ForkRegistryMismatch(mode_, forkRegistry_);
        }
        if (forkRegistry_ != address(0) && forkRegistry_.code.length == 0) revert ForkRegistryHasNoCode(forkRegistry_);

        beaconRoots = beaconRoots_;
        mode = mode_;
        genesisTime = genesisTime_;
        secondsPerSlot = secondsPerSlot_;
        slotsPerEpoch = slotsPerEpoch_;
        genesisValidatorsRoot = genesisValidatorsRoot_;
        deploymentSlot = BeaconClock.slotAt(block.timestamp, genesisTime_, secondsPerSlot_);
        forkRegistry = IForkRegistry(forkRegistry_);
        opcodeProbe = _deployProbe(PROBE_RUNTIME);

        if (mode_ == GateMode.Enforcing || mode_ == GateMode.SealOnly || mode_ == GateMode.SealOnlyWithRegistry) {
            _state.enforcing = true;
        }
    }

    // ------------------------------------------------------------------ entry points

    /// @inheritdoc IDepositGate
    /// @dev The seal-only modes read the seal and return. In the other modes: step 0 refuses a sealed gate. Step 1 asks
    /// the registry (registry mode only). Step 2 detects in detection mode: the beacon roots probe, then the execution
    /// canaries. Step 3 returns when the epoch is confirmed. Step 4 decodes the evidence and confirms. Empty evidence
    /// in an unconfirmed epoch reverts.
    function admit(bytes calldata evidence) external override {
        if (mode >= GateMode.SealOnly) {
            if (_state.isSealed) revert GateSealed();
            return;
        }
        GateState memory state = _state;
        if (state.isSealed) revert GateSealed();
        _requireObservedShapeAllowed();
        if (!state.enforcing) {
            if (!_detectAndEnter()) return;
            state.enforcing = true;
        }
        uint256 epoch = _currentEpoch();
        if (state.hasConfirmedEpoch && state.confirmedEpoch == epoch) return;
        if (evidence.length == 0) revert ForkNotConfirmed(epoch);
        _confirm(abi.decode(evidence, (ForkEvidence)), epoch);
    }

    /// @notice Confirms an allowed state shape for the current epoch with no deposit. Anyone may call it, for
    /// example a keeper. It runs the same checks as `admit`. A confirmed epoch makes the call do nothing.
    /// In detection mode it first needs a working probe.
    /// @param evidence An `abi.encode` of a `ForkEvidence`.
    function confirm(bytes calldata evidence) external {
        if (_state.isSealed) revert GateSealed();
        _requireObservedShapeAllowed();
        GateState memory state = _wake();
        uint256 epoch = _currentEpoch();
        if (state.hasConfirmedEpoch && state.confirmedEpoch == epoch) return;
        _confirm(abi.decode(evidence, (ForkEvidence)), epoch);
    }

    /// @notice Seals the gate for good, given a valid version branch at a depth outside the allowed set of shapes. There
    /// is no epoch rule, but the header must not be older than the deployment slot or the newest header that a
    /// confirmation accepted (`SealEvidenceTooOld`). Fork versions only move forward, so a shape outside the allowed set
    /// at or after a slot where an allowed shape was live cannot be a stale one. Without this rule, an old header that
    /// the beacon roots ring buffer still holds could seal the gate. In detection mode it first needs a working probe.
    /// Withdrawals are not affected.
    /// @param evidence An `abi.encode` of a `ForkEvidence`. The version branch length must imply a depth from
    /// `ForkShape.MIN_SEAL_DEPTH` to `ForkShape.MAX_SEAL_DEPTH`. The genesis validators root branch is not read for a disallowed depth.
    /// In registry mode, empty evidence seals from the registry instead: it succeeds when the registry shows a shape
    /// outside the allowed set.
    function seal(bytes calldata evidence) external {
        if (_state.isSealed) revert GateSealed();
        if (evidence.length == 0 && address(forkRegistry) != address(0)) {
            _sealFromRegistry();
            return;
        }
        _wake();
        ForkEvidence memory proof = abi.decode(evidence, (ForkEvidence));

        _requireBeaconHeader(proof);
        uint64 minimumSlot = _state.highestConfirmedSlot > deploymentSlot ? _state.highestConfirmedSlot : deploymentSlot;
        if (proof.header.slot < minimumSlot) revert SealEvidenceTooOld(proof.header.slot, minimumSlot);
        _requireDisallowedShapeProven(proof);

        _state.isSealed = true;
        emit GateSealedByFork(proof.version, proof.header.slot);
    }

    // ------------------------------------------------------------------ views

    /// @notice Whether the gate applies its rules. True from deployment in `Enforcing` and the seal-only modes, and
    /// after detection.
    function enforcing() external view returns (bool) {
        return _state.enforcing;
    }

    /// @notice Whether a seal proof closed the gate. (`sealed` is a reserved word in Solidity.)
    function isSealed() external view returns (bool) {
        return _state.isSealed;
    }

    /// @notice The last epoch confirmed by a proof, and whether any epoch was confirmed.
    function confirmedEpoch() external view returns (uint64 epoch, bool exists) {
        GateState memory state = _state;
        return (state.confirmedEpoch, state.hasConfirmedEpoch);
    }

    /// @notice The epoch of the current block.
    function currentEpoch() external view returns (uint256) {
        return _currentEpoch();
    }

    /// @notice The allowed state shapes: plain depths and `ForkShape.PROGRESSIVE`. The set is the same on both chains.
    function allowedShapes() external pure returns (uint8[] memory) {
        return ForkShape.allowedShapes();
    }

    // ------------------------------------------------------------------ internals

    /// @dev Detection mode: a working probe or canary is needed, then the gate enforces. Returns the state after the
    /// switch.
    function _wake() private returns (GateState memory state) {
        state = _state;
        if (state.enforcing) return state;
        if (!_detectAndEnter()) revert BeaconRootsAbsent();
        state.enforcing = true;
    }

    /// @dev Runs the detectors in order: the beacon roots probe, then the canaries. The first that works sets
    /// `enforcing` for good. Returns whether one worked. A revert later in the same call undoes the switch.
    function _detectAndEnter() private returns (bool) {
        if (_beaconRootsPresent()) {
            _state.enforcing = true;
            emit BeaconRootsDetected();
            return true;
        }
        (bool fired, Canary canary) = _firedCanary();
        if (!fired) return false;
        _state.enforcing = true;
        emit ExecutionCanaryFired(canary);
        return true;
    }

    /// @dev The first canary that works, in the order of the `Canary` enum.
    function _firedCanary() private returns (bool fired, Canary canary) {
        if (_probeFires(Canary.TransientStorage)) return (true, Canary.TransientStorage);
        if (_probeFires(Canary.MemoryCopy)) return (true, Canary.MemoryCopy);
        if (_probeFires(Canary.BlobBaseFee)) return (true, Canary.BlobBaseFee);
        if (_probeFires(Canary.CountLeadingZeros)) return (true, Canary.CountLeadingZeros);
        if (_blsPrecompileWorks()) return (true, Canary.Bls12381Precompile);
        return (false, Canary.TransientStorage);
    }

    /// @dev Calls the opcode probe once for one canary, with `PROBE_GAS`. The calldata is one byte: the index of the
    /// canary plus one. The canary works when the call succeeds and returns exactly the word 1. A call whose opcode is
    /// not valid fails and costs only the forwarded gas. Each call runs one path alone, so a missing opcode fails only
    /// its own canary. A plain `CALL` is used, not `STATICCALL`, because `TSTORE` is a state change and fails in a
    /// static context (EIP-1153).
    function _probeFires(Canary canary) private returns (bool) {
        address probe = opcodeProbe;
        uint256 selector = uint256(uint8(canary)) + 1;
        bool ok;
        uint256 size;
        uint256 word;
        assembly {
            let scratch := mload(0x40)
            mstore8(scratch, selector)
            mstore(add(scratch, 0x20), 0)
            ok := call(PROBE_GAS, probe, 0, scratch, 1, add(scratch, 0x20), 0x20)
            size := returndatasize()
            word := mload(add(scratch, 0x20))
        }
        return ok && size == 32 && word == PROBE_WORD;
    }

    /// @dev Calls `BLS12_G1ADD` with the generator and the point at infinity. A chain that has the precompile
    /// returns the generator (128 bytes). A chain without it treats the address as an empty account: the call
    /// succeeds and returns nothing, so the size check rejects it.
    function _blsPrecompileWorks() private view returns (bool) {
        bool ok;
        uint256 size;
        bool same;
        bytes32 xHigh = BLS_G1_X_HIGH;
        bytes32 xLow = BLS_G1_X_LOW;
        bytes32 yHigh = BLS_G1_Y_HIGH;
        bytes32 yLow = BLS_G1_Y_LOW;
        assembly {
            let input := mload(0x40)
            mstore(input, xHigh)
            mstore(add(input, 0x20), xLow)
            mstore(add(input, 0x40), yHigh)
            mstore(add(input, 0x60), yLow)
            mstore(add(input, 0x80), 0)
            mstore(add(input, 0xa0), 0)
            mstore(add(input, 0xc0), 0)
            mstore(add(input, 0xe0), 0)
            let output := add(input, 0x100)
            ok := staticcall(PRECOMPILE_GAS, 0x0b, input, 0x100, output, 0x80)
            size := returndatasize()
            same := and(
                and(eq(mload(output), xHigh), eq(mload(add(output, 0x20)), xLow)),
                and(eq(mload(add(output, 0x40)), yHigh), eq(mload(add(output, 0x60)), yLow))
            )
        }
        return ok && size == 0x80 && same;
    }

    /// @dev Registry mode: refuses while the latest observed shape is set and not allowed.
    function _requireObservedShapeAllowed() private view {
        IForkRegistry registry = forkRegistry;
        if (address(registry) == address(0)) return;
        (bytes4 version, uint8 shape, uint64 slot) = registry.latestObserved();
        if (slot == 0) return;
        if (!ForkShape.isAllowed(shape)) revert ObservedShapeNotAllowed(version, shape, slot);
    }

    /// @dev Seals from the registry, with no proof: the registry already holds a proven shape outside the allowed set.
    function _sealFromRegistry() private {
        (bytes4 version, uint8 shape, uint64 slot) = forkRegistry.latestObserved();
        if (slot == 0) revert NoDisallowedObservedShape();
        if (ForkShape.isAllowed(shape)) revert NoDisallowedObservedShape();
        _state.isSealed = true;
        emit GateSealedByFork(version, slot);
    }

    /// @dev Deploys raw runtime code with `create`. The init code copies the runtime code and returns it:
    /// `PUSH1 len DUP1 PUSH1 9 PUSH0 CODECOPY PUSH0 RETURN`.
    function _deployProbe(bytes memory runtime) private returns (address probe) {
        bytes memory initCode = abi.encodePacked(hex"60", uint8(runtime.length), hex"8060095f395ff3", runtime);
        assembly {
            probe := create(0, add(initCode, 0x20), mload(initCode))
        }
        if (probe == address(0)) revert ProbeDeploymentFailed();
    }

    /// @dev The probe. The beacon roots contract is present when it returns exactly 32 non-zero bytes for the
    /// timestamp of this block. A call that fails, a short or long answer, or a zero word means absent. The answer is
    /// copied into one scratch word, so a long answer costs nothing extra.
    function _beaconRootsPresent() private view returns (bool present) {
        address target = beaconRoots;
        uint256 lookupKey = block.timestamp;
        uint256 word;
        uint256 size;
        bool ok;
        assembly {
            let scratch := mload(0x40)
            mstore(scratch, lookupKey)
            ok := staticcall(gas(), target, scratch, 0x20, scratch, 0x20)
            size := returndatasize()
            word := mload(scratch)
        }
        return ok && size == 32 && word != 0;
    }

    /// @dev The beacon root for a timestamp, or zero when the call fails or does not return 32 bytes.
    function _beaconRootAt(uint256 lookupKey) private view returns (bytes32 root) {
        address target = beaconRoots;
        uint256 size;
        bool ok;
        assembly {
            let scratch := mload(0x40)
            mstore(scratch, lookupKey)
            ok := staticcall(gas(), target, scratch, 0x20, scratch, 0x20)
            size := returndatasize()
            root := mload(scratch)
        }
        if (!ok || size != 32) return bytes32(0);
        return root;
    }

    /// @dev The epoch of the current block. Reverts before the genesis time.
    function _currentEpoch() private view returns (uint256) {
        if (block.timestamp < genesisTime) revert BeforeGenesis(block.timestamp, genesisTime);
        return (block.timestamp - genesisTime) / secondsPerSlot / slotsPerEpoch;
    }

    /// @dev The checks of a confirmation, then the write.
    function _confirm(ForkEvidence memory proof, uint256 epoch) private {
        _requireBeaconHeader(proof);
        uint256 headerEpoch = proof.header.slot / slotsPerEpoch;
        if (headerEpoch != epoch) revert HeaderNotInCurrentEpoch(headerEpoch, epoch);
        _requireAllowedShapeProven(proof);

        GateState memory state = _state;
        state.confirmedEpoch = uint64(epoch);
        state.hasConfirmedEpoch = true;
        if (proof.header.slot > state.highestConfirmedSlot) state.highestConfirmedSlot = proof.header.slot;
        _state = state;
        emit ForkConfirmed(epoch, proof.version);
    }

    /// @dev Judges the evidence with `ForkShape` and reverts unless the shape is allowed and both branches verify.
    function _requireAllowedShapeProven(ForkEvidence memory proof) private view {
        (ForkShape.Verdict verdict,) = _judge(proof);
        if (verdict == ForkShape.Verdict.Allowed) return;
        if (verdict == ForkShape.Verdict.GenesisValidatorsRootProofInvalid) {
            revert GenesisValidatorsRootBranchInvalid();
        }
        if (verdict == ForkShape.Verdict.VersionProofInvalid) revert ForkProofInvalid();
        revert ShapeNotAllowed(ForkShape.depthOfVersionBranch(proof.branch.length));
    }

    /// @dev A seal needs a valid version branch at a depth outside the allowed set, inside the seal bounds.
    function _requireDisallowedShapeProven(ForkEvidence memory proof) private view {
        uint256 depth = ForkShape.depthOfVersionBranch(proof.branch.length);
        if (depth < ForkShape.MIN_SEAL_DEPTH || depth > ForkShape.MAX_SEAL_DEPTH) revert SealDepthNotAllowed(depth);
        (ForkShape.Verdict verdict, uint8 shape) = _judge(proof);
        if (verdict == ForkShape.Verdict.Allowed) revert ShapeIsAllowed(shape);
        if (verdict == ForkShape.Verdict.GenesisValidatorsRootProofInvalid) {
            revert GenesisValidatorsRootBranchInvalid();
        }
        if (verdict == ForkShape.Verdict.VersionProofInvalid) revert ForkProofInvalid();
        if (!ForkShape.provesPlainVersion(proof.header.stateRoot, proof.version, proof.branch, depth)) {
            revert ForkProofInvalid();
        }
    }

    /// @dev Judges the evidence with the shape rule, against the genesis validators root that this gate holds.
    function _judge(ForkEvidence memory proof) private view returns (ForkShape.Verdict, uint8) {
        return ForkShape.judge(
            proof.header.stateRoot,
            proof.version,
            proof.branch,
            proof.genesisValidatorsRootBranch,
            genesisValidatorsRoot
        );
    }

    /// @dev The header must be the block whose root the beacon roots contract holds for the timestamp.
    function _requireBeaconHeader(ForkEvidence memory proof) private view {
        bytes32 root = _beaconRootAt(proof.timestamp);
        if (root == bytes32(0)) revert BeaconRootUnavailable(proof.timestamp);
        bytes32 headerRoot = SSZ.hashTreeRootMemory(proof.header);
        if (headerRoot != root) revert HeaderRootMismatch(root, headerRoot);
    }
}
        

src/hardened/BeaconClock.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

/// @title BeaconClock
/// @notice The slot that a timestamp falls in, on one beacon chain. The deposit gate and the light client share it,
/// so both read the clock with the same formula.
library BeaconClock {
    /// @notice The slot at `timestamp`, or zero when the timestamp is before genesis.
    /// @param timestamp The time in seconds.
    /// @param genesisTime The genesis time of the beacon chain, in seconds. It must not be zero.
    /// @param secondsPerSlot The seconds per slot of the beacon chain. It must not be zero.
    function slotAt(uint256 timestamp, uint64 genesisTime, uint64 secondsPerSlot) internal pure returns (uint64) {
        if (timestamp < genesisTime) return 0;
        return uint64((timestamp - genesisTime) / secondsPerSlot);
    }
}
          

src/hardened/SSZ.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/// @notice A beacon block header, as in the consensus specification.
struct BeaconBlockHeader {
    uint64 slot;
    uint64 proposerIndex;
    bytes32 parentRoot;
    bytes32 stateRoot;
    bytes32 bodyRoot;
}

/// @title SSZ
/// @notice The small part of SimpleSerialize that the bridge needs: the hash tree root of a
/// `BeaconBlockHeader`, and the check of a Merkle branch by generalized index.
/// @dev Every hash is SHA-256 through the precompile at address 0x02, which exists on Ethereum and PulseChain.
/// The compiler emits a call to that precompile for `sha256`.
library SSZ {
    /// @notice The branch length differs from the depth of the generalized index.
    error BranchLengthMismatch(uint256 expected, uint256 actual);
    /// @notice The generalized index is zero.
    error ZeroGeneralizedIndex();

    /// @notice The hash tree root of a beacon block header: five leaves padded to eight.
    /// @param header The header.
    function hashTreeRoot(BeaconBlockHeader calldata header) internal pure returns (bytes32) {
        bytes32 left = _hashPair(
            _hashPair(_uint64Leaf(header.slot), _uint64Leaf(header.proposerIndex)),
            _hashPair(header.parentRoot, header.stateRoot)
        );
        bytes32 right = _hashPair(_hashPair(header.bodyRoot, bytes32(0)), _hashPair(bytes32(0), bytes32(0)));
        return _hashPair(left, right);
    }

    /// @notice The hash tree root of a header held in memory.
    /// @param header The header.
    function hashTreeRootMemory(BeaconBlockHeader memory header) internal pure returns (bytes32) {
        bytes32 left = _hashPair(
            _hashPair(_uint64Leaf(header.slot), _uint64Leaf(header.proposerIndex)),
            _hashPair(header.parentRoot, header.stateRoot)
        );
        bytes32 right = _hashPair(_hashPair(header.bodyRoot, bytes32(0)), _hashPair(bytes32(0), bytes32(0)));
        return _hashPair(left, right);
    }

    /// @notice Checks that `leaf` sits at `generalizedIndex` under `root`, given the sibling hashes from leaf to root.
    /// @dev The branch length must equal the depth of the index, which fixes the tree shape. A branch of another
    /// length is an error, not a failed check, so a wrong fork row shows up as a clear revert.
    /// @param leaf The leaf value.
    /// @param branch The siblings, deepest first.
    /// @param generalizedIndex The generalized index of the leaf.
    /// @param root The expected root.
    function isValidBranch(bytes32 leaf, bytes32[] calldata branch, uint256 generalizedIndex, bytes32 root)
        internal
        pure
        returns (bool)
    {
        uint256 depth = depthOf(generalizedIndex);
        if (branch.length != depth) revert BranchLengthMismatch(depth, branch.length);
        bytes32 value = leaf;
        for (uint256 level = 0; level < depth; level++) {
            bool nodeIsRight = (generalizedIndex >> level) & 1 == 1;
            value = nodeIsRight ? _hashPair(branch[level], value) : _hashPair(value, branch[level]);
        }
        return value == root;
    }

    /// @notice The same check for a branch held in memory, for evidence that the caller decoded from `bytes`.
    /// @param leaf The leaf value.
    /// @param branch The siblings, deepest first.
    /// @param generalizedIndex The generalized index of the leaf.
    /// @param root The expected root.
    function isValidBranchMemory(bytes32 leaf, bytes32[] memory branch, uint256 generalizedIndex, bytes32 root)
        internal
        pure
        returns (bool)
    {
        uint256 depth = depthOf(generalizedIndex);
        if (branch.length != depth) revert BranchLengthMismatch(depth, branch.length);
        bytes32 value = leaf;
        for (uint256 level = 0; level < depth; level++) {
            bool nodeIsRight = (generalizedIndex >> level) & 1 == 1;
            value = nodeIsRight ? _hashPair(branch[level], value) : _hashPair(value, branch[level]);
        }
        return value == root;
    }

    /// @notice The depth of a generalized index: the number of bits below the leading one.
    /// @param generalizedIndex The index. It must not be zero.
    function depthOf(uint256 generalizedIndex) internal pure returns (uint256 depth) {
        if (generalizedIndex == 0) revert ZeroGeneralizedIndex();
        while (generalizedIndex > 1) {
            generalizedIndex >>= 1;
            depth++;
        }
    }

    /// @dev A uint64 leaf is the little-endian bytes of the value, padded on the right with zeros.
    function _uint64Leaf(uint64 value) private pure returns (bytes32) {
        uint64 swapped = ((value & 0xFF00FF00FF00FF00) >> 8) | ((value & 0x00FF00FF00FF00FF) << 8);
        swapped = ((swapped & 0xFFFF0000FFFF0000) >> 16) | ((swapped & 0x0000FFFF0000FFFF) << 16);
        swapped = (swapped >> 32) | (swapped << 32);
        return bytes32(uint256(swapped) << 192);
    }

    function _hashPair(bytes32 left, bytes32 right) private pure returns (bytes32) {
        return sha256(abi.encodePacked(left, right));
    }
}
          

src/hardened/ForkShape.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {SSZ} from "./SSZ.sol";

/// @title ForkShape
/// @notice The one rule that decides which fork versions the bridge accepts, on both chains. It looks at the shape of the
/// `BeaconState` tree, never at the name of a fork version.
/// @dev A shape is a plain tree depth (5, 6 or 7) or the progressive form of Gloas, marked by `PROGRESSIVE`. A shape is
/// allowed when it is in the list that `allowedShapes` returns. That list is the only place where the set is written.
/// Both paths of `BeaconForkGate` read it: the path with EIP-4788 evidence (`judge`) and the path with the registry
/// (`isAllowed`). A new allowed shape added here reaches both paths and `allowedShapes` at once, so they cannot drift.
///
/// The evidence of one shape has two branches under the same state root:
///  - The version branch proves `fork.current_version`. In a plain tree of depth d the leaf sits at
///    `((2**d + 3) * 4) + 1` and the branch has d + 2 entries. In the progressive form it sits at 169 with 7 entries.
///  - The genesis validators root branch proves `genesis_validators_root` (field 1) at its position for that shape: `2**d + 1` with d
///    entries, or node 40 with 5 entries. The leaf is the value that the gate holds as an immutable.
/// A version branch of 7 entries fits both plain depth 5 and the progressive form. `judge` tries each and takes the
/// first for which both branches verify.
///
/// Trade-off: the rule judges the shape, not the meaning of the fields. A future fork that reorders fields at the same
/// depth passes the gate. The light client then fails closed, because its own proofs check fixed positions.
library ForkShape {
    /// @notice The marker of the progressive `BeaconState` (Gloas on).
    uint8 internal constant PROGRESSIVE = 255;
    /// @notice The smallest depth for which a seal proof is looked at. Lower depths land above the fields.
    uint8 internal constant MIN_SEAL_DEPTH = 5;
    /// @notice The largest depth for which a seal proof is looked at.
    uint8 internal constant MAX_SEAL_DEPTH = 31;
    /// @notice The depth of the three field `Fork` container.
    uint256 internal constant FORK_DEPTH = 2;

    /// @dev The generalized index of `fork.current_version` in the progressive state: node 42 times 4, plus 1.
    uint256 private constant PROGRESSIVE_VERSION_GINDEX = 169;
    /// @dev The generalized index of `genesis_validators_root` (chunk 1) in the progressive state.
    uint256 private constant PROGRESSIVE_GENESIS_VALIDATORS_ROOT_GINDEX = 40;
    /// @dev Branch length of the version leaf in the progressive state: 5 state levels and the `Fork` container.
    uint256 private constant PROGRESSIVE_VERSION_LENGTH = 7;
    /// @dev Branch length of the genesis validators root leaf in the progressive state.
    uint256 private constant PROGRESSIVE_GENESIS_VALIDATORS_ROOT_LENGTH = 5;
    /// @dev The position of `fork` among the `BeaconState` fields.
    uint256 private constant FORK_FIELD_INDEX = 3;
    /// @dev The position of `genesis_validators_root` among the `BeaconState` fields.
    uint256 private constant GENESIS_VALIDATORS_ROOT_FIELD_INDEX = 1;

    /// @notice The result of judging evidence.
    enum Verdict {
        /// @dev A shape in the allowed set, with both branches valid.
        Allowed,
        /// @dev No candidate shape has a valid version branch.
        VersionProofInvalid,
        /// @dev The version branch is valid for a candidate shape, but its genesis validators root branch is not.
        GenesisValidatorsRootProofInvalid,
        /// @dev The version branch length fits no allowed shape.
        ShapeNotAllowed
    }

    /// @notice The allowed shapes, in the order in which `judge` tries them.
    function allowedShapes() internal pure returns (uint8[] memory shapes) {
        shapes = new uint8[](4);
        shapes[0] = 5;
        shapes[1] = 6;
        shapes[2] = 7;
        shapes[3] = PROGRESSIVE;
    }

    /// @notice Whether a shape is in the allowed set. The registry path uses this check.
    /// @param shape A plain depth, or `PROGRESSIVE`.
    function isAllowed(uint8 shape) internal pure returns (bool) {
        uint8[] memory shapes = allowedShapes();
        for (uint256 i = 0; i < shapes.length; i++) {
            if (shapes[i] == shape) return true;
        }
        return false;
    }

    /// @notice The generalized index of `fork.current_version` for an allowed shape.
    function versionGindex(uint8 shape) internal pure returns (uint256) {
        if (shape == PROGRESSIVE) return PROGRESSIVE_VERSION_GINDEX;
        return plainVersionGindex(shape);
    }

    /// @notice The generalized index of `fork.current_version` in a plain tree of any depth.
    function plainVersionGindex(uint256 depth) internal pure returns (uint256) {
        return (((uint256(1) << depth) + FORK_FIELD_INDEX) * 4) + 1;
    }

    /// @notice The generalized index of `genesis_validators_root` for an allowed shape.
    function genesisValidatorsRootGindex(uint8 shape) internal pure returns (uint256) {
        if (shape == PROGRESSIVE) return PROGRESSIVE_GENESIS_VALIDATORS_ROOT_GINDEX;
        return (uint256(1) << shape) + GENESIS_VALIDATORS_ROOT_FIELD_INDEX;
    }

    /// @notice The number of entries in the version branch of an allowed shape.
    function versionBranchLength(uint8 shape) internal pure returns (uint256) {
        if (shape == PROGRESSIVE) return PROGRESSIVE_VERSION_LENGTH;
        return uint256(shape) + FORK_DEPTH;
    }

    /// @notice The number of entries in the genesis validators root branch of an allowed shape.
    function genesisValidatorsRootBranchLength(uint8 shape) internal pure returns (uint256) {
        if (shape == PROGRESSIVE) return PROGRESSIVE_GENESIS_VALIDATORS_ROOT_LENGTH;
        return shape;
    }

    /// @notice The tree depth that a version branch length implies, or zero when the length is below the `Fork` depth.
    function depthOfVersionBranch(uint256 length) internal pure returns (uint256) {
        if (length < FORK_DEPTH) return 0;
        return length - FORK_DEPTH;
    }

    /// @notice Judges the evidence of the EIP-4788 path.
    /// @param stateRoot The state root of the header that the beacon roots contract vouches for.
    /// @param version The claimed `fork.current_version`.
    /// @param versionBranch The branch of the version leaf, deepest first.
    /// @param genesisValidatorsRootBranch The branch of `genesis_validators_root`, deepest first.
    /// @param genesisValidatorsRoot The value that the genesis validators root leaf must hold.
    /// @return verdict The result.
    /// @return shape The shape that was proven. Zero unless the verdict is `Allowed`.
    function judge(
        bytes32 stateRoot,
        bytes4 version,
        bytes32[] memory versionBranch,
        bytes32[] memory genesisValidatorsRootBranch,
        bytes32 genesisValidatorsRoot
    ) internal pure returns (Verdict verdict, uint8 shape) {
        uint8[] memory shapes = allowedShapes();
        bool anyCandidate;
        bool versionProven;
        for (uint256 i = 0; i < shapes.length; i++) {
            uint8 candidate = shapes[i];
            if (versionBranch.length != versionBranchLength(candidate)) continue;
            anyCandidate = true;
            if (!SSZ.isValidBranchMemory(bytes32(version), versionBranch, versionGindex(candidate), stateRoot)) continue;
            versionProven = true;
            if (_genesisValidatorsRootHolds(candidate, genesisValidatorsRootBranch, genesisValidatorsRoot, stateRoot)) return (Verdict.Allowed, candidate);
        }
        if (!anyCandidate) return (Verdict.ShapeNotAllowed, 0);
        if (versionProven) return (Verdict.GenesisValidatorsRootProofInvalid, 0);
        return (Verdict.VersionProofInvalid, 0);
    }

    /// @notice Whether a version branch is valid at the plain position of `depth`. A seal uses it for a depth outside
    /// the allowed set. The branch length must equal `depth + 2`.
    /// @param stateRoot The state root.
    /// @param version The claimed version.
    /// @param versionBranch The branch of the version leaf.
    /// @param depth The plain tree depth that the branch length implies.
    function provesPlainVersion(bytes32 stateRoot, bytes4 version, bytes32[] memory versionBranch, uint256 depth)
        internal
        pure
        returns (bool)
    {
        return SSZ.isValidBranchMemory(bytes32(version), versionBranch, plainVersionGindex(depth), stateRoot);
    }

    /// @dev Whether the genesis validators root branch has the length of the shape and proves the genesis validators root.
    function _genesisValidatorsRootHolds(uint8 shape, bytes32[] memory genesisValidatorsRootBranch, bytes32 genesisValidatorsRoot, bytes32 stateRoot)
        private
        pure
        returns (bool)
    {
        if (genesisValidatorsRootBranch.length != genesisValidatorsRootBranchLength(shape)) return false;
        return SSZ.isValidBranchMemory(genesisValidatorsRoot, genesisValidatorsRootBranch, genesisValidatorsRootGindex(shape), stateRoot);
    }
}
          

src/hardened/IDepositGate.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/// @title IDepositGate
/// @notice A check that the vault runs first in `deposit`. A gate that reverts refuses the deposit.
interface IDepositGate {
    /// @notice Admits a deposit, or reverts.
    /// @param evidence Gate-specific evidence. The vault passes the `gateEvidence` of the deposit unchanged.
    function admit(bytes calldata evidence) external;
}
          

src/hardened/IForkRegistry.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/// @title IForkRegistry
/// @notice The part of the fork observation registry that the deposit gate reads. The gate judges the shape with `ForkShape`.
interface IForkRegistry {
    /// @notice The fork version seen under the highest attested slot, the shape of the attested state that carried it,
    /// and that slot.
    /// @return version The version. It is meaningful only when `slot` is not zero.
    /// @return shape The proven shape of the state: a plain depth (5, 6 or 7 allowed, 8 to 31 disallowed), or 255 for
    /// the progressive form. A disallowed depth is what lets the gate refuse deposits and seal.
    /// Meaningful only when `slot` is not zero.
    /// @return slot The highest observed attested slot, or zero when nothing was observed.
    function latestObserved() external view returns (bytes4 version, uint8 shape, uint64 slot);
}
          

Compiler Settings

{"viaIR":false,"remappings":["@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/","forge-std/=lib/forge-std/src/","erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/","halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/","openzeppelin-contracts/=lib/openzeppelin-contracts/"],"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode"]}},"optimizer":{"runs":200,"enabled":true},"metadata":{"useLiteralContent":false,"bytecodeHash":"none","appendCBOR":false},"libraries":{},"evmVersion":"shanghai"}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"beaconRoots_","internalType":"address"},{"type":"uint8","name":"mode_","internalType":"enum BeaconForkGate.GateMode"},{"type":"uint64","name":"genesisTime_","internalType":"uint64"},{"type":"uint64","name":"secondsPerSlot_","internalType":"uint64"},{"type":"uint64","name":"slotsPerEpoch_","internalType":"uint64"},{"type":"bytes32","name":"genesisValidatorsRoot_","internalType":"bytes32"},{"type":"address","name":"forkRegistry_","internalType":"address"}]},{"type":"error","name":"BeaconRootUnavailable","inputs":[{"type":"uint256","name":"timestamp","internalType":"uint256"}]},{"type":"error","name":"BeaconRootsAbsent","inputs":[]},{"type":"error","name":"BeforeGenesis","inputs":[{"type":"uint256","name":"timestamp","internalType":"uint256"},{"type":"uint64","name":"genesisTime","internalType":"uint64"}]},{"type":"error","name":"BranchLengthMismatch","inputs":[{"type":"uint256","name":"expected","internalType":"uint256"},{"type":"uint256","name":"actual","internalType":"uint256"}]},{"type":"error","name":"ForkNotConfirmed","inputs":[{"type":"uint256","name":"epoch","internalType":"uint256"}]},{"type":"error","name":"ForkProofInvalid","inputs":[]},{"type":"error","name":"ForkRegistryHasNoCode","inputs":[{"type":"address","name":"forkRegistry","internalType":"address"}]},{"type":"error","name":"ForkRegistryMismatch","inputs":[{"type":"uint8","name":"mode","internalType":"enum BeaconForkGate.GateMode"},{"type":"address","name":"forkRegistry","internalType":"address"}]},{"type":"error","name":"GateSealed","inputs":[]},{"type":"error","name":"GenesisValidatorsRootBranchInvalid","inputs":[]},{"type":"error","name":"HeaderNotInCurrentEpoch","inputs":[{"type":"uint256","name":"headerEpoch","internalType":"uint256"},{"type":"uint256","name":"currentEpoch","internalType":"uint256"}]},{"type":"error","name":"HeaderRootMismatch","inputs":[{"type":"bytes32","name":"expected","internalType":"bytes32"},{"type":"bytes32","name":"actual","internalType":"bytes32"}]},{"type":"error","name":"NoDisallowedObservedShape","inputs":[]},{"type":"error","name":"ObservedShapeNotAllowed","inputs":[{"type":"bytes4","name":"version","internalType":"bytes4"},{"type":"uint8","name":"shape","internalType":"uint8"},{"type":"uint64","name":"slot","internalType":"uint64"}]},{"type":"error","name":"ProbeDeploymentFailed","inputs":[]},{"type":"error","name":"SealDepthNotAllowed","inputs":[{"type":"uint256","name":"depth","internalType":"uint256"}]},{"type":"error","name":"SealEvidenceTooOld","inputs":[{"type":"uint64","name":"slot","internalType":"uint64"},{"type":"uint64","name":"minimumSlot","internalType":"uint64"}]},{"type":"error","name":"ShapeIsAllowed","inputs":[{"type":"uint8","name":"shape","internalType":"uint8"}]},{"type":"error","name":"ShapeNotAllowed","inputs":[{"type":"uint256","name":"depth","internalType":"uint256"}]},{"type":"error","name":"ZeroGeneralizedIndex","inputs":[]},{"type":"error","name":"ZeroValue","inputs":[{"type":"string","name":"name","internalType":"string"}]},{"type":"event","name":"BeaconRootsDetected","inputs":[],"anonymous":false},{"type":"event","name":"ExecutionCanaryFired","inputs":[{"type":"uint8","name":"canary","internalType":"enum BeaconForkGate.Canary","indexed":false}],"anonymous":false},{"type":"event","name":"ForkConfirmed","inputs":[{"type":"uint256","name":"epoch","internalType":"uint256","indexed":true},{"type":"bytes4","name":"version","internalType":"bytes4","indexed":false}],"anonymous":false},{"type":"event","name":"GateSealedByFork","inputs":[{"type":"bytes4","name":"version","internalType":"bytes4","indexed":false},{"type":"uint64","name":"slot","internalType":"uint64","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"BLS_G1_ADD","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"PRECOMPILE_GAS","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"PROBE_GAS","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"PROBE_WORD","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"admit","inputs":[{"type":"bytes","name":"evidence","internalType":"bytes"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint8[]","name":"","internalType":"uint8[]"}],"name":"allowedShapes","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"beaconRoots","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"confirm","inputs":[{"type":"bytes","name":"evidence","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint64","name":"epoch","internalType":"uint64"},{"type":"bool","name":"exists","internalType":"bool"}],"name":"confirmedEpoch","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"currentEpoch","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint64","name":"","internalType":"uint64"}],"name":"deploymentSlot","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"enforcing","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IForkRegistry"}],"name":"forkRegistry","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint64","name":"","internalType":"uint64"}],"name":"genesisTime","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"genesisValidatorsRoot","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isSealed","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"enum BeaconForkGate.GateMode"}],"name":"mode","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"opcodeProbe","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"seal","inputs":[{"type":"bytes","name":"evidence","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint64","name":"","internalType":"uint64"}],"name":"secondsPerSlot","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint64","name":"","internalType":"uint64"}],"name":"slotsPerEpoch","inputs":[]}]
              

Contract Creation Code

0x6101a0604052348015610010575f5ffd5b5060405161250538038061250583398101604081905261002f9161044d565b6001600160a01b0387166100795760405163046c82ad60e41b815260206004820152600b60248201526a626561636f6e526f6f747360a81b60448201526064015b60405180910390fd5b846001600160401b03165f036100c05760405163046c82ad60e41b815260206004820152600b60248201526a67656e6573697354696d6560a81b6044820152606401610070565b836001600160401b03165f0361010a5760405163046c82ad60e41b815260206004820152600e60248201526d1cd958dbdb991cd4195c94db1bdd60921b6044820152606401610070565b826001600160401b03165f036101535760405163046c82ad60e41b815260206004820152600d60248201526c0e6d8dee8e6a0cae48ae0dec6d609b1b6044820152606401610070565b816101a15760405163046c82ad60e41b815260206004820152601560248201527f67656e6573697356616c696461746f7273526f6f7400000000000000000000006044820152606401610070565b5f60028760048111156101b6576101b66104cc565b14806101d3575060048760048111156101d1576101d16104cc565b145b90508015156001600160a01b0383161515146102065786826040516302f1236560e61b81526004016100709291906104e0565b6001600160a01b0382161580159061022657506001600160a01b0382163b155b1561024f57604051631cc5e02760e11b81526001600160a01b0383166004820152602401610070565b6001600160a01b03881660805286600481111561026e5761026e6104cc565b60a0816004811115610282576102826104cc565b9052506001600160401b0380871661012052858116610140528416610160526101008390526102b2428787610372565b6001600160401b0316610180526001600160a01b03821660c052604080516080810190915260488082526102ee91906124bd60208301396103be565b6001600160a01b031660e0525f87600481111561030d5761030d6104cc565b148061032a57506003876004811115610328576103286104cc565b145b8061034657506004876004811115610344576103446104cc565b145b15610365575f805460ff60501b19166a01000000000000000000001790555b50505050505050506105d3565b5f826001600160401b031684101561038b57505f6103b7565b816001600160401b0316836001600160401b0316856103aa9190610518565b6103b4919061053d565b90505b9392505050565b5f5f8251836040516020016103d492919061055c565b60405160208183030381529060405290508051602082015ff091506001600160a01b038216610416576040516353ccc26d60e01b815260040160405180910390fd5b50919050565b80516001600160a01b0381168114610432575f5ffd5b919050565b80516001600160401b0381168114610432575f5ffd5b5f5f5f5f5f5f5f60e0888a031215610463575f5ffd5b61046c8861041c565b965060208801516005811061047f575f5ffd5b955061048d60408901610437565b945061049b60608901610437565b93506104a960808901610437565b925060a088015191506104be60c0890161041c565b905092959891949750929550565b634e487b7160e01b5f52602160045260245ffd5b604081016005841061050057634e487b7160e01b5f52602160045260245ffd5b9281526001600160a01b039190911660209091015290565b8181038181111561053757634e487b7160e01b5f52601160045260245ffd5b92915050565b5f8261055757634e487b7160e01b5f52601260045260245ffd5b500490565b600360fd1b815260f883901b7fff00000000000000000000000000000000000000000000000000000000000000166001820152668060095f395ff360c81b600282015281515f90815b818110156105c257602081860181015160098684010152016105a5565b505f92016009019182525092915050565b60805160a05160c05160e0516101005161012051610140516101605161018051611e156106a85f395f818161026c015281816104ca01526104fb01525f818161021e015281816109280152610f2201525f81816101ab015261095201525f8181610245015281816108ad015281816108f9015261097c01525f81816102b8015261125201525f81816103ad01526116ea01525f818161030001528181610460015281816109c80152610d5701525f81816101ea015261060701525f818161013b0152818161114501526112ab0152611e155ff3fe608060405234801561000f575f5ffd5b5060043610610132575f3560e01c806378e1ead0116100b4578063c247ecae11610079578063c247ecae14610322578063e58f20c4146103a8578063e9a83101146103cf578063eafbed07146103e4578063f2ddc772146103f7578063f92a34601461040a575f5ffd5b806378e1ead0146102b35780638bd06e31146102da5780639b2c84d3146102e2578063a0416ddb146102ea578063c14486b2146102fb575f5ffd5b80633e1577d0116100fa5780633e1577d01461021957806342c6498a1461024057806346fe980714610267578063631f98521461028e57806376671808146102ab575f5ffd5b806308713144146101365780630b4ce99d1461017a57806313b7cac41461018f57806322a111fc146101a6578063295a5212146101e5575b5f5ffd5b61015d7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b610182610413565b6040516101719190611979565b61019861019081565b604051908152602001610171565b6101cd7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160401b039091168152602001610171565b61020c7f000000000000000000000000000000000000000000000000000000000000000081565b60405161017191906119f1565b6101cd7f000000000000000000000000000000000000000000000000000000000000000081565b6101cd7f000000000000000000000000000000000000000000000000000000000000000081565b6101cd7f000000000000000000000000000000000000000000000000000000000000000081565b5f54600160481b900460ff165b6040519015158152602001610171565b610198610422565b6101987f000000000000000000000000000000000000000000000000000000000000000081565b610198600181565b61015d600b81565b5f54600160501b900460ff1661029b565b61015d7f000000000000000000000000000000000000000000000000000000000000000081565b6103896040805160a0810182525f546001600160401b0380821680845260ff600160401b84048116151560208601819052600160481b85048216151596860196909652600160501b84041615156060850152600160581b9092041660809092019190915291565b604080516001600160401b039093168352901515602083015201610171565b61015d7f000000000000000000000000000000000000000000000000000000000000000081565b6103e26103dd366004611a04565b61042b565b005b6103e26103f2366004611a04565b610603565b6103e2610405366004611a04565b610778565b6101986107d081565b606061041d6107e5565b905090565b5f61041d6108aa565b5f54600160481b900460ff161561045557604051632dd132b360e01b815260040160405180910390fd5b8015801561048b57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031615155b1561049c576104986109c3565b5050565b6104a4610afe565b505f6104b282840184611bef565b90506104bd81610bbf565b5f80546001600160401b037f00000000000000000000000000000000000000000000000000000000000000008116600160581b909204161161051f577f0000000000000000000000000000000000000000000000000000000000000000610532565b5f54600160581b90046001600160401b03165b9050806001600160401b031682602001515f01516001600160401b0316101561058d57602082015151604051631ae1dfd360e11b81526001600160401b03918216600482015290821660248201526044015b60405180910390fd5b61059682610c31565b5f805460ff60481b1916600160481b1790556040828101516020808501515183516001600160e01b031990931683526001600160401b0316908201527fa3a79f3372e3f6ebce4863a27c346bccf4160dbc4ca1278297e954642f6465df910160405180910390a150505050565b60037f00000000000000000000000000000000000000000000000000000000000000006004811115610637576106376119be565b10610666575f54600160481b900460ff161561049857604051632dd132b360e01b815260040160405180910390fd5b6040805160a0810182525f546001600160401b03808216835260ff600160401b8304811615156020850152600160481b8304811615801595850195909552600160501b83041615156060840152600160581b909104166080820152906106df57604051632dd132b360e01b815260040160405180910390fd5b6106e7610d55565b8060600151610709576106f8610e50565b61070157505050565b600160608201525b5f6107126108aa565b90508160200151801561072e575081516001600160401b031681145b156107395750505050565b5f83900361075d5760405163e58a03ef60e01b815260048101829052602401610584565b61077261076c84860186611bef565b82610f0b565b50505050565b5f54600160481b900460ff16156107a257604051632dd132b360e01b815260040160405180910390fd5b6107aa610d55565b5f6107b3610afe565b90505f6107be6108aa565b9050816020015180156107da575081516001600160401b031681145b1561075d5750505050565b60408051600480825260a08201909252606091602082016080803683370190505090506005815f8151811061081c5761081c611cb2565b602002602001019060ff16908160ff168152505060068160018151811061084557610845611cb2565b602002602001019060ff16908160ff168152505060078160028151811061086e5761086e611cb2565b60ff928316602091820292909201015281518290600390811061089357610893611cb2565b602002602001019060ff16908160ff168152505090565b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160401b03164210156109265760405163124d0c7960e21b81524260048201526001600160401b037f0000000000000000000000000000000000000000000000000000000000000000166024820152604401610584565b7f00000000000000000000000000000000000000000000000000000000000000006001600160401b03167f00000000000000000000000000000000000000000000000000000000000000006001600160401b03167f00000000000000000000000000000000000000000000000000000000000000006001600160401b0316426109af9190611cda565b6109b99190611d01565b61041d9190611d01565b5f5f5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632fec65ed6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610a22573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a469190611d14565b925092509250806001600160401b03165f03610a755760405163f7fed25960e01b815260040160405180910390fd5b610a7e826110e9565b15610a9c5760405163f7fed25960e01b815260040160405180910390fd5b5f805460ff60481b1916600160481b179055604080516001600160e01b0319851681526001600160401b03831660208201527fa3a79f3372e3f6ebce4863a27c346bccf4160dbc4ca1278297e954642f6465df910160405180910390a1505050565b6040805160a0810182525f80825260208201819052918101829052606081018290526080810191909152506040805160a0810182525f546001600160401b03808216835260ff600160401b8304811615156020850152600160481b83048116151594840194909452600160501b82049093161580156060840152600160581b909104909216608082015290610b905790565b610b98610e50565b610bb55760405163e6bf066960e01b815260040160405180910390fd5b6001606082015290565b5f610bcc825f0151611141565b905080610bf257815160405163bad725f760e01b81526004810191909152602401610584565b5f610c0083602001516111a5565b9050818114610c2c5760405163d532058160e01b81526004810183905260248101829052604401610584565b505050565b5f610c40826060015151611211565b90506005811080610c515750601f81115b15610c725760405163fd8e2c6160e01b815260048101829052602401610584565b5f5f610c7d84611233565b90925090505f826003811115610c9557610c956119be565b03610cb857604051630412e39160e11b815260ff82166004820152602401610584565b6002826003811115610ccc57610ccc6119be565b03610cea5760405163d6f9b2eb60e01b815260040160405180910390fd5b6001826003811115610cfe57610cfe6119be565b03610d1c576040516313c8752560e01b815260040160405180910390fd5b610d38846020015160600151856040015186606001518661127f565b610772576040516313c8752560e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b038116610d875750565b5f5f5f836001600160a01b0316632fec65ed6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610dc6573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dea9190611d14565b925092509250806001600160401b03165f03610e065750505050565b610e0f826110e9565b610772576040516302a737ab60e11b81526001600160e01b03198416600482015260ff831660248201526001600160401b0382166044820152606401610584565b5f610e596112a7565b15610e9d575f805460ff60501b1916600160501b1781556040517f76d7e01988101511925fbaeed7d524e87a031ffd7e3519f6fae855bc74d391889190a150600190565b5f5f610ea761130d565b9150915081610eb8575f9250505090565b5f805460ff60501b1916600160501b1790556040517f8f7a7f3914d09b2d231bf75844e9670f4243f512ed7df9399f03cdff696c318390610efa9083906119f1565b60405180910390a160019250505090565b610f1482610bbf565b6020820151515f90610f47907f000000000000000000000000000000000000000000000000000000000000000090611d63565b6001600160401b03169050818114610f7c57604051633efb04c960e21b81526004810182905260248101839052604401610584565b610f858361138f565b6040805160a0810182525f54600160481b810460ff908116151593830193909352600160501b810490921615156060820152600160581b9091046001600160401b039081166080830181905284821683526001602080850191909152860151519091161115611003576020840151516001600160401b031660808201525b80515f80546020840151604080860151606087015160808801516001600160401b03908116600160581b0267ffffffffffffffff60581b19921515600160501b0260ff60501b19941515600160481b02949094166affff00000000000000000019961515600160401b0268ffffffffffffffffff199098169290991691909117959095179390931695909517949094171617905584810151905184917f616275f0e48e20a1fc8b75ff5186dd129b246539bf1ffff5dc40b4973151ae89916110db91906001600160e01b031991909116815260200190565b60405180910390a250505050565b5f5f6110f36107e5565b90505f5b8151811015611138578360ff1682828151811061111657611116611cb2565b602002602001015160ff1603611130575060019392505050565b6001016110f7565b505f9392505050565b5f5f7f000000000000000000000000000000000000000000000000000000000000000090505f5f604051858152602081602083875afa905194503d9250905080158061118e575081602014155b1561119d57505f949350505050565b505050919050565b5f5f6111dd6111cb6111b9855f0151611446565b6111c68660200151611446565b6114a8565b6111c6856040015186606001516114a8565b90505f6111fd6111f385608001515f5f1b6114a8565b6111c65f806114a8565b905061120982826114a8565b949350505050565b5f600282101561122257505f919050565b61122d600283611cda565b92915050565b5f5f6112768360200151606001518460400151856060015186608001517f0000000000000000000000000000000000000000000000000000000000000000611526565b91509150915091565b5f61129e6001600160e01b03198516846112988561160c565b88611631565b95945050505050565b5f5f7f000000000000000000000000000000000000000000000000000000000000000090505f4290505f5f5f604051848152602081602083895afa905193503d925090508080156112f85750816020145b801561130357508215155b9550505050505090565b5f5f6113185f6116e7565b1561132657506001915f9150565b61133060016116e7565b1561133e5750600191829150565b61134860026116e7565b15611357575060019160029150565b61136160036116e7565b15611370575060019160039150565b61137861177a565b15611387575060019160049150565b505f91829150565b5f61139982611233565b5090505f8160038111156113af576113af6119be565b036113b8575050565b60028160038111156113cc576113cc6119be565b036113ea5760405163d6f9b2eb60e01b815260040160405180910390fd5b60018160038111156113fe576113fe6119be565b0361141c576040516313c8752560e01b815260040160405180910390fd5b61142a826060015151611211565b60405163c1363eb760e01b815260040161058491815260200190565b65ff000000ff00600882811b91821664ff000000ff9390911c92831617601090811b67ff000000ff0000009290921666ff000000ff0000939093169290921790911c17602081811c63ffffffff1691901b67ffffffff00000000161760c01b90565b5f600283836040516020016114c7929190918252602082015260400190565b60408051601f19818403018152908290526114e191611d90565b602060405180830381855afa1580156114fc573d5f5f3e3d5ffd5b5050506040513d601f19601f8201168201806040525081019061151f9190611dbc565b9392505050565b5f5f5f6115316107e5565b90505f80805b83518110156115cd575f84828151811061155357611553611cb2565b602002602001015190506115668161187f565b8a511461157357506115c5565b600193506115956001600160e01b03198c168b61158f846118a2565b8f611631565b61159f57506115c5565b600192506115af818a8a8f6118c3565b156115c3575f965094506116029350505050565b505b600101611537565b50816115e25760035f94509450505050611602565b80156115f75760025f94509450505050611602565b60015f945094505050505b9550959350505050565b5f61161b60036001841b611dd3565b611626906004611de6565b61122d906001611dd3565b5f5f61163c846118ef565b90508085511461166c5784516040516322b3ddb960e01b8152610584918391600401918252602082015260400190565b855f5b828110156116da57600186821c811614806116ac576116a78389848151811061169a5761169a611cb2565b60200260200101516114a8565b6116cf565b6116cf8883815181106116c1576116c1611cb2565b6020026020010151846114a8565b92505060010161166f565b5090921495945050505050565b5f7f00000000000000000000000000000000000000000000000000000000000000008183600481111561171c5761171c6119be565b61172a9060ff166001611dd3565b90505f5f5f6040518481535f602082015260208082016001835f8a610190f193503d925060208101519150508280156117635750816020145b801561176f5750600181145b979650505050505050565b5f5f5f5f5f6f17f1d3a73197d7942695638c4fa9ac0f5f1b90505f7fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb5f1b90505f6f08b3f481e3aaa0f1a09e30ed741d8ae45f1b90505f7ffcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e15f1b90506040518481528360208201528260408201528160608201525f60808201525f60a08201525f60c08201525f60e0820152610100810160808161010084600b6107d0fa98503d9750826060820151148460408301511416856020830151148783511416169650505086801561186a5750856080145b80156118735750845b97505050505050505090565b5f60fe1960ff83160161189457506007919050565b61122d600260ff8416611dd3565b5f60fe1960ff8316016118b7575060a9919050565b61122d8260ff1661160c565b5f6118cd85611937565b8451146118db57505f611209565b61129e83856118e988611953565b85611631565b5f815f0361191057604051638e4fa1b760e01b815260040160405180910390fd5b60018211156119325760019190911c908061192a81611dfd565b915050611910565b919050565b5f60fe1960ff83160161194c57506005919050565b5060ff1690565b5f60fe1960ff83160161196857506028919050565b61122d600160ff841681901b611dd3565b602080825282518282018190525f918401906040840190835b818110156119b357835160ff16835260209384019390920191600101611992565b509095945050505050565b634e487b7160e01b5f52602160045260245ffd5b600581106119ee57634e487b7160e01b5f52602160045260245ffd5b50565b602081016119fe836119d2565b91905290565b5f5f60208385031215611a15575f5ffd5b82356001600160401b03811115611a2a575f5ffd5b8301601f81018513611a3a575f5ffd5b80356001600160401b03811115611a4f575f5ffd5b856020828401011115611a60575f5ffd5b6020919091019590945092505050565b634e487b7160e01b5f52604160045260245ffd5b60405160a081016001600160401b0381118282101715611aa657611aa6611a70565b60405290565b604051601f8201601f191681016001600160401b0381118282101715611ad457611ad4611a70565b604052919050565b6001600160401b03811681146119ee575f5ffd5b5f60a08284031215611b00575f5ffd5b611b08611a84565b90508135611b1581611adc565b81526020820135611b2581611adc565b6020820152604082810135908201526060808301359082015260809182013591810191909152919050565b6001600160e01b0319811681146119ee575f5ffd5b803561193281611b50565b5f82601f830112611b7f575f5ffd5b81356001600160401b03811115611b9857611b98611a70565b8060051b611ba860208201611aac565b91825260208185018101929081019086841115611bc3575f5ffd5b6020860192505b83831015611be5578235825260209283019290910190611bca565b9695505050505050565b5f60208284031215611bff575f5ffd5b81356001600160401b03811115611c14575f5ffd5b82016101208185031215611c26575f5ffd5b611c2e611a84565b81358152611c3f8560208401611af0565b6020820152611c5060c08301611b65565b604082015260e08201356001600160401b03811115611c6d575f5ffd5b611c7986828501611b70565b6060830152506101008201356001600160401b03811115611c98575f5ffd5b611ca486828501611b70565b608083015250949350505050565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b8181038181111561122d5761122d611cc6565b634e487b7160e01b5f52601260045260245ffd5b5f82611d0f57611d0f611ced565b500490565b5f5f5f60608486031215611d26575f5ffd5b8351611d3181611b50565b602085015190935060ff81168114611d47575f5ffd5b6040850151909250611d5881611adc565b809150509250925092565b5f6001600160401b03831680611d7b57611d7b611ced565b806001600160401b0384160491505092915050565b5f82515f5b81811015611daf5760208186018101518583015201611d95565b505f920191825250919050565b5f60208284031215611dcc575f5ffd5b5051919050565b8082018082111561122d5761122d611cc6565b808202811582820484141761122d5761122d611cc6565b5f60018201611e0e57611e0e611cc6565b5060010190565f3560f81c8060011460245780600214602c578060031460355780600414603b575f5ffd5b60015f5d603f565b60205f5f5e603f565b4a50603f565b5f1e505b60015f5260205ff3000000000000000000000000000f3df6d732807ef1319fb7b8bb8522d0beac0200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000064377651000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000020d81664ba97279a6fa0832041b4aee6009172b4750a99467ff670a9faf3a34e640000000000000000000000000f094a965f280599b41f57a5182955f4afad063f

Deployed ByteCode

0x608060405234801561000f575f5ffd5b5060043610610132575f3560e01c806378e1ead0116100b4578063c247ecae11610079578063c247ecae14610322578063e58f20c4146103a8578063e9a83101146103cf578063eafbed07146103e4578063f2ddc772146103f7578063f92a34601461040a575f5ffd5b806378e1ead0146102b35780638bd06e31146102da5780639b2c84d3146102e2578063a0416ddb146102ea578063c14486b2146102fb575f5ffd5b80633e1577d0116100fa5780633e1577d01461021957806342c6498a1461024057806346fe980714610267578063631f98521461028e57806376671808146102ab575f5ffd5b806308713144146101365780630b4ce99d1461017a57806313b7cac41461018f57806322a111fc146101a6578063295a5212146101e5575b5f5ffd5b61015d7f000000000000000000000000000f3df6d732807ef1319fb7b8bb8522d0beac0281565b6040516001600160a01b0390911681526020015b60405180910390f35b610182610413565b6040516101719190611979565b61019861019081565b604051908152602001610171565b6101cd7f000000000000000000000000000000000000000000000000000000000000000a81565b6040516001600160401b039091168152602001610171565b61020c7f000000000000000000000000000000000000000000000000000000000000000481565b60405161017191906119f1565b6101cd7f000000000000000000000000000000000000000000000000000000000000002081565b6101cd7f000000000000000000000000000000000000000000000000000000006437765181565b6101cd7f0000000000000000000000000000000000000000000000000000000000ac897b81565b5f54600160481b900460ff165b6040519015158152602001610171565b610198610422565b6101987fd81664ba97279a6fa0832041b4aee6009172b4750a99467ff670a9faf3a34e6481565b610198600181565b61015d600b81565b5f54600160501b900460ff1661029b565b61015d7f0000000000000000000000000f094a965f280599b41f57a5182955f4afad063f81565b6103896040805160a0810182525f546001600160401b0380821680845260ff600160401b84048116151560208601819052600160481b85048216151596860196909652600160501b84041615156060850152600160581b9092041660809092019190915291565b604080516001600160401b039093168352901515602083015201610171565b61015d7f000000000000000000000000ced71e22c93937fdba3de6f9a0203b3d130c1b4581565b6103e26103dd366004611a04565b61042b565b005b6103e26103f2366004611a04565b610603565b6103e2610405366004611a04565b610778565b6101986107d081565b606061041d6107e5565b905090565b5f61041d6108aa565b5f54600160481b900460ff161561045557604051632dd132b360e01b815260040160405180910390fd5b8015801561048b57507f0000000000000000000000000f094a965f280599b41f57a5182955f4afad063f6001600160a01b031615155b1561049c576104986109c3565b5050565b6104a4610afe565b505f6104b282840184611bef565b90506104bd81610bbf565b5f80546001600160401b037f0000000000000000000000000000000000000000000000000000000000ac897b8116600160581b909204161161051f577f0000000000000000000000000000000000000000000000000000000000ac897b610532565b5f54600160581b90046001600160401b03165b9050806001600160401b031682602001515f01516001600160401b0316101561058d57602082015151604051631ae1dfd360e11b81526001600160401b03918216600482015290821660248201526044015b60405180910390fd5b61059682610c31565b5f805460ff60481b1916600160481b1790556040828101516020808501515183516001600160e01b031990931683526001600160401b0316908201527fa3a79f3372e3f6ebce4863a27c346bccf4160dbc4ca1278297e954642f6465df910160405180910390a150505050565b60037f00000000000000000000000000000000000000000000000000000000000000046004811115610637576106376119be565b10610666575f54600160481b900460ff161561049857604051632dd132b360e01b815260040160405180910390fd5b6040805160a0810182525f546001600160401b03808216835260ff600160401b8304811615156020850152600160481b8304811615801595850195909552600160501b83041615156060840152600160581b909104166080820152906106df57604051632dd132b360e01b815260040160405180910390fd5b6106e7610d55565b8060600151610709576106f8610e50565b61070157505050565b600160608201525b5f6107126108aa565b90508160200151801561072e575081516001600160401b031681145b156107395750505050565b5f83900361075d5760405163e58a03ef60e01b815260048101829052602401610584565b61077261076c84860186611bef565b82610f0b565b50505050565b5f54600160481b900460ff16156107a257604051632dd132b360e01b815260040160405180910390fd5b6107aa610d55565b5f6107b3610afe565b90505f6107be6108aa565b9050816020015180156107da575081516001600160401b031681145b1561075d5750505050565b60408051600480825260a08201909252606091602082016080803683370190505090506005815f8151811061081c5761081c611cb2565b602002602001019060ff16908160ff168152505060068160018151811061084557610845611cb2565b602002602001019060ff16908160ff168152505060078160028151811061086e5761086e611cb2565b60ff928316602091820292909201015281518290600390811061089357610893611cb2565b602002602001019060ff16908160ff168152505090565b5f7f00000000000000000000000000000000000000000000000000000000643776516001600160401b03164210156109265760405163124d0c7960e21b81524260048201526001600160401b037f0000000000000000000000000000000000000000000000000000000064377651166024820152604401610584565b7f00000000000000000000000000000000000000000000000000000000000000206001600160401b03167f000000000000000000000000000000000000000000000000000000000000000a6001600160401b03167f00000000000000000000000000000000000000000000000000000000643776516001600160401b0316426109af9190611cda565b6109b99190611d01565b61041d9190611d01565b5f5f5f7f0000000000000000000000000f094a965f280599b41f57a5182955f4afad063f6001600160a01b0316632fec65ed6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610a22573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a469190611d14565b925092509250806001600160401b03165f03610a755760405163f7fed25960e01b815260040160405180910390fd5b610a7e826110e9565b15610a9c5760405163f7fed25960e01b815260040160405180910390fd5b5f805460ff60481b1916600160481b179055604080516001600160e01b0319851681526001600160401b03831660208201527fa3a79f3372e3f6ebce4863a27c346bccf4160dbc4ca1278297e954642f6465df910160405180910390a1505050565b6040805160a0810182525f80825260208201819052918101829052606081018290526080810191909152506040805160a0810182525f546001600160401b03808216835260ff600160401b8304811615156020850152600160481b83048116151594840194909452600160501b82049093161580156060840152600160581b909104909216608082015290610b905790565b610b98610e50565b610bb55760405163e6bf066960e01b815260040160405180910390fd5b6001606082015290565b5f610bcc825f0151611141565b905080610bf257815160405163bad725f760e01b81526004810191909152602401610584565b5f610c0083602001516111a5565b9050818114610c2c5760405163d532058160e01b81526004810183905260248101829052604401610584565b505050565b5f610c40826060015151611211565b90506005811080610c515750601f81115b15610c725760405163fd8e2c6160e01b815260048101829052602401610584565b5f5f610c7d84611233565b90925090505f826003811115610c9557610c956119be565b03610cb857604051630412e39160e11b815260ff82166004820152602401610584565b6002826003811115610ccc57610ccc6119be565b03610cea5760405163d6f9b2eb60e01b815260040160405180910390fd5b6001826003811115610cfe57610cfe6119be565b03610d1c576040516313c8752560e01b815260040160405180910390fd5b610d38846020015160600151856040015186606001518661127f565b610772576040516313c8752560e01b815260040160405180910390fd5b7f0000000000000000000000000f094a965f280599b41f57a5182955f4afad063f6001600160a01b038116610d875750565b5f5f5f836001600160a01b0316632fec65ed6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610dc6573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dea9190611d14565b925092509250806001600160401b03165f03610e065750505050565b610e0f826110e9565b610772576040516302a737ab60e11b81526001600160e01b03198416600482015260ff831660248201526001600160401b0382166044820152606401610584565b5f610e596112a7565b15610e9d575f805460ff60501b1916600160501b1781556040517f76d7e01988101511925fbaeed7d524e87a031ffd7e3519f6fae855bc74d391889190a150600190565b5f5f610ea761130d565b9150915081610eb8575f9250505090565b5f805460ff60501b1916600160501b1790556040517f8f7a7f3914d09b2d231bf75844e9670f4243f512ed7df9399f03cdff696c318390610efa9083906119f1565b60405180910390a160019250505090565b610f1482610bbf565b6020820151515f90610f47907f000000000000000000000000000000000000000000000000000000000000002090611d63565b6001600160401b03169050818114610f7c57604051633efb04c960e21b81526004810182905260248101839052604401610584565b610f858361138f565b6040805160a0810182525f54600160481b810460ff908116151593830193909352600160501b810490921615156060820152600160581b9091046001600160401b039081166080830181905284821683526001602080850191909152860151519091161115611003576020840151516001600160401b031660808201525b80515f80546020840151604080860151606087015160808801516001600160401b03908116600160581b0267ffffffffffffffff60581b19921515600160501b0260ff60501b19941515600160481b02949094166affff00000000000000000019961515600160401b0268ffffffffffffffffff199098169290991691909117959095179390931695909517949094171617905584810151905184917f616275f0e48e20a1fc8b75ff5186dd129b246539bf1ffff5dc40b4973151ae89916110db91906001600160e01b031991909116815260200190565b60405180910390a250505050565b5f5f6110f36107e5565b90505f5b8151811015611138578360ff1682828151811061111657611116611cb2565b602002602001015160ff1603611130575060019392505050565b6001016110f7565b505f9392505050565b5f5f7f000000000000000000000000000f3df6d732807ef1319fb7b8bb8522d0beac0290505f5f604051858152602081602083875afa905194503d9250905080158061118e575081602014155b1561119d57505f949350505050565b505050919050565b5f5f6111dd6111cb6111b9855f0151611446565b6111c68660200151611446565b6114a8565b6111c6856040015186606001516114a8565b90505f6111fd6111f385608001515f5f1b6114a8565b6111c65f806114a8565b905061120982826114a8565b949350505050565b5f600282101561122257505f919050565b61122d600283611cda565b92915050565b5f5f6112768360200151606001518460400151856060015186608001517fd81664ba97279a6fa0832041b4aee6009172b4750a99467ff670a9faf3a34e64611526565b91509150915091565b5f61129e6001600160e01b03198516846112988561160c565b88611631565b95945050505050565b5f5f7f000000000000000000000000000f3df6d732807ef1319fb7b8bb8522d0beac0290505f4290505f5f5f604051848152602081602083895afa905193503d925090508080156112f85750816020145b801561130357508215155b9550505050505090565b5f5f6113185f6116e7565b1561132657506001915f9150565b61133060016116e7565b1561133e5750600191829150565b61134860026116e7565b15611357575060019160029150565b61136160036116e7565b15611370575060019160039150565b61137861177a565b15611387575060019160049150565b505f91829150565b5f61139982611233565b5090505f8160038111156113af576113af6119be565b036113b8575050565b60028160038111156113cc576113cc6119be565b036113ea5760405163d6f9b2eb60e01b815260040160405180910390fd5b60018160038111156113fe576113fe6119be565b0361141c576040516313c8752560e01b815260040160405180910390fd5b61142a826060015151611211565b60405163c1363eb760e01b815260040161058491815260200190565b65ff000000ff00600882811b91821664ff000000ff9390911c92831617601090811b67ff000000ff0000009290921666ff000000ff0000939093169290921790911c17602081811c63ffffffff1691901b67ffffffff00000000161760c01b90565b5f600283836040516020016114c7929190918252602082015260400190565b60408051601f19818403018152908290526114e191611d90565b602060405180830381855afa1580156114fc573d5f5f3e3d5ffd5b5050506040513d601f19601f8201168201806040525081019061151f9190611dbc565b9392505050565b5f5f5f6115316107e5565b90505f80805b83518110156115cd575f84828151811061155357611553611cb2565b602002602001015190506115668161187f565b8a511461157357506115c5565b600193506115956001600160e01b03198c168b61158f846118a2565b8f611631565b61159f57506115c5565b600192506115af818a8a8f6118c3565b156115c3575f965094506116029350505050565b505b600101611537565b50816115e25760035f94509450505050611602565b80156115f75760025f94509450505050611602565b60015f945094505050505b9550959350505050565b5f61161b60036001841b611dd3565b611626906004611de6565b61122d906001611dd3565b5f5f61163c846118ef565b90508085511461166c5784516040516322b3ddb960e01b8152610584918391600401918252602082015260400190565b855f5b828110156116da57600186821c811614806116ac576116a78389848151811061169a5761169a611cb2565b60200260200101516114a8565b6116cf565b6116cf8883815181106116c1576116c1611cb2565b6020026020010151846114a8565b92505060010161166f565b5090921495945050505050565b5f7f000000000000000000000000ced71e22c93937fdba3de6f9a0203b3d130c1b458183600481111561171c5761171c6119be565b61172a9060ff166001611dd3565b90505f5f5f6040518481535f602082015260208082016001835f8a610190f193503d925060208101519150508280156117635750816020145b801561176f5750600181145b979650505050505050565b5f5f5f5f5f6f17f1d3a73197d7942695638c4fa9ac0f5f1b90505f7fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb5f1b90505f6f08b3f481e3aaa0f1a09e30ed741d8ae45f1b90505f7ffcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e15f1b90506040518481528360208201528260408201528160608201525f60808201525f60a08201525f60c08201525f60e0820152610100810160808161010084600b6107d0fa98503d9750826060820151148460408301511416856020830151148783511416169650505086801561186a5750856080145b80156118735750845b97505050505050505090565b5f60fe1960ff83160161189457506007919050565b61122d600260ff8416611dd3565b5f60fe1960ff8316016118b7575060a9919050565b61122d8260ff1661160c565b5f6118cd85611937565b8451146118db57505f611209565b61129e83856118e988611953565b85611631565b5f815f0361191057604051638e4fa1b760e01b815260040160405180910390fd5b60018211156119325760019190911c908061192a81611dfd565b915050611910565b919050565b5f60fe1960ff83160161194c57506005919050565b5060ff1690565b5f60fe1960ff83160161196857506028919050565b61122d600160ff841681901b611dd3565b602080825282518282018190525f918401906040840190835b818110156119b357835160ff16835260209384019390920191600101611992565b509095945050505050565b634e487b7160e01b5f52602160045260245ffd5b600581106119ee57634e487b7160e01b5f52602160045260245ffd5b50565b602081016119fe836119d2565b91905290565b5f5f60208385031215611a15575f5ffd5b82356001600160401b03811115611a2a575f5ffd5b8301601f81018513611a3a575f5ffd5b80356001600160401b03811115611a4f575f5ffd5b856020828401011115611a60575f5ffd5b6020919091019590945092505050565b634e487b7160e01b5f52604160045260245ffd5b60405160a081016001600160401b0381118282101715611aa657611aa6611a70565b60405290565b604051601f8201601f191681016001600160401b0381118282101715611ad457611ad4611a70565b604052919050565b6001600160401b03811681146119ee575f5ffd5b5f60a08284031215611b00575f5ffd5b611b08611a84565b90508135611b1581611adc565b81526020820135611b2581611adc565b6020820152604082810135908201526060808301359082015260809182013591810191909152919050565b6001600160e01b0319811681146119ee575f5ffd5b803561193281611b50565b5f82601f830112611b7f575f5ffd5b81356001600160401b03811115611b9857611b98611a70565b8060051b611ba860208201611aac565b91825260208185018101929081019086841115611bc3575f5ffd5b6020860192505b83831015611be5578235825260209283019290910190611bca565b9695505050505050565b5f60208284031215611bff575f5ffd5b81356001600160401b03811115611c14575f5ffd5b82016101208185031215611c26575f5ffd5b611c2e611a84565b81358152611c3f8560208401611af0565b6020820152611c5060c08301611b65565b604082015260e08201356001600160401b03811115611c6d575f5ffd5b611c7986828501611b70565b6060830152506101008201356001600160401b03811115611c98575f5ffd5b611ca486828501611b70565b608083015250949350505050565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b8181038181111561122d5761122d611cc6565b634e487b7160e01b5f52601260045260245ffd5b5f82611d0f57611d0f611ced565b500490565b5f5f5f60608486031215611d26575f5ffd5b8351611d3181611b50565b602085015190935060ff81168114611d47575f5ffd5b6040850151909250611d5881611adc565b809150509250925092565b5f6001600160401b03831680611d7b57611d7b611ced565b806001600160401b0384160491505092915050565b5f82515f5b81811015611daf5760208186018101518583015201611d95565b505f920191825250919050565b5f60208284031215611dcc575f5ffd5b5051919050565b8082018082111561122d5761122d611cc6565b808202811582820484141761122d5761122d611cc6565b5f60018201611e0e57611e0e611cc6565b506001019056