Skip to content

Commit

Permalink
Problem: contract verifier enforces the last 64 bytes metadata check (#…
Browse files Browse the repository at this point in the history
…93)

Co-authored-by: Thomas Nguy <[email protected]>
  • Loading branch information
JayT106 and thomas-nguy committed Jan 23, 2025
1 parent 3ce7e8a commit 5607aae
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions core/lib/contract_verifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,26 @@ impl ContractVerifier {
compiled = hex::encode(artifacts.deployed_bytecode()),
"Deployed (runtime) bytecode mismatch",
);
return Err(ContractVerifierError::BytecodeMismatch);

// try without the last 64bytes which usually represents the compiler metadata
let mut deployed_bytecode_without_metadata: Vec<u8> = deployed_bytecode.to_vec();
// Check if the length of the vector is greater than or equal to 64
if deployed_bytecode_without_metadata.len() >= 64 {
// Remove the last 64 bytes
let new_len = deployed_bytecode_without_metadata.len() - 64;
deployed_bytecode_without_metadata.truncate(new_len);
if artifacts.bytecode.clone() != deployed_bytecode_without_metadata {
tracing::info!(
"Bytecode without metadata mismatch req {}, deployed: 0x{}, compiled 0x{}",
request.id,
hex::encode(deployed_bytecode_without_metadata.clone()),
hex::encode(artifacts.bytecode.clone())
);
return Err(ContractVerifierError::BytecodeMismatch);
}
} else {
return Err(ContractVerifierError::BytecodeMismatch);
}
}

match constructor_args {
Expand All @@ -292,7 +311,7 @@ impl ContractVerifier {
tracing::trace!(%verified_at, "verified request");
Ok(VerificationInfo {
request,
artifacts,
artifacts: artifacts.clone(),
verified_at,
})
}
Expand Down

0 comments on commit 5607aae

Please sign in to comment.