State storage/locality #1028
-
Forgive me if this is covered in the docs and I missed it, but I'm wondering where the state for a contract is stored? Is it simply stored on the nodes that are operating that particular contract? Or is it stored in some kind of DHT? I've been evaluating projects like Freenet and Holochain for building a system where multiple agents can interact with a decentralized system that has "rules" on its own state. For a contrived example, take currency. Let's say a contract represents a shared pool of money. The users authorized to interact with that contract can deposit and withdraw, however if the contract's state-value goes to zero then it would not allow any more withdrawls. Something like this is difficult in Holochain because all state is stored in the DHT, and each transaction would have to read the DHT (possibly multiple locations) leading to situations where some peer-validators might validate the transaction and others reject it, depending on their view of the DHT at a given time. In other words, to my understanding transactions must be self-contained in Holochain. So my question extends from a scenario like this...does any given contract have local access to its own state? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Contracts and their state are stored in a type of DHT called a small-world network. Contracts control what state is permitted to be associated with them, and the circumstances under which it can be modified. This is explained in this talk if you have time to watch it, and I just gave a new talk in which I go into more detail about how the small-world network works. I hope that is helpful. |
Beta Was this translation helpful? Give feedback.
Oh, lol, you answered that here: https://youtu.be/enTAromEeHo?si=_-68CiMhz-SIrNz0&t=2917. I had the video running in the background as I typed the above follow up and you answered it not even a minute later. 😄
So from my understanding, each peer holding a contract keeps the state locally, and will sync changes to other peers with the same contract.