Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 107 additions & 41 deletions .github/workflows/ci-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,112 @@ jobs:
run: forge build
working-directory: packages/erc4337-contracts

- name: Verify ERC-4337 contract ABIs exist
- name: Run clippy
run: |
rustup component add clippy --toolchain stable
rustup component add --toolchain 1.91.0-x86_64-unknown-linux-gnu clippy
cargo clippy --all-targets -- -D warnings
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337

- name: Install cargo-nextest
uses: taiki-e/install-action@nextest

- name: Run rust tests with nextest
env:
SSO_ZKSYNC_OS_PRINT_LOGS: "false"
run: cargo nextest run --profile ci --all-features
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337

rust-sdk-erc4337-zksync-os:
name: Rust 4337 SDK (zksync-os)
runs-on: ubuntu-latest
strategy:
matrix:
config:
- debug
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.4

- name: Install Rust
run: |
rustup update stable && rustup default stable
rustup toolchain install nightly

- name: Run rustfmt
run: |
rustup component add rustfmt --toolchain nightly
cargo +nightly fmt --all -- --check
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1.4.0
with:
# zksync-os-server's zkos-l1-state.json doesn't work on latest version of anvil
version: v1.5.1

- name: Install dependencies
run: forge soldeer install
working-directory: packages/erc4337-contracts

- name: Install Node.js 22 via nvm
run: |
export NVM_DIR="$HOME/.nvm"
mkdir -p "$NVM_DIR"
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
. "$NVM_DIR/nvm.sh"
nvm install 22
nvm use 22
node -v
npm install -g yarn
# Expose Node.js bin dir to subsequent steps
echo "$(dirname $(nvm which 22))" >> $GITHUB_PATH

- name: Configure pnpm store dir
run: echo "PNPM_STORE_DIR=$HOME/.pnpm-store" >> $GITHUB_ENV

