Skip to content

Commit 3b700ee

Browse files
authored
fix(l1): fix the crates.io publish failure and make the workflow re-runnable (#6899)
**Motivation** The first real `Publish crates to crates.io` run published `ethrex-rlp`, `ethrex-crypto`, `ethrex-sdk-contract-utils`, then **failed on the 4th crate, `ethrex-trie`**: ``` error: unused import: `std::arch::x86_64::*` --> nibbles.rs:198:9 = note: `-D unused-imports` implied by `-D warnings` error: failed to verify package tarball ``` Three distinct problems surfaced: 1. **The crate failure.** `use std::arch::x86_64::*` is only used inside a `#[cfg(target_feature = "ssse3")]` block. The publish verify build runs under `-D warnings` (injected by `setup-rust-toolchain`), and that `RUSTFLAGS` *also overrides* the `+ssse3` target-feature set in `.cargo/config.toml` — so SSSE3 is off, the import is unused, and `-D warnings` turns it into a hard error. 2. **The dry-run was useless.** `cargo publish --dry-run` over an unpublished workspace makes every dependent fail dependency resolution (its siblings aren't on the index yet) *before it compiles*; the tolerant logic reported success while testing nothing. That's why the trie failure wasn't caught. 3. **Re-runs weren't idempotent.** The workflow matched `"already exists"`, but modern cargo emits `"already uploaded"` — so a re-run would fail on `ethrex-rlp` (already published) instead of skipping it. **Description** - **`crates/common/trie/nibbles.rs`**: move `use std::arch::x86_64::*` into the `#[cfg(target_feature = "ssse3")]` block so it is only present when its intrinsics are. - **`publish.yml` — disable `-D warnings`** (`rustflags: ""` on `setup-rust-toolchain`). Publishing already-reviewed, separately-linted code should not deny warnings; this also stops `RUSTFLAGS` from clobbering the config.toml target-features during the verify build. Neutralizes the entire warning class for all crates. - **`publish.yml` — idempotent re-runs**: match `already (uploaded|exists)` so re-running skips versions already on crates.io. - **`publish.yml` — a dry-run that works**: replace `cargo publish --dry-run` with `cargo package --no-verify --list` (tarball file set, no index lookup) + `cargo check` (compile with default features). Both run against workspace path deps, so they validate every crate without anything being published. **Validation** - Reproduced the trie failure locally under the exact verify conditions (`--target x86_64-unknown-linux-gnu`, `RUSTFLAGS=-D warnings`); confirmed the fix compiles clean there and the import is still used when SSSE3 is on. - Audited every `std::arch` / `target_feature` site in the publish set: only `ethrex-trie` (fixed) and `ethrex-crypto` (already published OK) have arch-gated code. - Ran the new dry-run on a real x86_64 CI runner: all 16 crates pass (`cargo check` green for each). **How to re-run the publish after merge** 1. **Actions → Publish crates to crates.io → Run workflow**, `dry_run` checked (default) → verifies all 16 without publishing. 2. Re-run with `dry_run` off → publishes; the 3 already-published crates are skipped, `ethrex-trie` onward publish. **Checklist** - [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR includes breaking changes to the `Store` requiring a re-sync. — N/A.
1 parent 1a55752 commit 3b700ee

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

.github/workflows/publish.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
workflow_dispatch:
1212
inputs:
1313
dry_run:
14-
description: "List package contents only, do not publish"
14+
description: "Verify each crate (package + compile) without publishing"
1515
type: boolean
1616
default: true
1717

@@ -30,6 +30,12 @@ jobs:
3030
uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1
3131
with:
3232
toolchain: stable
33+
# This action defaults RUSTFLAGS to "-D warnings", which (a) makes the
34+
# cargo-publish verify build fail on lints and (b) overrides the
35+
# `[target.*].rustflags` target-features in .cargo/config.toml. Publishing
36+
# already-reviewed, CI-linted code should not deny warnings -- lints are
37+
# gated on PRs separately -- so disable it here.
38+
rustflags: ""
3339

3440
- name: Publish crates in dependency order
3541
env:
@@ -59,18 +65,20 @@ jobs:
5965
for c in "${CRATES[@]}"; do
6066
echo "::group::$c"
6167
if [ "${DRY_RUN:-false}" = "true" ]; then
62-
# Real publish dry-run: packaging + index resolution + verify build.
63-
# On a dry-run nothing is actually published, so crates later in the
64-
# order can't resolve their siblings yet -- tolerate ONLY that error.
65-
OUTPUT=$(cargo publish -p "$c" --dry-run 2>&1) || {
66-
echo "$OUTPUT"
67-
echo "$OUTPUT" | grep -q "no matching package named" || exit 1
68-
echo "$c: sibling not on crates.io yet (expected during a dry-run)"
69-
}
68+
# `cargo publish --dry-run` (and `cargo package` without --list)
69+
# resolve each crate's siblings against the crates.io index, which
70+
# aren't published yet -- so dependents fail at resolution before they
71+
# ever compile. Validate against workspace path deps instead, which
72+
# needs nothing published: list the tarball file set (no index lookup)
73+
# and compile with default features (what cargo's verify step builds).
74+
cargo package -p "$c" --no-verify --list >/dev/null
75+
cargo check -p "$c"
7076
else
7177
OUTPUT=$(cargo publish -p "$c" 2>&1) || {
7278
echo "$OUTPUT"
73-
if echo "$OUTPUT" | grep -q "already exists"; then
79+
# Idempotent re-runs: skip versions already on crates.io. cargo emits
80+
# "already uploaded" (modern) or "already exists" (older/other registries).
81+
if echo "$OUTPUT" | grep -qiE "already (uploaded|exists)"; then
7482
echo "$c already published, skipping"
7583
echo "::endgroup::"
7684
continue

crates/common/trie/nibbles.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,6 @@ unsafe fn pack_nibble_pairs(nibbles: &[u8], output: *mut u8) {
195195
#[allow(unsafe_code)]
196196
#[inline]
197197
unsafe fn pack_nibble_pairs_x86_64(nibbles: &[u8], output: *mut u8) {
198-
use std::arch::x86_64::*;
199-
200198
let n = nibbles.len(); // always even
201199
let mut i = 0usize; // index into nibbles (steps of 32)
202200
let mut o = 0usize; // index into output (steps of 16)
@@ -207,6 +205,7 @@ unsafe fn pack_nibble_pairs_x86_64(nibbles: &[u8], output: *mut u8) {
207205
#[cfg(target_feature = "ssse3")]
208206
// SAFETY: SSSE3 enabled at compile time; pointer arithmetic stays within bounds.
209207
unsafe {
208+
use std::arch::x86_64::*;
210209
// Multiplier: weight = [16, 1] repeated → multiply even nibble by 16, odd by 1
211210
let weights = _mm_set1_epi16(0x0110_u16 as i16); // bytes: [16, 1, 16, 1, ...]
212211
while i + 32 <= n {

0 commit comments

Comments
 (0)