@dashevo/dapi-grpc 5.0.0-rc.6 → 5.0.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build.rs +8 -3
- package/clients/drive/v0/nodejs/drive_pbjs.js +1026 -15
- package/clients/platform/v0/nodejs/platform_pbjs.js +1026 -15
- package/clients/platform/v0/nodejs/platform_protoc.js +1144 -21
- package/clients/platform/v0/web/platform_pb.d.ts +146 -3
- package/clients/platform/v0/web/platform_pb.js +1144 -21
- package/package.json +2 -2
- package/protos/platform/v0/platform.proto +33 -4
- package/test/unit/nonunique-proof.spec.js +64 -20
- package/tests/nonunique_identity_lookup_wire.rs +56 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-grpc",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.8",
|
|
4
4
|
"description": "DAPI GRPC definition file and generated clients",
|
|
5
5
|
"browser": "browser.js",
|
|
6
6
|
"main": "node.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://github.com/dashevo/dapi-grpc#readme",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@dashevo/grpc-common": "5.0.0-rc.
|
|
48
|
+
"@dashevo/grpc-common": "5.0.0-rc.8",
|
|
49
49
|
"@dashevo/protobufjs": "6.10.5",
|
|
50
50
|
"@grpc/grpc-js": "^1.14.5",
|
|
51
51
|
"@improbable-eng/grpc-web": "^0.15.0",
|
|
@@ -2544,22 +2544,51 @@ message GetIdentityByNonUniquePublicKeyHashRequest {
|
|
|
2544
2544
|
optional bytes start_after = 2; // Give one result after a previous result
|
|
2545
2545
|
bool prove = 3;
|
|
2546
2546
|
}
|
|
2547
|
-
|
|
2547
|
+
// The same lookup as V0, answered with one proof of the index selection
|
|
2548
|
+
// and the identity.
|
|
2549
|
+
message GetIdentityByNonUniquePublicKeyHashRequestV1 {
|
|
2550
|
+
bytes public_key_hash = 1;
|
|
2551
|
+
optional bytes start_after = 2; // Give one result after a previous result
|
|
2552
|
+
bool prove = 3;
|
|
2553
|
+
}
|
|
2554
|
+
oneof version {
|
|
2555
|
+
GetIdentityByNonUniquePublicKeyHashRequestV0 v0 = 1;
|
|
2556
|
+
GetIdentityByNonUniquePublicKeyHashRequestV1 v1 = 2;
|
|
2557
|
+
}
|
|
2548
2558
|
}
|
|
2549
2559
|
|
|
2550
2560
|
message GetIdentityByNonUniquePublicKeyHashResponse {
|
|
2561
|
+
// A proved answer carries separate index and identity proofs.
|
|
2551
2562
|
message GetIdentityByNonUniquePublicKeyHashResponseV0 {
|
|
2552
2563
|
message IdentityResponse { optional bytes identity = 1; }
|
|
2553
2564
|
|
|
2554
|
-
|
|
2565
|
+
message IdentityProvedResponse {
|
|
2566
|
+
Proof grovedb_identity_public_key_hash_proof = 1;
|
|
2567
|
+
optional bytes identity_proof_bytes = 2;
|
|
2568
|
+
}
|
|
2569
|
+
reserved 4;
|
|
2570
|
+
oneof result {
|
|
2571
|
+
IdentityResponse identity = 1;
|
|
2572
|
+
IdentityProvedResponse proof = 2;
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
ResponseMetadata metadata = 3; // Metadata about the blockchain state
|
|
2576
|
+
}
|
|
2577
|
+
// A proved answer is one proof of the index selection and the identity.
|
|
2578
|
+
message GetIdentityByNonUniquePublicKeyHashResponseV1 {
|
|
2579
|
+
message IdentityResponse { optional bytes identity = 1; }
|
|
2580
|
+
|
|
2555
2581
|
oneof result {
|
|
2556
2582
|
IdentityResponse identity = 1;
|
|
2557
|
-
Proof proof =
|
|
2583
|
+
Proof proof = 2;
|
|
2558
2584
|
}
|
|
2559
2585
|
|
|
2560
2586
|
ResponseMetadata metadata = 3; // Metadata about the blockchain state
|
|
2561
2587
|
}
|
|
2562
|
-
oneof version {
|
|
2588
|
+
oneof version {
|
|
2589
|
+
GetIdentityByNonUniquePublicKeyHashResponseV0 v0 = 1;
|
|
2590
|
+
GetIdentityByNonUniquePublicKeyHashResponseV1 v1 = 2;
|
|
2591
|
+
}
|
|
2563
2592
|
}
|
|
2564
2593
|
|
|
2565
2594
|
message WaitForStateTransitionResultRequest {
|
|
@@ -5,38 +5,82 @@ const protobufMessages = require('../../clients/platform/v0/nodejs/platform_pbjs
|
|
|
5
5
|
const driveMessages = require('../../clients/drive/v0/nodejs/drive_pbjs');
|
|
6
6
|
|
|
7
7
|
const name = 'GetIdentityByNonUniquePublicKeyHashResponse';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
8
|
+
// Response V0 (tag 1) with result field 2: the index proof and the identity proof bytes,
|
|
9
|
+
// exactly as 4.1 nodes send a match.
|
|
10
|
+
const v0Wire = Buffer.from([
|
|
11
|
+
0x0a, 0x0c, 0x12, 0x0a, 0x0a, 0x04, 0x0a, 0x02, 1, 2, 0x12, 0x02, 3, 4,
|
|
12
|
+
]);
|
|
13
|
+
// Response V1 (tag 2) with result field 2: one Proof.
|
|
14
|
+
const v1Wire = Buffer.from([0x12, 0x06, 0x12, 0x04, 0x0a, 0x02, 1, 2]);
|
|
15
|
+
// Response V0 with a Proof at field 4, as the 5.0 prereleases sent it.
|
|
16
|
+
const field4Wire = Buffer.from([0x0a, 0x06, 0x22, 0x04, 0x0a, 0x02, 1, 2]);
|
|
11
17
|
|
|
12
|
-
describe('non-unique identity
|
|
13
|
-
it('should round trip
|
|
14
|
-
const
|
|
15
|
-
const v0 = new nodeMessages[name][innerName]();
|
|
18
|
+
describe('non-unique identity proof wire format', () => {
|
|
19
|
+
it('should round trip the two-proof V0 answer across all published JS clients', () => {
|
|
20
|
+
const v0Name = `${name}V0`;
|
|
16
21
|
const proof = new nodeMessages.Proof();
|
|
17
22
|
proof.setGrovedbProof(Buffer.from([1, 2]));
|
|
18
|
-
|
|
23
|
+
const proved = new nodeMessages[name][v0Name].IdentityProvedResponse();
|
|
24
|
+
proved.setGrovedbIdentityPublicKeyHashProof(proof);
|
|
25
|
+
proved.setIdentityProofBytes(Buffer.from([3, 4]));
|
|
26
|
+
const v0 = new nodeMessages[name][v0Name]();
|
|
27
|
+
v0.setProof(proved);
|
|
28
|
+
const response = new nodeMessages[name]();
|
|
19
29
|
response.setV0(v0);
|
|
20
|
-
assert.deepEqual(Buffer.from(response.serializeBinary()),
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
assert.deepEqual(Buffer.from(response.serializeBinary()), v0Wire);
|
|
31
|
+
|
|
32
|
+
const web = webMessages[name].deserializeBinary(v0Wire).getV0().getProof();
|
|
33
|
+
assert.deepEqual(
|
|
34
|
+
Buffer.from(web.getGrovedbIdentityPublicKeyHashProof().getGrovedbProof_asU8()),
|
|
35
|
+
Buffer.from([1, 2]),
|
|
36
|
+
);
|
|
37
|
+
assert.deepEqual(Buffer.from(web.getIdentityProofBytes_asU8()), Buffer.from([3, 4]));
|
|
23
38
|
[protobufMessages, driveMessages].forEach((messages) => {
|
|
24
39
|
const Response = messages.org.dash.platform.dapi.v0[name];
|
|
25
|
-
const decoded = Response.decode(
|
|
26
|
-
assert.deepEqual(
|
|
27
|
-
|
|
40
|
+
const decoded = Response.decode(v0Wire);
|
|
41
|
+
assert.deepEqual(
|
|
42
|
+
Buffer.from(decoded.v0.proof.grovedbIdentityPublicKeyHashProof.grovedbProof),
|
|
43
|
+
Buffer.from([1, 2]),
|
|
44
|
+
);
|
|
45
|
+
assert.deepEqual(Buffer.from(decoded.v0.proof.identityProofBytes), Buffer.from([3, 4]));
|
|
46
|
+
assert.deepEqual(Buffer.from(Response.encode(decoded).finish()), v0Wire);
|
|
28
47
|
});
|
|
29
48
|
});
|
|
30
49
|
|
|
31
|
-
it('should
|
|
50
|
+
it('should round trip the single-proof V1 answer across all published JS clients', () => {
|
|
51
|
+
const proof = new nodeMessages.Proof();
|
|
52
|
+
proof.setGrovedbProof(Buffer.from([1, 2]));
|
|
53
|
+
const v1 = new nodeMessages[name][`${name}V1`]();
|
|
54
|
+
v1.setProof(proof);
|
|
55
|
+
const response = new nodeMessages[name]();
|
|
56
|
+
response.setV1(v1);
|
|
57
|
+
assert.deepEqual(Buffer.from(response.serializeBinary()), v1Wire);
|
|
58
|
+
|
|
59
|
+
const web = webMessages[name].deserializeBinary(v1Wire);
|
|
60
|
+
assert.equal(web.hasV0(), false);
|
|
61
|
+
assert.deepEqual(
|
|
62
|
+
Buffer.from(web.getV1().getProof().getGrovedbProof_asU8()),
|
|
63
|
+
Buffer.from([1, 2]),
|
|
64
|
+
);
|
|
65
|
+
[protobufMessages, driveMessages].forEach((messages) => {
|
|
66
|
+
const Response = messages.org.dash.platform.dapi.v0[name];
|
|
67
|
+
const decoded = Response.decode(v1Wire);
|
|
68
|
+
assert.equal(decoded.v0, null);
|
|
69
|
+
assert.deepEqual(Buffer.from(decoded.v1.proof.grovedbProof), Buffer.from([1, 2]));
|
|
70
|
+
assert.deepEqual(Buffer.from(Response.encode(decoded).finish()), v1Wire);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should find no result in a V0 answer at field 4', () => {
|
|
32
75
|
[nodeMessages, webMessages].forEach((messages) => {
|
|
33
|
-
|
|
34
|
-
assert.equal(messages[name][
|
|
76
|
+
const v0 = messages[name].deserializeBinary(field4Wire).getV0();
|
|
77
|
+
assert.equal(v0.getResultCase(), messages[name][`${name}V0`].ResultCase.RESULT_NOT_SET);
|
|
35
78
|
});
|
|
36
79
|
[protobufMessages, driveMessages].forEach((messages) => {
|
|
37
|
-
const
|
|
38
|
-
assert.equal(
|
|
39
|
-
assert.equal(
|
|
80
|
+
const { v0 } = messages.org.dash.platform.dapi.v0[name].decode(field4Wire);
|
|
81
|
+
assert.equal(v0.result, undefined);
|
|
82
|
+
assert.equal(v0.proof, null);
|
|
83
|
+
assert.equal(v0.identity, null);
|
|
40
84
|
});
|
|
41
85
|
});
|
|
42
86
|
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
use dapi_grpc::platform::v0::get_identity_by_non_unique_public_key_hash_response::{
|
|
2
|
+
get_identity_by_non_unique_public_key_hash_response_v0::Result as V0Result,
|
|
3
|
+
get_identity_by_non_unique_public_key_hash_response_v1::Result as V1Result, Version,
|
|
4
|
+
};
|
|
5
|
+
use dapi_grpc::{platform::v0::GetIdentityByNonUniquePublicKeyHashResponse, Message};
|
|
6
|
+
|
|
7
|
+
#[test]
|
|
8
|
+
fn should_decode_the_two_proof_v0_answer_4_1_nodes_send() {
|
|
9
|
+
// V0, result field 2: an index Proof whose GroveDB bytes are [1, 2], and identity
|
|
10
|
+
// proof bytes [3, 4].
|
|
11
|
+
let wire = [
|
|
12
|
+
0x0a, 0x0c, 0x12, 0x0a, 0x0a, 0x04, 0x0a, 0x02, 1, 2, 0x12, 0x02, 3, 4,
|
|
13
|
+
];
|
|
14
|
+
let response = GetIdentityByNonUniquePublicKeyHashResponse::decode(&wire[..]).unwrap();
|
|
15
|
+
let Some(Version::V0(v0)) = &response.version else {
|
|
16
|
+
panic!("response version 0")
|
|
17
|
+
};
|
|
18
|
+
let Some(V0Result::Proof(proved)) = &v0.result else {
|
|
19
|
+
panic!("field 2 is the two-proof answer")
|
|
20
|
+
};
|
|
21
|
+
assert_eq!(
|
|
22
|
+
proved
|
|
23
|
+
.grovedb_identity_public_key_hash_proof
|
|
24
|
+
.as_ref()
|
|
25
|
+
.map(|proof| proof.grovedb_proof.as_slice()),
|
|
26
|
+
Some(&[1, 2][..])
|
|
27
|
+
);
|
|
28
|
+
assert_eq!(proved.identity_proof_bytes.as_deref(), Some(&[3, 4][..]));
|
|
29
|
+
assert_eq!(response.encode_to_vec(), wire);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#[test]
|
|
33
|
+
fn should_decode_the_single_proof_v1_answer() {
|
|
34
|
+
// V1, result field 2, a Proof whose GroveDB bytes are [1, 2].
|
|
35
|
+
let wire = [0x12, 0x06, 0x12, 0x04, 0x0a, 0x02, 1, 2];
|
|
36
|
+
let response = GetIdentityByNonUniquePublicKeyHashResponse::decode(&wire[..]).unwrap();
|
|
37
|
+
let Some(Version::V1(v1)) = &response.version else {
|
|
38
|
+
panic!("response version 1")
|
|
39
|
+
};
|
|
40
|
+
let Some(V1Result::Proof(proof)) = &v1.result else {
|
|
41
|
+
panic!("field 2 is the proof")
|
|
42
|
+
};
|
|
43
|
+
assert_eq!(proof.grovedb_proof, [1, 2]);
|
|
44
|
+
assert_eq!(response.encode_to_vec(), wire);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#[test]
|
|
48
|
+
fn should_find_no_result_in_a_v0_answer_at_field_4() {
|
|
49
|
+
// V0 with a Proof at field 4, as the 5.0 prereleases sent it.
|
|
50
|
+
let wire = [0x0a, 0x06, 0x22, 0x04, 0x0a, 0x02, 1, 2];
|
|
51
|
+
let response = GetIdentityByNonUniquePublicKeyHashResponse::decode(&wire[..]).unwrap();
|
|
52
|
+
let Some(Version::V0(v0)) = &response.version else {
|
|
53
|
+
panic!("response version 0")
|
|
54
|
+
};
|
|
55
|
+
assert!(v0.result.is_none());
|
|
56
|
+
}
|