gakonst / sgx-revm

PoC of Revm execution in SGX
80 stars 9 forks source link

Build fail: failed to run custom build command for `mbedtls-sys-auto v2.28.3` #3

Open pbeza opened 1 year ago

pbeza commented 1 year ago

I followed the build process described in the README but the build fails with the following error:

$ cargo run --release --target x86_64-fortanix-unknown-sgx
   Compiling autocfg v1.1.0
   Compiling libc v0.2.147
   Compiling version_check v0.9.4
   Compiling proc-macro2 v1.0.66
   Compiling unicode-ident v1.0.11
   Compiling typenum v1.16.0
   Compiling zeroize v1.6.0
   Compiling cfg-if v1.0.0
   Compiling subtle v2.5.0
   Compiling syn v1.0.109
   Compiling const-oid v0.9.5
   Compiling serde v1.0.188
   Compiling generic-array v0.14.7
   Compiling num-traits v0.2.16
   Compiling glob v0.3.1
   Compiling crunchy v0.2.2
   Compiling num-integer v0.1.45
   Compiling prettyplease v0.2.12
   Compiling quote v1.0.33
   Compiling rand_core v0.6.4
   Compiling regex-syntax v0.7.5
   Compiling clang-sys v1.6.1
   Compiling syn v2.0.29
   Compiling cc v1.0.83
   Compiling minimal-lexical v0.2.1
   Compiling byteorder v1.4.3
   Compiling rustc-hex v2.1.0
   Compiling memchr v2.6.2
   Compiling libloading v0.7.4
   Compiling static_assertions v1.1.0
   Compiling bindgen v0.65.1
   Compiling block-buffer v0.10.4
   Compiling crypto-common v0.1.6
   Compiling digest v0.10.7
   Compiling nom v7.1.3
   Compiling either v1.9.0
   Compiling which v4.4.0
   Compiling proc-macro-error-attr v1.0.4
   Compiling lazycell v1.3.0
   Compiling shlex v1.1.0
   Compiling hex v0.4.3
   Compiling rustc-hash v1.1.0
   Compiling log v0.4.20
   Compiling lazy_static v1.4.0
   Compiling bitflags v1.3.2
   Compiling peeking_take_while v0.1.2
   Compiling crossbeam-utils v0.8.16
   Compiling regex-automata v0.3.7
   Compiling uint v0.9.5
   Compiling fixed-hash v0.8.0
   Compiling cmake v0.1.50
   Compiling memoffset v0.9.0
   Compiling proc-macro-error v1.0.4
   Compiling ahash v0.8.3
   Compiling once_cell v1.18.0
   Compiling radium v0.7.0
   Compiling cexpr v0.6.0
   Compiling primitive-types v0.12.1
   Compiling regex v1.9.4
   Compiling ff v0.13.0
   Compiling crossbeam-epoch v0.9.15
   Compiling num-bigint v0.4.4
   Compiling der v0.7.8
   Compiling convert_case v0.4.0
   Compiling tap v1.0.1
   Compiling cpufeatures v0.2.9
   Compiling ruint-macro v1.1.0
   Compiling base16ct v0.2.0
   Compiling wyz v0.5.1
   Compiling sec1 v0.7.3
   Compiling group v0.13.0
   Compiling serde_derive v1.0.188
   Compiling secp256k1-sys v0.8.1
   Compiling hmac v0.12.1
   Compiling crypto-bigint v0.5.2
   Compiling num-rational v0.4.1
   Compiling derive_more v0.99.17
   Compiling num-iter v0.1.43
   Compiling keccak v0.1.4
   Compiling funty v2.0.0
   Compiling allocator-api2 v0.2.16
   Compiling scopeguard v1.2.0
   Compiling hex-literal v0.4.1
   Compiling hashbrown v0.14.0
   Compiling bitvec v1.0.1
   Compiling elliptic-curve v0.13.5
   Compiling sha3 v0.10.8
   Compiling auto_impl v1.1.0
   Compiling rfc6979 v0.4.0
   Compiling enumn v0.1.11
   Compiling mbedtls-platform-support v0.1.0
   Compiling signature v2.1.0
   Compiling num-bigint v0.2.6
   Compiling spin v0.5.2
   Compiling bitflags v2.4.0
   Compiling rayon-core v1.11.0
   Compiling ecdsa v0.16.8
   Compiling crossbeam-deque v0.8.3
   Compiling sha2 v0.10.7
   Compiling crossbeam-channel v0.5.8
   Compiling time v0.1.45
   Compiling mbedtls-sys-auto v2.28.3
   Compiling num_cpus v1.16.0
   Compiling rs-libc v0.1.0
   Compiling num-complex v0.4.4
   Compiling rand v0.8.5
   Compiling tiny-keccak v2.0.2
   Compiling num v0.4.1
   Compiling chrono v0.4.28
   Compiling substrate-bn v0.6.0
   Compiling bytes v1.4.0
   Compiling k256 v0.13.1
   Compiling rlp v0.5.2
   Compiling ruint v1.10.1
   Compiling secp256k1 v0.27.0
   Compiling revm-primitives v1.1.2 (https://github.com/bluealloy/revm#6bd05c90)
   Compiling mbedtls v0.7.4
   Compiling ripemd v0.1.3
   Compiling itoa v1.0.9
   Compiling bit-vec v0.5.1
   Compiling eyre v0.6.8
   Compiling serde_json v1.0.105
   Compiling yasna v0.2.2
   Compiling rayon v1.7.0
   Compiling revm-interpreter v1.1.2 (https://github.com/bluealloy/revm#6bd05c90)
   Compiling revm-precompile v2.0.3 (https://github.com/bluealloy/revm#6bd05c90)
   Compiling const-hex v1.8.0
   Compiling indenter v0.3.3
   Compiling ryu v1.0.15
   Compiling revm v3.3.0 (https://github.com/bluealloy/revm#6bd05c90)
   Compiling alloy-primitives v0.3.3
error: failed to run custom build command for `mbedtls-sys-auto v2.28.3`

Caused by:
  process didn't exit successfully: `/home/ubuntu/sgx-revm/target/release/build/mbedtls-sys-auto-b684d9dfea9a0994/build-script-build` (exit status: 101)
  --- stdout
  cargo:rustc-cfg=threading_component="custom"
  cargo:rustc-cfg=c_compiler_component="freestanding"
  cargo:platform-components=threading_component=custom,c_compiler_component=freestanding
  cargo:rerun-if-env-changed=RUST_MBEDTLS_SYS_SOURCE
  cargo:rerun-if-changed=vendor/CMakeLists.txt
  cargo:rerun-if-changed=vendor/include/mbedtls/config_psa.h
  cargo:rerun-if-changed=vendor/include/mbedtls/platform_time.h
  cargo:rerun-if-changed=vendor/include/mbedtls/platform_util.h
  cargo:rerun-if-changed=vendor/include/mbedtls/bignum.h
  cargo:rerun-if-changed=vendor/include/mbedtls/md.h
  cargo:rerun-if-changed=vendor/include/mbedtls/threading.h
  cargo:rerun-if-changed=vendor/include/mbedtls/ecp.h
  cargo:rerun-if-changed=vendor/include/mbedtls/rsa.h
  cargo:rerun-if-changed=vendor/include/mbedtls/ecdsa.h
  cargo:rerun-if-changed=vendor/include/mbedtls/asn1.h
  cargo:rerun-if-changed=vendor/include/mbedtls/pk.h
  cargo:rerun-if-changed=vendor/include/mbedtls/x509.h
  cargo:rerun-if-changed=vendor/include/mbedtls/cipher.h
  cargo:rerun-if-changed=vendor/include/mbedtls/x509_crl.h
  cargo:rerun-if-changed=vendor/include/mbedtls/aes.h
  cargo:rerun-if-changed=vendor/include/mbedtls/ssl_ciphersuites.h
  cargo:rerun-if-changed=vendor/include/mbedtls/x509_crt.h
  cargo:rerun-if-changed=vendor/include/mbedtls/dhm.h
  cargo:rerun-if-changed=vendor/include/mbedtls/ecdh.h
  cargo:rerun-if-changed=vendor/include/mbedtls/oid.h
  cargo:rerun-if-changed=vendor/include/mbedtls/ctr_drbg.h
  cargo:rerun-if-changed=vendor/include/mbedtls/hmac_drbg.h
  cargo:rerun-if-changed=vendor/include/mbedtls/ssl.h
  cargo:rerun-if-changed=vendor/include/mbedtls/md5.h
  cargo:rerun-if-changed=vendor/include/mbedtls/sha1.h
  cargo:rerun-if-changed=vendor/include/mbedtls/sha256.h
  cargo:rerun-if-changed=vendor/include/mbedtls/sha512.h
  cargo:rerun-if-changed=vendor/include/mbedtls/ecjpake.h
  cargo:rerun-if-changed=vendor/include/mbedtls/psa_util.h
  cargo:rerun-if-changed=vendor/include/mbedtls/net_sockets.h
  cargo:rerun-if-changed=vendor/include/mbedtls/havege.h
  cargo:rerun-if-changed=vendor/include/mbedtls/poly1305.h
  cargo:rerun-if-changed=vendor/include/mbedtls/chacha20.h
  cargo:rerun-if-changed=vendor/include/mbedtls/xtea.h
  cargo:rerun-if-changed=vendor/include/mbedtls/x509_csr.h
  cargo:rerun-if-changed=vendor/include/mbedtls/version.h
  cargo:rerun-if-changed=vendor/include/mbedtls/timing.h
  cargo:rerun-if-changed=vendor/include/mbedtls/ssl_ticket.h
  cargo:rerun-if-changed=vendor/include/mbedtls/ssl_internal.h
  cargo:rerun-if-changed=vendor/include/mbedtls/ssl_cookie.h
  cargo:rerun-if-changed=vendor/include/mbedtls/ssl_cache.h
  cargo:rerun-if-changed=vendor/include/mbedtls/rsa_internal.h
  cargo:rerun-if-changed=vendor/include/mbedtls/ripemd160.h
  cargo:rerun-if-changed=vendor/include/mbedtls/platform.h
  cargo:rerun-if-changed=vendor/include/mbedtls/pkcs5.h
  cargo:rerun-if-changed=vendor/include/mbedtls/pkcs12.h
  cargo:rerun-if-changed=vendor/include/mbedtls/pk_internal.h
  cargo:rerun-if-changed=vendor/include/mbedtls/pem.h
  cargo:rerun-if-changed=vendor/include/mbedtls/padlock.h
  cargo:rerun-if-changed=vendor/include/mbedtls/nist_kw.h
  cargo:rerun-if-changed=vendor/include/mbedtls/net.h
  cargo:rerun-if-changed=vendor/include/mbedtls/memory_buffer_alloc.h
  cargo:rerun-if-changed=vendor/include/mbedtls/md_internal.h
  cargo:rerun-if-changed=vendor/include/mbedtls/md4.h
  cargo:rerun-if-changed=vendor/include/mbedtls/md2.h
  cargo:rerun-if-changed=vendor/include/mbedtls/hkdf.h
  cargo:rerun-if-changed=vendor/include/mbedtls/gcm.h
  cargo:rerun-if-changed=vendor/include/mbedtls/error.h
  cargo:rerun-if-changed=vendor/include/mbedtls/entropy_poll.h
  cargo:rerun-if-changed=vendor/include/mbedtls/entropy.h
  cargo:rerun-if-changed=vendor/include/mbedtls/ecp_internal.h
  cargo:rerun-if-changed=vendor/include/mbedtls/des.h
  cargo:rerun-if-changed=vendor/include/mbedtls/debug.h
  cargo:rerun-if-changed=vendor/include/mbedtls/constant_time.h
  cargo:rerun-if-changed=vendor/include/mbedtls/cmac.h
  cargo:rerun-if-changed=vendor/include/mbedtls/cipher_internal.h
  cargo:rerun-if-changed=vendor/include/mbedtls/chachapoly.h
  cargo:rerun-if-changed=vendor/include/mbedtls/ccm.h
  cargo:rerun-if-changed=vendor/include/mbedtls/camellia.h
  cargo:rerun-if-changed=vendor/include/mbedtls/bn_mul.h
  cargo:rerun-if-changed=vendor/include/mbedtls/blowfish.h
  cargo:rerun-if-changed=vendor/include/mbedtls/base64.h
  cargo:rerun-if-changed=vendor/include/mbedtls/asn1write.h
  cargo:rerun-if-changed=vendor/include/mbedtls/aria.h
  cargo:rerun-if-changed=vendor/include/mbedtls/arc4.h
  cargo:rerun-if-changed=vendor/include/mbedtls/aesni.h
  cargo:rerun-if-changed=vendor/library/platform_util.c
  cargo:rerun-if-changed=vendor/library/ctr_drbg.c
  cargo:rerun-if-changed=vendor/library/ssl_cookie.c
  cargo:rerun-if-changed=vendor/library/ssl_srv.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_mac.h
  cargo:rerun-if-changed=vendor/library/timing.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_slot_management.h
  cargo:rerun-if-changed=vendor/library/base64.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_cipher.c
  cargo:rerun-if-changed=vendor/library/x509_create.c
  cargo:rerun-if-changed=vendor/library/error.c
  cargo:rerun-if-changed=vendor/library/rsa.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_client.c
  cargo:rerun-if-changed=vendor/library/cipher_wrap.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_hash.c
  cargo:rerun-if-changed=vendor/library/xtea.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_rsa.c
  cargo:rerun-if-changed=vendor/library/pk.c
  cargo:rerun-if-changed=vendor/library/ssl_msg.c
  cargo:rerun-if-changed=vendor/library/ripemd160.c
  cargo:rerun-if-changed=vendor/library/aes.c
  cargo:rerun-if-changed=vendor/library/mps_error.h
  cargo:rerun-if-changed=vendor/library/ssl_ciphersuites.c
  cargo:rerun-if-changed=vendor/library/debug.c
  cargo:rerun-if-changed=vendor/library/net_sockets.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_se.h
  cargo:rerun-if-changed=vendor/library/Makefile
  cargo:rerun-if-changed=vendor/library/arc4.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_aead.c
  cargo:rerun-if-changed=vendor/library/x509write_crt.c
  cargo:rerun-if-changed=vendor/library/x509.c
  cargo:rerun-if-changed=vendor/library/pem.c
  cargo:rerun-if-changed=vendor/library/bignum.c
  cargo:rerun-if-changed=vendor/library/mps_reader.h
  cargo:rerun-if-changed=vendor/library/sha256.c
  cargo:rerun-if-changed=vendor/library/aesni.c
  cargo:rerun-if-changed=vendor/library/ecdh.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_cipher.h
  cargo:rerun-if-changed=vendor/library/md.c
  cargo:rerun-if-changed=vendor/library/md4.c
  cargo:rerun-if-changed=vendor/library/pkcs5.c
  cargo:rerun-if-changed=vendor/library/oid.c
  cargo:rerun-if-changed=vendor/library/mps_common.h
  cargo:rerun-if-changed=vendor/library/ecjpake.c
  cargo:rerun-if-changed=vendor/library/ccm.c
  cargo:rerun-if-changed=vendor/library/constant_time_internal.h
  cargo:rerun-if-changed=vendor/library/blowfish.c
  cargo:rerun-if-changed=vendor/library/x509write_csr.c
  cargo:rerun-if-changed=vendor/library/hkdf.c
  cargo:rerun-if-changed=vendor/library/hmac_drbg.c
  cargo:rerun-if-changed=vendor/library/des.c
  cargo:rerun-if-changed=vendor/library/mps_trace.h
  cargo:rerun-if-changed=vendor/library/asn1write.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_its.h
  cargo:rerun-if-changed=vendor/library/certs.c
  cargo:rerun-if-changed=vendor/library/constant_time_invasive.h
  cargo:rerun-if-changed=vendor/library/poly1305.c
  cargo:rerun-if-changed=vendor/library/memory_buffer_alloc.c
  cargo:rerun-if-changed=vendor/library/chachapoly.c
  cargo:rerun-if-changed=vendor/library/entropy.c
  cargo:rerun-if-changed=vendor/library/mps_trace.c
  cargo:rerun-if-changed=vendor/library/md5.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_invasive.h
  cargo:rerun-if-changed=vendor/library/common.h
  cargo:rerun-if-changed=vendor/library/version.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_ecp.h
  cargo:rerun-if-changed=vendor/library/psa_crypto_slot_management.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_storage.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_core.h
  cargo:rerun-if-changed=vendor/library/ssl_cache.c
  cargo:rerun-if-changed=vendor/library/pkwrite.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_ecp.c
  cargo:rerun-if-changed=vendor/library/entropy_poll.c
  cargo:rerun-if-changed=vendor/library/aria.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_driver_wrappers.h
  cargo:rerun-if-changed=vendor/library/.gitignore
  cargo:rerun-if-changed=vendor/library/x509_crt.c
  cargo:rerun-if-changed=vendor/library/ssl_cli.c
  cargo:rerun-if-changed=vendor/library/nist_kw.c
  cargo:rerun-if-changed=vendor/library/md2.c
  cargo:rerun-if-changed=vendor/library/threading.c
  cargo:rerun-if-changed=vendor/library/asn1parse.c
  cargo:rerun-if-changed=vendor/library/CMakeLists.txt
  cargo:rerun-if-changed=vendor/library/psa_its_file.c
  cargo:rerun-if-changed=vendor/library/sha512.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_rsa.h
  cargo:rerun-if-changed=vendor/library/havege.c
  cargo:rerun-if-changed=vendor/library/rsa_internal.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_driver_wrappers.c
  cargo:rerun-if-changed=vendor/library/ssl_tls13_keys.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_mac.c
  cargo:rerun-if-changed=vendor/library/pkcs11.c
  cargo:rerun-if-changed=vendor/library/psa_crypto.c
  cargo:rerun-if-changed=vendor/library/pk_wrap.c
  cargo:rerun-if-changed=vendor/library/ecp_curves.c
  cargo:rerun-if-changed=vendor/library/pkparse.c
  cargo:rerun-if-changed=vendor/library/version_features.c
  cargo:rerun-if-changed=vendor/library/gcm.c
  cargo:rerun-if-changed=vendor/library/dhm.c
  cargo:rerun-if-changed=vendor/library/x509_csr.c
  cargo:rerun-if-changed=vendor/library/platform.c
  cargo:rerun-if-changed=vendor/library/chacha20.c
  cargo:rerun-if-changed=vendor/library/constant_time.c
  cargo:rerun-if-changed=vendor/library/ecp.c
  cargo:rerun-if-changed=vendor/library/ssl_tls.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_se.c
  cargo:rerun-if-changed=vendor/library/ecdsa.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_random_impl.h
  cargo:rerun-if-changed=vendor/library/pkcs12.c
  cargo:rerun-if-changed=vendor/library/x509_crl.c
  cargo:rerun-if-changed=vendor/library/sha1.c
  cargo:rerun-if-changed=vendor/library/padlock.c
  cargo:rerun-if-changed=vendor/library/check_crypto_config.h
  cargo:rerun-if-changed=vendor/library/cmac.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_aead.h
  cargo:rerun-if-changed=vendor/library/ecp_invasive.h
  cargo:rerun-if-changed=vendor/library/ssl_tls13_keys.h
  cargo:rerun-if-changed=vendor/library/cipher.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_hash.h
  cargo:rerun-if-changed=vendor/library/mps_reader.c
  cargo:rerun-if-changed=vendor/library/ssl_ticket.c
  cargo:rerun-if-changed=vendor/library/psa_crypto_storage.h
  cargo:rerun-if-changed=vendor/library/camellia.c
  OPT_LEVEL = Some("3")
  TARGET = Some("x86_64-fortanix-unknown-sgx")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_x86_64-fortanix-unknown-sgx
  CC_x86_64-fortanix-unknown-sgx = None
  cargo:rerun-if-env-changed=CC_x86_64_fortanix_unknown_sgx
  CC_x86_64_fortanix_unknown_sgx = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  RUSTC_LINKER = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,rdrand,rdseed,sse,sse2")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-fortanix-unknown-sgx
  CFLAGS_x86_64-fortanix-unknown-sgx = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_fortanix_unknown_sgx
  CFLAGS_x86_64_fortanix_unknown_sgx = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  CMAKE_TOOLCHAIN_FILE_x86_64-fortanix-unknown-sgx = None
  CMAKE_TOOLCHAIN_FILE_x86_64_fortanix_unknown_sgx = None
  TARGET_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_x86_64-fortanix-unknown-sgx = None
  CMAKE_GENERATOR_x86_64_fortanix_unknown_sgx = None
  TARGET_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_x86_64-fortanix-unknown-sgx = None
  CMAKE_PREFIX_PATH_x86_64_fortanix_unknown_sgx = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_x86_64-fortanix-unknown-sgx = None
  CMAKE_x86_64_fortanix_unknown_sgx = None
  TARGET_CMAKE = None
  CMAKE = None
  running: cd "/home/ubuntu/sgx-revm/target/x86_64-fortanix-unknown-sgx/release/build/mbedtls-sys-auto-f72b828e96063be4/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mbedtls-sys-auto-2.28.3/vendor" "-DENABLE_PROGRAMS=OFF" "-DENABLE_TESTING=OFF" "-DCMAKE_SYSTEM_NAME=unknown" "-DCMAKE_SYSTEM_PROCESSOR=x86_64" "-DCMAKE_INSTALL_PREFIX=/home/ubuntu/sgx-revm/target/x86_64-fortanix-unknown-sgx/release/build/mbedtls-sys-auto-f72b828e96063be4/out" "-DCMAKE_C_FLAGS= -DMBEDTLS_CONFIG_FILE=\"\\\"/home/ubuntu/sgx-revm/target/x86_64-fortanix-unknown-sgx/release/build/mbedtls-sys-auto-f72b828e96063be4/out/config.h\\\"\" -fno-builtin -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -fno-stack-protector -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Release"
  -- The C compiler identification is GNU 11.4.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /usr/bin/cc - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Found Python3: /usr/bin/python3.10 (found version "3.10.12") found components: Interpreter 
  -- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS
  -- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS - Success
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /home/ubuntu/sgx-revm/target/x86_64-fortanix-unknown-sgx/release/build/mbedtls-sys-auto-f72b828e96063be4/out/build
  running: cd "/home/ubuntu/sgx-revm/target/x86_64-fortanix-unknown-sgx/release/build/mbedtls-sys-auto-f72b828e96063be4/out/build" && MAKEFLAGS="-j --jobserver-fds=7,8 --jobserver-auth=7,8" "cmake" "--build" "." "--target" "lib" "--config" "Release"
  [  1%] Building C object library/CMakeFiles/mbedcrypto.dir/aes.c.obj
  [  2%] Building C object library/CMakeFiles/mbedcrypto.dir/aesni.c.obj
  [  3%] Building C object library/CMakeFiles/mbedcrypto.dir/arc4.c.obj
  [  4%] Building C object library/CMakeFiles/mbedcrypto.dir/aria.c.obj
  [  5%] Building C object library/CMakeFiles/mbedcrypto.dir/asn1parse.c.obj
  [  6%] Building C object library/CMakeFiles/mbedcrypto.dir/asn1write.c.obj
  [  7%] Building C object library/CMakeFiles/mbedcrypto.dir/base64.c.obj
  [  8%] Building C object library/CMakeFiles/mbedcrypto.dir/bignum.c.obj
  [  9%] Building C object library/CMakeFiles/mbedcrypto.dir/blowfish.c.obj
  [ 10%] Building C object library/CMakeFiles/mbedcrypto.dir/camellia.c.obj
  [ 11%] Building C object library/CMakeFiles/mbedcrypto.dir/ccm.c.obj
  [ 12%] Building C object library/CMakeFiles/mbedcrypto.dir/chacha20.c.obj
  [ 13%] Building C object library/CMakeFiles/mbedcrypto.dir/chachapoly.c.obj
  [ 14%] Building C object library/CMakeFiles/mbedcrypto.dir/cipher.c.obj
  [ 15%] Building C object library/CMakeFiles/mbedcrypto.dir/cipher_wrap.c.obj
  [ 16%] Building C object library/CMakeFiles/mbedcrypto.dir/constant_time.c.obj
  [ 17%] Building C object library/CMakeFiles/mbedcrypto.dir/cmac.c.obj
  [ 18%] Building C object library/CMakeFiles/mbedcrypto.dir/ctr_drbg.c.obj
  [ 19%] Building C object library/CMakeFiles/mbedcrypto.dir/des.c.obj
  [ 20%] Building C object library/CMakeFiles/mbedcrypto.dir/dhm.c.obj
  [ 21%] Building C object library/CMakeFiles/mbedcrypto.dir/ecdh.c.obj
  [ 22%] Building C object library/CMakeFiles/mbedcrypto.dir/ecdsa.c.obj
  [ 23%] Building C object library/CMakeFiles/mbedcrypto.dir/ecjpake.c.obj
  [ 24%] Building C object library/CMakeFiles/mbedcrypto.dir/ecp.c.obj
  [ 25%] Building C object library/CMakeFiles/mbedcrypto.dir/ecp_curves.c.obj
  [ 26%] Building C object library/CMakeFiles/mbedcrypto.dir/entropy.c.obj
  [ 27%] Building C object library/CMakeFiles/mbedcrypto.dir/entropy_poll.c.obj
  [ 28%] Building C object library/CMakeFiles/mbedcrypto.dir/error.c.obj
  [ 29%] Building C object library/CMakeFiles/mbedcrypto.dir/gcm.c.obj
  [ 30%] Building C object library/CMakeFiles/mbedcrypto.dir/havege.c.obj
  [ 31%] Building C object library/CMakeFiles/mbedcrypto.dir/hkdf.c.obj
  [ 32%] Building C object library/CMakeFiles/mbedcrypto.dir/hmac_drbg.c.obj
  [ 33%] Building C object library/CMakeFiles/mbedcrypto.dir/md.c.obj
  [ 34%] Building C object library/CMakeFiles/mbedcrypto.dir/md2.c.obj
  [ 35%] Building C object library/CMakeFiles/mbedcrypto.dir/md4.c.obj
  [ 36%] Building C object library/CMakeFiles/mbedcrypto.dir/md5.c.obj
  [ 37%] Building C object library/CMakeFiles/mbedcrypto.dir/memory_buffer_alloc.c.obj
  [ 38%] Building C object library/CMakeFiles/mbedcrypto.dir/mps_reader.c.obj
  [ 39%] Building C object library/CMakeFiles/mbedcrypto.dir/mps_trace.c.obj
  [ 40%] Building C object library/CMakeFiles/mbedcrypto.dir/nist_kw.c.obj
  [ 41%] Building C object library/CMakeFiles/mbedcrypto.dir/oid.c.obj
  [ 42%] Building C object library/CMakeFiles/mbedcrypto.dir/padlock.c.obj
  [ 43%] Building C object library/CMakeFiles/mbedcrypto.dir/pem.c.obj
  [ 44%] Building C object library/CMakeFiles/mbedcrypto.dir/pk.c.obj
  [ 45%] Building C object library/CMakeFiles/mbedcrypto.dir/pk_wrap.c.obj
  [ 46%] Building C object library/CMakeFiles/mbedcrypto.dir/pkcs12.c.obj
  [ 47%] Building C object library/CMakeFiles/mbedcrypto.dir/pkcs5.c.obj
  [ 48%] Building C object library/CMakeFiles/mbedcrypto.dir/pkparse.c.obj
  [ 49%] Building C object library/CMakeFiles/mbedcrypto.dir/pkwrite.c.obj
  [ 50%] Building C object library/CMakeFiles/mbedcrypto.dir/platform.c.obj
  [ 51%] Building C object library/CMakeFiles/mbedcrypto.dir/platform_util.c.obj
  [ 52%] Building C object library/CMakeFiles/mbedcrypto.dir/poly1305.c.obj
  [ 53%] Building C object library/CMakeFiles/mbedcrypto.dir/psa_crypto.c.obj
  [ 54%] Building C object library/CMakeFiles/mbedcrypto.dir/psa_crypto_aead.c.obj
  [ 55%] Building C object library/CMakeFiles/mbedcrypto.dir/psa_crypto_cipher.c.obj
  [ 56%] Building C object library/CMakeFiles/mbedcrypto.dir/psa_crypto_client.c.obj
  [ 57%] Building C object library/CMakeFiles/mbedcrypto.dir/psa_crypto_driver_wrappers.c.obj
  [ 58%] Building C object library/CMakeFiles/mbedcrypto.dir/psa_crypto_ecp.c.obj
  [ 59%] Building C object library/CMakeFiles/mbedcrypto.dir/psa_crypto_hash.c.obj
  [ 60%] Building C object library/CMakeFiles/mbedcrypto.dir/psa_crypto_mac.c.obj
  [ 61%] Building C object library/CMakeFiles/mbedcrypto.dir/psa_crypto_rsa.c.obj
  [ 62%] Building C object library/CMakeFiles/mbedcrypto.dir/psa_crypto_se.c.obj
  [ 63%] Building C object library/CMakeFiles/mbedcrypto.dir/psa_crypto_slot_management.c.obj
  [ 64%] Building C object library/CMakeFiles/mbedcrypto.dir/psa_crypto_storage.c.obj
  [ 65%] Building C object library/CMakeFiles/mbedcrypto.dir/psa_its_file.c.obj
  [ 66%] Building C object library/CMakeFiles/mbedcrypto.dir/ripemd160.c.obj
  [ 67%] Building C object library/CMakeFiles/mbedcrypto.dir/rsa.c.obj
  [ 68%] Building C object library/CMakeFiles/mbedcrypto.dir/rsa_internal.c.obj
  [ 69%] Building C object library/CMakeFiles/mbedcrypto.dir/sha1.c.obj
  [ 70%] Building C object library/CMakeFiles/mbedcrypto.dir/sha256.c.obj
  [ 71%] Building C object library/CMakeFiles/mbedcrypto.dir/sha512.c.obj
  [ 72%] Building C object library/CMakeFiles/mbedcrypto.dir/threading.c.obj
  [ 73%] Building C object library/CMakeFiles/mbedcrypto.dir/timing.c.obj
  [ 74%] Building C object library/CMakeFiles/mbedcrypto.dir/version.c.obj
  [ 75%] Building C object library/CMakeFiles/mbedcrypto.dir/version_features.c.obj
  [ 76%] Building C object library/CMakeFiles/mbedcrypto.dir/xtea.c.obj
  [ 77%] Linking C static library libmbedcrypto.a
  [ 77%] Built target mbedcrypto
  [ 78%] Building C object library/CMakeFiles/mbedx509.dir/certs.c.obj
  [ 79%] Building C object library/CMakeFiles/mbedx509.dir/pkcs11.c.obj
  [ 80%] Building C object library/CMakeFiles/mbedx509.dir/x509.c.obj
  [ 81%] Building C object library/CMakeFiles/mbedx509.dir/x509_create.c.obj
  [ 82%] Building C object library/CMakeFiles/mbedx509.dir/x509_crl.c.obj
  [ 84%] Building C object library/CMakeFiles/mbedx509.dir/x509_csr.c.obj
  [ 84%] Building C object library/CMakeFiles/mbedx509.dir/x509_crt.c.obj
  [ 86%] Building C object library/CMakeFiles/mbedx509.dir/x509write_csr.c.obj
  [ 86%] Building C object library/CMakeFiles/mbedx509.dir/x509write_crt.c.obj
  [ 87%] Linking C static library libmbedx509.a
  [ 87%] Built target mbedx509
  [ 88%] Building C object library/CMakeFiles/mbedtls.dir/debug.c.obj
  [ 90%] Building C object library/CMakeFiles/mbedtls.dir/net_sockets.c.obj
  [ 90%] Building C object library/CMakeFiles/mbedtls.dir/ssl_cache.c.obj
  [ 92%] Building C object library/CMakeFiles/mbedtls.dir/ssl_ciphersuites.c.obj
  [ 92%] Building C object library/CMakeFiles/mbedtls.dir/ssl_cookie.c.obj
  [ 93%] Building C object library/CMakeFiles/mbedtls.dir/ssl_cli.c.obj
  [ 94%] Building C object library/CMakeFiles/mbedtls.dir/ssl_msg.c.obj
  [ 95%] Building C object library/CMakeFiles/mbedtls.dir/ssl_srv.c.obj
  [ 96%] Building C object library/CMakeFiles/mbedtls.dir/ssl_ticket.c.obj
  [ 97%] Building C object library/CMakeFiles/mbedtls.dir/ssl_tls.c.obj
  [ 98%] Building C object library/CMakeFiles/mbedtls.dir/ssl_tls13_keys.c.obj
  [100%] Linking C static library libmbedtls.a
  [100%] Built target mbedtls
  [100%] Built target lib
  cargo:root=/home/ubuntu/sgx-revm/target/x86_64-fortanix-unknown-sgx/release/build/mbedtls-sys-auto-f72b828e96063be4/out
  cargo:rustc-link-search=native=/home/ubuntu/sgx-revm/target/x86_64-fortanix-unknown-sgx/release/build/mbedtls-sys-auto-f72b828e96063be4/out/build/library
  cargo:rustc-link-search=native=/home/ubuntu/sgx-revm/target/x86_64-fortanix-unknown-sgx/release/build/mbedtls-sys-auto-f72b828e96063be4/out/build/crypto/library
  cargo:rustc-link-lib=mbedtls
  cargo:rustc-link-lib=mbedx509
  cargo:rustc-link-lib=mbedcrypto
  cargo:include=/home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mbedtls-sys-auto-2.28.3/vendor/include
  cargo:config_h=/home/ubuntu/sgx-revm/target/x86_64-fortanix-unknown-sgx/release/build/mbedtls-sys-auto-f72b828e96063be4/out/config.h
  OPT_LEVEL = Some("3")
  TARGET = Some("x86_64-fortanix-unknown-sgx")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_x86_64-fortanix-unknown-sgx
  CC_x86_64-fortanix-unknown-sgx = None
  cargo:rerun-if-env-changed=CC_x86_64_fortanix_unknown_sgx
  CC_x86_64_fortanix_unknown_sgx = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  RUSTC_LINKER = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,rdrand,rdseed,sse,sse2")
  cargo:rerun-if-env-changed=CFLAGS_x86_64-fortanix-unknown-sgx
  CFLAGS_x86_64-fortanix-unknown-sgx = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_fortanix_unknown_sgx
  CFLAGS_x86_64_fortanix_unknown_sgx = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None

  --- stderr
  System is unknown to cmake, create:
  Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  System is unknown to cmake, create:
  Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  System is unknown to cmake, create:
  Platform/unknown to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  CMake Warning:
    Manually-specified variables were not used by the project:

      CMAKE_ASM_COMPILER
      CMAKE_ASM_FLAGS
      CMAKE_CXX_COMPILER
      CMAKE_CXX_FLAGS

  /usr/include/limits.h:26:10: fatal error: 'bits/libc-header-start.h' file not found
  thread 'main' panicked at /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mbedtls-sys-auto-2.28.3/build/bindgen.rs:142:14:
  bindgen error: ClangDiagnostic("/usr/include/limits.h:26:10: fatal error: 'bits/libc-header-start.h' file not found\n")
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Any help would be greatly appreciated!

pbeza commented 1 year ago

It turned out that I was missing gcc-multilib Ubuntu package (all credits goes to @dyxushuai for suggesting that – thanks a lot!). Once I installed it, I progressed to yet different compilation error message:

ubuntu@VM-0-6-ubuntu:~/sgx-revm$ cargo run --release --target x86_64-fortanix-unknown-sgx                                                                                                                                                                                                                                                                                                                                                                                          [328/1981]
   Compiling autocfg v1.1.0
   Compiling libc v0.2.147
   Compiling version_check v0.9.4
   Compiling proc-macro2 v1.0.66
   Compiling unicode-ident v1.0.11
   Compiling typenum v1.16.0
   Compiling zeroize v1.6.0
   Compiling cfg-if v1.0.0
   Compiling subtle v2.5.0
   Compiling syn v1.0.109
   Compiling const-oid v0.9.5
   Compiling serde v1.0.188
   Compiling generic-array v0.14.7
   Compiling num-traits v0.2.16
   Compiling crunchy v0.2.2
   Compiling glob v0.3.1
   Compiling num-integer v0.1.45
   Compiling prettyplease v0.2.12
   Compiling rand_core v0.6.4
   Compiling quote v1.0.33
   Compiling minimal-lexical v0.2.1
   Compiling memchr v2.6.2
   Compiling clang-sys v1.6.1
   Compiling syn v2.0.29
   Compiling cc v1.0.83
   Compiling byteorder v1.4.3
   Compiling regex-syntax v0.7.5
   Compiling rustc-hex v2.1.0
   Compiling nom v7.1.3
   Compiling libloading v0.7.4
   Compiling block-buffer v0.10.4
   Compiling crypto-common v0.1.6
   Compiling digest v0.10.7
   Compiling bindgen v0.65.1
   Compiling either v1.9.0
   Compiling static_assertions v1.1.0
   Compiling which v4.4.0
   Compiling proc-macro-error-attr v1.0.4
   Compiling hex v0.4.3
   Compiling lazycell v1.3.0
   Compiling crossbeam-utils v0.8.16
   Compiling lazy_static v1.4.0
   Compiling bitflags v1.3.2
   Compiling rustc-hash v1.1.0
   Compiling log v0.4.20
   Compiling peeking_take_while v0.1.2
   Compiling shlex v1.1.0
   Compiling uint v0.9.5
   Compiling fixed-hash v0.8.0
   Compiling cmake v0.1.50
   Compiling memoffset v0.9.0
   Compiling proc-macro-error v1.0.4
   Compiling ahash v0.8.3
   Compiling once_cell v1.18.0
   Compiling regex-automata v0.3.7
   Compiling cexpr v0.6.0
   Compiling radium v0.7.0
   Compiling primitive-types v0.12.1
   Compiling ff v0.13.0
   Compiling crossbeam-epoch v0.9.15
   Compiling num-bigint v0.4.4
   Compiling der v0.7.8
   Compiling regex v1.9.4
   Compiling convert_case v0.4.0
   Compiling base16ct v0.2.0
   Compiling ruint-macro v1.1.0
   Compiling cpufeatures v0.2.9
   Compiling tap v1.0.1
   Compiling wyz v0.5.1
   Compiling sec1 v0.7.3
   Compiling group v0.13.0
   Compiling serde_derive v1.0.188
   Compiling secp256k1-sys v0.8.1
   Compiling hmac v0.12.1
   Compiling crypto-bigint v0.5.2
   Compiling derive_more v0.99.17
   Compiling num-rational v0.4.1
   Compiling num-iter v0.1.43
   Compiling hex-literal v0.4.1
   Compiling funty v2.0.0
   Compiling keccak v0.1.4
   Compiling scopeguard v1.2.0
   Compiling allocator-api2 v0.2.16
   Compiling elliptic-curve v0.13.5
   Compiling hashbrown v0.14.0
   Compiling bitvec v1.0.1
   Compiling sha3 v0.10.8
   Compiling auto_impl v1.1.0
   Compiling rfc6979 v0.4.0
   Compiling enumn v0.1.11
   Compiling mbedtls-platform-support v0.1.0
   Compiling signature v2.1.0
   Compiling num-bigint v0.2.6
   Compiling rayon-core v1.11.0
   Compiling spin v0.5.2
   Compiling bitflags v2.4.0
   Compiling ecdsa v0.16.8
   Compiling crossbeam-deque v0.8.3
   Compiling sha2 v0.10.7
   Compiling crossbeam-channel v0.5.8
   Compiling num_cpus v1.16.0
   Compiling time v0.1.45
   Compiling mbedtls-sys-auto v2.28.3
   Compiling rs-libc v0.1.0
   Compiling num-complex v0.4.4
   Compiling rand v0.8.5
   Compiling tiny-keccak v2.0.2
   Compiling num v0.4.1
   Compiling chrono v0.4.28
   Compiling substrate-bn v0.6.0
   Compiling bytes v1.4.0
   Compiling k256 v0.13.1
   Compiling rlp v0.5.2
   Compiling ruint v1.10.1
   Compiling secp256k1 v0.27.0
   Compiling revm-primitives v1.1.2 (https://github.com/bluealloy/revm#6bd05c90)
   Compiling mbedtls v0.7.4
   Compiling ripemd v0.1.3
   Compiling eyre v0.6.8
   Compiling bit-vec v0.5.1
   Compiling itoa v1.0.9
   Compiling serde_json v1.0.105
   Compiling yasna v0.2.2
   Compiling revm-interpreter v1.1.2 (https://github.com/bluealloy/revm#6bd05c90)
   Compiling rayon v1.7.0
   Compiling revm-precompile v2.0.3 (https://github.com/bluealloy/revm#6bd05c90)
   Compiling const-hex v1.8.0
   Compiling ryu v1.0.15
   Compiling indenter v0.3.3
   Compiling alloy-primitives v0.3.3
   Compiling revm v3.3.0 (https://github.com/bluealloy/revm#6bd05c90)
   Compiling sgx-revm v0.1.0 (/home/ubuntu/sgx-revm)
warning: unused import: `TcpListener`
  --> src/server.rs:17:11
   |
17 |     net::{TcpListener, TcpStream},
   |           ^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unnecessary parentheses around assigned value
  --> src/server.rs:24:28
   |
24 | const CERT_VAL_SECS: u64 = (365 * DAYS_TO_SES);
   |                            ^                 ^
   |
   = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
   |
24 - const CERT_VAL_SECS: u64 = (365 * DAYS_TO_SES);
24 + const CERT_VAL_SECS: u64 = 365 * DAYS_TO_SES;
   |

warning: unused import: `serve`
  --> src/main.rs:10:32
   |
10 | use server::{get_key_and_cert, serve};
   |                                ^^^^^

warning: use of deprecated method `chrono::TimeZone::timestamp`: use `timestamp_opt()` instead
   --> src/server.rs:107:26
    |
107 |     let not_before = Utc.timestamp(start as _, 0);
    |                          ^^^^^^^^^
    |
    = note: `#[warn(deprecated)]` on by default

warning: use of deprecated method `chrono::TimeZone::timestamp`: use `timestamp_opt()` instead
   --> src/server.rs:108:25
    |
108 |     let not_after = Utc.timestamp(end as _, 0);
    |                         ^^^^^^^^^

error[E0308]: mismatched types
  --> src/main.rs:67:57
   |
67 |         transact_to: revm::primitives::TransactTo::Call(receiver),
   |                      ---------------------------------- ^^^^^^^^ expected `B160`, found `Address`
   |                      |
   |                      arguments to this enum variant are incorrect
   |
note: tuple variant defined here
  --> /home/ubuntu/.cargo/git/checkouts/revm-bf744d8ffabcbad9/6bd05c9/crates/primitives/src/env.rs:53:5
   |
53 |     Call(B160),
   |     ^^^^

For more information about this error, try `rustc --explain E0308`.
warning: `sgx-revm` (bin "sgx-revm") generated 5 warnings
error: could not compile `sgx-revm` (bin "sgx-revm") due to previous error; 5 warnings emitted

I believe that is because revm dependency is not pinned to the fixed version and thus cargo is fetching the latest version, whereas sgx-revm is using revm's outdated API for revm::primitives::TransactTo::Call(receiver). Notice that this commit: https://github.com/bluealloy/revm/commit/eb6a9f09e8ac2227bc1c353b698ad9e68a9574b2#diff-0ade7f08f6db390934f025d9f530c64cc6d399de28856684a8b98185d43b46dcL52 reverted this commit https://github.com/bluealloy/revm/commit/f95b7a42a60c857dfe25040b98086fae01e94a71 that introduced the API that we are using here: https://github.com/gakonst/sgx-revm/blob/212d285d67d9434513272e9a8e0db84e08f60c70/src/main.rs#L67

(after the revert receiver's type is now B160 yet again instead of Address)

So I just replaced this line: https://github.com/gakonst/sgx-revm/blob/212d285d67d9434513272e9a8e0db84e08f60c70/Cargo.toml#L10 with this one:

revm = { git = "https://github.com/bluealloy/revm", rev = "e5227c4" }

(https://github.com/bluealloy/revm/commit/e5227c4399ea8b4a8b518075b553e25cddee4134 is one commit before the API revert mentioned above)

but it now errors out with:

$ RUST_BACKTRACE=1 cargo run  --target x86_64-fortanix-unknown-sgx

(...)

Error: Init(Io(Os { code: 22, kind: InvalidInput, message: "Invalid argument" }))

   0: failure::backtrace::Backtrace::new
   1: <failure::error::error_impl::ErrorImpl as core::convert::From<F>>::from
   2: sgxs_loaders::generic::Device<D>::load
   3: enclave_runner::loader::EnclaveBuilder::build
   4: ftxsgx_runner::main
   5: std::sys_common::backtrace::__rust_begin_short_backtrace
   6: std::rt::lang_start::{{closure}}
   7: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/ops/function.rs:284:13
      std::panicking::try::do_call
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:500:40
      std::panicking::try
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:464:19
      std::panic::catch_unwind
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panic.rs:142:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/rt.rs:148:48
      std::panicking::try::do_call
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:500:40
      std::panicking::try
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:464:19
      std::panic::catch_unwind
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panic.rs:142:14
      std::rt::lang_start_internal
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/rt.rs:148:20
   8: main
   9: <unknown>
  10: __libc_start_main
  11: _start

While loading SGX enclave
ERROR: while running "ftxsgx-runner" "target/x86_64-fortanix-unknown-sgx/debug/sgx-revm.sgxs" got exit status: 1

It seems to be something wrong with my Fortanix setup (see relevant: https://github.com/fortanix/rust-sgx/issues/526). Investigating...

pbeza commented 1 year ago

It seems to be something wrong with my Fortanix setup (see relevant: fortanix/rust-sgx#526). Investigating...

It was indeed caused by the issue with Fortanix misconfiguration (see the details here; TL;DR I just needed to upgrade Linux kernel to the latest one which is ver. 6.5).

Now running cargo run --release --target x86_64-fortanix-unknown-sgx succeeds, meaning it waits for the request I send from the other terminal (as described here). The problem is that when I run:

nc localhost 7878
{ "sender": "0xdafea492d9c6733ae3d56b7ed1adb60692c98bc5", "amount": 40 }

and press Ctrl+C, I'm getting this in the first terminal:

Attaching debugger
Error while executing SGX enclave.
Enclave panicked: Exited with status code 101
ERROR: while running "ftxsgx-runner" "target/x86_64-fortanix-unknown-sgx/release/sgx-revm.sgxs" got exit status: 255

Why? 🤔

pbeza commented 1 year ago

Why? 🤔

Because supposedly there is a bug in the code. Instead of: https://github.com/gakonst/sgx-revm/blob/212d285d67d9434513272e9a8e0db84e08f60c70/src/main.rs#L76 should be:

U256::from(71)

Once I fixed it, it works as expected! Output from the first terminal (i.e. server's output):

[src/main.rs:79] &result = ResultAndState {
    result: Success {
        reason: Stop,
        gas_used: 21000,
        gas_refunded: 0,
        logs: [],
        output: Call(
            Bytes(0x),
        ),
    },
    state: {
        0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97: Account {
            info: AccountInfo {
                balance: 0x0000000000000000000000000000000000000000000000000000000000000047_U256,
                nonce: 1,
                code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
                code: Some(
                    Bytecode {
                        bytecode: Bytes(0x00),
                        state: Analysed {
                            len: 0,
                            jump_map: JumpMap {
                                map: BinaryString(
                                    "00000000",
                                ),
                            },
                        },
                    },
                ),
            },
            storage: {},
            status: AccountStatus(
                Touched,
            ),
        },
        0x0000000000000000000000000000000000000000: Account {
            info: AccountInfo {
                balance: 0x0_U256,
                nonce: 0,
                code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
                code: Some(
                    Bytecode {
                        bytecode: Bytes(0x00),
                        state: Analysed {
                            len: 0,
                            jump_map: JumpMap {
                                map: BinaryString(
                                    "00000000",
                                ),
                            },
                        },
                    },
                ),
            },
            storage: {},
            status: AccountStatus(
                Touched | LoadedAsNotExisting,
            ),
        },
        0xdafea492d9c6733ae3d56b7ed1adb60692c98bc5: Account {
            info: AccountInfo {
                balance: 0x0000000000000000000000000000000000000000000000000000000000000028_U256,
                nonce: 0,
                code_hash: 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470,
                code: Some(
                    Bytecode {
                        bytecode: Bytes(0x00),
                        state: Analysed {
                            len: 0,
                            jump_map: JumpMap {
                                map: BinaryString(
                                    "00000000",
                                ),
                            },
                        },
                    },
                ),
            },
            storage: {},
            status: AccountStatus(
                Touched | LoadedAsNotExisting,
            ),
        },
    },
}

I think I can close this issue, but before doing that – @gakonst please feel free to comment if I missed something in the above investigation. I had to workaround/solve a lot of intermediate problems before it started working as advertised in the README, but maybe I missed something.