Skip to content

Commit

Permalink
[#275] container: Document contract storage model
Browse files Browse the repository at this point in the history
Add comments (outside the docs) with key-value storage structure and
some explanations. The memory mode will allow to more precisely
understand and migrate the contract storage.

Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Feb 2, 2023
1 parent 43e3e7e commit bbe1162
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions container/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,55 @@ it in Container contract.
type: Integer
*/
package container

/*
Contract storage model.
# Summary
Current conventions:
<cid>: 32-byte container identifier (SHA-256 hashes of container data)
<owner>: 25-byte NEO3 account of owner of the particular container
<epoch>: 8-byte little-endian unsigned integer NeoFS epoch
Key-value storage format:
- 'notary' -> bool
is notary mode disabled
- 'netmapScriptHash' -> interop.Hash160
Netmap contract reference
- 'balanceScriptHash' -> interop.Hash160
Balance contract reference
- 'identityScriptHash' -> interop.Hash160
NeoFSID contract reference
- 'nnsScriptHash' -> interop.Hash160
NNS contract reference
- 'nnsRoot' -> interop.Hash160
NNS root domain zone for containers
- 'x<cid>' -> []byte
container descriptors encoded into NeoFS API binary protocol format
- 'o<owner><cid>' -> <cid>
user-by-user containers
- 'nnsHasAlias<cid>' -> string
domains registered for containers in the NNS
- 'cnr<epoch><cid>' + [10]byte -> std.Serialize(estimation)
estimation of the container size sent by the storage node. Key suffix is first
10 bytes of RIPEMD-160 hash of the storage node's public key
(interop.PublicKey). Here estimation is a type.
- 'est' + [20]byte -> []<epoch>
list of NeoFS epochs when particular storage node sent estimations. Suffix is
RIPEMD-160 hash of the storage node's public key (interop.PublicKey).
# Setting
Contract can be deployed in notary and notary-disabled mode.
To handle some events, the contract refers to other contracts.
# Containers
Contract stores information about all containers presented in the NeoFS network
for which the contract is deployed. For performance optimization, container
are additionally indexed by their owners.
# NNS
Contract tracks container-related domains registered in the NNS.
# Size estimations
Contract stores containers' size estimations came from NeoFS storage nodes.
*/

0 comments on commit bbe1162

Please sign in to comment.