Skip to content

Add immutable support#498

Merged
pgherveou merged 5 commits intomasterfrom
pg/add-immutable
Jan 20, 2026
Merged

Add immutable support#498
pgherveou merged 5 commits intomasterfrom
pg/add-immutable

Conversation

@pgherveou
Copy link
Copy Markdown

@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
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown

@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
Copy Markdown
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

Comment thread crates/anvil-polkadot/tests/it/state_injector.rs
- 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 <noreply@anthropic.com>
@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
dimartiro pushed a commit to ChainSafe/foundry-polkadot that referenced this pull request Feb 9, 2026
* add immutable

* Remove unnecessary genesis.rs changes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* add test

* refactor: improve anvil_setImmutableStorageAt API to accept Vec<Bytes>

- 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 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
re-gius added a commit that referenced this pull request Feb 10, 2026
* [Anvil] Fix impersonation marker collision with storage keys (#489)

* [Anvil] Fix impersonation marker collision with storage keys

Use 0xDE marker instead of 0x00 for impersonated transaction signatures
to avoid collision with Solidity mapping key computations for slot 0.

Closes #488

* !fixup af24a53a0

* Use original syntax

* fix

* update to latest polkadot-sdk (#467)

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
Co-authored-by: zerosnacks <zerosnacks@protonmail.com>

* Fix etch cheatcode (#486)

* Add initial sync between REVM and pallet-revive (#487)

* add more deposit_limits (#493)

* add more deposit_limits

* clippy

* update compilers (#497)

* update foundry-compilers

* hardcode resolc version

* Fix external-projects results parsing (#499)

* Fix external-projects results parsing

* Change to json

* Add check for cheatcodes usage in pallet-revive (#494)

* Add immutable support (#498)

* add immutable

* Remove unnecessary genesis.rs changes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* add test

* refactor: improve anvil_setImmutableStorageAt API to accept Vec<Bytes>

- 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 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* Fix polkadotskip test (#502)

* Fix JSON parsing in external-projects CI (#501)

Co-authored-by: Pavlo Khrystenko <45178695+pkhry@users.noreply.github.com>

* Fix contract storage migration (#500)

* Skip auto-funding for accounts that were explicitly dealt (#496)

* Skip auto-funding for accounts that were explicitly dealt

* Use existing eth_deals

* Add repro test case for fund_pranked_accounts bug

* Remove unnecessary test

* Sync dealt balances to pallet-revive when pranking and pass eth_deals directly instead of cloning

* Add warning when overflow happens (#503)

* Set storage deposit for etched accounts (#504)

* Limit uint to u64::MAX for fuzz tests (#507)

* Add cheatcode tests (#435)

* update compilers (#511)

* Fix timestamp clamping to prevent overflow when converting to milliseconds (#510)

* Default eth_estimateGas block parameter to pending to match Anvil/EDR behavior (#509)

* Default eth_estimateGas to pending block to match Anvil/EDR

* Fix snapshot issues (#512)

* Add Claude config (#517)

* Attempt to fix CI (#513)

* change urls

* add transient storage support in `polkadot` test execution mode (#449)

* improve logging to match upstream anvil (#522)

* Fix compatibility issues after syncing with master

* Fmt

* Remove consensus.rs

* Fix retrieve para id

* skip proof recorder when forking is enabled

* Add comment explaining the irrelevant harcoded slot duration

* Fix fmt and clippy

---------

Co-authored-by: PG Herveou <pgherveou@parity.io>
Co-authored-by: Pavlo Khrystenko <45178695+pkhry@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: zerosnacks <95942363+zerosnacks@users.noreply.github.com>
Co-authored-by: zerosnacks <zerosnacks@protonmail.com>
Co-authored-by: Sebastian Miasojed <s.miasojed@gmail.com>
Co-authored-by: filip-parity <filip.baciu@parity.io>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Marian Radu <marian@parity.io>
Co-authored-by: Giuseppe Re <giuseppe.re@parity.io>
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.

2 participants