Skip to content

Conversation

@pgherveou
Copy link

@pgherveou pgherveou commented Jan 19, 2026

Adds immutable variable support

To replay an existing PVM contract from another chain, we need to restore both its mutable storage state and its immutable state.

Unlike EVM, where immutables are embedded in the runtime bytecode, PVM contracts use a single bytecode. Immutable values are instead stored in a dedicated immutable storage map, which is initialized during contract construction.

This PR introduces a new Anvil RPC anvil_setImmutableStorageAt method to set this storage

@pgherveou pgherveou marked this pull request as ready for review January 19, 2026 10:50
Copy link

@re-gius re-gius left a comment

Choose a reason for hiding this comment

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

It would be good to have unit tests here, e.g. a smart contract with an immutable value that you can read to check it's actually changed. Since this is not a classic anvil method, you can also leave a TODO to add tests

@pgherveou
Copy link
Author

It would be good to have unit tests here, e.g. a smart contract with an immutable value that you can read to check it's actually changed. Since this is not a classic anvil method, you can also leave a TODO to add tests

will add a test

- Changed RPC interface to accept individual immutable values instead of concatenated bytes
- Moved endianness conversion (big-endian to little-endian) from test to RPC handler
- Updated test to pass immutable values as separate ABI-encoded Bytes elements
- Simplified byte conversion logic: removed unnecessary intermediate vector, using direct indexing
- Added comprehensive documentation explaining data format and conversion process
- All immutable values now handled consistently with better API clarity

This makes the RPC easier to invoke and aligns with how Sourcify and solc provide immutable data.

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
@pgherveou pgherveou enabled auto-merge (squash) January 20, 2026 16:08
@pgherveou pgherveou merged commit 4ad768f into master Jan 20, 2026
16 of 26 checks passed
@pgherveou pgherveou deleted the pg/add-immutable branch January 20, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants