bitpay / bitcore

A full stack for bitcoin and blockchain-based applications
https://bitcore.io/
MIT License
4.87k stars 2.1k forks source link

scrypt incompatible with node 12 - Compilation error on 8.6.0 & master #2354

Open jamespharvey20 opened 5 years ago

jamespharvey20 commented 5 years ago

It looks like uses of plain scrypt need to be dropped for one of its still maintained alternatives.

This log is copied from master, but the same error occurs on 8.6.0 (ebb58c5ed)

This is immediately from a fresh git clone, and running npm install in the repo directory.

...
> scrypt@6.0.3 install /home/bitcore/bitcore.git/packages/bitcore-node/node_modules/scrypt
> node-gyp rebuild
...
lerna ERR! npm install stderr:
...
../../nan/nan_implementation_12_inl.h: In static member function ‘static Nan::imp::FactoryBase<v8::Function>::return_t Nan::imp::Factory<v8::Function>::New(Nan::FunctionCallback, v8::Local<v8::Value>)’:
../../nan/nan_implementation_12_inl.h:103:42: error: cannot convert ‘v8::Isolate*’ to ‘v8::Local<v8::Context>’
  103 |   return scope.Escape(v8::Function::New( isolate
...
../../nan/nan_implementation_12_inl.h: In static member function ‘static Nan::imp::FactoryBase<v8::StringObject>::return_t Nan::imp::Factory<v8::StringObject>::New(v8::Local<v8::String>)’:
../../nan/nan_implementation_12_inl.h:337:37: error: no matching function for call to ‘v8::StringObject::New(v8::Local<v8::String>&)’
  337 |   return v8::StringObject::New(value).As<v8::StringObject>();
...
/home/bitcore/.cache/node-gyp/12.9.1/include/node/v8.h:5394:23: note:   candidate expects 2 arguments, 1 provided
In file included from ../../nan/nan_new.h:189,
                 from ../../nan/nan.h:203,
                 from ../src/node-boilerplate/scrypt_common.cc:28:
../../nan/nan_implementation_12_inl.h:337:58: error: expected primary-expression before ‘>’ token
  337 |   return v8::StringObject::New(value).As<v8::StringObject>();
      |                                                          ^
../../nan/nan_implementation_12_inl.h:337:60: error: expected primary-expression before ‘)’ token
  337 |   return v8::StringObject::New(value).As<v8::StringObject>();
      |                                                            ^
In file included from ../src/node-boilerplate/scrypt_common.cc:28:
../../nan/nan.h: In constructor ‘Nan::Utf8String::Utf8String(v8::Local<v8::Value>)’:
../../nan/nan.h:1034:53: error: no matching function for call to ‘v8::Value::ToString()’
 1034 |       v8::Local<v8::String> string = from->ToString();
...(a few more errors)...
make: *** [scrypt.target.mk:125: Release/obj.target/scrypt/src/node-boilerplate/scrypt_common.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/node-gyp/lib/build.js:190:23)
gyp ERR! stack     at ChildProcess.emit (events.js:209:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 5.2.9-arch1-1-ARCH
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/bitcore/bitcore.git/packages/bitcore-node/node_modules/scrypt
gyp ERR! node -v v12.9.1
gyp ERR! node-gyp -v v5.0.2
gyp ERR! not ok
...
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/bitcore/.npm/_logs/2019-08-28T11_20_06_525Z-debug.log

The full compilation output can be viewed here: http://ix.io/1TGC

The 3 debug.log files it references can be viewed here: http://ix.io/1TGF http://ix.io/1TGG http://ix.io/1TGD

I was previously running v8.3.4 (49166f0d1). Trying to recompile this previously working version now fails with the same error, so I knew this must be an incompatibility with a new version of something.

Arch upgraded to nodejs 12 some time in the last 2 months, and is on 12.9.1.

I found scrypt 6.0.3 does not support nodejs 12, and worse yet, is no longer maintained so will never be updated. https://github.com/barrysteyn/node-scrypt/issues/193 The recommendation there is to either use the native node.js crypto module, or scrypt-kdf, depending on what functionality is used.

I also found scrypt-js saying their package is compatible, and switching from scrypt to it or possibly the ethers library could be a fix. https://github.com/ricmoo/scrypt-js/issues/18

A lot of discussion about how to fix this for web3.js happened at https://github.com/ethereum/web3.js/issues/2913

Downgrading my system to nodejs 11.15.0 is a temporary workaround, but isn't viable as other packages require nodejs 12, and nodejs 11 likely soon won't be usable on Arch, at least without recompiling it from source.

h4x3rotab commented 5 years ago

Thanks for the walkaround! The deprecated deps are really annoying.

zidagar commented 4 years ago

please, upgrade abi-decoder to 2.1.0, this will fix the problem (but remains node 12 build problem)