-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update orbitdb #2600
base: develop
Are you sure you want to change the base?
Update orbitdb #2600
Conversation
6b0cea5
to
0695992
Compare
"pnpm": "^9.12.1", | ||
"typescript": "^4.9.3" | ||
}, | ||
"volta": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anywhere you see this volta config it can be ignored. It will only have an effect if you have volta installed and it just does the same thing as nvm (but faster).
@@ -2,11 +2,11 @@ version: "3.9" | |||
# Creates local network of peers | |||
|
|||
x-with-tor: &with-tor | |||
BOOTSTRAP_ADDRS: /dns4/ix2oumqrtjaupt53l6cqpk6ct6iaa5guconwgtvgdk2v3i5wjiyehryd.onion/tcp/7788/ws/p2p/QmRbkBkhTt2DbLMF8kAaf1oxpfKQuEfLKFzVCDzQhabwkw | |||
BOOTSTRAP_ADDRS: /dns4/ix2oumqrtjaupt53l6cqpk6ct6iaa5guconwgtvgdk2v3i5wjiyehryd.onion/tcp/7788/ws/p2p/12D3KooWPYjyHnYYwe3kzEESMVbpAUHkQyEQpRHehH8QYtGRntVn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any of these changes to peer IDs that are hardcoded are just for testing and because of the change in peer ID format.
"test-replication-no-tor": "cross-env NODE_OPTIONS=--experimental-vm-modules ts-node -v && cross-env DEBUG='backend:dbSnap*,backend:localTest*' ts-node src/nodeTest/testReplicate.ts --nodesCount 1 --timeThreshold 200 --entriesCount 1000 --no-useTor", | ||
"test-replication-tor": "cross-env NODE_OPTIONS=--experimental-vm-modules cross-env DEBUG='backend:dbSnap*,backend:localTest*' ts-node src/nodeTest/testReplicate.ts --nodesCount 1 --timeThreshold 500 --entriesCount 1000 --useTor", | ||
"test-it": "cross-env NODE_OPTIONS=--experimental-vm-modules DEBUG=ipfs:*,backend:* node_modules/jest/bin/jest.js --runInBand --verbose --testPathIgnorePatterns=\".src/(!?nodeTest*)|(.node_modules*)\" --", | ||
"test-nest": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --experimental-global-customevent\" DEBUG=ipfs:*,backend:* node_modules/jest/bin/jest.js --detectOpenHandles --forceExit ./src/nest/**/*.spec.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The experimental global custom event flag is necessary since we aren't on node 20+ and the new libp2p relies on it.
@@ -0,0 +1,47 @@ | |||
--- packages/backend/node_modules/@helia/block-brokers/node_modules/ipfs-bitswap/dist/src/bitswap.js 2024-10-03 13:15:45 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch just adds extra debug logging for testing purposes.
conn.rtt = (Date.now() - start) / 2; | ||
} | ||
}) | ||
+ // #PATCH: This behavior is pulled from libp2p v2.1.5 (the latest as of writing this) as the original didn't actually honor this flag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a weird one. This bug has been patched but not in a version we can use yet.
@@ -0,0 +1,50 @@ | |||
--- packages/backend/node_modules/@libp2p/kad-dht/dist/src/providers.js 2024-10-03 13:05:48 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More debug logging.
@@ -0,0 +1,15 @@ | |||
--- packages/backend/node_modules/@orbitdb/core/src/oplog/log.js 2024-10-03 11:17:39 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This resolves an issue where entries that are generated by a peer aren't saved locally and when that peer is offline it throws a ton of errors and crashes.
@@ -153,6 +153,11 @@ export class AppModule { | |||
useFactory: (baseDir: string) => path.join(baseDir, 'backendDB'), | |||
inject: [QUIET_DIR], | |||
}, | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added because I was experimenting with using Level for the Libp2p datastore. Right now I'm using a memory store but it might be worth doing a persisted store in the future.
} | ||
|
||
return this.ipfsInstance | ||
} | ||
|
||
private async initializeStores(init?: StoreInit): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more complicated than it should be because we need to ensure that valueEncoding is set to buffer no matter what. I hit so many issues due to level not properly encoding to buffer...
@@ -0,0 +1,76 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wrapper allows us to use the correct valueEncoding on all of our OrbitDB DBs.
@@ -0,0 +1,60 @@ | |||
import { AccessControllerType, IdentitiesType, LogEntry, Events, LogType } from '@orbitdb/core' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wrapper allows us to ensure the correct level value encoding.
@@ -0,0 +1,60 @@ | |||
import { AccessControllerType, KeyValue, IdentitiesType, LogType, LogEntry } from '@orbitdb/core' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wrapper allows us to ensure the correct level value encoding.
throw new Error('IPFS instance does not exist') | ||
} | ||
|
||
await this.blockstore?.db.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little weird but there are issues that can arise from not closing the underlying level DB, apparently.
@@ -102,7 +102,8 @@ export class CertificatesRequestsStore extends EventStoreBase<string> { | |||
const pubKey = keyFromCertificate(parsedCsr) | |||
|
|||
if (filteredCsrsMap.has(pubKey)) { | |||
filteredCsrsMap.delete(pubKey) | |||
this.logger.warn(`Skipping csr due to existing pubkey`, pubKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event store now returns records in descending order rather than ascending order.
|
||
const storage = await ComposedStorage( | ||
await LRUStorage({ size: 1000 }), | ||
await LevelStorage({ path, valueEncoding: 'buffer' }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Level value encoding strikes again.
@@ -16,9 +16,11 @@ export const processInvitationCode = (mainWindow: BrowserWindow, code: string | | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This had nothing to do with the upgrade but I got tired of the errors so I cleaned this up.
backendProcess = fork(backendBundlePath, forkArgvs, { | ||
env: { | ||
NODE_OPTIONS: '--experimental-global-customevent', | ||
DEBUG: 'backend*,quiet*,state-manager*,desktop*,utils*,identity*,common*,libp2p:connection-manager:auto-dial', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The debug flag doesn't seem to be inherited from desktop anymore for some reason.
@@ -1,3 +1,5 @@ | |||
import { jest } from '@jest/globals' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleaned up the test organization and introduced some improvements.
import { createLogger } from './logger' | ||
|
||
const logger = createLogger('utils') | ||
|
||
export const BACKWARD_COMPATIBILITY_BASE_VERSION = '2.0.1' // Pre-latest production version | ||
export const BACKWARD_COMPATIBILITY_BASE_VERSION = '2.3.1' // Pre-latest production version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't actually end up needing this but we'll wanna update this when we know if this will be part of 3.0.0 or 4.0.0.
@@ -0,0 +1,9 @@ | |||
root = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added helia as a package which is NOT ideal but it was the fastest way to get it integrated, from my perspective. We should ultimately update it to be a submodule like lfa but I don't have it in me to do it right now.
@@ -176,7 +176,7 @@ - (void)applicationDidEnterBackground:(UIApplication *)application | |||
{ | |||
[self stopTor]; | |||
|
|||
NSString * message = [NSString stringWithFormat:@""]; | |||
NSString * message = [NSString stringWithFormat:@"app:close"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just to get rid of an error that didn't break anything, it was just annoying.
Pull Request Checklist
(Optional) Mobile checklist
Please ensure you completed the following checks if you did any changes to the mobile package: