Zilliqa / scilla

Scilla - A Smart Contract Intermediate Level Language
https://scilla-lang.org
GNU General Public License v3.0
240 stars 78 forks source link

Check for openssl v. 1.1 during build #1165

Open jjcnn opened 2 years ago

jjcnn commented 2 years ago

Versions of openssl after 1.1 are not supported by the crypto submodules, and build errors due to later versions of openssl are difficult to identify as being caused by this.

The version requirement is documented in INSTALL.md, but we should introduce an actual check somewhere (@anton-trunov suggests here: https://github.com/ocaml/opam-repository/blob/master/packages/conf-openssl/conf-openssl.1/opam) that the correct version is being used.

Depending on how the issue is resolved we should also document this in the troubleshooting part of https://github.com/Zilliqa/scilla/wiki#installation-troubleshooting.

Examples of build errors you may encounter:

In file included from /home/cnn/Projects/scilla/deps/schnorr/src/src/libSchnorr/src/SchnorrInternal.h:36,
                 from /home/cnn/Projects/scilla/deps/schnorr/src/src/libSchnorr/src/Schnorr_Signature.cpp:24:
/home/cnn/Projects/scilla/deps/schnorr/src/src/libSchnorr/src/Sha2.h: In member function ‘void SHA2<SIZE>::Update(const bytes&)’:
/home/cnn/Projects/scilla/deps/schnorr/src/src/libSchnorr/src/Sha2.h:59:18: error: ‘int SHA256_Update(SHA256_CTX*, const void*, size_t)’ is deprecated: Since OpenSSL 3.0 [-Werror=deprecated-declarations]
   59 |     SHA256_Update(&m_context, input.data(), input.size());
      |     ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/cnn/Projects/scilla/deps/schnorr/src/src/libSchnorr/src/Sha2.h:21,
                 from /home/cnn/Projects/scilla/deps/schnorr/src/src/libSchnorr/src/SchnorrInternal.h:36,
                 from /home/cnn/Projects/scilla/deps/schnorr/src/src/libSchnorr/src/Schnorr_Signature.cpp:24:
/usr/include/openssl/sha.h:74:27: note: declared here
   74 | OSSL_DEPRECATEDIN_3_0 int SHA256_Update(SHA256_CTX *c,
      |                           ^~~~~~~~~~~~~
[  6%] Building C object src/libSchnorr/src/CMakeFiles/Schnorr.dir/generate_dsa_nonce.c.o
/home/cnn/Projects/scilla/deps/schnorr/src/src/libSchnorr/src/generate_dsa_nonce.c: In function ‘BN_generate_dsa_nonce’:
/home/cnn/Projects/scilla/deps/schnorr/src/src/libSchnorr/src/generate_dsa_nonce.c:89:23: error: invalid use of incomplete typedef ‘BIGNUM’ {aka ‘const struct bignum_st’}
   89 |     todo = sizeof(priv->d[0]) * priv->top;
      |                       ^~
jjcnn commented 2 years ago

Before introducing this check we should investigate whether we can upgrade to the most recent version of openssl. I think openssl is only used in the crypto submodules, which may complicate matters, but it would be simpler if we can make it work with off-the-shelf openssl.