@@ -5,6 +5,7 @@ contract_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55repository_root=" $( cd " $contract_dir /../.." && pwd) "
66cargo_home_dir=" ${CARGO_HOME:- ${HOME} / .cargo} "
77target_dir=" ${CARGO_TARGET_DIR:- $contract_dir / target} "
8+ hash_target_dir=" ${CELLSCRIPT_HASH_TARGET_DIR:- $repository_root / target} "
89rust_sysroot=" $( rustc --print sysroot) "
910host_triple=" $( rustc -vV | awk ' /^host: / { print $2 }' ) "
1011rust_objcopy=" $rust_sysroot /lib/rustlib/$host_triple /bin/rust-objcopy"
@@ -34,17 +35,26 @@ env -u RUSTFLAGS \
3435 --bin cellscript-registry-type-script
3536
3637artifact=" $target_dir /riscv64imac-unknown-none-elf/release/cellscript-registry-type-script"
37- stripped_artifact=" $artifact .stripped"
38- " $rust_objcopy " --strip-all " $artifact " " $stripped_artifact "
39- mv " $stripped_artifact " " $artifact "
40-
41- sha256_hash=" $( shasum -a 256 " $artifact " | awk ' { print $1 }' ) "
42- artifact_bytes=" $( wc -c < " $artifact " | tr -d ' ' ) "
43- ckb_hash_json=" $( CARGO_TARGET_DIR=" $repository_root /target" cargo run --quiet --locked \
44- --manifest-path " $repository_root /Cargo.toml" \
45- -p cellscript --bin cellc -- ckb-hash --file " $artifact " --json) "
46- ckb_data_hash=" $( printf ' %s\n' " $ckb_hash_json " | sed -n ' s/.*"hash": "\([0-9a-f]*\)".*/\1/p' ) "
38+ host_artifact=" $artifact .$host_triple .stripped"
39+ " $rust_objcopy " --strip-all " $artifact " " $host_artifact "
40+
4741release_manifest=" $contract_dir /release-manifest.json"
42+ canonical_relative_path=" $( sed -n ' s/.*"artifact": "\([^"]*\)".*/\1/p' " $release_manifest " ) "
43+ canonical_artifact=" $contract_dir /$canonical_relative_path "
44+ if [[ -z " $canonical_relative_path " || ! -f " $canonical_artifact " ]]; then
45+ printf ' canonical Registry Type Script artifact is missing: %s\n' " $canonical_artifact " >&2
46+ exit 1
47+ fi
48+
49+ sha256_hash=" $( shasum -a 256 " $canonical_artifact " | awk ' { print $1 }' ) "
50+ artifact_bytes=" $( wc -c < " $canonical_artifact " | tr -d ' ' ) "
51+ ckb_data_hash=" $( CARGO_TARGET_DIR=" $hash_target_dir " cargo run --quiet --locked \
52+ --manifest-path " $contract_dir /Cargo.toml" \
53+ --features hash-tool \
54+ --bin cellscript-registry-type-script-hash \
55+ -- " $canonical_artifact " ) "
56+ ckb_hash_json=" $( printf ' {\n "algorithm": "blake2b-256",\n "hash": "%s",\n "input_bytes": %s,\n "personalization": "ckb-default-hash",\n "status": "ok"\n}' \
57+ " $ckb_data_hash " " $artifact_bytes " ) "
4858expected_sha256=" $( sed -n ' s/.*"sha256": "\([0-9a-f]*\)".*/\1/p' " $release_manifest " ) "
4959expected_artifact_bytes=" $( sed -n ' s/.*"artifact_bytes": \([0-9]*\).*/\1/p' " $release_manifest " ) "
5060expected_ckb_data_hash=" $( sed -n ' s/.*"ckb_data_hash": "0x\([0-9a-f]*\)".*/\1/p' " $release_manifest " ) "
@@ -55,6 +65,22 @@ if [[ "$artifact_bytes" != "$expected_artifact_bytes" || "$sha256_hash" != "$exp
5565 exit 1
5666fi
5767
68+ host_sha256=" $( shasum -a 256 " $host_artifact " | awk ' { print $1 }' ) "
69+ if [[ " $host_triple " == " x86_64-unknown-linux-gnu" ]]; then
70+ if ! cmp -s " $host_artifact " " $canonical_artifact " ; then
71+ printf ' canonical x86_64 Linux rebuild does not match the tracked Registry Type Script artifact\n' >&2
72+ printf ' expected sha256=%s actual sha256=%s\n' " $sha256_hash " " $host_sha256 " >&2
73+ exit 1
74+ fi
75+ printf ' canonical_rebuild=matched\n'
76+ else
77+ printf ' canonical_rebuild=not_claimed host=%s host_sha256=%s\n' " $host_triple " " $host_sha256 "
78+ fi
79+
80+ # Downstream tools always execute the exact tracked deployable bytes. A
81+ # non-canonical host build is retained beside this path for inspection.
82+ cp " $canonical_artifact " " $artifact "
83+
5884printf ' artifact=%s\n' " $artifact "
5985printf ' artifact_bytes=%s\n' " $artifact_bytes "
6086printf ' sha256=%s\n' " $sha256_hash "
0 commit comments