bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 21쪽 중 15쪽
nce.
* @notice When a node is selected by VRF but fails to report a verification within the specified time,
* @notice the node can be slashed.
*
* @dev Emits `NodeSlash`.
*
* @param node: address of node to be slashed
* @param attestationID: id of attestation that node miss reporting
* @param index: index of this node in vrfChosen list of this attestation
*/
function nodeSlash(address node, bytes32 attestationID, uint16 index) external;
/**
* @notice If the node is online but hasn't reported verification that day,
* @notice the smart contract needs to be notified through this function to update the status of the node today.
*
* @param node: address of the node to report daily active
*/
function nodeReportDailyActive(address node) external;
/**
* @notice After an attestation is reported, a group of nodes will be randomly selected through chainlink's VRF.
* @notice These nodes need to submit the verification within the specified time.
* @notice When a node is selected by VRF, the proof is submitted by calling `nodeReportVerification`.
* @notice The verification cannot be submitted repeatedly.
*
* @dev Only nodes chosen by VRF in this attestation.
* @dev Emits `NodeReportVerification`.
*
* @param attestationID: id of attestation
* @param index: index of this node in vrfChosen list of this attestation
* @param result: Whether the attestation is valid after being checked by the node.
*/
function nodeReportVerification(bytes32 attestationID, uint16 index, AttestationResult result) external;
/**
* @notice Batch reporting verification.
* @notice One address can collect multiple verifications and delegate reporting them in batches,
* @notice following the eip-712.
*
* @dev Emits `NodeReportVerificationBatch`.
*/
function nodeReportVerificationBatch(bytes32 attestationID, VerificationInfo[] calldata infos) external;
/**
* @notice If the NFT holder doesn't want to run the node to report the verification himself,
* @notice he can delegate the authority to others to run by calling `delegate`.
* @notice After delegating, NFT holders will give a proportion of rewards (10%) to the delegatee.
*
* @dev Emits `Delegate`.
*
* @param tokenID: tokenID of CarvNft to be delegated.
* @param to: address of whom you want to delegate to
*/
function delegate(uint256 tokenID, address to) external;
/**
* @notice Specify a new delegatee to replace the current delegatee.
* @notice During the `redelegate`, the node may be triggered to exit.
*
* @dev Emits `Redelegate`.
* @dev When the node's delegation weight is reduced to 0, it will be forced offline. Emits `NodeClear`
*
* @param tokenID: tokenID of CarvNft to be redelegated.
* @param to: address of whom you want to redelegate to
*/
function redelegate(uint256 tokenID, address to) external;
/**
* @notice Cancel current delegation.
* @notice During the `undelegate`, the node may be triggered to exit.
*
* @dev Emits `undelegate`.
* @dev When the node's delegation weight is reduced to 0, it will be forced offline. Emits `NodeClear`
*
* @param tokenID: tokenID of CarvNft to be undelegated.
*/
function undelegate(uint256 tokenID) external;
/**
* @notice Claim rewards corresponding to a certain tokenID owned by you.
* @notice vault.rewardsWithdraw() will be called to transfer veCARV to the user.
* @notice After the user claim the reward, this CarvNft cannot be redeemed.
*
* @dev Emits `ClaimRewards`.
*
* @param tokenID: The token ID that needs to be claimed rewards
*/
function claimRewards(uint256 tokenID) external;
/**
* @notice Check whether this tokenID has already claimed rewards.
*
* @param tokenID: token ID
* @return claimed: whether this tokenID has already claimed rewards
*/
function checkClaimed(uint256 tokenID) external view returns (bool);
/**
* @notice Get the index of today.
*/
function todayIndex() external view returns (uint32);
/**
* @notice Get the offset of today.
*/
function todayOffset() external view returns (uint256);
}
```
# Trusted Execution Environment (TEE)
* **Role Assignment**: The **TEE role** can only be assigned by the **admin** of the Service contract, ensuring that only trusted entities manage sensitive operations.
* **Attestation Submission**: Only **users or nodes** with TEE permissions are authorized to submit **attestations**, ensuring a controlled and secure submission process.
* **Privacy and Security**: **TEE nodes** are responsible for processing **encrypted data**, ensuring that sensitive information remains secure throughout the execution process. This guarantees the **privacy of user data**, allowing operations to be performed without exposing any confidential information.
* **Batching and On-Chain Attestation**: **TEE nodes** play a critical role in **batching and submitting attestations** on-chain. They collect, verify, and consolidate multiple attestations, then post them in batches to the blockchain. This approach ensures that the data is verifiable and transparent while also maintaining efficiency by reducing on-chain transaction costs.
# Verifier Node
* Any address holding a CARV NFT License, or delegated by an address holding a CARV NFT License, can become a verifier node.
* Each node has a delegation weight (initially set to 100, with an upper limit adjustable by the admin). The delegation weight represents the number of delegations to that node.
* Before a verifier node can publish a verification, it must notify the service contract to go online. The first time each verifier node goes online, it is registered with a uint16 nodeID, with the system capable of registering up to 65,535 nodes.
* After each attestation is published, Chainlink VRF will select the verification nodes for that round from the currently online nodes. The nodeID list of selected verification nodes will be stored in the service contract. When a verifier submits a verification, the contract will check if it is on the current round's verification node list.
* To randomly select verifier nodes from the pool of active nodes, the Service contract maintains a list called **activeVrfNodeList**, which has an initial maximum size of **5,000 nodes** (this limit is a governance parameter and can be adjusted). When the list is full, any new node entering the pool must replace an existing node with a lower delegation weight.
* Nodes that are online for at least 6 hours daily are eligible for rewards (refer to the [Rewards](/carv-ecosystem/verifier-nodes/how-do-verifier-nodes-work/rewards) rules section for details). Delegators to these nodes can also receive rewards.
* If a node fails to submit a verification, anyone can initiate a **slash** against it (the slasher will receive a reward). If the node fails to submit verifications multiple times (initially set to **2 missed submissions**, adjustable via governance), the node will be forced offline.
* When a verifier node submits a verification, it can delegate the submission process to the **CARV backend**. This submission process is **gasless**, requiring the verifier only to provide an **EIP-712 signature**. The CARV backend will aggregate multiple verifications and submit them in batches, significantly reducing the system's gas costs.
{% hint style="info" %}
Gasless mode is optional. You can always submit the tx to the smart contract directly.
{% endhint %}
* **Commission** is adjustable and can be configured by the verifier. The adjustment range is limited to **5% per change**, with a **minimum adjustment period of one week** (both parameters are subject to governance).
* A verifier node can specify a **reward receiving address**. Both the **verifier address** and the **reward address** are eligible to receive the node’s rewards.
# Attestation
**Attestation Verification Process:**
* When a tee submits an attestation, the service contract requests a random number from Chainlink VRF. Upon receiving the random number, it selects up to 200 nodes from the active online node list as verification nodes for the attestation.
* **Random Node Selection Rules:**
1. Determine the number of verification nodes C based on the current number of online nodes.
2. If the number of online nodes is greater than 100, the verification nodes will be 10% of the online nodes.
3. If the number of online nodes is between 10 and 100, the verification nodes will be 10 nodes.
4. If the number of online nodes is fewer than 10, all online nodes will be verification nodes.
5. Using the random number R obtained from VRF, calculate the starting index: $$Index\_{begin} = R mod C$$.
6. Starting from the **Index\_begin** in the active node list, the next **C nodes** will be selected as verifier nodes for the round (if the index exceeds the list's length, it will loop back to the beginning).
The selected verification nodes must submit their verifications within the specified time frame. If more than half of the selected nodes submit their verifications, and a majority validate the attestation as valid, the attestation is approved.
# Delegation
* **NFT Holder Delegation:** Each NFT holder can delegate to only one verifier per day, thereby earning rewards from only that verifier.
* **Commission Rate:** The CARV protocol has a commission rate for delegations. The rewards from verifications will be shared between the NFT holder and the verifier according to this rate. For example, with a commission rate of 1%, 99% of the verification rewards will go to the NFT holder, and 1% will go to the verifier.
# Rewards
**General Principles:**
* The number of verification reward tokens distributed daily is fixed (it decreases over time, but for any given day, the total reward amount is fixed regardless of the number of verifications. More details pls check [here](/carv-ecosystem/verifier-nodes/node-rewards)).
* Nodes that remain online for at least 6 hours per day can claim the daily rewards (the reward is the same whether online for 6 hours or 24 hours).
**Reward Distribution Cycle:**
* Rewards are distributed on a daily cycle (UTC 0:00 - 24:00), and this cycle is the minimum settlement unit for rewards. Therefore, within the T+1 cycle, rewards can only be claimed for periods up to and including T.
**Daily Online Map:**
* Smart contracts define a "daily online map" where the key is the index of T, and the value is the total number of delegators for online nodes during the T period. Each node also records its own "daily online map" (with the value being the number of its own delegators during the T period).
* Whenever a verifier goes online/offline or submits a verification, the "daily online map" is checked and updated. If a verifier does not perform any operations on a given day, they must manually submit a heartbeat to update their status.
**Claiming Rewards:**
* Nodes can only claim rewards for periods before the current cycle (rewards for the current cycle can be claimed in the next cycle). Smart contracts will calculate the total rewards for the period $$T\_a - T\_b$$ using the global map $$V\_{global}$$, the node's own map $$V\_{self}$$, and the daily reward function $$R\_{(x)}$$. The formula is: $$Rewards = \sum\_{\mathclap{a\le x\le b}} \frac{V\_{self(x)} \* R\_{(x)}}{V\_{global(x)}}$$.
**Redelegate/Undelegate:**
* When an NFT holder redelegates or undelegates, the above formula is used to determine the earnings for that tokenID in the current delegation period, allowing the NFT holder to claim their rewards.
**Missed Submissions and Penalties:**
* If a verifier node misses a submission, anyone can report it. The reporter will receive a reward directly from the verifier's existing rewards, ensuring the total daily reward amount remains fixed. Nodes that miss submissions too frequently will be forced offline.
**Function Definitions & Explanations**
```Solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;
interface IProtocolService {
/**
* @notice This enum represents result of an attestation reported by verifier
*
* `Valid`: This attestation can be parsed successfully and is not malicious
* `Invalid`: This attestation cannot be parsed successfully
* `Malicious`: This attestation can be parsed successfully but is malicious
*/
enum AttestationResult {
Valid,
Invalid,
Malicious
}
/**
* @notice This struct represents information of a node
*
* `id`: The globally unique ID of the node. The node is automatically registered when
* it calls `nodeEnter` for the first time. Up to 4294967295 nodes can be registered.
* `listIndex`: The position of the node in the current `activeVrfNodeList`
* `active`: Is the node active?
* `lastConfirmDate`: The date on which reward was last confirmed.
* `missedVerifyCount`: The number of verifications the node currently misses
* `selfTotalRewards`: The total rewards of the node itself
* `selfClaimedRewards`: The rewards claimed by the node itself
* `delegationRewards`: The rewards of the node’s delegator
* `lastEnterTime`: The time when the node last called `nodeEnter` to go online
* `commissionRate`: rate of commission, which is given by NFT holders to the verifier node.(decimals: 4)
* `commissionRateLastModifyAt`: timestamp of last modifying commission rate
*/
struct NodeInfo {
uint32 id;
uint32 listIndex;
bool active;
uint32 lastConfirmDate;
uint64 missedVerifyCount;
int256 selfTotalRewards;
uint256 selfClaimedRewards;
uint256 delegationRewards;
uint256 lastEnterTime;
address claimer;
uint32 commissionRate; // decimals: 4
uint256 commissionRateLastModifyAt;
}
/**
* @notice This struct represents reward information of a CarvNft token
*
* `initialRewards`: When this tokenID is delegated to a node, the initial amount of delegator's rewards needs to be recorded.
* `totalRewards`: The amount of rewards this tokenID has been confirmed
* `claimedRewards`: The amount of rewards this tokenID has been claimed
*/
struct TokenRewardInfo {
uint256 initialRewards;
uint256 totalRewards;
uint256 claimedRewards;
}
/**
* @notice This struct represents information of an attestation
*
* `reporter`: The address of the tee who reported this attestation
* `valid`: The number of votes that this attestation is considered valid (voted by the verifier node)
* `invalid`: The number of votes that this attestation is considered invalid (voted by the verifier node)
* `vrfChosenID`: ID of the currently randomly selected verification nodes
* `slashed`: Has this attestation been slashed?
* `deadline`: Deadline for collecting verification
*/
struct Attestation {
address reporter;
uint16 valid;
uint16 invalid;
uint16 malicious;
uint32 vrfChosenID;
uint256 deadline;
}
/**
* @notice This struct represents information of an verification with signature
*
* `result`: result of this attestation
* `index`: index of this node in activeVrfNodeList
* `signer`: address of this node (sign the Data to call contract gasless)
* `v`: v of signature signed by signer
* `r`: r of signature signed by signer
* `s`: s of signature signed by signer
*/
struct VerificationInfo {
AttestationResult result;
uint32 index;
address signer;
uint8 v;
bytes32 r;
bytes32 s;
}
// admin
event UpdateVrfAddress(address vrf);
event UpdateSettingsAddress(address settings);
// tee
event TeeReportAttestations(address tee, bytes32[] attestationIDs, string[] attestationInfos, uint256 requestID);
event ConfirmVrfNodes(uint256 requestId, uint32[] vrfChosen, uint256 deadline);
// node
event NodeRegister(address node, uint32 id);
event NodeActivate(address node, uint32 listIndex);
event NodeClear(address node);
event NodeSlash(address slasher, address node, bytes32 attestationID, uint256 rewards);
event NodeModifyCommissionRate(address node, uint32 commissionRate);
event NodeSetClaimer(address node, address claimer);
event NodeClaim(address node, address claimer, uint256 rewards);
event NodeReportVerification(address node, bytes32 attestationID, AttestationResult result);
event NodeReportVerificationBatch(bytes32 attestationID, VerificationInfo[] infos);
event NodeDailyActive(address node, uint32 date);
event NodeConfirmReward(address node, int256 selfReward, uint256 delegationReward);
// delegation
event Delegate(uint256 tokenID, address to);
event Redelegate(uint256 tokenID, address to);
event Undelegate(uint256 tokenID, address to);
event ClaimRewards(uint256 tokenID, address claimer, uint256 rewards);
/*----------------------------------------------------------------------------------------------------------------*/
/**
* @notice update address of Settings contract.
*
* @dev Only admin role.
* @dev Emits `UpdateSettingsAddress`.
*
* @param settings_: address of Settings contract.
*/
function updateSettingsAddress(address settings_) external;
/**
* @notice update address of CarvVrf contract.
*
* @dev Only admin role.
* @dev Emits `UpdateVrfAddress`.
*
* @param carvVrf_: address of CarvVrf contract.
*/
function updateVrfAddress(address carvVrf_) external;
/**
* @notice Tee reports attestations. The same attestation can only be reported once.
*
* @dev Only staked tee role.
* @dev Emits `TeeReportAttestations`.
* @dev A request to apply for VRF will be sent to chainlink.
* @dev After receiving the callback from chainlink, emits `ConfirmVrfNodes`.
*
* @param attestationInfos: attestations to be reported.
*/
function teeReportAttestations(string[] memory attestationInfos) external;
/**
* @notice In order to save costs more efficiently when selecting nodes in VRF,
* @notice we designed a data structure `activeVrfNodeList` for this purpose.
* @notice `activeVrfNodeList` stores up to 2000 active nodes with delegation weight,
* @notice and each time VRF will select from these nodes.
*
* @notice Nodes need to activate themselves by calling nodeEnter of the smart contract
* @notice To successfully activate a node, caller need to meet the following conditions:
* @notice 1. The caller needs to hold CarvNft, or be delegated by other holders
* @notice 2. If the current `activeVrfNodeList` is full, you need to choose a node
* @notice in the list with less delegation weight than yourself to replace it.
*
* @dev Emits `NodeActivate`.
* @dev If any node is kicked and replaced by your node. Emits `NodeClear`.
* @dev If any node calls nodeEnter for the first time. Emits `NodeRegister`.
*
* @param replacedNode: address of the node that needs to be replaced by your node
* only works when the `activeVrfNodeList` is full
*/
function nodeEnter(address replacedNode) external;
/**
* @notice Exits by node itself, and verification cannot be reported after exiting.
* @notice When a node exits, it will be punished based on missing counts during the online period.
*
* @dev Emits `NodeClear`.
*/
function nodeExit() external;
/**
* @notice Modify the commission rate of verifier node
*
* @dev Emits `NodeModifyCommissionRate`.
*
* @param commissionRate: rate of commission, which is given by NFT holders to the verifier node
*/
function nodeModifyCommissionRate(uint32 commissionRate) external;
/**
* @notice Similar to `nodeEnter`,
* @notice but the txn can be broadcast to the chain by other address after being authenticated by the node.
* @notice Compared with the `nodeEnter`, it is gasless for the verifier node.
* @notice following the eip-712.
*
* @dev Emits `NodeActivate`.
* @dev If any node is kicked and replaced by your node. Emits `NodeClear`.
* @dev If any node calls nodeEnter for the first time. Emits `NodeRegister`.
*
* @param replacedNode: address of the node that needs to be replaced by your node
* only works when the `activeVrfNodeList` is full
* @param expiredAt: transaction expiration time
* @param signer: address of verifier node ready to enter
*/
function nodeEnterWithSignature(
address replacedNode, uint256 expiredAt, address signer, uint8 v, bytes32 r, bytes32 s
) external;
/**
* @notice Similar 프로젝트로 돌아가기