Specification
Eternals
Eternals are cryptographically secure AI models programmed as smart contracts.
Here are the key fields in the smart contract:
fee
: fee collected from users who interact with the Eternal contractsystemPrompt
: system prompt used to guide the Eternal’s behavior and responsesfoundationModel
: foundational model upon which the Eternal operates
To create a new Eternal, call the mint
function in the Eternal smart contract.
_to
: address that will own the newly created Eternal_uri
: the URI pointing to the Eternal’s metadata, including details like name and description_data
: initial system prompt that guides the Eternal's behavior and responses_fee
: fee required from users who interact with this Eternal
The Eternal smart contract is designed to be as flexible as possible. For example, the metadata could be an inscription on Bitcoin, a file on Filecoin, or even a file on AWS. We leave it up to the Eternal creators to decide what works for their use cases. For maximum security, we recommend writing the data to Bitcoin. For less critical applications, we recommend writing the data to Filecoin.
Decentralized Inference
To perform decentralized inference, call the infer
function in the Eternal smart contract.
_eternalId
: id of the Eternal handling this inference request_calldata
: prompt provided by the user, which the Eternal will interpret and respond to based on its foundational model and system prompt
In the infer
function, a request is created with an Eternal’s system prompt attached. This request is then forwarded to the foundation model’s miners for processing.
The miners responsible for handling the inference requests are managed by a separate contract called WorkerHub
. This contract allows users to stake to become miners, manage worker assignments, and submit solutions for inference requests.
Key structs in the WorkerHub
:
inferenceId
: id for the inference request that the WorkerHub assigns to minerscommitment
: commitment hash that a miner submits to prove their intent to process the inference request securelydigest
: hash of the response provided by a minerrevealNonce
: random seed used to verify the miner’s commitment during the reveal phaseminer
: address of the miner assigned to the inference requestrole
: The role, either as a miner or as a verifier.output
: miner’s response to the prompt
assignments
: assignments that specify the miners handling this inference requestinput
: user’s promptvalue
: total inference fee for processing this requestsubmitTimeout
: time limit for the first miner to submit the responsecommitTimeout
: time limit for the second and third miners to submit their commitmentsrevealTimeout
: time limit for the second and third miners to reveal their responsesstatus
: current processing status of the inference, indicating phases likeProcessing
,Commit
,Reveal
,Processed
, orFailed
creator
: address of the user who initiated the inference requestprocessedMiner
: address of the first miner to process the inference request
These structs represent the data for each assignment and inference request, which are integral to the workflow of the WorkerHub
smart contract.
The key functions of the WorkerHub
smart contract are:
seizeMinerRole
function is called by an assigned miner to obtain the miner role.
_assignmentId
: assignment id
submitResponse
function is called by a miner who has obtained the miner role for processing the inference request.
_assignmentId
: assignment id_data
: the miner's response to the user's prompt
commit
function is called by the verifiers.
_assignmentId
: assignment id_commitment
: commitment hash, calculated by hashing the response, the miner’s address, and a random nonce. This commitment is later used in the reveal phase to verify the miner's response.
reveal
function is called by the verifiers.
_assignmentId
: assignment id_nonce
: random seed (nonce) initially used to create the commitment hash_data
: The response that aligns with the initial commitment hash, providing transparency and proof of the miner’s response
The processing of an inference begins by randomly selecting a few miners from the miner pool to handle the prompt.
The mining reward goes to the fastest miner who calls the seizeMinerRole
function to claim the task and then calls the submitSolution
function to provide the solution.
The other miners become verifiers. They then call the commit
function and the reveal
function to submit their verification votes for the fastest miner's solution. The reveal
function verifies the necessary revealed votes and finalizes the solution.
Last updated