diff --git a/eth-bytecode-db/eth-bytecode-db-server/tests/verifier_alliance.rs b/eth-bytecode-db/eth-bytecode-db-server/tests/verifier_alliance.rs
index 945824109..0c232f917 100644
--- a/eth-bytecode-db/eth-bytecode-db-server/tests/verifier_alliance.rs
+++ b/eth-bytecode-db/eth-bytecode-db-server/tests/verifier_alliance.rs
@@ -276,9 +276,9 @@ async fn insert_contract_deployment(txn: &DatabaseTransaction, test_case: &TestC
chain_id: Set(test_case.chain_id.into()),
address: Set(test_case.address.to_vec()),
transaction_hash: Set(test_case.transaction_hash.to_vec()),
- block_number: Set(Some(test_case.block_number.into())),
- txindex: Set(Some(test_case.transaction_index.into())),
- deployer: Set(Some(test_case.deployer.to_vec())),
+ block_number: Set(test_case.block_number.into()),
+ txindex: Set(test_case.transaction_index.into()),
+ deployer: Set(test_case.deployer.to_vec()),
contract_id: Set(contract_id),
}
.insert(txn)
@@ -386,17 +386,15 @@ async fn check_contract_deployment(db: &DatabaseConnection, test_case: &TestCase
"Invalid contract_deployments.transaction_hash"
);
assert_eq!(
- Some(test_case_block_number),
- contract_deployment.block_number,
+ test_case_block_number, contract_deployment.block_number,
"Invalid contract_deployments.block_number"
);
assert_eq!(
- Some(test_case_transaction_index),
- contract_deployment.txindex,
+ test_case_transaction_index, contract_deployment.txindex,
"Invalid contract_deployments.txindex"
);
assert_eq!(
- Some(test_case.deployer.to_vec()),
+ test_case.deployer.to_vec(),
contract_deployment.deployer,
"Invalid contract_deployments.deployer"
);
diff --git a/eth-bytecode-db/eth-bytecode-db/src/verification/db/verifier_alliance_db.rs b/eth-bytecode-db/eth-bytecode-db/src/verification/db/verifier_alliance_db.rs
index 3cd7a6bc9..d1300f162 100644
--- a/eth-bytecode-db/eth-bytecode-db/src/verification/db/verifier_alliance_db.rs
+++ b/eth-bytecode-db/eth-bytecode-db/src/verification/db/verifier_alliance_db.rs
@@ -6,7 +6,7 @@ use anyhow::Context;
use blockscout_display_bytes::Bytes as DisplayBytes;
use sea_orm::{
entity::prelude::ColumnTrait, ActiveValue::Set, DatabaseConnection, DatabaseTransaction,
- EntityTrait, JoinType, QueryFilter, QuerySelect, RelationTrait, TransactionTrait,
+ EntityTrait, QueryFilter, TransactionTrait,
};
use verifier_alliance_entity::{
code, compiled_contracts, contract_deployments, contracts, verified_contracts,
@@ -33,26 +33,35 @@ pub(crate) async fn insert_data(
.await
.context("begin database transaction")?;
- let contract = retrieve_contract(&txn, &deployment_data)
+ let contract_deployment = retrieve_contract_deployment(&txn, &deployment_data)
.await
- .context("retrieve contract")?
+ .context("retrieve contract contract_deployment")?
.ok_or_else(|| {
anyhow::anyhow!(
- "contract was not found: chain_id={}, address={}, transaction_hash={}",
+ "contract deployment was not found: chain_id={}, address={}, transaction_hash={}",
deployment_data.chain_id,
DisplayBytes::from(deployment_data.contract_address.clone()),
DisplayBytes::from(deployment_data.transaction_hash.clone())
)
})?;
+ let contract = retrieve_contract(&txn, &contract_deployment)
+ .await
+ .context("retrieve contract")?;
+
let compiled_contract = insert_compiled_contract(&txn, source_response)
.await
.context("insert compiled_contract")?;
- let _verified_contract =
- insert_verified_contract(&deployment_data, &txn, &contract, &compiled_contract)
- .await
- .context("insert verified_contract")?;
+ let _verified_contract = insert_verified_contract(
+ &deployment_data,
+ &txn,
+ &contract,
+ &contract_deployment,
+ &compiled_contract,
+ )
+ .await
+ .context("insert verified_contract")?;
txn.commit().await.context("commit transaction")?;
@@ -85,15 +94,11 @@ pub(crate) async fn insert_deployment_data(
Ok(())
}
-async fn retrieve_contract(
+async fn retrieve_contract_deployment(
txn: &DatabaseTransaction,
deployment_data: &ContractDeploymentData,
-) -> Result