Skip to content

Commit bce6df7

Browse files
committed
Make use of 'is_blueprint' verification response for search
1 parent afae3d6 commit bce6df7

File tree

7 files changed

+24
-9
lines changed

7 files changed

+24
-9
lines changed

eth-bytecode-db/eth-bytecode-db-server/src/types/source.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl From<search::MatchContract> for SourceWrapper {
4949
compilation_artifacts: value.compilation_artifacts,
5050
creation_input_artifacts: value.creation_input_artifacts,
5151
deployed_bytecode_artifacts: value.deployed_bytecode_artifacts,
52-
is_blueprint: false,
52+
is_blueprint: value.is_blueprint,
5353
}
5454
.into()
5555
}
@@ -206,6 +206,7 @@ mod tests {
206206
deployed_bytecode_artifacts: Some("deployed_bytecode_artifacts".into()),
207207
raw_creation_input: vec![0u8, 1u8, 2u8, 3u8, 4u8],
208208
raw_deployed_bytecode: vec![5u8, 6u8, 7u8, 8u8],
209+
is_blueprint: false,
209210
};
210211

211212
let expected = proto::Source {

eth-bytecode-db/eth-bytecode-db-server/tests/database_search.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ async fn search_blueprint_contracts() {
406406
/********** Setup **********/
407407

408408
let mut test_data = test_input_data::basic(verification::SourceType::Solidity, MatchType::Full);
409+
test_data.set_is_blueprint(true);
409410
test_data.set_bytecode(smart_contract_verifier_v2::verify_response::ExtraData {
410411
local_creation_input_parts: vec![
411412
smart_contract_verifier_v2::verify_response::extra_data::BytecodePart {

eth-bytecode-db/eth-bytecode-db-server/tests/verification_test_helpers/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,8 @@ pub mod test_cases {
130130
{
131131
let db = init_db(test_suite_name, "test_propagates_is_blueprint_in_response").await;
132132

133-
let test_data = {
134-
let test_data = test_input_data::basic(source_type, MatchType::Partial);
135-
let mut source = test_data.eth_bytecode_db_response.source.unwrap();
136-
let extra_data = test_data.verifier_response.extra_data.unwrap();
137-
source.is_blueprint = true;
138-
TestInputData::from_source_and_extra_data(source, extra_data)
139-
};
133+
let mut test_data = test_input_data::basic(source_type, MatchType::Partial);
134+
test_data.set_is_blueprint(true);
140135

141136
let db_url = db.db_url();
142137
let verifier_addr =

eth-bytecode-db/eth-bytecode-db-server/tests/verification_test_helpers/test_input_data.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ impl TestInputData {
132132
.source_files
133133
.insert(file_name, content);
134134
}
135+
136+
pub fn set_is_blueprint(&mut self, is_blueprint: bool) {
137+
self.verifier_response.source.as_mut().unwrap().is_blueprint = is_blueprint;
138+
self.eth_bytecode_db_response
139+
.source
140+
.as_mut()
141+
.unwrap()
142+
.is_blueprint = is_blueprint;
143+
}
135144
}
136145

137146
pub fn basic(source_type: SourceType, match_type: MatchType) -> TestInputData {

eth-bytecode-db/eth-bytecode-db/src/search/alliance_db.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ fn match_contract_from_model(
107107
// so for complexity reasons, we just ignore them for now
108108
raw_creation_input: vec![],
109109
raw_deployed_bytecode: vec![],
110+
is_blueprint: false,
110111
};
111112

112113
Ok(match_contract)

eth-bytecode-db/eth-bytecode-db/src/search/any_match.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ where
1414
let bytecode_type = remote.bytecode_type.to_string();
1515
let label_values = &[bytecode_type.as_str()];
1616

17+
let mut is_blueprint = false;
1718
if let BytecodeType::CreationInput = remote.bytecode_type {
1819
if let Some(parsed_blueprint_code) =
1920
blueprint_contracts::from_creation_code(remote.data.clone())
2021
{
21-
remote.data = parsed_blueprint_code
22+
remote.data = parsed_blueprint_code;
23+
is_blueprint = true;
2224
}
2325
}
2426

@@ -28,6 +30,7 @@ where
2830
{
2931
remote.data = parsed_blueprint_code;
3032
remote.bytecode_type = BytecodeType::CreationInput;
33+
is_blueprint = true;
3134
}
3235
}
3336

@@ -37,6 +40,9 @@ where
3740
.start_timer();
3841
find_match_contracts(db, &remote).await?
3942
};
43+
matches
44+
.iter_mut()
45+
.for_each(|value| value.is_blueprint = is_blueprint);
4046
metrics::ALL_MATCHES_COUNT
4147
.with_label_values(label_values)
4248
.observe(matches.len() as f64);

eth-bytecode-db/eth-bytecode-db/src/search/match_contract.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub struct MatchContract {
2828
pub deployed_bytecode_artifacts: Option<String>,
2929
pub raw_creation_input: Vec<u8>,
3030
pub raw_deployed_bytecode: Vec<u8>,
31+
pub is_blueprint: bool,
3132
}
3233

3334
impl MatchContract {
@@ -100,6 +101,7 @@ impl MatchContract {
100101
.map(|value| value.to_string()),
101102
raw_creation_input: source.raw_creation_input,
102103
raw_deployed_bytecode: source.raw_deployed_bytecode,
104+
is_blueprint: false,
103105
};
104106

105107
Ok(match_contract)

0 commit comments

Comments
 (0)