chore(sdk + twap-monitor): hex helpers via alloy_primitives::hex::encode - #51
Closed
brunota20 wants to merge 1 commit into
Closed
chore(sdk + twap-monitor): hex helpers via alloy_primitives::hex::encode#51brunota20 wants to merge 1 commit into
brunota20 wants to merge 1 commit into
Conversation
mfw78 review of PR #8 (nullislabs#8) flagged "we already pull alloy, so pulling hex via there is really not much of a deal". The PR #47 (COW-1074) commit acc9654 then introduced two new custom hex helpers that recreate the same antipattern at a different scope: - `crates/shepherd-sdk/src/cow/app_data.rs::encode_hex` - 32-byte hash → `0x...`. Used by `resolve_app_data` to format the orderbook lookup path. - `modules/twap-monitor/src/strategy.rs::hex_short` - 8-byte prefix → `0x...…`. Used to format `appData` hashes in INFO log lines. Both crates already depend on `alloy-primitives` (sdk: 1.6, twap-monitor: 1.5), so the swap is a one-liner per call site: - `encode_hex(b)` → `format!("0x{}", alloy_primitives::hex::encode(b))` - `hex_short(b)` → `format!("0x{}…", alloy_primitives::hex::encode(&b[..8]))` Both functions keep their old signature so callers (`resolve_app_data` in the SDK, every `host.log` line in twap-monitor strategy) need no changes. Comments on both helpers now explicitly reference mfw78's PR #8 guidance so the next person tempted to hand-roll a `0123456789abcdef` table has a hook. Validation: cargo test -p shepherd-sdk -p twap-monitor: 32 + 23 passed; cargo clippy --all-targets -- -D warnings: clean; cargo fmt --check: clean; zero em-dash drift. Why this PR sits in a separate branch rather than amending PR #47: PR #47 is already In Review, and #48/#49/#50 stack on top of it. Amending would require force-pushing 4 branches. A small follow-up PR keeps each one bisectable and lets mfw78 review the alloy alignment in isolation. AI assistance disclosure: drafted by Claude (Opus 4.7, 1M context) while sweeping all open PRs for the same antipatterns mfw78 flagged on PRs #8 and #9.
Author
|
Work landed via |
lgahdl
pushed a commit
that referenced
this pull request
Jul 17, 2026
…ing (nullislabs#424) * feat(runtime): gate the WASI surface behind manifest capabilities Link only the WASI interfaces a module declares; undeclared sockets, filesystem, cli and environment are refused at load, including the 0.1 fallback manifest. Refs #51 * feat(runtime): enforce per-module resource limits and local-store quota Manifest [limits] overrides layer over the engine defaults per module; the redb local store charges true on-disk bytes per namespace and rejects over-quota writes. Module store paths are reduced to a single sanitized path component. Refs #53 * feat(runtime): bound host-call wall time with a per-dispatch deadline Fuel meters only guest instructions, so a dispatch parked in a blocked host call is bounded by a wall-clock deadline over the whole on_event. Refs nullislabs#107 * feat(runtime): rate-limit event dispatch per module A per-module token bucket, checked before on_event, drops over-rate events at the dispatch boundary without starving other modules. Refs nullislabs#244 * feat(runtime): add a graceful-drain tier for durable-state flush on shutdown Ctrl-C fires a shutdown signal that a durable-flush guard blocks on until drained or a timeout elapses; redb writes are fsync-durable so a write is never truncated. Reconnect pumps stay abort-only. Refs nullislabs#266 * fix(runtime): treat wasi:cli/environment as ambient; rustdoc and fmt for CI Rust std imports wasi:cli/environment on every guest, and the host builds the guest WasiCtx without inherit_env, so the guest environment is always empty. Gating it was noise (every module would declare it) and guarded nothing; the empty-env host isolation is the real boundary. The gate still covers wasi:sockets and wasi:filesystem. Also drop two private intra-doc links and apply rustfmt. Refs #51 * docs: tighten rustdoc and comments; remove issue-number citations Cut the rationale/marketing prose to terse contract lines and drop every issue-number reference from code comments and rustdoc. * feat: add nexum-tasks crate and route every runtime spawn through it Fold ShutdownController and the injectable executor into a dedicated nexum-tasks crate owning task lifecycle and graceful shutdown: - TaskManager owns the latched shutdown signal, the drain-guard counter, and the critical-task failure channel; dropping it fires shutdown, graceful_shutdown_with_timeout drives the bounded drain. - TaskExecutor (Clone) exposes spawn, spawn_critical (return or panic shuts the runtime down), spawn_graceful (holds a GracefulShutdownGuard the drain blocks on), and spawn_blocking. - The launcher constructs the manager, spawns the OS signal listener via spawn_critical and the event loop via spawn_graceful, deleting RuntimeDropGuard; RuntimeHandle holds the manager, wait() drains and also winds down on a critical-task end. - BuilderContext threads the executor into component builders so the local-store open runs on the blocking pool through it. No raw tokio::spawn/spawn_blocking/std::thread::spawn remains in nexum-runtime; nexum-tasks is the sole spawning crate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mfw78's review of PR #8 flagged: "we already pull alloy, so pulling hex via there is really not much of a deal". PR #47 (COW-1074, commit acc9654) then introduced two new custom hex helpers that recreate the same antipattern at a different scope.
This PR removes both:
crates/shepherd-sdk/src/cow/app_data.rsencode_hex(&[u8; 32])0123456789abcdeftableformat!(\"0x{}\", alloy_primitives::hex::encode(b))modules/twap-monitor/src/strategy.rshex_short(&[u8; 32])format!(\"0x{}…\", alloy_primitives::hex::encode(&b[..8]))Both crates already depend on
alloy-primitives(sdk 1.6, twap-monitor 1.5), so this is a pure simplification - no Cargo.toml change. Both helpers keep their signatures so call sites (resolve_app_datain the SDK, everyhost.logline in twap-monitor strategy) need no changes. Comments on both helpers now explicitly reference mfw78's PR #8 guidance so the next person tempted to hand-roll the table has a hook.Stack
Stacked on
fix/twap-calldata-helper-cow-1077(PR #50) →feat/ethflow-expected-excessive-validto-cow-1076(PR #49) →feat/forward-orderbook-error-cow-1075(PR #48) →feat/resolve-app-data-cow-1074(PR #47).Why a separate PR rather than amending #47
PR #47 is already In Review and #48/#49/#50 stack on top. Amending #47 would force-push 4 branches and obscure the reviewer's history. A small follow-up PR keeps each commit bisectable and lets the alloy alignment be reviewed in isolation.
The other surfaces flagged by mfw78 on PRs #8 and #9 are also being addressed:
hex_encodeincrates/nexum-engine/src/host/error.rs- same antipattern in the engine binary. Fixed onfeat/supervisor-event-loop(PR feat(ethflow-watcher): decode CoWSwapEthFlow OrderPlacement (BLEU-832) #9) headdb860c0. The M4 stack will inherit it on rebase post-merge.ProviderPool::emptycfg gating - same story; tightened to#[cfg(test)]on PR feat(ethflow-watcher): decode CoWSwapEthFlow OrderPlacement (BLEU-832) #9 head.ParseError+CapabilityViolationthiserror - already corrected on PR feat(ethflow-watcher): decode CoWSwapEthFlow OrderPlacement (BLEU-832) #9 head4051979.extract_hostURL parsing viaurl::Url- already corrected on PR feat(ethflow-watcher): decode CoWSwapEthFlow OrderPlacement (BLEU-832) #9 head4051979.4051979.Validation
cargo test -p shepherd-sdk -p twap-monitor: 32 + 23 passed, 0 failed.cargo clippy --all-targets --tests -- -D warnings: clean.cargo fmt --check: clean.AI assistance disclosure: drafted by Claude (Opus 4.7, 1M context) while sweeping all open PRs for the same antipatterns mfw78 flagged on PRs #8 and #9.