File tree 3 files changed +27
-1
lines changed
3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @nomicfoundation/edr " : patch
3
+ ---
4
+
5
+ Fixed a bug in ` hardhat_metadata ` where the local chain id was being used in the fork metadata
Original file line number Diff line number Diff line change @@ -89,6 +89,8 @@ pub struct ForkedBlockchain {
89
89
/// The chan id of the forked blockchain is either the local chain id
90
90
/// override or the chain id of the remote blockchain.
91
91
chain_id : u64 ,
92
+ /// The chain id of the remote blockchain. It might deviate from chain_id.
93
+ remote_chain_id : u64 ,
92
94
network_id : u64 ,
93
95
spec_id : SpecId ,
94
96
hardfork_activations : Option < HardforkActivations > ,
@@ -218,13 +220,19 @@ impl ForkedBlockchain {
218
220
remote : RemoteBlockchain :: new ( rpc_client, runtime) ,
219
221
state_root_generator,
220
222
chain_id : chain_id_override. unwrap_or ( remote_chain_id) ,
223
+ remote_chain_id,
221
224
fork_block_number,
222
225
network_id,
223
226
spec_id,
224
227
hardfork_activations,
225
228
} )
226
229
}
227
230
231
+ /// Returns the chain id of the remote blockchain.
232
+ pub fn remote_chain_id ( & self ) -> u64 {
233
+ self . remote_chain_id
234
+ }
235
+
228
236
fn runtime ( & self ) -> & runtime:: Handle {
229
237
self . remote . runtime ( )
230
238
}
Original file line number Diff line number Diff line change @@ -2323,7 +2323,7 @@ fn create_blockchain_and_state(
2323
2323
2324
2324
Ok ( BlockchainAndState {
2325
2325
fork_metadata : Some ( ForkMetadata {
2326
- chain_id : blockchain. chain_id ( ) ,
2326
+ chain_id : blockchain. remote_chain_id ( ) ,
2327
2327
fork_block_number,
2328
2328
fork_block_hash : * blockchain
2329
2329
. block_by_number ( fork_block_number)
@@ -2777,6 +2777,19 @@ mod tests {
2777
2777
Ok ( ( ) )
2778
2778
}
2779
2779
2780
+ #[ test]
2781
+ fn fork_metadata_fork_mode ( ) -> anyhow:: Result < ( ) > {
2782
+ let fixture = ProviderTestFixture :: new_forked ( None ) ?;
2783
+
2784
+ let fork_metadata = fixture
2785
+ . provider_data
2786
+ . fork_metadata ( )
2787
+ . expect ( "fork metadata should exist" ) ;
2788
+ assert_eq ! ( fork_metadata. chain_id, 1 ) ;
2789
+
2790
+ Ok ( ( ) )
2791
+ }
2792
+
2780
2793
#[ test]
2781
2794
fn console_log_mine_block ( ) -> anyhow:: Result < ( ) > {
2782
2795
let mut fixture = ProviderTestFixture :: new_local ( ) ?;
You can’t perform that action at this time.
0 commit comments