Expected Behavior: If I set a registry entry, I should be able to fetch and update it.
Actual behavior: I set a registry entry and it remains with nothing inside it, so every time I fetch it it returns null and if I check it on CID.one it is empty.
Example code:
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import 'package:hive/hive.dart';
import 'package:lib5/identity.dart';
import 'package:lib5/node.dart';
import 'package:lib5/registry.dart';
import 'package:logger/logger.dart';
import 'package:s5/s5.dart';
import 'package:upload_s5_file/logger.dart';
Logger logger = Logger();
String seed = "";
// generates a new seed every time, I know it's abd
Future<S5> initS5(String nodeURL, String dbPath) async {
Hive.init(dbPath);
final S5 s5 = await S5.create(logger: FileLogger(file: "log.txt"));
if (!s5.hasIdentity) {
if (seed == "") {
// seed gets saved to hive btw
seed = s5.generateSeedPhrase();
}
print(seed);
await s5.recoverIdentityFromSeedPhrase(seed);
await s5.registerOnNewStorageService(
nodeURL,
);
}
return s5;
}
Future<void> uploadFile(List<String> argument) async {
if (argument.length == 2) {
seed = argument[1];
} else if (argument.length == 1) {
seed = "";
} else {
exit(1);
}
// FIRST: Upload to S5
S5 s5 = await initS5("https://s5.ninja", "hive");
late File toUpload;
try {
toUpload = File(argument.first);
} catch (e) {
print("Failed to parse file: $e");
exit(1);
}
S5NodeAPIWithIdentity nodewIden = (s5.api as S5NodeAPIWithIdentity);
CID uploadedFile = await nodewIden.uploadBlob(toUpload.readAsBytesSync());
print(uploadedFile.toBase58());
// SECOND: Generate thumbhash
... Truncated ...
// THIRD: Write that CID to data key
await updateResolver(s5, uploadedFile, null);
exit(0);
}
Future<CID> updateResolver(S5 s5, CID staticCID, String? dataKey) async {
dataKey ??= 'upload_s5';
print("Hashing seed $seed");
// Then we get get an set the resolver
final resolverSeed = s5.api.crypto.hashBlake3Sync(
Uint8List.fromList(
validatePhrase(seed, crypto: s5.api.crypto) +
utf8.encode(dataKey), // this identifies the backup
),
);
final s5User = await s5.api.crypto.newKeyPairEd25519(seed: resolverSeed);
SignedRegistryEntry? existing;
int revision = 0;
try {
final res = await s5.api.registryGet(s5User.publicKey);
existing = res;
revision = existing!.revision + 1;
} catch (e) {
existing = null;
print(e);
revision = 1;
}
final sre = await signRegistryEntry(
kp: s5User,
data: staticCID.toRegistryEntry(),
revision: (existing?.revision ?? -1) + 1,
crypto: s5.api.crypto,
);
await s5.api.registrySet(sre);
final resolverCID = CID(
0x25,
Multihash(
Uint8List.fromList(
s5User.publicKey,
),
));
print("Revision: $revision");
print("Resolver: ${resolverCID.toBase58()}");
return resolverCID;
}
Logs
Example of failing to fetch registry entry. First two are with s5 logging disabled, and the third is with logging enabled.
covalent@fw13-fedora39:~/devStuff/upload_s5_file$ dart run bin/upload_s5_file.dart ~/Downloads/mountain.png
change fever cow pepper total value nose fade height warm hip code title help joke
z2H7AJ1Pt8FdqG5UNzt4ffEhMY28c2z3K13TGf9fGcCRRwN7kS5B
Hashing seed change fever cow pepper total value nose fade height warm hip code title help joke
Null check operator used on a null value
Revision: 1
Resolver: zrjNeaRUHaLpfjtSPS9LhSKZ8vjbCtEgj3Djy6pUyqiBABT
covalent@fw13-fedora39:~/devStuff/upload_s5_file$ dart run bin/upload_s5_file.dart ~/Downloads/tofy.jpg "change fever cow pepper total value nose fade height warm hip code title help joke"
z2H7A5tzJVxrL4xJh7ZddhKLZaXtP4c8fJ73UqfDWFr8LzyNeDip
Hashing seed change fever cow pepper total value nose fade height warm hip code title help joke
Null check operator used on a null value
Revision: 1
Resolver: zrjNeaRUHaLpfjtSPS9LhSKZ8vjbCtEgj3Djy6pUyqiBABT
covalent@fw13-fedora39:~/devStuff/upload_s5_file$ dart run bin/upload_s5_file.dart ~/Downloads/tofy.jpg "change fever cow pepper total value nose fade height warm hip code title help joke"
NODE ID: z2DQRJMCejSz9h7xSkse3XyeztvyYJpSakbVEFPnJpGsKtY
[connect] wss://z2Das8aEF7oNoxkcrfvzerZ1iBPWfm6D7gy3hVE4ALGSpVB@node.sfive.net/s5/p2p
[connect] wss://z2DdbxV4xyoqWck5pXXJdVzRnwQC6Gbv6o7xDvyZvzKUfuj@s5.vup.dev/s5/p2p
[connect] wss://z2DWuWNZcdSyZLpXFK2uCU3haaWMXrDAgxzv17sDEMHstZb@s5.garden/s5/p2p
HandshakeException: Handshake error in client (OS Error:
CERTIFICATE_VERIFY_FAILED: certificate has expired(handshake.cc:393))
[+] z2Das8aEF7oNoxkcrfvzerZ1iBPWfm6D7gy3hVE4ALGSpVB (wss://node.sfive.net/s5/p2p)
initStorageServices
[registry] get (cached) 7Q06O2MPhMZA_rf716iFn4NhQfhLMyGtZB1W1a4JUYlo
WebSocketException: Connection to 'https://s5.vup.dev:0/s5/p2p#' was not upgraded to websocket
[try] https://f5o5.fra2.idrivee2-56.com/s5-public/1/H9W-j56_UNM1mO6sQORsvKN3fu2ws9Myf0aUxgh6NsOs?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=85HZKc2LAsWxgFucKXHo%2F20240813%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240813T171421Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=69c09a386c526d247fba023295d6bb73bc9afb3d77dc5fcdd803d6e755bdab9a
[registry] set 7Q06O2MPhMZA_rf716iFn4NhQfhLMyGtZB1W1a4JUYlo 0 (z2Das8aEF7oNoxkcrfvzerZ1iBPWfm6D7gy3hVE4ALGSpVB)
[connect] wss://z2DWuWNZcdSyZLpXFK2uCU3haaWMXrDAgxzv17sDEMHstZb@s5.garden/s5/p2p
[account] setup s5.ninja:d7IwGzJr-4XfIxp2
_uploadRawFileInternal s5.ninja:d7IwGzJr-4XfIxp2
HandshakeException: Handshake error in client (OS Error:
CERTIFICATE_VERIFY_FAILED: certificate has expired(handshake.cc:393))
[connect] wss://z2DdbxV4xyoqWck5pXXJdVzRnwQC6Gbv6o7xDvyZvzKUfuj@s5.vup.dev/s5/p2p
[connect] wss://z2DWuPbL5pweybXnEB618pMnV58ECj2VPDNfVGm3tFqBvjF@s5.ninja/s5/p2p
z2H7A5tzJVxrL4xJh7ZddhKLZaXtP4c8fJ73UqfDWFr8LzyNeDip
Hashing seed change fever cow pepper total value nose fade height warm hip code title help joke
[registry] get (clean) 7ap1QB7kXYj6X69uyT2iZt65S7EpL4LwS5lymkk1X75C
WebSocketException: Connection to 'https://s5.vup.dev:0/s5/p2p#' was not upgraded to websocket
[+] z2DWuPbL5pweybXnEB618pMnV58ECj2VPDNfVGm3tFqBvjF (wss://s5.ninja/s5/p2p)
[connect] wss://z2DWuWNZcdSyZLpXFK2uCU3haaWMXrDAgxzv17sDEMHstZb@s5.garden/s5/p2p
HandshakeException: Handshake error in client (OS Error:
CERTIFICATE_VERIFY_FAILED: certificate has expired(handshake.cc:393))
[connect] wss://z2DdbxV4xyoqWck5pXXJdVzRnwQC6Gbv6o7xDvyZvzKUfuj@s5.vup.dev/s5/p2p
Null check operator used on a null value
[registry] set 7ap1QB7kXYj6X69uyT2iZt65S7EpL4LwS5lymkk1X75C 0 (null)
[registry] broadcastEntry
Revision: 1
Resolver: zrjNeaRUHaLpfjtSPS9LhSKZ8vjbCtEgj3Djy6pUyqiBABT
Note: This is tested on s5.ninja but the exact same thing happens if I try on s5.jptr.tech.
Expected Behavior: If I set a registry entry, I should be able to fetch and update it.
Actual behavior: I set a registry entry and it remains with nothing inside it, so every time I fetch it it returns null and if I check it on CID.one it is empty.
Example code:
Logs
Example of failing to fetch registry entry. First two are with s5 logging disabled, and the third is with logging enabled.
Note: This is tested on
s5.ninjabut the exact same thing happens if I try ons5.jptr.tech.