Skip to content

bug: zebra-state 3.1.2 makes breaking changes to its API #10253

@str4d

Description

@str4d

What happened?

zebra-state 3.1.1 depends on zebra-chain 3.1 in its public API, in particular zebra_state::request::HashOrHeight exposes zebra-chain types.

zebra-state 3.1.2 (a non-breaking patch release) updated this to zebra-chain 4 (a breaking change). This has broken zaino-proto compilation because it depends on both zebra-chain 3.1 and zebra-state 3.1, resulting in incompatible types:

error[E0277]: the trait bound `HashOrHeight: From<zebra_chain::block::Hash>` is not satisfied
   --> /Users/runner/.cargo/git/checkouts/zaino-63485a060b8db32e/da2717f/zaino-proto/src/proto/utils.rs:340:5
    |
340 | /     <[u8; 32]>::try_from(block_id.hash)
341 | |         .map(zebra_chain::block::Hash)
342 | |         .map(HashOrHeight::from)
    | |________________________________^ the trait `From<zebra_chain::block::Hash>` is not implemented for `HashOrHeight`
    |
help: the following other types implement trait `From<T>`
   --> /Users/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/zebra-state-3.1.2/src/request.rs:188:1
    |
188 | impl From<block::Hash> for HashOrHeight {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `HashOrHeight` implements `From<zebra_chain::block::hash::Hash>`
...
194 | impl From<block::Height> for HashOrHeight {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `HashOrHeight` implements `From<zebra_chain::block::height::Height>`
...
200 | impl From<(block::Height, block::Hash)> for HashOrHeight {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `HashOrHeight` implements `From<(zebra_chain::block::height::Height, zebra_chain::block::hash::Hash)>`
...
207 | impl From<(block::Hash, block::Height)> for HashOrHeight {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `HashOrHeight` implements `From<(zebra_chain::block::hash::Hash, zebra_chain::block::height::Height)>`

error[E0277]: the trait bound `HashOrHeight: From<zebra_chain::block::Hash>` is not satisfied
   --> /Users/runner/.cargo/git/checkouts/zaino-63485a060b8db32e/da2717f/zaino-proto/src/proto/utils.rs:342:14
    |
342 |         .map(HashOrHeight::from)
    |              ^^^^^^^^^^^^ the trait `From<zebra_chain::block::Hash>` is not implemented for `HashOrHeight`
    |
help: the following other types implement trait `From<T>`
   --> /Users/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/zebra-state-3.1.2/src/request.rs:188:1
    |
188 | impl From<block::Hash> for HashOrHeight {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `HashOrHeight` implements `From<zebra_chain::block::hash::Hash>`
...
194 | impl From<block::Height> for HashOrHeight {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `HashOrHeight` implements `From<zebra_chain::block::height::Height>`
...
200 | impl From<(block::Height, block::Hash)> for HashOrHeight {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `HashOrHeight` implements `From<(zebra_chain::block::height::Height, zebra_chain::block::hash::Hash)>`
...
207 | impl From<(block::Hash, block::Height)> for HashOrHeight {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `HashOrHeight` implements `From<(zebra_chain::block::hash::Hash, zebra_chain::block::height::Height)>`

error[E0308]: mismatched types
   --> /Users/runner/.cargo/git/checkouts/zaino-63485a060b8db32e/da2717f/zaino-proto/src/proto/utils.rs:347:52
    |
347 |                 .map(|height| HashOrHeight::Height(Height(height)))
    |                               -------------------- ^^^^^^^^^^^^^^ expected `zebra_chain::block::height::Height`, found `zebra_chain::block::Height`
    |                               |
    |                               arguments to this enum variant are incorrect
    |
note: there are multiple different versions of crate `zebra_chain` in the dependency graph
   --> /Users/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/zebra-chain-4.0.0/src/block/height.rs:28:1
    |
 28 | pub struct Height(pub u32);
    | ^^^^^^^^^^^^^^^^^ this is the expected type
    |
   ::: /Users/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/zebra-chain-3.1.0/src/block/height.rs:28:1
    |
 28 | pub struct Height(pub u32);
    | ----------------- this is the found type
    = help: you can use `cargo tree` to explore your dependency tree
note: tuple variant defined here
   --> /Users/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/zebra-state-3.1.2/src/request.rs:91:5
    |
 91 |     Height(block::Height),
    |     ^^^^^^

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `zaino-proto` (lib) due to 3 previous errors

What were you doing when the issue happened?

Migrating Zallet to latest Zaino revision (which includes a migration from zebra-* 2 to zebra-* 3).

Zebra logs

No response

Zebra Version

No response

Which operating systems does the issue happen on?

  • Linux
  • macOS
  • Windows
  • Other OS

OS details

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bugS-needs-triageStatus: A bug report needs triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions