Skip to content

Commit

Permalink
Merge pull request #65 from multiversx/prepare-v7
Browse files Browse the repository at this point in the history
Prepare v7 release, with Rust "nightly-2024-05-22"
  • Loading branch information
andreibancioiu authored May 28, 2024
2 parents 3181fe0 + fa37b99 commit 69bd20a
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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}

Expand All @@ -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}
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
44 changes: 17 additions & 27 deletions integration_tests/previous_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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"
),
]
8 changes: 8 additions & 0 deletions integration_tests/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 0 additions & 4 deletions multiversx_sdk_rust_contract_builder/build_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"],
)
Expand All @@ -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,
}

0 comments on commit 69bd20a

Please sign in to comment.