Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eth-bytecode-db): integrate verifier_alliance schema v1 #1202

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
5f9e0e9
chore(eth-bytecode-db): update 'verification-common-v1' to rev '5481500'
rimrakhimov Jan 15, 2025
983dd29
chore(eth-bytecode-db): bump 'verification-common' to rev '5481500'
rimrakhimov Jan 15, 2025
52da999
refactor(eth-bytecode-db): make use of verification-common comparison…
rimrakhimov Jan 15, 2025
47bd28b
test(eth-bytecode-db): remove verifier alliance test cases from 'eth-…
rimrakhimov Jan 15, 2025
8bb143f
refactor(eth-bytecode-db): extract verifier-alliance database test ca…
rimrakhimov Jan 16, 2025
1779c39
test(eth-bytecode-db): add test cases for verify-standard-json endpoi…
rimrakhimov Jan 17, 2025
9c07b75
feat(eth-bytecode-db): make use of verifier-alliance-database and ver…
rimrakhimov Jan 20, 2025
d6e3a61
feat(eth-bytecode-db): add VerifierAlliance service into http client
rimrakhimov Jan 20, 2025
00402c8
test(eth-bytecode-db): add tests for solidity_batch_import endpoint
rimrakhimov Jan 21, 2025
920db5e
feat(eth-bytecode-db): make search support verifier alliance v1 schema
rimrakhimov Jan 21, 2025
0f462c8
chore(eth-bytecode-db): remove '-v1' suffix from verifier-alliance-en…
rimrakhimov Jan 21, 2025
7a58866
chore(eth-bytecode-db): apply code-rabbit suggestions
rimrakhimov Jan 22, 2025
d40cd30
chore(eth-bytecode-db): remove unused async-backtrace crate from Carg…
rimrakhimov Jan 22, 2025
3f33fa0
fix(eth-bytecode-db): convert compiled contract language value to low…
rimrakhimov Jan 22, 2025
cb61641
fix(eth-bytecode-db): sort contract_deployments by block_numbers to o…
rimrakhimov Jan 22, 2025
7d71e6e
refactor(eth-bytecode-db): extract artifacts parsing into a function
rimrakhimov Jan 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 70 additions & 37 deletions eth-bytecode-db/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions eth-bytecode-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
"eth-bytecode-db/verifier-alliance-entity",
"eth-bytecode-db/verifier-alliance-migration",
"verifier-alliance-database",
"verifier-alliance-database-tests",
]

[workspace.dependencies]
Expand All @@ -17,13 +18,10 @@ eth-bytecode-db = { path = "eth-bytecode-db" }
eth-bytecode-db-proto = { path = "eth-bytecode-db-proto" }
eth-bytecode-db-server = { path = "eth-bytecode-db-server" }
migration = { path = "eth-bytecode-db/migration" }
verifier-alliance-entity = { git = "https://github.com/blockscout/blockscout-rs", rev = "ec1c755" }
verifier-alliance-entity = { path = "eth-bytecode-db/verifier-alliance-entity" }
verifier-alliance-database = { path = "verifier-alliance-database" }
verifier-alliance-migration = { git = "https://github.com/blockscout/blockscout-rs", rev = "ec1c755" }

verifier-alliance-entity-v1 = { path = "eth-bytecode-db/verifier-alliance-entity", package = "verifier-alliance-entity" }
verifier-alliance-migration-v1 = { path = "eth-bytecode-db/verifier-alliance-migration", package = "verifier-alliance-migration" }
verification-common-v1 = { git = "https://github.com/blockscout/blockscout-rs", rev = "1164e09", package = "verification-common" }
verifier-alliance-database-tests = { path = "verifier-alliance-database-tests" }
verifier-alliance-migration = { path = "eth-bytecode-db/verifier-alliance-migration" }

actix-prost = { git = "https://github.com/blockscout/actix-prost", rev = "4cbba2a" }
actix-prost-macros = { git = "https://github.com/blockscout/actix-prost", rev = "4cbba2a" }
Expand All @@ -35,7 +33,7 @@ anyhow = { version = "1" }
async-std = { version = "^1" }
async-trait = { version = "0.1" }
blockscout-display-bytes = { version = "1.1.0" }
blockscout-service-launcher = { version = "0.15.0", default-features = false, features = ["database-1_0"] }
blockscout-service-launcher = { version = "0.16.2", default-features = false, features = ["database-1_0"] }
bytes = { version = "1.2" }
ethabi = { version = "18.0" }
ethers = { version = "2.0.0" }
Expand Down Expand Up @@ -68,6 +66,7 @@ smart-contract-verifier-proto = { git = "https://github.com/blockscout/blockscou
solidity-metadata = { version = "1.0" }
sourcify = { git = "https://github.com/blockscout/blockscout-rs", rev = "457af68" }
strum = { version = "0.26.3", default-features = false, features = ["derive"] }
test-log = { version = "0.2.16" }
thiserror = { version = "1" }
tokio = { version = "1" }
tokio-stream = { version = "0.1" }
Expand All @@ -76,4 +75,4 @@ tonic-build = { version = "0.8" }
tracing = { version = "0.1" }
tracing-subscriber = { version = "0.3" }
url = { version = "2" }
verification-common = { git = "https://github.com/blockscout/blockscout-rs", rev = "3892914" }
verification-common = { git = "https://github.com/blockscout/blockscout-rs", rev = "5481500" }
24 changes: 24 additions & 0 deletions eth-bytecode-db/eth-bytecode-db-proto/src/http_client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,30 @@ pub mod sourcify_verifier_client {
}
}

