Skip to content

Conversation

zerosnacks
Copy link
Member

@zerosnacks zerosnacks commented Jul 14, 2025

Motivation

We currently allow users to specify as:

block_timestamp = 100123
block_number = 12345678

but serialize (when running forge config) / work internally with:

block_number = "0xbc614e"
block_timestamp = "0x1871b"

which is difficult to read / not in a format users regularly encounter when looking at a block explorer

Solution

We have a serialization method that attempts to fit the number in a u64, else serializing in U256 per suggestion by @DaniPopes in #10838 (comment)

foundry.toml set as:

block_number = 12345678
block_timestamp = 100123

serializes as:

block_number = 12345678
block_timestamp = 100123

foundry.toml set as:

block_number = "0x732143"
block_timestamp = "0x123123"

serializes as:

block_number = 7545155
block_timestamp = 1192227

foundry.toml set as (u64::max):

block_number = "0xffffffffffffffff"
block_timestamp = "0xffffffffffffffff"

serializes as:

block_number = "18446744073709551615"
block_timestamp = "18446744073709551615"

foundry.toml set as (u64::max + 1):

block_number = "0x10000000000000000"
block_timestamp = "0x10000000000000000"

serializes as:

block_number = "0x10000000000000000"
block_timestamp = "0x10000000000000000"

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@zerosnacks
Copy link
Member Author

@DaniPopes / @yash-atreya do you have any ideas how we could fix the deserialization issue with values close to u64::MAX that are eagerly evaluated - I think by Figment

@zerosnacks zerosnacks added the L-ignore Log: ignore PR in changelog label Jul 14, 2025
@zerosnacks zerosnacks self-assigned this Jul 14, 2025
@zerosnacks zerosnacks moved this to In Progress in Foundry Jul 14, 2025
Copy link
Contributor

@yash-atreya yash-atreya left a comment

Choose a reason for hiding this comment

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

this lgtm!

@zerosnacks zerosnacks marked this pull request as ready for review July 15, 2025 07:54
@zerosnacks zerosnacks merged commit 42ac804 into zerosnacks/bump-revm-26.0.0 Jul 15, 2025
21 checks passed
@zerosnacks zerosnacks deleted the zerosnacks/bump-revm-26.0.0-serialize-to-u64-if-fits-or-u256 branch July 15, 2025 07:56
@github-project-automation github-project-automation bot moved this from In Progress to Done in Foundry Jul 15, 2025
yash-atreya added a commit that referenced this pull request Jul 15, 2025
* bump revm, pending alloy-evm alloy-rs/evm#100, pending foundry-fork-db

* bump alloy-evm, foundry-fork-db

* bump deps

* apply alloy-evm fix

* start porting types

* unpin revm-inspectors

* fix issues

* continue preperation

* .control field was removed

* frame_return_result now needs to happen in bigger run_exec_loop block

* update handler and inspector per latest changes removing previous methods

* add new frame loop

* pass in frame

* fix transact_raw

* continue fixes

* apply will_exit, on continue should skip as it is none, on exit (any ok, revert or error) we exit

* continue clean up, some attention points in regards to InstructionResult::Continue

* continue porting

* continue porting

* temporarily use hardcoded BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE

* remove clamping now that revm supports U256 internally for number and timestamp

* fix clippy

* fix doctest

* bump alloy version

* make assertion on `bytecode`

* revert bytecode(), fix to come in upcoming release

* bump revm 27

* fix debug

* revert Cargo.toml change

* clean up

* fix(`config`): block_timestamp and block_number mismatch in Config and EvmOpts (#10903)

* fix clippy

* fix(`anvil/test`): change delegatecall.value in test_call_ots_trace_transaction

* bump revm: 27.0.2

* apply clippy fixes

* fix fmt

* fix config defaults

* fix config change of block_number, block_timestamp require hex formatting

* fix(`evm`): create2 in InspectorHandler and trace decoder for None status (#10925)

* fix: handler CREATE2 override in InspectorHandler

* fix: account for trace.status: None - this is due to removal of InstructionResult::Continue

* fix(`forge/test`): update test fixture: can_run_test_with_json_output_verbose - as trace.status can be null and trace.success can be false due to removal of InstructionResult::Continue

* fix(`forge/test`): repro 6501 - account for success being false due to status being None

* fix(`evm/inspectors`): prevent panic in should_revert_on_address_opcode (#10940)

* fix(`evm/inspectors`): prevent panic by checking interp.action.is_some - fixes: should_revert_on_address_opcode

* undo step removal

* fix merge conflict

* fix(`evm`): enable tx_chain_id_check (#10943)

* use dynamic blob_base_fee_update_fraction selection based on hardfork set

* bump alloy-chains version w/ foundry-fork-db

* fix: fork errors getting overriden by RevertDiagnostic inspector (#10954)

* fix: fork revert diagnostic

* feat(`cheatcodes`): introduces `ForkRevertDiagnostic`

* patch revm to include fix for `call_end` not being called

* fix: can_run_test_with_json_output_verbose

* Revert "fix: fork errors getting overriden by RevertDiagnostic inspector (#10954)"

This reverts commit b74f48a.

* fix(`cast`): disable balance check for impersonated txs. (#10972)

fix(`cast/test`): disable balance check for impersonated tx

* Revert "fix(`anvil/test`): change delegatecall.value in test_call_ots_trace_transaction"

This reverts commit 6db3d97.

* fix(`evm`): remove Handler impl for `FoundryHandler` (#10975)

* fix(`evm`): Handler impl for FoundryEvm

* cleanup

* fmt

* bump foundry-fork-db 0.16, fix tests

* bump alloy

* unify blob_base_fee_update_fraction in helper, clarify exception

* move helpers to evm-core for blob_base_fee_update_fraction

* Update mod.rs

Co-authored-by: DaniPopes <[email protected]>

* unpatch revm, update to 27.0.3

* fix fmt

* revert to solar 1.4, waiting for upgrade PR

* bump alloy-evm / alloy-op-evm

* forcibly downgrade solar-config, solar-macros due to breaking change in 0.1.5

* feat(`revm bump`): add serialization method that serializes as `u64` if fits or `U256` if not (#11008)

* add serialization method that serializes as u64 if fits or u256 if not

* clean up, no longer a need for 0x1

* toml spec limits number representation to i64

---------

Co-authored-by: Yash Atreya <[email protected]>
Co-authored-by: DaniPopes <[email protected]>
@grandizzy grandizzy moved this from Done to Completed in Foundry Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L-ignore Log: ignore PR in changelog

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

2 participants