Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Problem "the trait Hash is not implemented for composabilitylabs_mod::AssetId" during the build with contract built on sway v0.46 #1385

Closed
chlenc opened this issue Sep 27, 2023 · 4 comments

Comments

@chlenc
Copy link

chlenc commented Sep 27, 2023

Problem "the trait Hash is not implemented for composabilitylabs_mod::AssetId" during the build with contract built on sway v0.46

Hi guys, we just released our swaylend on beta-4 using sway v0.44.4 with indexer, and now I'm trying to switch it on sway v0.46 and having a problem with building the indexer.
After rebuilding, redeploying, and changing abi of the contract in manifest I got that problem during forc index build

▸▹▹▹▹ ⏰ Building indexer...                                                                                                                                     Compiling swaylend_indexer v0.0.0 (/Users/alexey/projects/fuel/sway-lend/services/swaylend-indexer)
▹▸▹▹▹ ⏰ Building indexer...                                                                                                                                  error[E0277]: the trait bound `composabilitylabs_mod::AssetId: Hash` is not satisfied
 --> src/lib.rs:4:1
  |
4 | #[indexer(manifest = "swaylend_indexer.manifest.yaml")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Hash` is not implemented for `composabilitylabs_mod::AssetId`
  |
  = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `composabilitylabs_mod::AssetId: Serialize` is not satisfied
    --> src/lib.rs:4:1
     |
4    | #[indexer(manifest = "swaylend_indexer.manifest.yaml")]
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Serialize` is not implemented for `composabilitylabs_mod::AssetId`
     |
     = help: the following other types implement trait `Serialize`:
               bool
               char
               isize
               i8
               i16
               i32
               i64
               i128
             and 424 others
note: required by a bound in `_::_serde::ser::SerializeStruct::serialize_field`
    --> /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.188/src/ser/mod.rs:1865:12
     |
1859 |     fn serialize_field<T: ?Sized>(
     |        --------------- required by a bound in this associated function
...
1865 |         T: Serialize;
     |            ^^^^^^^^^ required by this bound in `SerializeStruct::serialize_field`
     = note: this error originates in the attribute macro `indexer` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `composabilitylabs_mod::AssetId: Deserialize<'_>` is not satisfied
    --> src/lib.rs:4:1
     |
4    | #[indexer(manifest = "swaylend_indexer.manifest.yaml")]
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `composabilitylabs_mod::AssetId`
     |
     = help: the following other types implement trait `Deserialize<'de>`:
               bool
               char
               isize
               i8
               i16
               i32
               i64
               i128
             and 417 others
note: required by a bound in `next_element`
    --> /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.188/src/de/mod.rs:1724:12
     |
1722 |     fn next_element<T>(&mut self) -> Result<Option<T>, Self::Error>
     |        ------------ required by a bound in this associated function
1723 |     where
1724 |         T: Deserialize<'de>,
     |            ^^^^^^^^^^^^^^^^ required by this bound in `SeqAccess::next_element`
     = note: this error originates in the attribute macro `indexer` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `composabilitylabs_mod::AssetId: Deserialize<'_>` is not satisfied
    --> src/lib.rs:4:1
     |
4    | #[indexer(manifest = "swaylend_indexer.manifest.yaml")]
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `composabilitylabs_mod::AssetId`
     |
     = help: the following other types implement trait `Deserialize<'de>`:
               bool
               char
               isize
               i8
               i16
               i32
               i64
               i128
             and 417 others
note: required by a bound in `next_value`
    --> /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.188/src/de/mod.rs:1863:12
     |
1861 |     fn next_value<V>(&mut self) -> Result<V, Self::Error>
     |        ---------- required by a bound in this associated function
1862 |     where
1863 |         V: Deserialize<'de>,
     |            ^^^^^^^^^^^^^^^^ required by this bound in `MapAccess::next_value`
     = note: this error originates in the attribute macro `indexer` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> src/lib.rs:4:1
    |
4   | #[indexer(manifest = "swaylend_indexer.manifest.yaml")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `composabilitylabs_mod::AssetId`, found `fuel_indexer_utils::prelude::AssetId`
    |
    = note: `fuel_indexer_utils::prelude::AssetId` and `composabilitylabs_mod::AssetId` have similar names, but are actually distinct types
note: `fuel_indexer_utils::prelude::AssetId` is defined in crate `fuel_types`
   --> /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/fuel-types-0.35.3/src/array_types.rs:343:1
    |
343 | key!(AssetId, 32);
    | ^^^^^^^^^^^^^^^^^
note: `composabilitylabs_mod::AssetId` is defined in the current crate
   --> src/lib.rs:4:1
    |
4   | #[indexer(manifest = "swaylend_indexer.manifest.yaml")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in the attribute macro `indexer` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> src/lib.rs:4:1
    |
4   | #[indexer(manifest = "swaylend_indexer.manifest.yaml")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | |
    | expected `fuel_indexer_utils::prelude::AssetId`, found `composabilitylabs_mod::AssetId`
    | arguments to this enum variant are incorrect
    |
    = note: `composabilitylabs_mod::AssetId` and `fuel_indexer_utils::prelude::AssetId` have similar names, but are actually distinct types
note: `composabilitylabs_mod::AssetId` is defined in the current crate
   --> src/lib.rs:4:1
    |
4   | #[indexer(manifest = "swaylend_indexer.manifest.yaml")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `fuel_indexer_utils::prelude::AssetId` is defined in crate `fuel_types`
   --> /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/fuel-types-0.35.3/src/array_types.rs:343:1
    |
343 | key!(AssetId, 32);
    | ^^^^^^^^^^^^^^^^^