pub mod verifier_alliance_client {
use super::{proto, Client, Result};

pub async fn batch_import_solidity_multi_part(
client: &Client,
request: proto::VerifierAllianceBatchImportSolidityMultiPartRequest,
) -> Result<proto::VerifierAllianceBatchImportResponse> {
let path = "/api/v2/alliance/solidity/multi-part:batch-import";
client
.post_request_with_headers(client.build_url(path), &request, client.key_headers())
.await
}

pub async fn batch_import_solidity_standard_json(
client: &Client,
request: proto::VerifierAllianceBatchImportSolidityStandardJsonRequest,
) -> Result<proto::VerifierAllianceBatchImportResponse> {
let path = "/api/v2/alliance/solidity/standard-json:batch-import";
client
.post_request_with_headers(client.build_url(path), &request, client.key_headers())
.await
}
}

pub mod health_client {
use super::{proto, Client, Result};

Expand Down
32 changes: 31 additions & 1 deletion eth-bytecode-db/eth-bytecode-db-proto/src/http_client/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ use crate::blockscout::eth_bytecode_db::v2::{
database_actix::route_database, database_server::Database,
solidity_verifier_actix::route_solidity_verifier, solidity_verifier_server::SolidityVerifier,
sourcify_verifier_actix::route_sourcify_verifier, sourcify_verifier_server::SourcifyVerifier,
verifier_alliance_actix::route_verifier_alliance, verifier_alliance_server::VerifierAlliance,
vyper_verifier_actix::route_vyper_verifier, vyper_verifier_server::VyperVerifier,
AllianceStats, BatchSearchEventDescriptionsRequest, BatchSearchEventDescriptionsResponse,
GetAllianceStatsRequest, ListCompilerVersionsRequest, ListCompilerVersionsResponse,
SearchAllSourcesRequest, SearchAllSourcesResponse, SearchAllianceSourcesRequest,
SearchEventDescriptionsRequest, SearchEventDescriptionsResponse, SearchSourcesRequest,
SearchSourcesResponse, SearchSourcifySourcesRequest, VerifyFromEtherscanSourcifyRequest,
SearchSourcesResponse, SearchSourcifySourcesRequest, VerifierAllianceBatchImportResponse,
VerifierAllianceBatchImportSolidityMultiPartRequest,
VerifierAllianceBatchImportSolidityStandardJsonRequest, VerifyFromEtherscanSourcifyRequest,
VerifyResponse, VerifySolidityMultiPartRequest, VerifySolidityStandardJsonRequest,
VerifySourcifyRequest, VerifyVyperMultiPartRequest, VerifyVyperStandardJsonRequest,
};
Expand Down Expand Up @@ -74,12 +77,25 @@ mock! {
}
}

mock! {
#[derive(Clone)]
pub VerifierAllianceService {}

#[async_trait::async_trait]
impl VerifierAlliance for VerifierAllianceService {
async fn batch_import_solidity_multi_part(&self, request: tonic::Request<VerifierAllianceBatchImportSolidityMultiPartRequest>) -> Result<tonic::Response<VerifierAllianceBatchImportResponse>, tonic::Status>;

async fn batch_import_solidity_standard_json(&self, request: tonic::Request<VerifierAllianceBatchImportSolidityStandardJsonRequest>) -> Result<tonic::Response<VerifierAllianceBatchImportResponse>, tonic::Status>;
}
}

#[derive(Default, Clone)]
pub struct EthBytecodeDbServer {
database_service: Option<Arc<MockDatabaseService>>,
solidity_verifier_service: Option<Arc<MockSolidityVerifierService>>,
vyper_verifier_service: Option<Arc<MockVyperVerifierService>>,
sourcify_verifier_service: Option<Arc<MockSourcifyVerifierService>>,
verifier_alliance_service: Option<Arc<MockVerifierAllianceService>>,
}

impl EthBytecodeDbServer {
Expand All @@ -89,6 +105,7 @@ impl EthBytecodeDbServer {
solidity_verifier_service: None,
vyper_verifier_service: None,
sourcify_verifier_service: None,
verifier_alliance_service: None,
}
}

Expand Down Expand Up @@ -118,6 +135,14 @@ impl EthBytecodeDbServer {
self
}

pub fn verifier_alliance_service(
mut self,
verifier_alliance_service: MockVerifierAllianceService,
) -> Self {
self.verifier_alliance_service = Some(Arc::new(verifier_alliance_service));
self
}

pub async fn start(&self) -> SocketAddr {
let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
let addr = listener.local_addr().unwrap();
Expand All @@ -126,6 +151,7 @@ impl EthBytecodeDbServer {
let solidity_verifier_service = self.solidity_verifier_service.clone();
let vyper_verifier_service = self.vyper_verifier_service.clone();
let sourcify_verifier_service = self.sourcify_verifier_service.clone();
let verifier_alliance_service = self.verifier_alliance_service.clone();

let configure_router = move |service_config: &mut actix_web::web::ServiceConfig| {
if let Some(database) = database_service.clone() {
Expand All @@ -140,6 +166,10 @@ impl EthBytecodeDbServer {
if let Some(sourcify) = sourcify_verifier_service.clone() {
service_config.configure(|config| route_sourcify_verifier(config, sourcify));
}
if let Some(verifier_alliance) = verifier_alliance_service.clone() {
service_config
.configure(|config| route_verifier_alliance(config, verifier_alliance));
}
};

let server =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod mock;

pub use client::{
database_client, health_client, solidity_verifier_client, sourcify_verifier_client,
vyper_verifier_client, Client,
verifier_alliance_client, vyper_verifier_client, Client,
};
pub use config::Config;

Expand Down
Loading
Loading