orbitdb / orbitdb

Peer-to-Peer Databases for the Decentralized Web
MIT License
8.31k stars 569 forks source link

Upgrade leveldown to avoid problems on M1, mobile platforms #1019

Closed holmesworcester closed 1 year ago

holmesworcester commented 2 years ago

Because OrbitDB uses leveldown 5.x (leveldown is now on 6.x) a patch is required to build OrbitDB on different hardware platforms e.g. mobile.

See: https://github.com/TryQuiet/quiet/issues/844#issuecomment-1227379574

OrbitDB should upgrade to the latest leveldown.

(I think leveldown is used in orbit-db-keystore and orbit-db-storage-adapter. If I should create issues in the respective repositories please let me know.)

holmesworcester commented 1 year ago

Update: this also causes problems and requires an annoying workaround for building on M1 Macs, which are supported in later versions of leveldown.

The workaround is:

cd packages/backend/node_modules/leveldown 
wget https://github.com/Level/leveldown/releases/download/v6.1.0/darwin-x64+arm64.tar.gz 
tar -xf darwin-x64+arm64.tar.gz 
mv darwin-x64+arm64/node.napi.node prebuilds/darwin-arm64 
file prebuilds/darwin-arm64/node.napi.node

And this should return:

file prebuilds/darwin-arm64/node.napi.node: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit bundle x86_64Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64Mach-O 64-bit bundle arm64] prebuilds/darwin-arm64/node.napi.node (for architecture x86_64): Mach-O 64-bit bundle x86_64 prebuilds/darwin-arm64/node.napi.node (for architecture arm64): Mach-O 64-bit bundle arm64
haadcode commented 1 year ago

LevelDB was upgraded to 8.0.0 in #1044. You can try it by installing orbit-db as the "next" version, eg. npm i orbit-db@next. There will be a new semver release in the coming days.

Does using that version solve the problem?

haydenyoung commented 1 year ago

Closing as no further information from OP. Feel free to re-open if problems persist.