I’ve been looking into why this string appears in the file.
Why do I feel it’s suspicious to have it there? This data is the output of a call to bincode::serialize
, and when it’s deserialized again there’s no way that string is going to be parsed into a valid publickey value.
Somewhere it seems that .to_string()
is being called on the public key, maybe not by maidsafe code, but somewhere. If this value were a ‘real’ public key and not a ‘string’ public key, it would be serialized as bytes, not as a string, since bincode would go for the most direct representation.
I tried serialize the sequence chunk into json (between these two lines), but there’s no way to convert some of the map keys to strings so it fails (in json all keys must be strings, but in a sequence chunk some keys are objects).
msgpack can use non-strings as keys, and yes msgpack does work for serializing a sequence chunk. So we can begin to investigate this data by converting the raw msgpack bytes to json.
This is the closest I could get (so far) to a human-readable format for the sequence chunk that is stored in the chunkstore:
{
"operations_pk": {
"Ed25519": "TDIfnZXtbwIhQqzTfqTokNMSAIMKF16gB+hRUAGNpRw="
},
"data": {
"Public": {
"actor": "PublicKey::Ed25519(4c321f..)",
"address": {
"Public": {
"name": [
201,36,89,170,131,92,169,118,94,9,43,181,155,
94,159,203,153,202,173,127,52,138,251,161,88,
247,249,220,131,54,116,223
],
"tag": 1200
}
},
"data": {
"{\"path\":[[1,\"PublicKey::Ed25519(4c321f..)\"]]}": {
"seq": [
{
"id": {
"path": [
[
1023,
"PublicKey::Ed25519(4c321f..)"
]
]
},
"dot": {
"actor": "PublicKey::Ed25519(4c321f..)",
"counter": 1
},
"val": [
109,121,32,115,101,113,32,118,97,108
]
}
],
"gen": {
"initial_base_bits": 10,
"boundary": 1,
"site_id": "PublicKey::Ed25519(4c321f..)"
},
"clock": {
"dots": {
"PublicKey::Ed25519(4c321f..)": 1
}
}
}
},
"policy": {
"seq": [
{
"id": {
"path": [
[
1,
"PublicKey::Ed25519(4c321f..)"
]
]
},
"dot": {
"actor": "PublicKey::Ed25519(4c321f..)",
"counter": 1
},
"val": [
{
"owner": {
"Ed25519": "TDIfnZXtbwIhQqzTfqTokNMSAIMKF16gB+hRUAGNpRw="
},
"permissions": {
"{\"Key\":{\"Ed25519\":\"TDIfnZXtbwIhQqzTfqTokNMSAIMKF16gB+hRUAGNpRw=\"}}": {
"append": true,
"admin": true
}
}
},
null
]
}
],
"gen": {
"initial_base_bits": 10,
"boundary": 1,
"site_id": "PublicKey::Ed25519(4c321f..)"
},
"clock": {
"dots": {
"PublicKey::Ed25519(4c321f..)": 1
}
}
}
}
}
}
This gives some clues where the public-key-as-string value may be. It could be in
data.Public.actor
data.Public.data.(in a object-as-key).path.0.1
data.Public.data.(in the value for object-as-key).seq.0.id.path.0.1
data.Public.data.(in the value for object-as-key).seq.0.dot.actor
data.Public.data.(in the value for object-as-key).gen.site_id
data.Public.data.(in the value for object-as-key).clock.dots.(as a key)
data.Public.policy.seq.0.id.path.0.1
data.Public.policy.seq.0.dot.actor
data.Public.policy.gen.site_id
data.Public.policy.clock.dots.(as a key)
In the bincode serialized version the string 4c321f
appears 10 times.
The base64 Ed25519 value TDIfnZX...
when decoded to bytes and hex encoded is the same as the other hex public key values being displayed 4c321f..
. But the bincode version does not contain the string TDIfnZX
anywhere.
Notice the “data” value has an object for a key
"{\"path\":[[1,\"PublicKey::Ed25519(4c321f..)\"]]}"
and also permissions has an object as a key
"{\"Key\":{\"Ed25519\":\"TDIfnZXtbwIhQqzTfqTokNMSAIMKF16gB+hRUAGNpRw=\"}}"
Moving to json would be a great exercise. It would give human readable values which is a huge benefit. It will create clarity around the use of enums. It will create clarity around the use of non-strings as map keys.
JSON has no support for enums so that will need some attention to make work. (msgpack has no formal support for enums but the rust implementation can do enums as ints or strings which is handy, as can be seen in the above where there are strings representing enums, such as PublicKey
).
From json it’s very easy to move to a more efficient serialization such as messagepack later on.
I feel that the move to json will require a simplification of the data structures, since the way they are now is not convertible to valid json. Moving away from bincode will be a big but imo very important and enlightening job.
For reference here’s the bincode bytes for this sequence chunk (from the file baby-fleming-nodes/sn-node-X/chunks/sequence/<the file>)
[0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 76, 50, 31, 157, 149, 237, 111, 2, 33, 66, 172, 211, 126, 164, 232, 144, 211, 18, 0, 131, 10, 23, 94, 160, 7, 232, 81, 80, 1, 141, 165, 28, 0, 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, 0, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 0, 0, 0, 0, 201, 36, 89, 170, 131, 92, 169, 118, 94, 9, 43, 181, 155, 94, 159, 203, 153, 202, 173, 127, 52, 138, 251, 161, 88, 247, 249, 220, 131, 54, 116, 223, 176, 4, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 28, 0, 0, 0, 0, 0, 0, 0, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 255, 3, 0, 0, 0, 0, 0, 0, 1, 28, 0, 0, 0, 0, 0, 0, 0, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 28, 0, 0, 0, 0, 0, 0, 0, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 1, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 109, 121, 32, 115, 101, 113, 32, 118, 97, 108, 10, 1, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, 0, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 1, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, 0, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 28, 0, 0, 0, 0, 0, 0, 0, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 28, 0, 0, 0, 0, 0, 0, 0, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 76, 50, 31, 157, 149, 237, 111, 2, 33, 66, 172, 211, 126, 164, 232, 144, 211, 18, 0, 131, 10, 23, 94, 160, 7, 232, 81, 80, 1, 141, 165, 28, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 76, 50, 31, 157, 149, 237, 111, 2, 33, 66, 172, 211, 126, 164, 232, 144, 211, 18, 0, 131, 10, 23, 94, 160, 7, 232, 81, 80, 1, 141, 165, 28, 1, 1, 1, 1, 0, 10, 1, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, 0, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 1, 0, 0, 0, 0, 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, 0, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 1, 0, 0, 0, 0, 0, 0, 0]
and the msgpack bytes for the exact same data (from the additional node logging I added)
[130, 173, 111, 112, 101, 114, 97, 116, 105, 111, 110, 115, 95, 112, 107, 129, 167, 69, 100, 50, 53, 53, 49, 57, 196, 32, 76, 50, 31, 157, 149, 237, 111, 2, 33, 66, 172, 211, 126, 164, 232, 144, 211, 18, 0, 131, 10, 23, 94, 160, 7, 232, 81, 80, 1, 141, 165, 28, 164, 100, 97, 116, 97, 129, 166, 80, 117, 98, 108, 105, 99, 132, 165, 97, 99, 116, 111, 114, 188, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 167, 97, 100, 100, 114, 101, 115, 115, 129, 166, 80, 117, 98, 108, 105, 99, 130, 164, 110, 97, 109, 101, 220, 0, 32, 204, 201, 36, 89, 204, 170, 204, 131, 92, 204, 169, 118, 94, 9, 43, 204, 181, 204, 155, 94, 204, 159, 204, 203, 204, 153, 204, 202, 204, 173, 127, 52, 204, 138, 204, 251, 204, 161, 88, 204, 247, 204, 249, 204, 220, 204, 131, 54, 116, 204, 223, 163, 116, 97, 103, 205, 4, 176, 164, 100, 97, 116, 97, 129, 129, 164, 112, 97, 116, 104, 145, 146, 1, 188, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 131, 163, 115, 101, 113, 145, 131, 162, 105, 100, 129, 164, 112, 97, 116, 104, 145, 146, 205, 3, 255, 188, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 163, 100, 111, 116, 130, 165, 97, 99, 116, 111, 114, 188, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 167, 99, 111, 117, 110, 116, 101, 114, 1, 163, 118, 97, 108, 154, 109, 121, 32, 115, 101, 113, 32, 118, 97, 108, 163, 103, 101, 110, 131, 177, 105, 110, 105, 116, 105, 97, 108, 95, 98, 97, 115, 101, 95, 98, 105, 116, 115, 10, 168, 98, 111, 117, 110, 100, 97, 114, 121, 1, 167, 115, 105, 116, 101, 95, 105, 100, 188, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 165, 99, 108, 111, 99, 107, 129, 164, 100, 111, 116, 115, 129, 188, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 1, 166, 112, 111, 108, 105, 99, 121, 131, 163, 115, 101, 113, 145, 131, 162, 105, 100, 129, 164, 112, 97, 116, 104, 145, 146, 1, 188, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 163, 100, 111, 116, 130, 165, 97, 99, 116, 111, 114, 188, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 167, 99, 111, 117, 110, 116, 101, 114, 1, 163, 118, 97, 108, 146, 130, 165, 111, 119, 110, 101, 114, 129, 167, 69, 100, 50, 53, 53, 49, 57, 196, 32, 76, 50, 31, 157, 149, 237, 111, 2, 33, 66, 172, 211, 126, 164, 232, 144, 211, 18, 0, 131, 10, 23, 94, 160, 7, 232, 81, 80, 1, 141, 165, 28, 171, 112, 101, 114, 109, 105, 115, 115, 105, 111, 110, 115, 129, 129, 163, 75, 101, 121, 129, 167, 69, 100, 50, 53, 53, 49, 57, 196, 32, 76, 50, 31, 157, 149, 237, 111, 2, 33, 66, 172, 211, 126, 164, 232, 144, 211, 18, 0, 131, 10, 23, 94, 160, 7, 232, 81, 80, 1, 141, 165, 28, 130, 166, 97, 112, 112, 101, 110, 100, 195, 165, 97, 100, 109, 105, 110, 195, 192, 163, 103, 101, 110, 131, 177, 105, 110, 105, 116, 105, 97, 108, 95, 98, 97, 115, 101, 95, 98, 105, 116, 115, 10, 168, 98, 111, 117, 110, 100, 97, 114, 121, 1, 167, 115, 105, 116, 101, 95, 105, 100, 188, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 165, 99, 108, 111, 99, 107, 129, 164, 100, 111, 116, 115, 129, 188, 80, 117, 98, 108, 105, 99, 75, 101, 121, 58, 58, 69, 100, 50, 53, 53, 49, 57, 40, 52, 99, 51, 50, 49, 102, 46, 46, 41, 1]