Anvil: Fix everything to make it work with real assethub westend #508
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.
Description
This PR enables forking from production chains like Westend Asset Hub by implementing dynamic transaction building and batch storage prefetching to address pallet index mismatches and reduce RPC latency.
Changes
Dynamic Transaction Building
When forking from a chain with a different runtime configuration, the hardcoded pallet index used by
subxt_client::tx().revive().eth_transact()may not match the forked chain's pallet ordering, causing transaction failures. This PR introduces dynamic transaction building using subxt'sdynamic_tx()which reads pallet indices from the runtime metadata at execution time, ensuring correct encoding regardless of the forked chain's configuration.Batch Storage Prefetching
Each storage read from a remote chain requires an individual RPC call, causing significant latency during transaction validation. This PR implements batch prefetching using
state_queryStorageAtto fetch multiple storage keys in a single RPC call. Before validating an Ethereum transaction, the sender's account info is prefetched to avoid sequential RPC round-trips.Tests
send_transaction_and_wait()anddeploy_contract_and_wait()helpers that poll for transaction receipts with configurable timeouts, essential for reliable testing against remote networks with variable block timesforking-testsfeature flag - forking tests now run without special configurationAll forking tests pass against real Westend Asset Hub