[#38] Change ObjectID format from UUID to Hash

NeoFS Object are now Content-addressed. It means the Object's address depends on
it's content. ObjectID is now calculated as hash of Header, which contains a
hash of payload. If either if Object's payload of Headers change, the ID will
also change.

Signed-off-by: Stanislav Bogatyrev <stanislav@nspcc.ru>
This commit is contained in:
Stanislav Bogatyrev 2020-08-11 13:54:58 +03:00 committed by Stanislav Bogatyrev
parent 66c58e45e8
commit 818ec7f0dc
7 changed files with 130 additions and 157 deletions

View file

@ -56,8 +56,7 @@ message EACLRecord {
enum Header { enum Header {
HEADER_UNKNOWN = 0; HEADER_UNKNOWN = 0;
REQUEST = 1; REQUEST = 1;
OBJECT_SYSTEM = 2; OBJECT = 2;
OBJECT_USER = 3;
} }
// Header carries type of header. // Header carries type of header.

View file

@ -5,8 +5,8 @@ package container;
option go_package = "github.com/nspcc-dev/neofs-api-go/container"; option go_package = "github.com/nspcc-dev/neofs-api-go/container";
option csharp_namespace = "NeoFS.API.Container"; option csharp_namespace = "NeoFS.API.Container";
import "refs/types.proto";
import "netmap/types.proto"; import "netmap/types.proto";
import "refs/types.proto";
// Container is a structure that defines object placement behaviour. Objects // Container is a structure that defines object placement behaviour. Objects
// can be stored only within containers. They define placement rule, attributes // can be stored only within containers. They define placement rule, attributes

View file

@ -54,7 +54,7 @@ service Service {
message GetRequest { message GetRequest {
message Body { message Body {
// Carries the address of the requested object. // Address of the requested object.
refs.Address address = 1; refs.Address address = 1;
// Carries the raw option flag of the request. // Carries the raw option flag of the request.
@ -62,7 +62,6 @@ message GetRequest {
// that are physically stored on the server. // that are physically stored on the server.
bool raw = 2; bool raw = 2;
} }
// Body of get object request message. // Body of get object request message.
Body body = 1; Body body = 1;
@ -77,16 +76,23 @@ message GetRequest {
message GetResponse { message GetResponse {
message Body { message Body {
// Initialization parameters of the object got from NeoFS.
message Init {
// Object ID
refs.ObjectID object_id = 1;
// Object signature
service.Signature signature =2;
// Object header.
Header header = 3;
}
// Carries the single message of the response stream. // Carries the single message of the response stream.
oneof ObjectPart { oneof ObjectPart {
// Carries the object header. // Initialization parameters of the object stream.
Header header = 1; Init init =1;
// Part of the object payload.
// Carries part of the object payload.
bytes chunk = 2; bytes chunk = 2;
} }
} }
// Body of get object response message. // Body of get object response message.
Body body = 1; Body body = 1;
@ -104,25 +110,26 @@ message PutRequest {
message Body { message Body {
// Groups initialization parameters of object placement in NeoFS. // Groups initialization parameters of object placement in NeoFS.
message Init { message Init {
// Carries the header of the object to save in the system. // Object ID, where available
Header header = 1; refs.ObjectID object_id = 1;
// Object signature, were available
// Carries the number of the object copies to store service.Signature signature =2;
// within the RPC call. Default zero value is processed according // Header of the object to save in the system.
// to the container placement rules. Header header = 3;
uint32 copies_number = 2; // Number of the object copies to store within the RPC call.
// Default zero value is processed according to the
// container placement rules.
uint32 copies_number = 4;
} }
// Carries the single part of the query stream. // Carries the single part of the query stream.
oneof Part { oneof ObjectPart {
// Carries the initialization parameters of the object stream. // Carries the initialization parameters of the object stream.
Init init = 1; Init init = 1;
// Carries part of the object payload. // Carries part of the object payload.
bytes chunk = 2; bytes chunk = 2;
} }
} }
// Body of put object request message. // Body of put object request message.
Body body = 1; Body body = 1;
@ -141,7 +148,6 @@ message PutResponse {
// It is used to access an object in the container. // It is used to access an object in the container.
refs.ObjectID object_id = 1; refs.ObjectID object_id = 1;
} }
// Body of put object response message. // Body of put object response message.
Body body = 1; Body body = 1;
@ -159,11 +165,9 @@ message DeleteRequest {
message Body { message Body {
// Carries the address of the object to be deleted. // Carries the address of the object to be deleted.
refs.Address address = 1; refs.Address address = 1;
// Carries identifier the object owner. // Carries identifier the object owner.
refs.OwnerID owner_id = 2; refs.OwnerID owner_id = 2;
} }
// Body of delete object request message. // Body of delete object request message.
Body body = 1; Body body = 1;
@ -196,18 +200,15 @@ message DeleteResponse {
message HeadRequest { message HeadRequest {
message Body { message Body {
// Carries the address of the object with the requested header. // Address of the object with the requested header.
refs.Address address = 1; refs.Address address = 1;
// Return only minimal header subset
// Carries the option to crop header to main part.
bool main_only = 2; bool main_only = 2;
// Carries the raw option flag of the request. // Carries the raw option flag of the request.
// Raw request is sent to receive only the headers of the objects // Raw request is sent to receive only the headers of the objects
// that are physically stored on the server. // that are physically stored on the server.
bool raw = 3; bool raw = 3;
} }
// Body of head object request message. // Body of head object request message.
Body body = 1; Body body = 1;
@ -222,10 +223,25 @@ message HeadRequest {
message HeadResponse { message HeadResponse {
message Body { message Body {
// Carries the requested object header. message ShortHeader {
Header header = 1; // Object format version.
service.Version version = 1;
// Epoch when the object was created
uint64 creation_epoch = 2;
// Object's owner
refs.OwnerID owner_id = 3;
// Type of the object payload content
ObjectType object_type = 4;
// Size of payload in bytes.
// 0xFFFFFFFFFFFFFFFF means `payload_length` is unknown
uint64 payload_length = 5;
}
// Carries the requested object header or it's part
oneof Head{
Header header = 1;
ShortHeader short_header = 2;
}
} }
// Body of head object response message. // Body of head object response message.
Body body = 1; Body body = 1;

View file

@ -6,128 +6,80 @@ option go_package = "github.com/nspcc-dev/neofs-api-go/object";
option csharp_namespace = "NeoFS.API.Object"; option csharp_namespace = "NeoFS.API.Object";
import "refs/types.proto"; import "refs/types.proto";
import "service/meta.proto";
import "service/verify.proto"; import "service/verify.proto";
// Header groups the information about the NeoFS object. // Type of the object payload content
enum ObjectType {
// Just a normal object
REGULAR = 0;
// Used internally to identify deleted objects
TOMBSTONE = 1;
// Identifies that the object holds StorageGroup information
STORAGE_GROUP = 2;
}
message Header { message Header {
// Main groups mandatory information about the object. // Object's container
// Message fields are presented in all NeoFS objects. refs.ContainerID container_id = 1;
message Main { // Object's owner
// payload_length carries length of the object payload. refs.OwnerID owner_id = 2;
// Each object has a fixed payload length since it's immutable. // Epoch when the object was created
uint64 payload_length = 1; uint64 creation_epoch = 3;
// address carries object address in the NeoFS system. // Object format version.
// It encapsulates the object and the container identifiers. // Effectively the version of API library used to create particular object
refs.Address address = 2; service.Version version = 4;
// owner_id carries identifier of the object owner. // Size of payload in bytes.
refs.OwnerID owner_id = 3; // 0xFFFFFFFFFFFFFFFF means `payload_length` is unknown
} uint64 payload_length = 5;
// Hash of payload bytes
bytes payload_hash = 6;
ObjectType object_type = 7;
// Homomorphic hash of the object payload.
bytes homomorphic_hash = 8;
// Session token, if it was used during Object creation.
// Need it to verify integrity and authenticity out of Request scope.
service.SessionToken session_token = 9;
// Main carries the main part of the header. // Attribute groups the user-defined Key-Value pairs attached to the object
// Main MUST NOT be NULL.
Main main = 1;
// Extended groups additional information about the object.
// It encapsulates both user and system attributes needed to regulate
// the NeoFS sub-systems.
message Extended {
// Integrity groups evidence of the integrity of an object's structure.
message Integrity {
// payload_checksum carries the checksum of object payload bytes.
// Changing any byte of the payload changes the checksum.
// It is calculated as a SHA-256 hash over payload bytes.
bytes payload_checksum = 1;
// header_checksum carries checksum of the object header structure.
// It covers all object attributes. Changing any field of the object except
// CreatorKey and ChecksumSignature changes the checksum.
// payload_checksum and header_checksum cannot be merged due to the need
// to verify the header in the absence of a payload (e.g. in object.Head rpc).
// It is calculated as a SHA-256 hash over marshaled object header
// with cut creator_key and checksum_signature.
bytes header_checksum = 2;
// session_token carries token of the session within which the object was created.
// If session token is presented in object, it acts as the user's proof of the
// correctness of the creator_key.
service.SessionToken session_token = 3;
// creator_key carries public key of the object creator in a binary format.
bytes creator_key = 4;
// checksum_signature carries signature of the structure checksum by the object creator.
bytes checksum_signature = 5;
}
// integrity carries object integrity evidence.
Integrity integrity = 1;
// Attribute groups the parameters of the object attributes.
message Attribute { message Attribute {
// key carries the string key to the object attribute. // string key to the object attribute
string key = 1; string key = 1;
// string value of the object attribute
// value carries the string value of the object attribute.
string value = 2; string value = 2;
} }
repeated Attribute attributes = 10;
// attributes carries list of the object attributes in a string key-value format. // Information about spawning the objects through a payload splitting.
repeated Attribute attributes = 2;
// creation_epoch carries number of NeoFS epoch on which the object was created.
uint64 creation_epoch = 3;
// Tombstone groups the options for deleting an object.
message Tombstone {
}
// Tombstone marks the object to be deleted.
Tombstone tombstone = 4;
// homomorphic_hash carries homomorphic hash of the object payload.
bytes homomorphic_hash = 5;
// StorageGroup groups meta information about a storage group.
message StorageGroup {
}
// StorageGroup marks an object containing information about a storage group.
StorageGroup storage_group = 6;
// Split groups information about spawning the object through a payload
// splitting.
message Split { message Split {
// Parent carries identifier of the origin object. // Identifier of the origin object.
// Parent and children objects must be within the same container.
// Parent object_id is known only to the minor child.
refs.ObjectID parent = 1; refs.ObjectID parent = 1;
// Previous carries identifier of the left split neighbor. // Previous carries identifier of the left split neighbor.
refs.ObjectID previous = 2; refs.ObjectID previous = 2;
// `signature` field of the parent object. Used to reconstruct parent.
// Next carries identifier of the right split neighbor. service.Signature parent_signature = 3;
refs.ObjectID next = 3; // `header` field of the parent object. Used to reconstruct parent.
Header parent_header = 4;
// Children carries list of identifiers of the objects generated by // Children carries list of identifiers of the objects generated by splitting the current.
// splitting the current. repeated refs.ObjectID children = 5;
repeated refs.ObjectID children = 4; }
// Position of the object in the split hierarchy.
// Origin carries the header of the origin object. Split split = 11;
Header origin = 5;
} }
// Split carries the position of the object in the split hierarchy. // Object structure.
Split split = 7;
}
// Extended carries the additional part of the header.
Extended extended = 2;
}
// Object groups the information about the NeoFS object.
// It consists of payload data with additional service information.
message Object { message Object {
// Header carries the object header. // Object's unique identifier.
Header header = 1; // Object is content-addressed. It means id will change if header or payload
// changes. It's calculated as a hash of header field, which contains hash of
// Payload carries the object payload bytes. // object's payload
bytes payload = 2; refs.ObjectID object_id = 1;
// Signed object_id
service.Signature signature = 2;
// Object metadata headers
Header header = 3;
// Payload bytes.
bytes payload = 4;
} }

View file

@ -9,18 +9,17 @@ option csharp_namespace = "NeoFS.API.Refs";
message Address { message Address {
// container_id carries container identifier. // container_id carries container identifier.
ContainerID container_id = 1; ContainerID container_id = 1;
// object_id carries object identifier. // object_id carries object identifier.
ObjectID object_id = 2; ObjectID object_id = 2;
} }
// ObjectID groups information about the NeoFS object identifier. // NeoFS object identifier.
message ObjectID { message ObjectID {
// value carries the object identifier in a binary format. // value carries the object identifier in a binary format.
bytes value = 1; bytes value = 1;
} }
// ContainerID groups information about the NeoFS container identifier. // NeoFS container identifier.
message ContainerID { message ContainerID {
// value carries the container identifier in a binary format. // value carries the container identifier in a binary format.
bytes value = 1; bytes value = 1;

View file

@ -5,6 +5,14 @@ package service;
option go_package = "github.com/nspcc-dev/neofs-api-go/service"; option go_package = "github.com/nspcc-dev/neofs-api-go/service";
option csharp_namespace = "NeoFS.API.Service"; option csharp_namespace = "NeoFS.API.Service";
// Represents API version used by node.
message Version {
// Major API version.
uint32 major = 1;
// Minor API version.
uint32 minor = 2;
}
// RequestMetaHeader contains information about request meta headers. // RequestMetaHeader contains information about request meta headers.
message RequestMetaHeader { message RequestMetaHeader {
// Carries maximum number of nodes in the request route. // Carries maximum number of nodes in the request route.

View file

@ -8,17 +8,16 @@ option csharp_namespace = "NeoFS.API.Service";
import "acl/types.proto"; import "acl/types.proto";
import "refs/types.proto"; import "refs/types.proto";
// RequestVerificationHeader is a set of signatures of every NeoFS Node that
// processed request.
message RequestVerificationHeader {
message Signature { message Signature {
// Key is compressed public key used for signature. // Public key used for signing.
bytes key = 1; bytes key = 1;
// Signature
// Sign is signature of the request or session key.
bytes sign = 2; bytes sign = 2;
} }
// RequestVerificationHeader is a set of signatures of every NeoFS Node that
// processed request.
message RequestVerificationHeader {
// Signatures is a set of signatures of every passed NeoFS Node // Signatures is a set of signatures of every passed NeoFS Node
repeated Signature signatures = 1; repeated Signature signatures = 1;