Skip to content

fix(anvil): parse Tempo expiring nonce fields from hex strings#14259

Merged
zerosnacks merged 2 commits intofoundry-rs:masterfrom
figtracer:fix/anvil-expiring-nonce
Apr 13, 2026
Merged

fix(anvil): parse Tempo expiring nonce fields from hex strings#14259
zerosnacks merged 2 commits intofoundry-rs:masterfrom
figtracer:fix/anvil-expiring-nonce

Conversation

@figtracer
Copy link
Copy Markdown
Collaborator

@figtracer figtracer commented Apr 10, 2026

Summary

Fixes cast send --tempo.expiring-nonce against local anvil which previously failed with expiring nonce transaction requires tempo_tx_env.

validBefore arrives as a hex string in the RPC other fields.
Deserializing as u64 silently failed, causing tempo_tx_env to never
be set. Parse as U256 (which handles hex) then convert to u64.

Also set tempo_tx_env when valid_before is present, even if
nonce_key is zero.
// unique hash for expiring-nonce replay protection. The nonce
// manager needs a non-zero hash; the actual value doesn't matter
// because the state is discarded after estimation.
let estimation_hash = keccak256(base.data.as_ref());
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is prob too heavy for the use-case, something to think abt

The custom parse_hex helper only handled string values, breaking
gas estimation when validBefore was passed as a JSON number.

U256's Deserialize impl already handles both hex strings and plain
numbers, so use get_deserialized<U256> consistently and convert to
u64 with saturating_to.

Co-authored-by: Amp <amp@ampcode.com>
Copy link
Copy Markdown
Collaborator

@mablr mablr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed regression due to wrong deserialization 🫡

@zerosnacks zerosnacks enabled auto-merge (squash) April 13, 2026 07:41
@zerosnacks zerosnacks merged commit 2086ea5 into foundry-rs:master Apr 13, 2026
15 checks passed
@github-project-automation github-project-automation bot moved this to Done in Foundry Apr 13, 2026
@figtracer figtracer deleted the fix/anvil-expiring-nonce branch April 13, 2026 08:59
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