paritytech / srtool

A fork of chevdor's srtool
MIT License
64 stars 18 forks source link

srtool is not deterministic generating images #39

Closed crystalin closed 2 years ago

crystalin commented 2 years ago

Something must have changed in substrate recently I suppose that is breaking the deterministic part of srtool. Ex:

git clone https://github.com/purestake/moonbeam moonbeam-1201
cd moonbeam-1201
git checkout runtime-1201
docker run -i --rm -e PACKAGE=moonbase-runtime -e RUNTIME_DIR="runtime/moonbase/" -v $(pwd):/build paritytech/srtool:1.57.0  build --app --json -cM

Will generate

{
    "gen": "srtool v0.9.19",
    "src": "git",
    "version": "0.8.4",
    "commit": "7b2778fb108741790a57bca55cf4f57d60e52333",
    "tag": "runtime-1201",
    "branch": "HEAD",
    "rustc": "rustc 1.57.0 (f1edd0429 2021-11-29)",
    "pkg": "moonbase-runtime",
    "tmsp": "2022-02-08T22:58:25Z",
    "size": "4868948",
    "prop": "0xd2efbe451b04b4fbe425880ef72b17232fccd4b1901edfb60b7064c18aa63c71",
    "ipfs": "QmRySxNoZqU4TP8vhJVtrwkTpcaXJ9f1DghB7TAZex4uBn",
    "sha256": "0xc918c2371c2a71da7b2875ef0258df83c48f4b94ebb137b475690d4931df5abd",
    "wasm": "runtime/moonbase//target/srtool/release/wbuild/moonbase-runtime/moonbase_runtime.compact.wasm",
    "info":
    {
        "generator":
        {
            "name": "srtool",
            "version": "0.9.19"
        },
        "src": "git",
        "version": "0.8.4",
        "git":
        {
            "commit": "7b2778fb108741790a57bca55cf4f57d60e52333",
            "tag": "runtime-1201",
            "branch": "HEAD"
        },
        "rustc": "rustc 1.57.0 (f1edd0429 2021-11-29)",
        "pkg": "moonbase-runtime",
        "profile": "release"
    },
    "context":
    {
        "package": "moonbase-runtime",
        "runtime_dir": "runtime/moonbase/",
        "docker":
        {
            "image": "paritytech/srtool",
            "tag": "1.57.0"
        },
        "profile": "release"
    },
    "runtimes":
    {
        "compact":
        {
            "tmsp": "2022-02-08T22:57:16Z",
            "size": "4868948",
            "prop": "0xd2efbe451b04b4fbe425880ef72b17232fccd4b1901edfb60b7064c18aa63c71",
            "blake2_256": "0xcd6dea94038d1f49424b8eb97d8ee73fbe9f386fd631263c5600a95f1f759f8d",
            "ipfs": "QmRySxNoZqU4TP8vhJVtrwkTpcaXJ9f1DghB7TAZex4uBn",
            "sha256": "0xc918c2371c2a71da7b2875ef0258df83c48f4b94ebb137b475690d4931df5abd",
            "wasm": "runtime/moonbase//target/srtool/release/wbuild/moonbase-runtime/moonbase_runtime.compact.wasm",
            "subwasm":
            {
                "size": 4868948,
                "compression":
                {
                    "size_compressed": 4868948,
                    "size_decompressed": 4868948,
                    "compressed": false
                },
                "reserved_meta":
                [
                    109,
                    101,
                    116,
                    97
                ],
                "reserved_meta_valid": true,
                "metadata_version": 14,
                "core_version": "moonbase-1201 (moonbase-0.tx2.au3)",
                "proposal_hash": "0xd2efbe451b04b4fbe425880ef72b17232fccd4b1901edfb60b7064c18aa63c71",
                "parachain_authorize_upgrade_hash": "0x38c11e736fe688199d0bab09f9771753a90ad841dee398a959079a72af63b02b",
                "ipfs_hash": "QmRySxNoZqU4TP8vhJVtrwkTpcaXJ9f1DghB7TAZex4uBn",
                "blake2_256": "0xcd6dea94038d1f49424b8eb97d8ee73fbe9f386fd631263c5600a95f1f759f8d"
            }
        },
        "compressed":
        {
            "tmsp": "2022-02-08T22:57:16Z",
            "size": "1163967",
            "prop": "0xd4833c0dcfa48a7687f7ce8aef4522f1cf0155c9c4a4836a8dbc56262659660d",
            "blake2_256": "0x3f0c03f1c101299fd1a3549a77320836e6200008641130e69d560c546a5c4b62",
            "ipfs": "QmZZxUHKNGA5De1U5w7GStdUCKefxuxzQwJfGHBpjUtNhU",
            "sha256": "0x05f7598b6d560a1a90f79b4827f331643bc0980fc6d70da2f18e3dba247c0075",
            "wasm": "runtime/moonbase//target/srtool/release/wbuild/moonbase-runtime/moonbase_runtime.compact.compressed.wasm",
            "subwasm":
            {
                "size": 1163967,
                "compression":
                {
                    "size_compressed": 1163967,
                    "size_decompressed": 4868948,
                    "compressed": true
                },
                "reserved_meta":
                [
                    109,
                    101,
                    116,
                    97
                ],
                "reserved_meta_valid": true,
                "metadata_version": 14,
                "core_version": "moonbase-1201 (moonbase-0.tx2.au3)",
                "proposal_hash": "0xd4833c0dcfa48a7687f7ce8aef4522f1cf0155c9c4a4836a8dbc56262659660d",
                "parachain_authorize_upgrade_hash": "0x25cf4417319a3d74fe658c33d837468366fe562901381e41b120be2f208cabcf",
                "ipfs_hash": "QmZZxUHKNGA5De1U5w7GStdUCKefxuxzQwJfGHBpjUtNhU",
                "blake2_256": "0x3f0c03f1c101299fd1a3549a77320836e6200008641130e69d560c546a5c4b62"
            }
        }
    }
}
{
    "gen": "srtool v0.9.19",
    "src": "git",
    "version": "0.8.4",
    "commit": "7b2778fb108741790a57bca55cf4f57d60e52333",
    "tag": "runtime-1201",
    "branch": "HEAD",
    "rustc": "rustc 1.57.0 (f1edd0429 2021-11-29)",
    "pkg": "moonbase-runtime",
    "tmsp": "2022-02-08T23:05:11Z",
    "size": "4868948",
    "prop": "0xeeaedc0446a8cef6741f8d4b23f9c6453da313af961f6ffae3b50344f131cf45",
    "ipfs": "QmWB4aC3ht2dyqRo1JdibPMqkFhVzKnhg19dwVxkbLJffC",
    "sha256": "0xf07a00615833f57646696b06db485ecb5610233f36e0eca7a07a84e23f542572",
    "wasm": "runtime/moonbase//target/srtool/release/wbuild/moonbase-runtime/moonbase_runtime.compact.wasm",
    "info":
    {
        "generator":
        {
            "name": "srtool",
            "version": "0.9.19"
        },
        "src": "git",
        "version": "0.8.4",
        "git":
        {
            "commit": "7b2778fb108741790a57bca55cf4f57d60e52333",
            "tag": "runtime-1201",
            "branch": "HEAD"
        },
        "rustc": "rustc 1.57.0 (f1edd0429 2021-11-29)",
        "pkg": "moonbase-runtime",
        "profile": "release"
    },
    "context":
    {
        "package": "moonbase-runtime",
        "runtime_dir": "runtime/moonbase/",
        "docker":
        {
            "image": "paritytech/srtool",
            "tag": "1.57.0"
        },
        "profile": "release"
    },
    "runtimes":
    {
        "compact":
        {
            "tmsp": "2022-02-08T23:03:33Z",
            "size": "4868948",
            "prop": "0xeeaedc0446a8cef6741f8d4b23f9c6453da313af961f6ffae3b50344f131cf45",
            "blake2_256": "0x5cbf13ea7d49a0846edfecedf5b5f3daf1b4d8856d2fc2f947b436f80ae5b0bf",
            "ipfs": "QmWB4aC3ht2dyqRo1JdibPMqkFhVzKnhg19dwVxkbLJffC",
            "sha256": "0xf07a00615833f57646696b06db485ecb5610233f36e0eca7a07a84e23f542572",
            "wasm": "runtime/moonbase//target/srtool/release/wbuild/moonbase-runtime/moonbase_runtime.compact.wasm",
            "subwasm":
            {
                "size": 4868948,
                "compression":
                {
                    "size_compressed": 4868948,
                    "size_decompressed": 4868948,
                    "compressed": false
                },
                "reserved_meta":
                [
                    109,
                    101,
                    116,
                    97
                ],
                "reserved_meta_valid": true,
                "metadata_version": 14,
                "core_version": "moonbase-1201 (moonbase-0.tx2.au3)",
                "proposal_hash": "0xeeaedc0446a8cef6741f8d4b23f9c6453da313af961f6ffae3b50344f131cf45",
                "parachain_authorize_upgrade_hash": "0xa45ae258f95756341db6c382a1a7be0285bc1acb57428fc4fc4341f79be0ef06",
                "ipfs_hash": "QmWB4aC3ht2dyqRo1JdibPMqkFhVzKnhg19dwVxkbLJffC",
                "blake2_256": "0x5cbf13ea7d49a0846edfecedf5b5f3daf1b4d8856d2fc2f947b436f80ae5b0bf"
            }
        },
        "compressed":
        {
            "tmsp": "2022-02-08T23:03:33Z",
            "size": "1163968",
            "prop": "0xb9e8f87cbb67a6960c8845a0eae78911881fff3ae351ec55f255e62d566f6e5a",
            "blake2_256": "0xd053796d6e6ad668dcf321f8106ab4499ca60d7299205a8cc90e53ea1d897824",
            "ipfs": "QmVR5Cr39rjnWGiUkrMp1maS3ZgkfSwxEFtXkxM6Qn2caz",
            "sha256": "0xfd257dd5d222bcf4fec367874ca97a14318885f4f9dd26d04761f24c41fa7cf6",
            "wasm": "runtime/moonbase//target/srtool/release/wbuild/moonbase-runtime/moonbase_runtime.compact.compressed.wasm",
            "subwasm":
            {
                "size": 1163968,
                "compression":
                {
                    "size_compressed": 1163968,
                    "size_decompressed": 4868948,
                    "compressed": true
                },
                "reserved_meta":
                [
                    109,
                    101,
                    116,
                    97
                ],
                "reserved_meta_valid": true,
                "metadata_version": 14,
                "core_version": "moonbase-1201 (moonbase-0.tx2.au3)",
                "proposal_hash": "0xb9e8f87cbb67a6960c8845a0eae78911881fff3ae351ec55f255e62d566f6e5a",
                "parachain_authorize_upgrade_hash": "0xdb0927f671337fd52049041c939b3fb468eba330863999c07834e7d1c6c4021f",
                "ipfs_hash": "QmVR5Cr39rjnWGiUkrMp1maS3ZgkfSwxEFtXkxM6Qn2caz",
                "blake2_256": "0xd053796d6e6ad668dcf321f8106ab4499ca60d7299205a8cc90e53ea1d897824"
            }
        }
    }
}
bkchr commented 2 years ago

@crystalin if that is failing reproducible. You will need to write some script that goes back on your master until the tool works again. If you have his this point, you know which commit to look at. I would not assume that something broke there. In Substrate & Polkadot we have CI jobs running that ensure that two build runs produce the same wasm binaries. Before we had achieved this, we also needed to fix some stuff.

crystalin commented 2 years ago

@bkchr Thanks, I'm going to track the regression and ping you if I can't identify the reason

crystalin commented 2 years ago

@bkchr I confirm it is when upgrading from v0.9.12 to v0.9.13 I'm looking at the PRs, but if you have any idea where that could be

bkchr commented 2 years ago

You can just write a simple script to use with git bisect. Then the computer can do this work for you 😬

notlesh commented 2 years ago

This was caused by using the crate gensym to generate some module names in our codebase, fixed here:

https://github.com/PureStake/moonbeam/pull/1328

I think this can be closed.

bkchr commented 2 years ago

Nice! Ty for reporting back. If you want to prevent this, you could copy the reproducible wasm build CI check from Substrate :)