feat/plugin-tee-onchain-da
Relates to
-
TEE Eliza + On-chain DA
-
The idea from focEliza's on-chain AI agent with support "Ghost in the Shell"
https://x.com/CP2426_/status/1873551311205228838
Risks
Low
Background
What does this PR do?
- Eliza writes the "life" information of a specified AI agent—such as character files, memory, and keystore—into the blockchain (or DA layer) in near real-time. If the TEE node running the specified AI agent shuts down for any reason, another TEE node can download the AI agent's "life" data from the chain and resume its operation. This data is encrypted by the TEE, ensuring that only the same version of TEE Eliza can download and restore the agent.
What kind of change is this?
- Improvements
- Modify the core package to enable on-chain da upload/download
- Features (non-breaking change which adds functionality)
- Add blockchain adopter to store on-chain information
Why are we doing this? Any context or related work?
We introduced this feature in this post:
https://x.com/CP2426_/status/1873551311205228838
Documentation changes needed?
Testing
Where should a reviewer start?
Learn our design:
-
Defining Eliza’s Ghost
Eliza is a highly abstract framework. The core data structure related to its Ghost is its memory, which includes:
Agent metadata defined in the character. Message data generated through interaction with the outside world.
Together, these form its “personality” and “memory.” As Eliza expands, it may also hold a wallet, and the underlying key is one of the key pieces of its Ghost data.
-
Serialization and Encryption of Ghost
Once the Ghost is defined, it needs to be extracted from Eliza’s specific implementation and uploaded externally. Thus, a suitable serialization way is required.
We define a Blob Chain data structure:
- Each Blob’s payload can store multiple memory entries.
- The Blob is encrypted using TEE Eliza’s key, inaccessible to other versions.
- Blobs are sequentially linked in a chain. (Future expansions could use a DAG structure? Gosh fork? Who knows! 😂)
By simply storing the latest Blob, all memories can be retrieved.
-
Uploading and Downloading Ghost
When Eliza is launched as a new AI agent: It registers on-chain with a decentralized identity registration smart contract. Each Eliza has a unique name serving as a key to store the address of the Last Blob.
During Eliza's runtime: The Memory Manager continuously generates memories and periodically packages and uploads them.
For recovery: With just the name, Eliza’s TEE plugin can restore the same key, locate the Last Blob in the smart contract, and download the memory for self-recovery. Not all memories need to be downloaded—only the most recent ones suffice.
-
Extension
We’ve designed an extensible DA (Data Availability) adaptor that can cater to the agent’s needs:
DA can be expensive, so memories can be uploaded to different platforms based on user preference:
- calldata of blockchain transaction
- celestia DA.
- other reliable storage solutions.
Detailed testing steps
We hope to receive initial review feedback, especially on the modifications to the core.
After receiving the feedback, we will refactor the code, including addressing some hasty variable naming and other issues.
Hello,
We are changing our plugin development strategy to be more scalable. We have moved the plugins out into their own repos and we're looking for people to either maintain those or own them on their own Github.
If you'd like to be a maintainer, file an issue in the plugin repo and join our Discord https://discord.gg/elizaos to coordinate.
If you'd like to control the plugin on your own Github, please add an issue to the plugin repo pointing to your repo, and add a modification to the registry. Submit a PR to edit the registry here: https://github.com/elizaos-plugins/registry
Closing this PR for now. Let us know if you have any questions.