From 0eb992ca1b4cae52de80ebf5bbebb2bbdb6d87ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Tue, 28 May 2024 14:23:18 +0300 Subject: [PATCH 1/2] Prepare v7 release, with Rust = nightly-2024-05-22. --- .github/workflows/tests.yml | 2 +- Dockerfile | 10 ++--- README.md | 15 ++----- integration_tests/previous_builds.py | 44 +++++++------------ integration_tests/shared.py | 8 ++++ .../build_metadata.py | 4 -- 6 files changed, 32 insertions(+), 51 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7bccd73..c82d1ac 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,7 +29,7 @@ jobs: export PYTHONPATH=. pytest . python ./integration_tests/test_project_folder_and_packaged_src_are_equivalent.py - python ./integration_tests/test_previous_builds_are_reproducible.py --selected-builds "a.1" "a.2" "a.3" "a.4" + python ./integration_tests/test_previous_builds_are_reproducible.py --selected-builds "a.1" "a.2" "a.3" - name: Save artifacts uses: actions/upload-artifact@v3 diff --git a/Dockerfile b/Dockerfile index a7b0542..bb3fd1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,11 @@ FROM ubuntu:22.04 # Constants -ARG BUILDER_NAME="multiversx/sdk-rust-contract-builder:v6.1.2" -ARG VERSION_RUST="nightly-2023-12-11" +ARG BUILDER_NAME="multiversx/sdk-rust-contract-builder:v7.0.0" +ARG VERSION_RUST="nightly-2024-05-22" ARG VERSION_BINARYEN="version_112" ARG DOWNLOAD_URL_BINARYEN="https://github.com/WebAssembly/binaryen/releases/download/${VERSION_BINARYEN}/binaryen-${VERSION_BINARYEN}-x86_64-linux.tar.gz" -ARG VERSION_WABT="1.0.27-1" -ARG VERSION_SC_META="0.43.3" +ARG VERSION_SC_META="0.50.3" ARG TARGETPLATFORM # Install system dependencies @@ -15,7 +14,6 @@ RUN apt-get update --fix-missing && apt-get install -y \ build-essential \ git \ python3.11 python-is-python3 python3-pip \ - wabt=${VERSION_WABT} \ pkg-config \ libssl-dev @@ -51,7 +49,6 @@ ENV PYTHONPATH=/ ENV BUILD_METADATA_BUILDER_NAME=${BUILDER_NAME} ENV BUILD_METADATA_VERSION_RUST=${VERSION_RUST} ENV BUILD_METADATA_VERSION_BINARYEN=${VERSION_BINARYEN} -ENV BUILD_METADATA_VERSION_WABT=${VERSION_WABT} ENV BUILD_METADATA_VERSION_SC_META=${VERSION_SC_META} ENV BUILD_METADATA_TARGETPLATFORM=${TARGETPLATFORM} @@ -66,5 +63,4 @@ ENTRYPOINT ["python", "/multiversx_sdk_rust_contract_builder/main.py", \ LABEL frozen="yes" LABEL rust=${VERSION_RUST} LABEL wasm-opt-binaryen=${VERSION_BINARYEN} -LABEL wabt=${VERSION_WABT} LABEL sc_meta=${VERSION_SC_META} diff --git a/README.md b/README.md index 276a29a..ac15d91 100644 --- a/README.md +++ b/README.md @@ -4,26 +4,17 @@ Docker image (and wrappers) for reproducible contract builds (Rust). See [docs.m ## Build the Docker image -We use `docker buildx` to build the image: - ``` -docker buildx build --network host --output type=docker . -t sdk-rust-contract-builder:next -f ./Dockerfile +docker build --network host . -t sdk-rust-contract-builder:next -f ./Dockerfile ``` Maintainers can publish the image as follows: ``` -docker buildx create --name multiarch --use - -docker buildx build --network host --push --platform=linux/amd64 . -t multiversx/sdk-rust-contract-builder:next -f ./Dockerfile - -docker buildx rm multiarch +docker build --network host . -t multiversx/sdk-rust-contract-builder:next -f ./Dockerfile +docker push multiversx/sdk-rust-contract-builder:next ``` -For the above to work properly, make sure to install `tonistiigi/binfmt` beforehand. Please follow the official Docker documentation [here](https://docs.docker.com/build/building/multi-platform/). - -Note that **we only build and publish the image for `linux/amd64`**. We recommend against using a `linux/arm64` image for performing reproducible contract builds. This is because a WASM binary generated on a `linux/arm64` image _might_ differ (at the bytecode level) from one generated on the recommended `linux/amd64` image - probably due to distinct (unfortunate) bytecode-emitting logic in the Rust compiler. - ## Build contract using the wrapper If you are using a Mac with ARM64, we _recommend_ setting the following variable beforehand (contract builds will be slower, but this eliminates the risk of not being able to reproduce the build on Linux): diff --git a/integration_tests/previous_builds.py b/integration_tests/previous_builds.py index 90f09b8..e320629 100644 --- a/integration_tests/previous_builds.py +++ b/integration_tests/previous_builds.py @@ -22,32 +22,6 @@ def __init__(self, name: str, previous_builds: List[PreviousBuild] = [ PreviousBuild( name="a.1", - project_archive_url="https://github.com/multiversx/mx-exchange-sc/archive/refs/heads/reproducible-v2.1.1-staking-upgrade.zip", - project_relative_path_in_archive="mx-exchange-sc-reproducible-v2.1.1-staking-upgrade", - packaged_src_url=None, - contract_name=None, - expected_code_hashes={ - "farm-staking": "6dc7c587b2cc4b177a192b709c092f3752b3dcf9ce1b484e69fe64dc333a9e0a", - "farm": "931ca233826ff9dacd889967365db1cde9ed8402eb553de2a3b9d58b6ff1098d", - "factory": "df06465b651594605466e817bfe9d8d7c68eef0f87df4a8d3266bcfb1bef6d83", - "pair": "f3f08ebd758fada871c113c18017d9761f157d00b19c4d3beaba530e6c53afc2", - "energy-factory": "241600c055df605cafd85b75d40b21316a6b35713485201b156d695b23c66a2f" - }, - docker_image="multiversx/sdk-rust-contract-builder:v4.2.1" - ), - PreviousBuild( - name="a.2", - project_archive_url="https://github.com/multiversx/mx-metabonding-sc/archive/refs/heads/reproducible-v1.1.1.zip", - project_relative_path_in_archive="mx-metabonding-sc-reproducible-v1.1.1", - packaged_src_url=None, - contract_name=None, - expected_code_hashes={ - "metabonding": "897b19e1990f7c487c99c12f50722febe1ee4468bcd3a7405641966dfff2791d" - }, - docker_image="multiversx/sdk-rust-contract-builder:v4.2.1" - ), - PreviousBuild( - name="a.3", project_archive_url="https://github.com/multiversx/mx-contracts-rs/archive/refs/tags/v0.45.2.1-reproducible.zip", project_relative_path_in_archive="mx-contracts-rs-0.45.2.1-reproducible", packaged_src_url=None, @@ -63,7 +37,7 @@ def __init__(self, name: str, docker_image="multiversx/sdk-rust-contract-builder:v5.4.1" ), PreviousBuild( - name="a.4", + name="a.2", project_archive_url="https://github.com/multiversx/mx-contracts-rs/archive/refs/tags/v0.45.2.1-reproducible.zip", project_relative_path_in_archive="mx-contracts-rs-0.45.2.1-reproducible", packaged_src_url=None, @@ -76,6 +50,22 @@ def __init__(self, name: str, "lottery-esdt": "a54bd4278b12cc93fedd6ca0addf6aad4043528c33e54ce43cf92d4d2dd755ee", "ping-pong-egld": "8b107da10aef0d9610a939c4ca07c666674c465d0266fb28d5f981861f084f62" }, + docker_image="multiversx/sdk-rust-contract-builder:v6.1.2" + ), + PreviousBuild( + name="a.3", + project_archive_url="https://github.com/multiversx/mx-contracts-rs/archive/9da0c4abe7aba6ae109c167be655b2ce80ca4b08.zip", + project_relative_path_in_archive="mx-contracts-rs-9da0c4abe7aba6ae109c167be655b2ce80ca4b08", + packaged_src_url=None, + contract_name=None, + expected_code_hashes={ + "adder": "384b680df7a95ebceca02ffb3e760a2fc288dea1b802685ef15df22ae88ba15b", + "multisig": "30cc24a9a8f271f27db44952a54c311ca54487f5a19533806ad213312a055ff8", + "multisig-full": "b4b9e11213e616564b2b4bd60eeee1bae295f51b14736f24fce64759e7d82295", + "multisig-view": "429a43e843a098dd3d8e5e882e0b0708a91e53ed41949017f4b732020fcb033d", + "lottery-esdt": "f53b8d157010a35e344d3c2b82606d3c38ad183faeac37e126c32d89349d3e8d", + "ping-pong-egld": "a3b146ec3d7d23101f3ab35e9a5e3d967e71709f20263d018a6af3b117cf28bf" + }, docker_image="sdk-rust-contract-builder:next" ), ] diff --git a/integration_tests/shared.py b/integration_tests/shared.py index c46ec76..b3445bf 100644 --- a/integration_tests/shared.py +++ b/integration_tests/shared.py @@ -36,6 +36,14 @@ def run_docker( image: str, output_folder: Path, ) -> Tuple[int, str, str]: + print(f"""Running docker... + project_path: {project_path}, + packaged_src_path: {packaged_src_path}, + contract_name: {contract_name}, + image: {image}, + output_folder: {output_folder} +""") + CARGO_TARGET_DIR.mkdir(parents=True, exist_ok=True) RUST_REGISTRY.mkdir(parents=True, exist_ok=True) RUST_GIT.mkdir(parents=True, exist_ok=True) diff --git a/multiversx_sdk_rust_contract_builder/build_metadata.py b/multiversx_sdk_rust_contract_builder/build_metadata.py index 4ca7ad7..f526fe9 100644 --- a/multiversx_sdk_rust_contract_builder/build_metadata.py +++ b/multiversx_sdk_rust_contract_builder/build_metadata.py @@ -8,14 +8,12 @@ def __init__( builder_name: str, version_rust: str, version_binaryen: str, - version_wabt: str, version_sc_meta: str, target_platform: str, ): self.builder_name = builder_name self.version_rust = version_rust self.version_binaryen = version_binaryen - self.version_wabt = version_wabt self.version_sc_meta = version_sc_meta self.target_platform = target_platform @@ -25,7 +23,6 @@ def from_env(cls) -> 'BuildMetadata': builder_name=os.environ["BUILD_METADATA_BUILDER_NAME"], version_rust=os.environ["BUILD_METADATA_VERSION_RUST"], version_binaryen=os.environ["BUILD_METADATA_VERSION_BINARYEN"], - version_wabt=os.environ["BUILD_METADATA_VERSION_WABT"], version_sc_meta=os.environ["BUILD_METADATA_VERSION_SC_META"], target_platform=os.environ["BUILD_METADATA_TARGETPLATFORM"], ) @@ -35,7 +32,6 @@ def to_dict(self) -> Dict[str, str]: "builderName": self.builder_name, "versionRust": self.version_rust, "versionBinaryen": self.version_binaryen, - "versionWabt": self.version_wabt, "versionScTool": self.version_sc_meta, "targetPlatform": self.target_platform, } From fa37b99aa9a9028b6d66697d394dcc7dc2f44b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Tue, 28 May 2024 14:30:37 +0300 Subject: [PATCH 2/2] Fix tests. --- .../test_project_folder_and_packaged_src_are_equivalent.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/integration_tests/test_project_folder_and_packaged_src_are_equivalent.py b/integration_tests/test_project_folder_and_packaged_src_are_equivalent.py index 27ea9fa..9abdbbc 100644 --- a/integration_tests/test_project_folder_and_packaged_src_are_equivalent.py +++ b/integration_tests/test_project_folder_and_packaged_src_are_equivalent.py @@ -9,9 +9,9 @@ def main(cli_args: List[str]): repository_url = "https://github.com/multiversx/mx-contracts-rs" - tag = "0.45.2.1-reproducible" - archve_subfolder = f"mx-contracts-rs-{tag}" - project_path = download_project_repository(f"{repository_url}/archive/refs/tags/v{tag}.zip", archve_subfolder) + commit = "9da0c4abe7aba6ae109c167be655b2ce80ca4b08" + archve_subfolder = f"mx-contracts-rs-{commit}" + project_path = download_project_repository(f"{repository_url}/archive/{commit}.zip", archve_subfolder) project_path = project_path / archve_subfolder check_project_folder_and_packaged_src_are_equivalent(