@@ -334,19 +334,30 @@ impl VerifyBytecodeArgs {
334334 // code cannot be verified. Verify the runtime bytecode instead by deploying the local
335335 // creation code and comparing the resulting runtime code with the onchain one.
336336 if creation_data. is_none ( ) {
337- let deploy_block = if maybe_predeploy {
338- if !shell :: is_json ( ) {
337+ if !shell :: is_json ( ) {
338+ if maybe_predeploy {
339339 sh_warn ! (
340340 "Attempting to verify predeployed contract at {:?}. Ignoring creation code verification." ,
341341 self . address
342342 ) ?;
343+ } else {
344+ sh_warn ! ( "Creation data is unavailable. Ignoring creation code verification." ) ?;
345+ }
346+ }
347+
348+ // Without creation data there is nothing else to verify when the runtime bytecode is
349+ // ignored.
350+ if self . ignore . is_some_and ( |b| b. is_runtime ( ) ) {
351+ if shell:: is_json ( ) {
352+ sh_println ! ( "{}" , serde_json:: to_string( & json_results) ?) ?;
343353 }
354+ return Ok ( ( ) ) ;
355+ }
356+
357+ let deploy_block = if maybe_predeploy {
344358 // Deploy at genesis
345359 0_u64
346360 } else {
347- if !shell:: is_json ( ) {
348- sh_warn ! ( "Creation data is unavailable. Ignoring creation code verification." ) ?;
349- }
350361 match self . block {
351362 Some ( BlockId :: Number ( BlockNumberOrTag :: Number ( block) ) ) => block,
352363 Some ( _) => eyre:: bail!( "Invalid block number" ) ,
@@ -405,13 +416,15 @@ impl VerifyBytecodeArgs {
405416 kind,
406417 ) ?;
407418
408- // Compare runtime bytecode
419+ // Compare runtime bytecode. The onchain code is read at `deploy_block` to stay
420+ // anchored to the same height as the local fork. Predeploys keep reading at the
421+ // latest block: their code is stable and genesis state often isn't served by RPCs.
409422 let ( deployed_bytecode, onchain_runtime_code) = crate :: utils:: get_runtime_codes :: < FEN > (
410423 & mut executor,
411424 & provider,
412425 self . address ,
413426 fork_address,
414- None ,
427+ ( !maybe_predeploy ) . then_some ( deploy_block ) ,
415428 )
416429 . await ?;
417430
0 commit comments