- name: Cache pnpm store
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('packages/erc4337-contracts/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Enable corepack and activate pnpm from contracts package.json
run: |
corepack enable
corepack prepare "$(node -p "require('./package.json').packageManager")" --activate
pnpm -v
working-directory: packages/erc4337-contracts

- name: Install dependencies
run: pnpm install --frozen-lockfile
working-directory: packages/erc4337-contracts

- name: Build ERC-4337 contracts
run: forge build
working-directory: packages/erc4337-contracts

- name: Clone zksync-os dependencies
run: |
set -euo pipefail
missing=()
files=(
"out/IERC7579Account.sol/IERC7579Account.json"
"out/EntryPoint.sol/EntryPoint.json"
)
for f in "${files[@]}"; do
if [ ! -f "$f" ]; then
missing+=("$f")
fi
done
if [ ${#missing[@]} -gt 0 ]; then
echo "Missing expected ABI JSON files:" >&2
for m in "${missing[@]}"; do echo " - $m" >&2; done
echo "\nAvailable JSON files under out/:" >&2
find out -maxdepth 2 -type f -name '*.json' | sort || true
exit 1
cd packages/sdk-platforms/rust/zksync-sso-erc4337
if [ ! -d account-abstraction ]; then
git clone https://github.com/eth-infinitism/account-abstraction
fi
working-directory: packages/erc4337-contracts
if [ ! -d zksync-os-server ]; then
git clone https://github.com/matter-labs/zksync-os-server
fi

- name: Build zksync-os-server
run: |
cd packages/sdk-platforms/rust/zksync-sso-erc4337/zksync-os-server
cargo build --release --bin zksync-os-server

- name: Run clippy
run: |
Expand All @@ -119,7 +204,10 @@ jobs:
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest

- name: Run rust tests with nextest
- name: Run rust tests with nextest (zksync-os)
env:
SSO_TEST_NODE_BACKEND: zksyncos
SSO_ZKSYNC_OS_PRINT_LOGS: "false"
run: cargo nextest run --profile ci --all-features
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337

Expand Down Expand Up @@ -153,28 +241,6 @@ jobs:
run: forge build
working-directory: packages/erc4337-contracts

- name: Verify ERC-4337 contract ABIs exist
run: |
set -euo pipefail
missing=()
files=(
"out/IERC7579Account.sol/IERC7579Account.json"
"out/EntryPoint.sol/EntryPoint.json"
)
for f in "${files[@]}"; do
if [ ! -f "$f" ]; then
missing+=("$f")
fi
done
if [ ${#missing[@]} -gt 0 ]; then
echo "Missing expected ABI JSON files:" >&2
for m in "${missing[@]}"; do echo " - $m" >&2; done
echo "\nAvailable JSON files under out/:" >&2
find out -maxdepth 2 -type f -name '*.json' | sort || true
exit 1
fi
working-directory: packages/erc4337-contracts

- name: Build WASM module (web target)
run: wasm-pack build --target web
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337/crates/zksync-sso-erc4337-ffi-web
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk-platforms/rust/zksync-sso-erc4337/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#Cargo.lock
zksync-os-server
account-abstraction
76 changes: 76 additions & 0 deletions packages/sdk-platforms/rust/zksync-sso-erc4337/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/sdk-platforms/rust/zksync-sso-erc4337/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@ tempfile = "3"
strip-ansi-escapes = "0.2"
libc = "0.2"

# Misc
ureq = "2.10"
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ base64.workspace = true
libc = { workspace = true, optional = true }
strip-ansi-escapes = { workspace = true, optional = true }
tempfile = { workspace = true, optional = true }
zksync-sso-zksyncos-node = { path = "../zksync-sso-zksyncos-node", optional = true }

# Explicitly add getrandom v0.2 with js feature for WASM (used by rand 0.8 from alloy)
[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand All @@ -60,7 +61,7 @@ web-sys = { version = "0.3", features = ["Window"] }
[features]
default = ["tokio-runtime"]
tokio-runtime = ["tokio"]
test-utilities = ["libc", "strip-ansi-escapes", "tempfile"]
test-utilities = ["libc", "strip-ansi-escapes", "tempfile", "zksync-sso-zksyncos-node"]

[dev-dependencies]
# Alloy
Expand All @@ -77,3 +78,4 @@ tempfile.workspace = true
strip-ansi-escapes.workspace = true
libc.workspace = true
wiremock.workspace = true
zksync-sso-zksyncos-node = { path = "../zksync-sso-zksyncos-node" }
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ mod tests {
signer::create_eoa_signer,
},
utils::alloy_utilities::test_utilities::{
TestInfraConfig,
start_anvil_and_deploy_contracts_and_start_bundler_with_config,
config::TestInfraConfig,
start_node_and_deploy_contracts_and_start_bundler_with_config,
},
};
use alloy::primitives::address;
Expand All @@ -139,18 +139,14 @@ mod tests {
bundler,
bundler_client,
) = {
let signer_private_key = "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6".to_string();
let config = TestInfraConfig {
signer_private_key: signer_private_key.clone(),
};
start_anvil_and_deploy_contracts_and_start_bundler_with_config(
let config = TestInfraConfig::rich_wallet_9();
start_node_and_deploy_contracts_and_start_bundler_with_config(
&config,
)
.await?
};

let entry_point_address =
address!("0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108");
let entry_point_address = contracts.entry_point;

let factory_address = contracts.account_factory;
let eoa_validator_address = contracts.eoa_validator;
Expand Down Expand Up @@ -239,18 +235,14 @@ mod tests {
bundler,
bundler_client,
) = {
let signer_private_key = "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6".to_string();
let config = TestInfraConfig {
signer_private_key: signer_private_key.clone(),
};
start_anvil_and_deploy_contracts_and_start_bundler_with_config(
let config = TestInfraConfig::rich_wallet_9();
start_node_and_deploy_contracts_and_start_bundler_with_config(
&config,
)
.await?
};

let entry_point_address =
address!("0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108");
let entry_point_address = contracts.entry_point;

let factory_address = contracts.account_factory;
let eoa_validator_address = contracts.eoa_validator;
Expand Down
Loading
Loading