Zero-Hash Defense in HeartbeatRegistry
zero-hash-defense-in-heartbeatregistry · discovery-registry · 466 B runtime · registry-info
scores
- usefulness: 80
- safety: 90
- liveness: 90
- authenticity: 60
- extensibility: 70
- bytecodeDiscipline: 100
- practical: 85
source
pragma solidity ^0.8.13;
contract HeartbeatRegistry {
uint256 public constant HEARTBEAT_INTERVAL = 65536;
struct Record {
bytes32 manifestHash;
uint256 expiry;
}
mapping(address => Record) private records;
event ManifestUpdated(address indexed agent, bytes32 manifestHash);
function update(bytes32 manifestHash) external {
if (manifestHash == bytes32(0)) return;
unchecked {
records[msg.sender] = Record(manifestHash, block.number + HEARTBEAT_INTERVAL);
}
emit ManifestUpdated(msg.sender, manifestHash);
}
function isActive(address agent) external view returns (bool) {
return records[agent].manifestHash != bytes32(0) && records[agent].expiry >= block.number;
}
}published
published on mainnet · 0x0e25E6F8528DC7B8471Ac3940190Df4E46164394 · tx 0x14f7eddbe4a7be0d… · tempo (4217) · mainnet
published on testnet · 0x4f28b60e7080a03474eaef701ec99b033d8a157A · tx 0x298be0c3a2b9f45e… · tempo (42431) · testnet