help: the type constructed contains `composabilitylabs_mod::AssetId` due to the type of the argument passed
   --> src/lib.rs:4:1
    |
4   | #[indexer(manifest = "swaylend_indexer.manifest.yaml")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this argument influences the type of `Some`
note: tuple variant defined here
   --> /Users/alexey/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:571:5
    |
571 |     Some(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     ^^^^
    = note: this error originates in the attribute macro `indexer` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `composabilitylabs_mod::AssetId: AsRef<[u8]>` is not satisfied
  --> src/lib.rs:4:1
   |
4  | #[indexer(manifest = "swaylend_indexer.manifest.yaml")]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsRef<[u8]>` is not implemented for `composabilitylabs_mod::AssetId`
   |
note: required by a bound in `chain_update`
  --> /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/digest-0.10.7/src/digest.rs:27:38
   |
27 |     fn chain_update(self, data: impl AsRef<[u8]>) -> Self;
   |                                      ^^^^^^^^^^^ required by this bound in `Digest::chain_update`
   = note: this error originates in the attribute macro `indexer` (in Nightly builds, run with -Z macro-backtrace for more info)

▹▹▸▹▹ ⏰ Building indexer...                                                                                                                                  error[E0308]: mismatched types
   --> src/lib.rs:4:1
    |
4   | #[indexer(manifest = "swaylend_indexer.manifest.yaml")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | |
    | expected `AssetId`, found `[u8; 32]`
    | arguments to this function are incorrect
    |
note: associated function defined here
   --> /Users/alexey/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/convert/mod.rs:543:8
    |
543 |     fn from(value: T) -> Self;
    |        ^^^^
    = note: this error originates in the attribute macro `indexer` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> src/lib.rs:4:1
    |
4   | #[indexer(manifest = "swaylend_indexer.manifest.yaml")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `fuel_indexer_utils::prelude::AssetId`, found `composabilitylabs_mod::AssetId`
    |
    = note: `composabilitylabs_mod::AssetId` and `fuel_indexer_utils::prelude::AssetId` have similar names, but are actually distinct types
note: `composabilitylabs_mod::AssetId` is defined in the current crate
   --> src/lib.rs:4:1
    |
4   | #[indexer(manifest = "swaylend_indexer.manifest.yaml")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `fuel_indexer_utils::prelude::AssetId` is defined in crate `fuel_types`
   --> /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/fuel-types-0.35.3/src/array_types.rs:343:1
    |
343 | key!(AssetId, 32);
    | ^^^^^^^^^^^^^^^^^
    = note: this error originates in the attribute macro `indexer` which comes from the expansion of the macro `key` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `swaylend_indexer` (lib) due to 10 previous errors
▪▪▪▪▪ ❌ Build failed.                                                                                                                                        Error: ❌ Failed to build index.

How to reproduce the problem

Running of fuel-indexer service

fuelup update  
docker run -d -p 5432:5432 --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword postgres  
fuel-indexer run --run-migrations --fuel-node-host beta-4.fuel.network --fuel-node-port 80 --postgres-host 127.0.0.1 --postgres-port 5432 --postgres-password mysecretpassword --postgres-user postgres

Deploying of the indexer

git clone https://github.com/compolabs/sway-lend.git
cd sway-lend
git checkout sway-v0.46
cd ./services/swaylend-indexer/ 
forc index build 

Toolchain

Default host: aarch64-apple-darwin
fuelup home: /Users/alexey/.fuelup

installed toolchains
--------------------
beta-3-aarch64-apple-darwin
beta-4-rc.2-aarch64-apple-darwin
latest-aarch64-apple-darwin (default)
beta-4-aarch64-apple-darwin
hotfix
my-custom-toolchain

active toolchain
-----------------
latest-aarch64-apple-darwin (default)
  forc : 0.46.0
    - forc-client
      - forc-deploy : 0.46.0
      - forc-run : 0.46.0
    - forc-doc : 0.46.0
    - forc-explore : 0.28.1
    - forc-fmt : 0.46.0
    - forc-index : 0.20.11
    - forc-lsp : 0.46.0
    - forc-tx : 0.46.0
    - forc-wallet : 0.3.0
  fuel-core : 0.20.5
  fuel-core-keygen : Error getting version string
  fuel-indexer : 0.20.11

fuels versions
---------------
forc : 0.45
forc-wallet : 0.45
@ra0x3
Copy link
Contributor

ra0x3 commented Sep 27, 2023

@chlenc

  • You should be using Sway 0.45 if possible (since that is what beta-4 supports)
  • AssetId is a defined in fuel-vm and has several implementation in the SDK
  • The indexer merely uses the AssetId it gets from upstream projects :)
  • I don't believe this is an Indexer issue - have you tried asking the Fuel Core team or the SDK team ?
    • Maybe just asking Fuel core to impl Hash for AssetId will do the trick

@chlenc
Copy link
Author

chlenc commented Sep 27, 2023

@ra0x3

I will try to replace AssetId with b256 on the contract and build the contract with swayv0.45

Also, I have rust-sdk assetId issue here

@chlenc
Copy link
Author

chlenc commented Sep 27, 2023

On sway-v0.45 I still have the next error during the build, even with the imported hash.
That has been discussed before here

image

@ra0x3
Copy link
Contributor

ra0x3 commented Sep 28, 2023

@chlenc

:)

Screenshot 2023-09-28 at 11 06 33 AM

@ra0x3 ra0x3 closed this as completed Sep 28, 2023
@FuelLabs FuelLabs locked and limited conversation to collaborators Sep 28, 2023
@ra0x3 ra0x3 converted this issue into discussion #1387 Sep 28, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants