hackbg / fadroma

Magical flying bulldozer for the Cosmosverse. Contains clients for Tendermint-based chains in various degrees of completeness, and a mini build system for deploying systems of multiple interdependent smart contracts from source.
https://fadroma.tech
GNU Affero General Public License v3.0
51 stars 15 forks source link

BlockInfo missing `random` #178

Closed luca992 closed 1 year ago

luca992 commented 1 year ago

I'm trying to add ensemble to my project, but after adding ensemble like: fadroma = { version = "0.8.7", features = ["ensemble", "scrt"] }

and running test I get this error.

error[E0063]: missing field `random` in initializer of `BlockInfo`
   --> /Users/luca/.cargo/registry/src/github.com-1ecc6299db9ec823/fadroma-0.8.7/ensemble/ensemble.rs:896:20
    |
896 |             block: BlockInfo {
    |                    ^^^^^^^^^ missing `random`

My project is using secret-cosmwasm-std v1.0.10

aakamenov commented 1 year ago

We re-export secret-cosmwasm-std from Fadroma and have designed it such that it is to be used with the version that we have. Our latest version 0.8.7 is using secret-cosmwasm-std v1.1.10 which is the latest from crates.io.

As for the compile error, it's expecting a field that is behind a feature flag in CW that we haven't enabled in our re-export: https://github.com/scrtlabs/cosmwasm/blob/v1.1.10-secret/packages/std/src/types.rs#L88-L90

We could publish a new version that allows you to enable it if you need it though.

If you have a workspace project, you can try slapping a

[workspace]
resolver = "2"

in your root workspace Cargo.toml. But I suspect that since you are using a different version of secret-cosmwasm-std you will be getting compile errors regardless.

Depending on your project structure, I suggest one of:

luca992 commented 1 year ago

Yeah as I said I was using 1.1.10. And using resolver ="2" doesn't help unfortunately.

Here's an example project/branch where running cargo test fails after adding fadroma: https://github.com/eqoty-labs/cw-migratable-contract-std/tree/fadroma-example

luca992 commented 1 year ago
Screenshot 2023-06-12 at 12 43 22 PM

I am also having issues with the iterator feature

luca992 commented 1 year ago

I managed to fix the iterator issue with:

https://github.com/eqoty-labs/cw-migratable-contract-std/blob/3c738dd5beef98c6385f0410502a5da944a57f75/Cargo.toml#L43-L46

# Enable iterator for testing (not supported in production)
[target.'cfg(not(target_arch="wasm32"))'.dependencies]
cosmwasm-storage = { package = "secret-cosmwasm-storage", version = "1.1.10", default-features = false, features = ["iterator"] }

is that expected to be needed to add?

luca992 commented 1 year ago

As for the compile error, it's expecting a field that is behind a feature flag in CW that we haven't enabled in our re-export: https://github.com/scrtlabs/cosmwasm/blob/v1.1.10-secret/packages/std/src/types.rs#L88-L90

We could publish a new version that allows you to enable it if you need it though.

I think I do need that since I'm using the latest secret-toolkit where random is enabled?

https://github.com/scrtlabs/secret-toolkit/blob/95428dd1e9cd4e653f8a8b0aa82fd7ca31ac6e9f/Cargo.toml#L60-L62

aakamenov commented 1 year ago

The iterator feature is not supported on SN so we have disabled it. I noticed that you are using both fadroma and secret-toolkit. I myself had trouble compiling when using both in the same workspace. Your fix for that seems to be the way to go though.

I see that the random flag does not enable any dependencies, so I don't see a reason why it should be a feature to begin with. I can make another release where we have it enabled. You can try that and let me know.

aakamenov commented 1 year ago

Can you try the latest master branch? fadroma = { git = "https://github.com/hackbg/fadroma", rev = "119ae46", features = ["scrt", "ensemble"] }

It's working for me in your project. It includes the fix for #179 as well.

Let me know if it's all good then and I will go ahead and publish a new version on crates.io

luca992 commented 1 year ago

@aakamenov working for me 👍 thanks

aakamenov commented 1 year ago

Cool! I've published that now: https://crates.io/crates/fadroma/0.8.8