Skip to content

chore(primitives): switch default keccak to sha3 - #1057

Merged
DaniPopes merged 1 commit into
mainfrom
dani/default-sha3
Jan 7, 2026
Merged

DaniPopes merged 1 commit into
mainfrom
dani/default-sha3

Conversation

@DaniPopes

@DaniPopes DaniPopes commented Jan 7, 2026 •

Copy link
Copy Markdown
Member

@github-project-automation github-project-automation Bot moved this to Reviewed in Alloy Jan 7, 2026
@DaniPopes
DaniPopes enabled auto-merge (squash) January 7, 2026 14:35
@DaniPopes
DaniPopes merged commit a53a86f into main Jan 7, 2026
@DaniPopes
DaniPopes deleted the dani/default-sha3 branch January 7, 2026 14:39
@github-project-automation github-project-automation Bot moved this from Reviewed to Done in Alloy Jan 7, 2026
@kayabaNerve

Copy link
Copy Markdown

It seems tiny-keccak is still in tree here:

tiny-keccak = { workspace = true, features = ["keccak"] }

Was that intentional (some blocker/requirement regarding the public API) or just an oversight?

@DaniPopes

Copy link
Copy Markdown
Member Author

You could call it an oversight, sha3 in its place would get duplicated too on release builds because it's a proc macro dep, but good to have only one by default: #1064

