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

Add input file SHA256 hash consts to Go/Rust generated code #89

Merged
merged 16 commits into from
Jun 18, 2022
Merged

Add input file SHA256 hash consts to Go/Rust generated code #89

merged 16 commits into from
Jun 18, 2022

Conversation

leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented Jun 15, 2022

What

Add input file SHA256 hash consts to Go/Rust generated code, injecting the following into the Stellar rs-stellar-xdr lib:

/// `XDR_FILES_SHA256` is a list of pairs of source files and their SHA256 hashes.
pub const XDR_FILES_SHA256: [(&str, &str); 6] = [
    (
        "xdr/curr/Stellar-SCP.x",
        "8f32b04d008f8bc33b8843d075e69837231a673691ee41d8b821ca229a6e802a",
    ),
    (
        "xdr/curr/Stellar-ledger-entries.x",
        "3aa135c309c2d67883f165961739b4940c90df59240d8aeef55deced8d7708b5",
    ),
    (
        "xdr/curr/Stellar-ledger.x",
        "ef746ead6bb8ef9541599796804d672f2994e2599a6dc595ece099e166b49f10",
    ),
    (
        "xdr/curr/Stellar-overlay.x",
        "8ecbc36d2a43103499a6416572c7cd7b4fd7638d1a2af515b81b463ce6909c51",
    ),
    (
        "xdr/curr/Stellar-transaction.x",
        "45fdeb428e68d6b07e3e3157b6404567e0efb712c9d4c90a61a1035854c32b90",
    ),
    (
        "xdr/curr/Stellar-types.x",
        "60b7588e573f5e5518766eb5e6b6ea42f0e53144663cbe557e485cceb6306c85",
    ),
];

Why

@graydon pointed out that in applications or systems like stellar-core that import multiple XDR generated libraries it is really easy to accidentally import libraries that were generated from different sources. This mistake has occurred once and could have reasonably significant consequences, so building in meta information that applications like stellar-core can validate seems worthwhile.

Close #88

Known Limitations

This change only adds them to the Go and Rust libs.

@leighmcculloch leighmcculloch marked this pull request as draft June 15, 2022 01:47
@leighmcculloch leighmcculloch marked this pull request as ready for review June 15, 2022 02:00
Copy link
Contributor

@graydon graydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should do this -- I'm writing the core-side stuff presently.

@leighmcculloch
Copy link
Member Author

leighmcculloch commented Jun 17, 2022

TODO:

  • Include the file name in the code, not just in the comment.

@leighmcculloch
Copy link
Member Author

@graydon I've updated it to include the name of the file as you requested:

/// `XDR_FILES_SHA256` is a list of pairs of source files and their SHA256 hashes.
pub const XDR_FILES_SHA256: [(&str, &str); 6] = [
    (
        "xdr/curr/Stellar-SCP.x",
        "8f32b04d008f8bc33b8843d075e69837231a673691ee41d8b821ca229a6e802a",
    ),
    (
        "xdr/curr/Stellar-ledger-entries.x",
        "3aa135c309c2d67883f165961739b4940c90df59240d8aeef55deced8d7708b5",
    ),
    (
        "xdr/curr/Stellar-ledger.x",
        "ef746ead6bb8ef9541599796804d672f2994e2599a6dc595ece099e166b49f10",
    ),
    (
        "xdr/curr/Stellar-overlay.x",
        "8ecbc36d2a43103499a6416572c7cd7b4fd7638d1a2af515b81b463ce6909c51",
    ),
    (
        "xdr/curr/Stellar-transaction.x",
        "45fdeb428e68d6b07e3e3157b6404567e0efb712c9d4c90a61a1035854c32b90",
    ),
    (
        "xdr/curr/Stellar-types.x",
        "60b7588e573f5e5518766eb5e6b6ea42f0e53144663cbe557e485cceb6306c85",
    ),
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add hash of each .x file as constant in resulting XDR
2 participants