From d6426bf0a8478394d7b9113859a4006aea1f1284 Mon Sep 17 00:00:00 2001 From: dboehm-avalabs Date: Wed, 3 May 2023 15:23:51 -0400 Subject: [PATCH 01/16] Update sync.proto --- proto/sync/sync.proto | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index 5fa7832cf8c..e12a61f4a9d 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -27,3 +27,20 @@ message ChangeProofRequest { uint32 key_limit = 5; uint32 bytes_limit = 6; } + +message KeyChange { + bytes key = 1; + bytes value = 2; +} + +message Node { + bytes key = 1; + bytes valueDigest = 2; + map children = 3; +} + +message RangeProofResponse { + repeated Node start_proof = 1; + repeated Node end_proof = 2; + repeated KeyChange changes = 3; +} From 51e75d865ec848e42091032e45775b9629593845 Mon Sep 17 00:00:00 2001 From: dboehm-avalabs Date: Wed, 3 May 2023 15:29:43 -0400 Subject: [PATCH 02/16] Update sync.proto --- proto/sync/sync.proto | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index e12a61f4a9d..f75a9830d19 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -28,19 +28,37 @@ message ChangeProofRequest { uint32 bytes_limit = 6; } -message KeyChange { +message KeyValue { bytes key = 1; bytes value = 2; } +message KeyChange { + bytes key = 1; + optional bytes value = 2; +} + message Node { bytes key = 1; bytes valueDigest = 2; map children = 3; } -message RangeProofResponse { +message RangeProof { + repeated Node start_proof = 1; + repeated Node end_proof = 2; + repeated KeyValue key_values = 3; +} + +message ChangeProof { repeated Node start_proof = 1; repeated Node end_proof = 2; - repeated KeyChange changes = 3; + repeated KeyChange key_changes = 3; +} + +message ChangeProofResponse { + oneof response { + ChangeProof change_proof = 1; + RangeProof range_proof = 2; + } } From dd74d3bffebd5a8bb6920d37d0894d1cd8a7dae9 Mon Sep 17 00:00:00 2001 From: dboehm-avalabs Date: Wed, 3 May 2023 15:33:10 -0400 Subject: [PATCH 03/16] Update sync.proto --- proto/sync/sync.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index f75a9830d19..c170f264535 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -40,7 +40,7 @@ message KeyChange { message Node { bytes key = 1; - bytes valueDigest = 2; + bytes value_digest = 2; map children = 3; } From b3b68ff06bba8280770f0aad751e0c56f60f8626 Mon Sep 17 00:00:00 2001 From: Ron Kuris Date: Wed, 3 May 2023 16:43:42 -0700 Subject: [PATCH 04/16] sync.proto recommended changes Proposed changes, just a few renames and documentation added --- proto/sync/sync.proto | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index c170f264535..2a67b6e0db4 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -4,6 +4,7 @@ package sync; option go_package = "github.com/ava-labs/avalanchego/proto/pb/sync"; +/* Request represents the two requests you can make */ message Request { oneof message { RangeProofRequest range_proof_request = 1; @@ -11,54 +12,64 @@ message Request { } } +/* A RangeProofRequest requests a proof between two keys at a specific revision */ message RangeProofRequest { - bytes root = 1; - bytes start = 2; - bytes end = 3; + bytes root_hash = 1; + bytes start_key = 2; + bytes end_key = 3; uint32 key_limit = 4; uint32 bytes_limit = 5; } +/* A ChangeProofRequest request a proof for all cahnges between two revisions */ message ChangeProofRequest { - bytes start_root = 1; - bytes end_root = 2; - bytes start = 3; - bytes end = 4; + bytes start_root_hash = 1; + bytes end_root_hash = 2; + bytes start_key = 3; + bytes end_key = 4; uint32 key_limit = 5; uint32 bytes_limit = 6; } +/* KeyValue represents a single key and its value */ message KeyValue { bytes key = 1; bytes value = 2; } +/* KeyChange is a change for a key from one version to another + used in ChangeProofResponse. If the value is nil, the key + is deleted in the final proof */ message KeyChange { bytes key = 1; optional bytes value = 2; } -message Node { +/* KeyProof represents a proof for a single key */ +message KeyProof { bytes key = 1; - bytes value_digest = 2; + bytes value_hash = 2; map children = 3; } -message RangeProof { - repeated Node start_proof = 1; - repeated Node end_proof = 2; +/* RangeProofResponse is the response for a RangeProofRequest */ +message RangeProofResponse { + repeated KeyProof start = 1; + repeated KeyProof end = 2; repeated KeyValue key_values = 3; } +/* RangeProofResponse is the response for a RangeProofRequest */ message ChangeProof { - repeated Node start_proof = 1; - repeated Node end_proof = 2; + repeated KeyProof start_proof = 1; + repeated KeyProof end_proof = 2; repeated KeyChange key_changes = 3; } +/* ChangeProofResponse is the response for a ChangeProofRequest */ message ChangeProofResponse { oneof response { ChangeProof change_proof = 1; - RangeProof range_proof = 2; + RangeProofResponse range_proof = 2; } } From f1eb6decfd79f3f90247d837208019ca07ecdf7c Mon Sep 17 00:00:00 2001 From: Ron Kuris Date: Thu, 4 May 2023 07:54:24 -0700 Subject: [PATCH 05/16] Review comments --- proto/sync/sync.proto | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index 2a67b6e0db4..14b68a34c80 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -21,7 +21,7 @@ message RangeProofRequest { uint32 bytes_limit = 5; } -/* A ChangeProofRequest request a proof for all cahnges between two revisions */ +/* A ChangeProofRequest request a proof for all changes between two revisions */ message ChangeProofRequest { bytes start_root_hash = 1; bytes end_root_hash = 2; @@ -59,7 +59,11 @@ message RangeProofResponse { repeated KeyValue key_values = 3; } -/* RangeProofResponse is the response for a RangeProofRequest */ +/* ChangeProof is a possible response to a ChangeProofRequests + which is in a shorter form: it only consists of a proof of the + lowest changed key, the high changed key, and the keys that + have changed between those. Some keys may be deleted (hence + the use of KeyChange instead of KeyValue) */ message ChangeProof { repeated KeyProof start_proof = 1; repeated KeyProof end_proof = 2; From 6cce0d30463c0edbd0cb6c3d2181ecace41af092 Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Thu, 18 May 2023 16:33:35 -0400 Subject: [PATCH 06/16] rename KeyProof to ProofNode; rename ProofNode.value_hash to ProofNode.vale_or_hash; add SerializedPath message --- proto/sync/sync.proto | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index 14b68a34c80..712f26cd84f 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -45,17 +45,17 @@ message KeyChange { optional bytes value = 2; } -/* KeyProof represents a proof for a single key */ -message KeyProof { +/* ProofNode is a node in a merkle proof */ +message ProofNode { bytes key = 1; - bytes value_hash = 2; + optional bytes value_or_hash = 2; map children = 3; } /* RangeProofResponse is the response for a RangeProofRequest */ message RangeProofResponse { - repeated KeyProof start = 1; - repeated KeyProof end = 2; + repeated ProofNode start = 1; + repeated ProofNode end = 2; repeated KeyValue key_values = 3; } @@ -65,8 +65,8 @@ message RangeProofResponse { have changed between those. Some keys may be deleted (hence the use of KeyChange instead of KeyValue) */ message ChangeProof { - repeated KeyProof start_proof = 1; - repeated KeyProof end_proof = 2; + repeated ProofNode start_proof = 1; + repeated ProofNode end_proof = 2; repeated KeyChange key_changes = 3; } From ec51aeb61157a3889786ab89f678bcd9cfabafb5 Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Thu, 18 May 2023 16:34:28 -0400 Subject: [PATCH 07/16] actually add SerializedPath message --- proto/sync/sync.proto | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index 712f26cd84f..83c34cd3d9b 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -45,6 +45,12 @@ message KeyChange { optional bytes value = 2; } +/* SerializedPath is the serialized representation of a path */ +message SerializedPath { + int nibble_length = 1; + bytes value = 2; +} + /* ProofNode is a node in a merkle proof */ message ProofNode { bytes key = 1; From 63386d4829ded622fba5155bbf0e27fe62f873a7 Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Fri, 19 May 2023 09:08:25 -0400 Subject: [PATCH 08/16] int --> uint32 in proto --- proto/sync/sync.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index 83c34cd3d9b..66d04341647 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -47,7 +47,7 @@ message KeyChange { /* SerializedPath is the serialized representation of a path */ message SerializedPath { - int nibble_length = 1; + uint32 nibble_length = 1; bytes value = 2; } From 35267b5ef74b6d60d9cd8ae572ba109956080091 Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Mon, 22 May 2023 09:32:37 -0400 Subject: [PATCH 09/16] add proto MaybeBytes type --- proto/sync/sync.proto | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index 66d04341647..c3a1f741e04 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -51,10 +51,18 @@ message SerializedPath { bytes value = 2; } +/* MaybeBytes is an option wrapping bytes. */ +message MaybeBytes { + // optional to distinguish nil from empty byte slice. + optional bytes value = 1; + // If false, this is None. + bool is_nothing = 2; +} + /* ProofNode is a node in a merkle proof */ message ProofNode { - bytes key = 1; - optional bytes value_or_hash = 2; + SerializedPath key = 1; + MaybeBytes value_or_hash = 2; map children = 3; } From d33831f6ad4f1cfba7d1ebb566bcfa8d94c6e946 Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Mon, 22 May 2023 14:10:23 -0400 Subject: [PATCH 10/16] make value in MaybeBytes non-optional; make value in KeyChange a MaybeBytes --- proto/sync/sync.proto | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index c3a1f741e04..be5a45aa4e5 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -38,11 +38,11 @@ message KeyValue { } /* KeyChange is a change for a key from one version to another - used in ChangeProofResponse. If the value is nil, the key - is deleted in the final proof */ + used in ChangeProofResponse. If the value is None, the key + was deleted. */ message KeyChange { bytes key = 1; - optional bytes value = 2; + MaybeBytes value = 2; } /* SerializedPath is the serialized representation of a path */ @@ -53,8 +53,7 @@ message SerializedPath { /* MaybeBytes is an option wrapping bytes. */ message MaybeBytes { - // optional to distinguish nil from empty byte slice. - optional bytes value = 1; + bytes value = 1; // If false, this is None. bool is_nothing = 2; } From 2859a5455f70c691df9218bb281336c780494b98 Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Mon, 22 May 2023 16:41:12 -0400 Subject: [PATCH 11/16] add had_roots_in_history to ChangeProof --- proto/sync/sync.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index be5a45aa4e5..ffaaef6e8ce 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -78,6 +78,7 @@ message RangeProofResponse { have changed between those. Some keys may be deleted (hence the use of KeyChange instead of KeyValue) */ message ChangeProof { + bool had_roots_in_history = 1; // TODO remove repeated ProofNode start_proof = 1; repeated ProofNode end_proof = 2; repeated KeyChange key_changes = 3; From d6daa7b0cdfb31a09710fbd7218308f799128afb Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Mon, 22 May 2023 16:45:02 -0400 Subject: [PATCH 12/16] fix proto ordering --- proto/sync/sync.proto | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index ffaaef6e8ce..6a3567504ba 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -79,9 +79,9 @@ message RangeProofResponse { the use of KeyChange instead of KeyValue) */ message ChangeProof { bool had_roots_in_history = 1; // TODO remove - repeated ProofNode start_proof = 1; - repeated ProofNode end_proof = 2; - repeated KeyChange key_changes = 3; + repeated ProofNode start_proof = 2; + repeated ProofNode end_proof = 3; + repeated KeyChange key_changes = 4; } /* ChangeProofResponse is the response for a ChangeProofRequest */ From de32cda35506371f4762965d4d8b9b6424636cab Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Mon, 22 May 2023 17:19:31 -0400 Subject: [PATCH 13/16] comment nit --- proto/sync/sync.proto | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index 6a3567504ba..4c3b1a95e9b 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -37,9 +37,8 @@ message KeyValue { bytes value = 2; } -/* KeyChange is a change for a key from one version to another - used in ChangeProofResponse. If the value is None, the key - was deleted. */ +/* KeyChange is a change for a key from one revision to another. + If the value is None, the key was deleted. */ message KeyChange { bytes key = 1; MaybeBytes value = 2; From 73bcfd0717511951a6dceda1cc682d4293482755 Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Tue, 23 May 2023 09:44:21 -0400 Subject: [PATCH 14/16] /* --> // for proto comments --- proto/sync/sync.proto | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index 4c3b1a95e9b..28b0eda2f33 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -31,51 +31,51 @@ message ChangeProofRequest { uint32 bytes_limit = 6; } -/* KeyValue represents a single key and its value */ +// KeyValue represents a single key and its value. message KeyValue { bytes key = 1; bytes value = 2; } -/* KeyChange is a change for a key from one revision to another. - If the value is None, the key was deleted. */ +// KeyChange is a change for a key from one revision to another. +// If the value is None, the key was deleted. message KeyChange { bytes key = 1; MaybeBytes value = 2; } -/* SerializedPath is the serialized representation of a path */ +// SerializedPath is the serialized representation of a path. message SerializedPath { uint32 nibble_length = 1; bytes value = 2; } -/* MaybeBytes is an option wrapping bytes. */ +// MaybeBytes is an option wrapping bytes. message MaybeBytes { bytes value = 1; // If false, this is None. bool is_nothing = 2; } -/* ProofNode is a node in a merkle proof */ +// ProofNode is a node in a merkle proof. message ProofNode { SerializedPath key = 1; MaybeBytes value_or_hash = 2; map children = 3; } -/* RangeProofResponse is the response for a RangeProofRequest */ +// RangeProofResponse is the response to a RangeProofRequest. message RangeProofResponse { repeated ProofNode start = 1; repeated ProofNode end = 2; repeated KeyValue key_values = 3; } -/* ChangeProof is a possible response to a ChangeProofRequests - which is in a shorter form: it only consists of a proof of the - lowest changed key, the high changed key, and the keys that - have changed between those. Some keys may be deleted (hence - the use of KeyChange instead of KeyValue) */ +// ChangeProof is a possible response to a ChangeProofRequest. +// It only consists of a proof of the smallest changed key, +// the highest changed key, and the keys that have changed +// between those. Some keys may be deleted (hence +// the use of KeyChange instead of KeyValue). message ChangeProof { bool had_roots_in_history = 1; // TODO remove repeated ProofNode start_proof = 2; @@ -83,7 +83,7 @@ message ChangeProof { repeated KeyChange key_changes = 4; } -/* ChangeProofResponse is the response for a ChangeProofRequest */ +// ChangeProofResponse is the response for a ChangeProofRequest. message ChangeProofResponse { oneof response { ChangeProof change_proof = 1; From 72b748c4195ee05236545f90df7351762c03b2f2 Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Tue, 23 May 2023 10:06:09 -0400 Subject: [PATCH 15/16] /* --> // for proto comments --- proto/sync/sync.proto | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index 28b0eda2f33..345d9873b4a 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -4,7 +4,7 @@ package sync; option go_package = "github.com/ava-labs/avalanchego/proto/pb/sync"; -/* Request represents the two requests you can make */ +// Request represents a request for information during syncing. message Request { oneof message { RangeProofRequest range_proof_request = 1; @@ -12,7 +12,8 @@ message Request { } } -/* A RangeProofRequest requests a proof between two keys at a specific revision */ +// A RangeProofRequest requests the key-value pairs in a given key range +// at a specific revision. message RangeProofRequest { bytes root_hash = 1; bytes start_key = 2; @@ -21,7 +22,7 @@ message RangeProofRequest { uint32 bytes_limit = 5; } -/* A ChangeProofRequest request a proof for all changes between two revisions */ +// A ChangeProofRequest requests the changes between two revisions. message ChangeProofRequest { bytes start_root_hash = 1; bytes end_root_hash = 2; From cad3a80bf41311828eec24904ea00d8643707199 Mon Sep 17 00:00:00 2001 From: Dan Laine Date: Wed, 24 May 2023 16:52:32 -0400 Subject: [PATCH 16/16] rename RangeProofResponse --> RangeProof --- proto/sync/sync.proto | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proto/sync/sync.proto b/proto/sync/sync.proto index 345d9873b4a..ca852b87a87 100644 --- a/proto/sync/sync.proto +++ b/proto/sync/sync.proto @@ -65,8 +65,8 @@ message ProofNode { map children = 3; } -// RangeProofResponse is the response to a RangeProofRequest. -message RangeProofResponse { +// RangeProof is the response to a RangeProofRequest. +message RangeProof { repeated ProofNode start = 1; repeated ProofNode end = 2; repeated KeyValue key_values = 3; @@ -88,6 +88,6 @@ message ChangeProof { message ChangeProofResponse { oneof response { ChangeProof change_proof = 1; - RangeProofResponse range_proof = 2; + RangeProof range_proof = 2; } }