scrtlabs / SecretNetwork

𝕊 The Secret Network
https://scrt.network
Other
529 stars 200 forks source link

Tendermint enclave build fails due to duplicate `enclave-ffi-types` crate in this repo #1439

Open likuilin opened 1 year ago

likuilin commented 1 year ago

I'm trying to build tendermint_enclave.signed.so from tm-secret-enclave myself (yes I know the MRSIGNER will be different so it won't work on-chain), and am running into this error:

error[E0432]: unresolved imports `enclave_ffi_types::INPUT_ENCRYPTED_SEED_SIZE`, `enclave_ffi_types::OUTPUT_ENCRYPTED_SEED_SIZE`
 --> /home/kuilin/.cargo/git/checkouts/secretnetwork-321ca7ab73a61848/a3edd66/cosmwasm/enclaves/shared/crypto/src/consts.rs:4:29
  |
4 | pub use enclave_ffi_types::{INPUT_ENCRYPTED_SEED_SIZE, OUTPUT_ENCRYPTED_SEED_SIZE};
  |                             ^^^^^^^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `OUTPUT_ENCRYPTED_SEED_SIZE` in the root
  |                             |
  |                             no `INPUT_ENCRYPTED_SEED_SIZE` in the root
  |
help: a similar name exists in the module
  |
4 | pub use enclave_ffi_types::{ENCRYPTED_SEED_SIZE, OUTPUT_ENCRYPTED_SEED_SIZE};
  |                             ~~~~~~~~~~~~~~~~~~~
help: a similar name exists in the module
  |
4 | pub use enclave_ffi_types::{INPUT_ENCRYPTED_SEED_SIZE, ENCRYPTED_SEED_SIZE};
  |                                                        ~~~~~~~~~~~~~~~~~~~

For more information about this error, try `rustc --explain E0432`.
error: could not compile `enclave_crypto` due to previous error

This error happens when building on my machine, but I was able to get the enclave to build successfully using the Dockerfile, so I was able to bisect what the exact issue is by following the xargo execs.

The root cause is that this repo has two enclave-ffi-types crates. On my machine, Cargo finds the one in /seed-service/src/enclaves/ffi-types rather than the correct one in /cosmwasm/enclaves/ffi-types. Both are named enclave-ffi-types with version 0.1.0, but the former (older?) one exports ENCRYPTED_SEED_SIZE, whereas the latter one exports INPUT_ENCRYPTED_SEED_SIZE and OUTPUT_ENCRYPTED_SEED_SIZE.

There's no way to specify the correct one with a local change to Cargo.toml in my checkout of tm-secret-enclave since they have the same version. I'm not sure how best to resolve this issue, but it seems like a clear bug that this repo should not have two crates that are the same name and version, since Cargo will pick one arbitrarily in this case.

likuilin commented 1 year ago

Using the test program whose source is here https://linux.die.net/man/2/getdents64 to get the raw readdir order of ~/.cargo/git/checkouts/secretnetwork-321ca7ab73a61848/a3edd66, I can confirm that seed-service comes before cosmwasm on my machine (non-working), but cosmwasm comes before seed-service in the Docker container on my machine (working).

Cashmaney commented 1 year ago

Thanks. This is probably due to lockfiles getting messed up somewhere. I'll update the issue when this is resolved