Wollac added a commit to boundless-xyz/steel that referenced this pull request Apr 17, 2026
alloy-primitives 1.5.3 (alloy-rs/core#1057) flipped the default keccak
backend from tiny-keccak to sha3 and made tiny-keccak opt-in via a new
`tiny-keccak` feature. Without enabling it, the tiny-keccak patch in
each guest is a no-op (cargo reports the patch as unused) and the
slower sha3 path is compiled into the ELF.

Enable `alloy-primitives/tiny-keccak` in every guest Cargo.toml and pin
the minimum version to 1.5.3 where the feature was introduced. Guests
that didn't previously list alloy-primitives as a direct dependency
now do so just to activate the feature.
Wollac added a commit to boundless-xyz/steel that referenced this pull request Apr 17, 2026
The `tiny-keccak` feature on alloy-primitives was introduced in 1.5.3
(alloy-rs/core#1057) when the default keccak backend flipped to sha3.
Declaring `version = "1.0"` with `features = ["tiny-keccak"]` only
works by accident — cargo resolves to the latest 1.x today, but the
declared range permits 1.0..1.5.3 where the feature doesn't exist.
Pin the floor to the version that actually provides the feature.
Wollac added a commit to boundless-xyz/steel that referenced this pull request Apr 17, 2026
The `tiny-keccak` feature on alloy-primitives was introduced in 1.5.3
(alloy-rs/core#1057) when the default keccak backend flipped to sha3.
Declaring `version = "1.0"` with `features = ["tiny-keccak"]` only
works by accident — cargo resolves to the latest 1.x today, but the
declared range permits 1.0..1.5.3 where the feature doesn't exist.
Pin the floor to the version that actually provides the feature.
Wollac added a commit to boundless-xyz/steel that referenced this pull request Apr 20, 2026
…house (#117)

* chore: update dependencies and bump Rust to 1.94

- Bump revm 34 -> 36, op-revm 15 -> 17
- Bump alloy-evm 0.27 -> 0.30, alloy-op-evm 0.27 -> 0.30
- Bump Rust toolchain 1.91 -> 1.94
- Bump risc0 crate version 3.0.4 -> 3.0.5 in CI workflows
- Patch op-alloy-network 0.24 to fix conflicting NetworkWallet<Optimism>
  impl with alloy-network 1.8's blanket impl (ethereum-optimism/optimism#19756)
- Add reqwest with `query` feature for reqwest 0.13 compatibility
- Add `slot_num` field to BlockEnv constructors (new in revm 36)
- Wrap OpTransaction in OpTx newtype (new in alloy-op-evm 0.30)

* fix: CI license check and clippy errors

- Update copyright year to 2026 in ethereum.rs
- Remove unused TypedTransaction import from op-alloy-network patch
- Skip patches/ directory in license checker (vendored upstream code)

* chore: add TODO for EIP-7843 slot_num population

Add tracked TODOs referencing #112 for when alloy adds slot_number
to the Header struct.

* fix: remove c-kzg from guest examples

The risc0 c-kzg fork is pinned at 2.1.5 but revm-precompile 32.1.0
requires c-kzg >=2.1.6. Remove c-kzg feature from revm in guest crates
since the point evaluation precompile is not used by these examples.

* fix: remove blst/c-kzg from guest examples to fix revm 36 compat

The risc0 blst fork (0.3.15) conflicts with revm-precompile 32.1.0
which needs blst ^0.3.16. Cargo resolves optional deps (like c-kzg)
even when not activated, causing an unsatisfiable version constraint.

- Add `revm-blst` and `revm-bn` features to steel/op-steel crates
- Use steel features instead of direct revm dep in guest crates
- Drop blst from guest precompiles until risc0 updates their fork

* refactor: revert feature forwarding, keep direct revm dep in guests

Use `revm = { version = "*", features = ["bn"] }` directly in guest
crates instead of forwarding features through steel/op-steel.

* fix: format guest Cargo.toml files (cargo sort)

* Revert "fix: format guest Cargo.toml files (cargo sort)"

This reverts commit 84b88c2.

* fix: sort guest Cargo.toml files (cargo sort --grouped)

* fix: add op-alloy-network patch to examples/op workspace

* refactor: replace vendored op-alloy-network with inline Optimism type

Define a minimal `Optimism` network type directly in op-steel instead
of maintaining a patched fork of op-alloy-network. This eliminates the
`patches/op-alloy-network` directory and both `[patch.crates-io]`
entries while preserving full functionality.

The upstream fix (ethereum-optimism/optimism#19756) for the
`NetworkWallet<Optimism>` conflict has been merged but not yet released.
Tracked by #116.

* fix: cargo fmt

* chore: bump ethereum-consensus to latest rev

* refactor: replace ethereum-consensus with Lighthouse types

Drop the semi-maintained ethereum-consensus git dependency (and its
transitive unpublished ssz_rs pin) in favor of Lighthouse's `types`
crate at v8.1.3. Lighthouse tracks all forks through Fulu/Gloas, so
the 613-line consensus.rs with hand-written Electra/Fulu types and
SignedBeaconBlock fork enum is no longer needed.

Because Lighthouse doesn't expose a generic SSZ merkle-proof API,
add a minimal 3-level proof builder that walks ExecutionPayload →
BeaconBlockBody → BeaconBlock using a flat-array Merkle tree. The
hand-maintained EP and block leaf lists are guarded against fork
drift by comparing the reconstructed roots to the lighthouse-computed
`tree_hash_root()`s, and `from_beacon_root` derives the expected leaf
from the concrete accessor (`ep.block_hash()` / `ep.state_root()`)
so a stale `LEAF_INDEX` constant is caught at preflight rather than
at final verification.

* refactor: tidy beacon host after Lighthouse migration

- Pin lighthouse-types by full commit SHA instead of the mutable v8.1.3 tag
- Avoid full-block serde_json::Value round-trip in ForkVersionedResponse
  by borrowing a &RawValue and re-parsing via from_str
- Tighten drift-guard comment, drop redundant narration
- Restore token-stats guest Cargo.toml ordering to match the other examples

* docs: update CHANGELOG for dep bumps and Lighthouse swap

Refresh the `Unreleased` section with the revm 36 / alloy-evm 0.30 dep
versions, the Rust 1.94 toolchain bump, the ethereum-consensus →
lighthouse-types migration, the inline Optimism network type, and the
blst/c-kzg guest precompile removal.

* docs: drop example- and test-internal entries from CHANGELOG

The `CHANGELOG` tracks changes visible to consumers of the published
crates, so purely internal test additions and guest-example Cargo tweaks
don't belong there.

* docs: drop temporary op-alloy-network entry from CHANGELOG

No release will go out until the upstream `NetworkWallet` fix lands, so
the inline replacement is not consumer-visible in any published version.

* fix: CI license headers and erc20-counter tokio features

- Bump copyright year to 2026 on files touched by this branch so the
  license check passes.
- Enable tokio `full` feature in the erc20-counter workspace; the host
  uses `#[tokio::main]`, which now requires an explicit runtime feature
  after the alloy 1.8 / reqwest 0.13 dep bump. Matches the other
  example workspaces.

* ci: pass --grouped to cargo sort for consistency

* fix: bump guest alloy-primitives floor to 1.5.3 for tiny-keccak feature

The `tiny-keccak` feature on alloy-primitives was introduced in 1.5.3
(alloy-rs/core#1057) when the default keccak backend flipped to sha3.
Declaring `version = "1.0"` with `features = ["tiny-keccak"]` only
works by accident — cargo resolves to the latest 1.x today, but the
declared range permits 1.0..1.5.3 where the feature doesn't exist.
Pin the floor to the version that actually provides the feature.

* chore: gitignore foundry.lock

forge install writes foundry.lock to pin the resolved commit of each
git-submodule dependency. The repo already ignores Cargo.lock so that
contributors don't churn it across branches; apply the same rule to
foundry.lock for consistency.

* refactor: tidy beacon host after Lighthouse swap

- Scope MainnetSignedBeaconBlock to pub(crate).
- Downgrade the EP/block tree root-consistency guards to
  debug_assert_eq! - commit.verify(..) at the call site is the
  production-path check.
- Drop redundant inline comments and rewrite the duplicate doc comments
  on create_eip4788_beacon_commit / create_slot_beacon_commit.
- Build HistoryCommit state_commits via push + a single reverse() at
  the end, replacing per-iteration insert(0, ..) (O(n^2) -> O(n)).

* fix: broaden reqwest req to span alloy 1.7 (0.12) and 1.8+ (0.13)

alloy-transport-http ^1.7 pins reqwest ^0.12 (where `query` is a
default feature) while ^1.8 pins reqwest ^0.13 (where `query` is
opt-in). Spanning the range lets cargo unify with whichever reqwest the
ambient alloy pulls in.
Wollac added a commit to boundless-xyz/steel that referenced this pull request Apr 20, 2026
* fix: replace ethereum-consensus with Lighthouse types

ethereum-consensus transitively depends on `core2`, which was fully
yanked from crates.io. That leaves the crate unbuildable from scratch
and breaks `risc0-steel --features host`.

Port the host-side beacon module to Lighthouse's `types` + `tree_hash` +
`context_deserialize` (pinned to v8.1.3). The API surface of
`GeneralizedBeaconCommit` is unchanged; only internals moved.

* fix: pin alloy sub-crates in op-steel to dodge NetworkWallet conflict

alloy-network 1.7.4 loosened the where-clause on its blanket
`NetworkWallet<N> for EthereumWallet` impl from Ethereum-specific
(`UnsignedTx = TypedTransaction`) to anything `SignableTransaction`,
which now applies to `Optimism` and conflicts with op-alloy-network's
explicit `NetworkWallet<Optimism>` impl.

Pin alloy-network below 1.7.4 directly on risc0-op-steel so the
constraint only bites consumers that actually pull op-alloy-network.
The sibling alloy-* sub-crates need to stay on the same 1.7.x line
because alloy 1.8 switched reqwest 0.12 -> 0.13 and mixing versions
produces "two versions of reqwest" type errors.

Can be reverted once op-alloy-network ships
ethereum-optimism/optimism#19756.

* fix: split op-steel pins into their own group for cargo sort

* fix: reorder op-steel deps for cargo sort --workspace (no --grouped)

* Revert "fix: reorder op-steel deps for cargo sort --workspace (no --grouped)"

This reverts commit 3ad9ba0.

* ci: pass --grouped to cargo sort so pin group is respected

* fix: bump copyright year to 2026 on files touched this year

* fix: pin mio <1.2 and gate op-steel alloy pins behind the host feature

mio 1.2.0 (released 2026-03-27) regressed compilation on the risc0
zkvm-elf guest target. alloy-provider hard-depends on tokio -> mio and
is pulled transitively by op-alloy-network even in guest builds, so the
pin has to be unconditional.

At the same time, move alloy-provider / alloy-rpc-client / alloy-transport
/ alloy-transport-http pin entries behind the `host` feature so guest
builds don't pay for those crates' compilation for no benefit. alloy-network
stays unconditional because the NetworkWallet<Optimism> coherence conflict
bites at compile time regardless of feature.

* fix: drop redundant mio pin

The mio compile failure only surfaced because my earlier unconditional
`alloy-provider` direct dep enabled its default `reqwest` feature, which
pulled reqwest -> tokio/net -> mio. Once alloy-provider is host-gated
(as it now is), op-alloy-network's transitive alloy-provider uses
`default-features = false` and tokio stays on sync+macros only, so mio
never enters the tree in guest builds.

* chore(release): bump risc0-steel to v2.4.4

Bump `risc0-steel` to 2.4.4 and `risc0-op-steel` to 0.8.3 and record
the two fixes (Lighthouse port, alloy-network pin) in CHANGELOG.md.

* fix: enable alloy-primitives tiny-keccak feature in guests

alloy-primitives 1.5.3 (alloy-rs/core#1057) flipped the default keccak
backend from tiny-keccak to sha3 and made tiny-keccak opt-in via a new
`tiny-keccak` feature. Without enabling it, the tiny-keccak patch in
each guest is a no-op (cargo reports the patch as unused) and the
slower sha3 path is compiled into the ELF.

Enable `alloy-primitives/tiny-keccak` in every guest Cargo.toml and pin
the minimum version to 1.5.3 where the feature was introduced. Guests
that didn't previously list alloy-primitives as a direct dependency
now do so just to activate the feature.

* refactor: tidy beacon host after Lighthouse swap

- Drop stray reqwest dep: alloy 1.7 pulls reqwest 0.12 where `query` is
  already a default feature, so the explicit dep only bloated the graph
  with a duplicate reqwest 0.13.
- Scope MainnetSignedBeaconBlock to pub(crate).
- Downgrade the EP/block tree root-consistency guards to
  debug_assert_eq! - commit.verify(..) at the call site is the
  production-path check.
- Drop redundant inline comments and rewrite the duplicate doc comments
  on create_eip4788_beacon_commit / create_slot_beacon_commit.

* fix: restore reqwest dep to enable `query` feature on alloy 1.8+

CI runs `cargo test` on the examples without `--locked`, so dep
resolution picks the latest compatible alloy (1.8+), whose reqwest 0.13
has `query` as an opt-in feature. Without this explicit dep,
BeaconClient::get_json fails to compile (RequestBuilder::query missing).

The previous removal was based on Cargo.lock, where alloy 1.7 pins
reqwest 0.12 (query is default) — that only held for locked builds.

* fix: broaden reqwest req to span alloy 1.7 (0.12) and 1.8+ (0.13)

alloy-transport-http ^1.7 pins reqwest ^0.12 (where `query` is a
default feature) while ^1.8 pins reqwest ^0.13 (where `query` is
opt-in). Spanning the range lets cargo unify with whichever reqwest the
ambient alloy pulls in, so the `query` feature lights up in both
scenarios without forcing a duplicate reqwest compile in the 1.8 path.
tezoslibrarian pushed a commit to tezos/tezos-mirror that referenced this pull request Oct 27, 2026
alloy-primitives 1.5.3 changed the default keccak256 backend from
tiny-keccak to sha3 (alloy-rs/core#1057). revm 43 brings
alloy-primitives 1.7.3, so the kernel now hashes with the soft backend
of keccak 0.2.2. In the WASM PVM, this backend costs about 5 times more
ticks: it does not unroll its loops and it calls copy_from_slice 5
times in each round.

Enable the tiny-keccak feature of alloy-primitives. The hash values do
not change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants