Skip to content

Commit

Permalink
chore: readme udpated and test-bridge's scarb version updated
Browse files Browse the repository at this point in the history
  • Loading branch information
mohiiit committed Dec 20, 2024
1 parent c06bff2 commit 425894f
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-bridge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- uses: rui314/setup-mold@v1
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.8.2"
scarb-version: "2.8.4"
- uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
Expand Down
89 changes: 76 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
.PHONY: setup setup-linux ensure-asdf starkgate-contracts-latest braavos-account-cairo argent-contracts-starknet artifacts starkgate-contracts-legacy
# =============================================================================
# Starknet Contract Build System
# =============================================================================
# This Makefile manages the build process for various Starknet contracts including
# StarkGate, Braavos, and Argent. It handles both legacy and latest versions,
# supporting multiple architectures (amd64/arm64).

.PHONY: setup setup-linux ensure-asdf starkgate-contracts-latest braavos-account-cairo argent-contracts-starknet artifacts starkgate-contracts-legacy

# =============================================================================
# Configuration Variables
# =============================================================================

# Contract version tags and commit hashes
STARKGATE_CONTRACTS_VERSION_TAG="v2.0.1"
ARGENT_CONTRACTS_COMMIT_HASH="1352198956f36fb35fa544c4e46a3507a3ec20e3"
BRAAVOS_CONTRACTS_COMMIT_HASH="12b82a87b93ba9bfdf2cbbde2566437df2e0c6c8"

# Environment setup
SHELL := /bin/bash
HOME_DIR := $(HOME)

# Virtual environment paths
VENV_DIR := $(PWD)/venv
VENV_BIN := $(VENV_DIR)/bin
PYTHON := $(VENV_BIN)/python
PIP := $(VENV_BIN)/pip
SOLC_SELECT := $(VENV_BIN)/solc-select
SOLC := $(VENV_BIN)/solc
# Add a target to create and setup virtual environment

# =============================================================================
# Virtual Environment Setup
# =============================================================================

# Target: setup-venv
# Creates and configures Python virtual environment with required dependencies
setup-venv:
python3 -m venv $(VENV_DIR)
$(PIP) install --upgrade pip
Expand All @@ -22,6 +42,13 @@ setup-venv:
$(SOLC_SELECT) use 0.8.24
$(VENV_BIN)/solc --version

# =============================================================================
# ASDF Version Manager Setup
# =============================================================================

# Target: ensure-asdf
# Installs and configures ASDF version manager for Scarb
# Handles both macOS (via Homebrew) and Linux installations
ensure-asdf:
@if [ "$$(uname)" = "Darwin" ] && command -v brew >/dev/null 2>&1; then \
BREW_ASDF_PATH="$$(brew --prefix asdf)/libexec/asdf.sh"; \
Expand All @@ -35,28 +62,48 @@ ensure-asdf:
fi; \
else \
if [ ! -f "$(HOME_DIR)/.asdf/asdf.sh" ]; then \
echo "ASDF not found in $(HOME_DIR)/.asdf/"; \
echo "Please install ASDF first:"; \
echo "git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.1"; \
exit 1; \
echo "Cleaning up existing ASDF installation..."; \
rm -rf $(HOME_DIR)/.asdf; \
echo "Installing ASDF..."; \
git clone https://github.com/asdf-vm/asdf.git $(HOME_DIR)/.asdf --branch v0.14.1; \
echo '. "$(HOME_DIR)/.asdf/asdf.sh"' >> $(HOME_DIR)/.bashrc; \
fi; \
. "$(HOME_DIR)/.asdf/asdf.sh" && \
if ! asdf plugin list | grep -q scarb; then \
asdf plugin add scarb https://github.com/software-mansion/asdf-scarb.git; \
if [ -f "$(HOME_DIR)/.asdf/asdf.sh" ]; then \
. "$(HOME_DIR)/.asdf/asdf.sh" && \
if ! asdf plugin list | grep -q scarb; then \
asdf plugin add scarb https://github.com/software-mansion/asdf-scarb.git; \
fi; \
else \
echo "Failed to install ASDF properly"; \
exit 1; \
fi; \
fi

# Setup cairo for mac os
# =============================================================================
# Cairo Environment Setup
# =============================================================================

# Target: setup
# Sets up Cairo environment for macOS (arm64/amd64)
setup:
mkdir -p .cairo
cd .cairo && \
wget -c https://github.com/starkware-libs/cairo/releases/download/v2.3.0/release-aarch64-apple-darwin.tar -O - | tar -xz

# Target: setup-linux
# Sets up Cairo environment for Linux (x86_64)
setup-linux:
mkdir -p .cairo
cd .cairo && \
wget -c https://github.com/starkware-libs/cairo/releases/download/v2.3.0/release-x86_64-unknown-linux-musl.tar.gz -O - | tar -xz
wget -c https://github.com/starkware-libs/cairo/releases/download/v2.3.0/release-x86_64-unknown-linux-musl.tar.gz -O - | tar -xz

# =============================================================================
# Contract Building Targets
# =============================================================================

# Target: starkgate-contracts-latest
# Builds the latest version of StarkGate contracts
# Prerequisites: setup-venv
starkgate-contracts-latest: setup-venv
# Building L2 contracts
# =====================
Expand Down Expand Up @@ -102,6 +149,8 @@ starkgate-contracts-latest: setup-venv
cp lib/starkgate-contracts-latest/artifacts/StarknetEthBridge.json artifacts/upgrade-contracts/eth_bridge_upgraded.json
cp lib/starkgate-contracts-latest/artifacts/StarkgateUpgradeAssistExternalInitializer.json artifacts/upgrade-contracts/eic_eth_bridge.json

# Target: starkgate-contracts-legacy
# Builds legacy StarkGate contracts using Docker
starkgate-contracts-legacy:
# Building Contracts
rm -rf lib/starkgate-contracts-old/Dockerfile
Expand All @@ -116,7 +165,9 @@ starkgate-contracts-legacy:
cp ./lib/starkgate-contracts-old/starkgate-artifacts/starkware/starknet/std_contracts/upgradability_proxy/proxy.json ./artifacts/proxy_starkgate.json
cp ./lib/starkgate-contracts-old/starkgate-artifacts/starkware/starknet/std_contracts/ERC20/ERC20.json ./artifacts/ERC20.json


# Target: braavos-account-cairo
# Builds Braavos account contracts
# Prerequisites: ensure-asdf
braavos-account-cairo: ensure-asdf
# Building
@if [ "$$(uname)" = "Darwin" ] && command -v brew >/dev/null 2>&1; then \
Expand Down Expand Up @@ -144,7 +195,9 @@ braavos-account-cairo: ensure-asdf
cp ./lib/braavos-account-cairo/target/dev/braavos_account_BraavosBaseAccount.contract_class.json ./artifacts/BraavosBaseAccount.sierra.json
cp ./lib/braavos-account-cairo/target/dev/braavos_account_BraavosBaseAccount.compiled_contract_class.json ./artifacts/BraavosBaseAccount.casm.json


# Target: argent-contracts-starknet
# Builds Argent account contracts
# Prerequisites: ensure-asdf
argent-contracts-starknet: ensure-asdf
# Building
@if [ "$$(uname)" = "Darwin" ] && command -v brew >/dev/null 2>&1; then \
Expand All @@ -166,16 +219,26 @@ argent-contracts-starknet: ensure-asdf
cp ./lib/argent-contracts-starknet/target/dev/argent_ArgentAccount.contract_class.json ./artifacts/ArgentAccount.sierra.json
cp ./lib/argent-contracts-starknet/target/dev/argent_ArgentAccount.compiled_contract_class.json ./artifacts/ArgentAccount.casm.json

# =============================================================================
# Main Build Targets
# =============================================================================

# Target: build-contracts
# Builds all contracts (legacy and latest versions)
build-contracts:
make starkgate-contracts-legacy
make starkgate-contracts-latest
make braavos-account-cairo
make argent-contracts-starknet

# Target: artifacts-linux
# Builds all artifacts for Linux environment
artifacts-linux:
make setup-linux
make build-contracts

# Target: artifacts
# Builds all artifacts for macOS environment
artifacts:
make setup
make build-contracts
5 changes: 4 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,12 @@ To run the Madara Bootstrapper on an Ubuntu machine with AMD architecture, pleas
9. **Build Artifacts**: Use the `make` command to build the necessary artifacts within the Madara Bootstrapper repository.

```shell
make artifacts-linux
make artifacts-linux # For Linux
make artifacts # For macOS
```

> **Note**: In case you get an error related to permission, try running the command with `sudo`
10. **Build the Rust Binary**: Compile the Rust project.

```shell
Expand Down

0 comments on commit 425894f

Please sign in to comment.