Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ordering of StrictValue fields relaxed #7

Open
zoedberg opened this issue Apr 17, 2023 · 1 comment
Open

Make ordering of StrictValue fields relaxed #7

zoedberg opened this issue Apr 17, 2023 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@zoedberg
Copy link

I'm trying to issue an RGB20 asset but encountering this error:

thread 'main' panicked at 'bug in business logic of type system. Details:
Union(
    Ord(
        0,
    ),
    Unit,
)
Tuple(
    UnnamedFields(
        Confined(
            [
                SemId(
                    Array<32>(5cd0c3c0db677e225d50c0cd55a38fd2a79d3a29d625e34f78dfd6166c3cb806),
                ),
            ],
        ),
    ),
)', /home/zoe/.cargo/registry/src/github.com-1ecc6299db9ec823/strict_types-1.0.0/src/value/encode.rs:180:23

As reported by the logs, the error comes from here. In rgb CLI the error comes from strict_serialize_type call.

I've managed to find the cause of the error, which is inverting order of Nominal keys in yaml file, for example:

globals:
  Nominal:
    details: ~
    name: USD Tether
    precision: 0
    ticker: USDT

doesn't work (throws the reported error) while this:

globals:
  Nominal:
    ticker: USDT
    name: USD Tether
    details: ~
    precision: 0

works. @dr-orlovsky I don't know how to fix the issue but I hope I provided enough info to address it.

@dr-orlovsky
Copy link
Member

dr-orlovsky commented Apr 17, 2023

Yeah, this means that the ordering of the fields in a structure doesn't match the type requirement. Strict types are so strict and semantic that they see structures with the same fields but of different order as different types (since they would have different in-memory binary reprensentation, would produce different commitments etc).

I think what I need to do here is to:

  1. Make error message more easy to understand (what's wrong)
  2. Allow JSON data types to have a different field order and "make them straight" inside TypeSystem::typify procedure which converts non-typed StrictVal into a well-typed TypedVal.

@dr-orlovsky dr-orlovsky self-assigned this Apr 17, 2023
@dr-orlovsky dr-orlovsky added documentation Improvements or additions to documentation enhancement New feature or request labels Apr 17, 2023
@dr-orlovsky dr-orlovsky changed the title bug in business logic of type system Make ordeting of StrictValue fields relaxed May 26, 2023
@zoedberg zoedberg changed the title Make ordeting of StrictValue fields relaxed Make ordering of StrictValue fields relaxed Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants