RichardAH / hotpocket

A smart contract consensus engine for severs and/or Codius
GNU General Public License v3.0
11 stars 0 forks source link

Both contracts and hotpocket reading/writing state directly from state directory #2

Closed asanka-indrajith closed 5 years ago

asanka-indrajith commented 5 years ago

As I figured smart contracts write state to state folder directly (Ex- Directory smart contract). Also, hotpocket also read and do operations to state files. Is this correct? What if some smart contract wants to write its sate to a different storage mechanism like database or S3 Buckets rather than to the file system. Shouldn't we just let smart contract handle the actual reading/writing state?

RichardAH commented 5 years ago

The state needs to be confined to the node its running on, and well defined. When a contract execution completes the state needs to be synchronised with the network. If the node is not running on consensus ledger it needs to copy state from a peer which is running on consensus ledger. For these reasons the state needs to be on the file system. That said a smart contract could optionally use a database like sqlite provided it writes to the filesystem.

ravinsp commented 5 years ago

How would we agree with the contract on how to recognize state deltas. If HP assumes each state record is a file on the disk, we somehow need to get the contract to play by that rule (maybe pass a state I/O fd to the contract and let HP manage the state storage). If we let the SC write to state folder voluntarily we can't ensure it does it in a HP-compatible way. A state I/O channel between HP and SC would require its own protocol (state CRUD). Any ideas for keeping it simple?

asanka-indrajith commented 5 years ago

Closing this issue. Please refer Contract state management in which we discuss about a state management protocol between HP and the smart contract.