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

Add lookup_methods endpoint #668

Merged
merged 6 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
571 changes: 459 additions & 112 deletions smart-contract-verifier/Cargo.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ http:
- selector: blockscout.smartContractVerifier.v2.SolidityVerifier.ListCompilerVersions
get: /api/v2/verifier/solidity/versions

- selector: blockscout.smartContractVerifier.v2.SolidityVerifier.LookupMethods
post: /api/v2/verifier/solidity/methods:lookup
body: "*"


#################### Vyper Verifier ####################

- selector: blockscout.smartContractVerifier.v2.VyperVerifier.VerifyMultiPart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ service SolidityVerifier {
rpc VerifyStandardJson(VerifySolidityStandardJsonRequest) returns (VerifyResponse) {}

rpc ListCompilerVersions(ListCompilerVersionsRequest) returns (ListCompilerVersionsResponse) {}

rpc LookupMethods(LookupMethodsRequest) returns (LookupMethodsResponse) {}
}

service VyperVerifier {
Expand Down Expand Up @@ -218,3 +220,19 @@ message ListCompilerVersionsResponse {
/// Compiler versions available
repeated string compiler_versions = 1;
}

message LookupMethodsRequest {
string bytecode = 1;
string abi = 2;
string source_map = 3;
map<uint32, string> file_ids = 4;
}

message LookupMethodsResponse {
message Method {
string file_name = 1;
int32 file_offset = 2;
int32 length = 3;
lok52 marked this conversation as resolved.
Show resolved Hide resolved
}
map<string, Method> methods = 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ consumes:
produces:
- application/json
paths:
/api/v2/verifier/solidity/methods:lookup:
post:
operationId: SolidityVerifier_LookupMethods
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/v2LookupMethodsResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: body
in: body
required: true
schema:
$ref: '#/definitions/v2LookupMethodsRequest'
tags:
- SolidityVerifier
/api/v2/verifier/solidity/sources:verify-multi-part:
post:
operationId: SolidityVerifier_VerifyMultiPart
Expand Down Expand Up @@ -186,10 +206,10 @@ definitions:
ExtraDataBytecodePart:
type: object
properties:
data:
type: string
type:
type: string
data:
type: string
HealthCheckResponseServingStatus:
type: string
enum:
Expand All @@ -198,6 +218,18 @@ definitions:
- NOT_SERVING
- SERVICE_UNKNOWN
default: UNKNOWN
description: ' - SERVICE_UNKNOWN: Used only by the Watch method.'
LookupMethodsResponseMethod:
type: object
properties:
fileName:
type: string
fileOffset:
type: integer
format: int32
length:
type: integer
format: int32
SourceMatchType:
type: string
enum:
Expand Down Expand Up @@ -238,12 +270,12 @@ definitions:
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
$ref: '#/definitions/protobufAny'
message:
type: string
protobufAny:
type: object
properties:
Expand All @@ -270,53 +302,73 @@ definitions:
items:
type: string
title: / Compiler versions available
v2Source:
v2LookupMethodsRequest:
type: object
properties:
bytecode:
type: string
abi:
type: string
title: |-
/ Contract abi (https://docs.soliditylang.org/en/latest/abi-spec.html?highlight=abi#json);
/ (does not exist for Yul contracts)
compilationArtifacts:
sourceMap:
type: string
description: |-
/ General and compiler-specific artifacts (abi, userdoc, devdoc, licenses, ast, etc),
/ encoded as a json.
fileIds:
type: object
additionalProperties:
type: string
v2LookupMethodsResponse:
type: object
properties:
methods:
type: object
additionalProperties:
$ref: '#/definitions/LookupMethodsResponseMethod'
v2Source:
type: object
properties:
fileName:
type: string
title: / The name of the file verified contract was located at
contractName:
type: string
title: / The name of the contract which was verified
compilerVersion:
type: string
title: Compiler version used to compile the contract
compilerSettings:
type: string
title: |-
/ 'settings' key in Standard Input JSON
/ (https://docs.soliditylang.org/en/latest/using-the-compiler.html#input-description)
compilerVersion:
sourceType:
$ref: '#/definitions/SourceSourceType'
sourceFiles:
type: object
additionalProperties:
type: string
abi:
type: string
title: Compiler version used to compile the contract
title: |-
/ Contract abi (https://docs.soliditylang.org/en/latest/abi-spec.html?highlight=abi#json);
/ (does not exist for Yul contracts)
constructorArguments:
type: string
title: |-
/ Constructor arguments used for deploying verified contract
/ (exists only for creation inputs)
contractName:
matchType:
$ref: '#/definitions/SourceMatchType'
title: / Similar to Sourcify (see https://docs.sourcify.dev/docs/full-vs-partial-match/)
compilationArtifacts:
type: string
title: / The name of the contract which was verified
description: |-
/ General and compiler-specific artifacts (abi, userdoc, devdoc, licenses, ast, etc),
/ encoded as a json.
creationInputArtifacts:
type: string
description: / Info about the creation code (sourcemaps, linkreferences) encoded as a json.
deployedBytecodeArtifacts:
type: string
description: / Info about the runtime code (sourcemaps, linkreferences, immutables) encoded as a json.
fileName:
type: string
title: / The name of the file verified contract was located at
matchType:
$ref: '#/definitions/SourceMatchType'
title: / Similar to Sourcify (see https://docs.sourcify.dev/docs/full-vs-partial-match/)
sourceFiles:
type: object
additionalProperties:
type: string
sourceType:
$ref: '#/definitions/SourceSourceType'
v2VerificationMetadata:
type: object
properties:
Expand All @@ -340,14 +392,14 @@ definitions:
v2VerifyResponse:
type: object
properties:
extraData:
$ref: '#/definitions/VerifyResponseExtraData'
message:
type: string
source:
$ref: '#/definitions/v2Source'
status:
$ref: '#/definitions/v2VerifyResponseStatus'
source:
$ref: '#/definitions/v2Source'
extraData:
$ref: '#/definitions/VerifyResponseExtraData'
v2VerifyResponseStatus:
type: string
enum:
Expand All @@ -370,14 +422,6 @@ definitions:
evmVersion:
type: string
title: / Version of the EVM to compile for. If absent results in default EVM version
libraries:
type: object
additionalProperties:
type: string
title: / Map from a library name to its address
metadata:
$ref: '#/definitions/v2VerificationMetadata'
title: / An optional field to be filled by explorers
optimizationRuns:
type: integer
format: int32
Expand All @@ -389,6 +433,14 @@ definitions:
additionalProperties:
type: string
title: / Map from a source file name to the actual source code
libraries:
type: object
additionalProperties:
type: string
title: / Map from a library name to its address
metadata:
$ref: '#/definitions/v2VerificationMetadata'
title: / An optional field to be filled by explorers
v2VerifySolidityStandardJsonRequest:
type: object
properties:
Expand Down Expand Up @@ -418,10 +470,6 @@ definitions:
title: |-
/ The chain (network) the contract was deployed to
/ (https://docs.sourcify.dev/docs/api/chains/)
chosenContract:
type: integer
format: int32
title: (optional) see Sourcify Api
files:
type: object
additionalProperties:
Expand All @@ -430,6 +478,10 @@ definitions:
/ Files required for verification (see Sourcify Api)
Is named as `files` instead of `source_files`
to correspond with Sourcify api
chosenContract:
type: integer
format: int32
title: (optional) see Sourcify Api
v2VerifyVyperMultiPartRequest:
type: object
properties:
Expand All @@ -445,6 +497,11 @@ definitions:
evmVersion:
type: string
title: / Version of the EVM to compile for. If absent results in default EVM version
sourceFiles:
type: object
additionalProperties:
type: string
title: / Map from a source file name to the actual source code
interfaces:
type: object
additionalProperties:
Expand All @@ -455,11 +512,6 @@ definitions:
metadata:
$ref: '#/definitions/v2VerificationMetadata'
title: / An optional field to be filled by explorers
sourceFiles:
type: object
additionalProperties:
type: string
title: / Map from a source file name to the actual source code
v2VerifyVyperStandardJsonRequest:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ sig-provider-extension = { path = "../sig-provider-extension", optional = true }

actix-web = "4"
actix-web-prom = "0.6"
amplify = { version = "3.13.0", features = ["derive"] }
anyhow = "1.0"
async-trait = "0.1"
blockscout-display-bytes = { version = "1.0" }
blockscout-service-launcher = { version = "0.6.0" }
blockscout-service-launcher = { version = "0.9.0" }
bytes = "1.3"
config = "0.13"
cron = "0.11"
ethers-solc = "2.0.6"
ethers-solc = "2.0.10"
ethers-core = "2.0.10"
futures = "0.3"
lazy_static = "1"
opentelemetry = { version = "0.18", features = ["rt-tokio"] }
Expand All @@ -38,7 +40,9 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
url = "2.3"

[dev-dependencies]
ethers-solc = { version = "2.0.10", features = ["svm-solc"] }
blockscout-service-launcher = { version = "0.9.0" , features = ["test-server"]}
ethabi = "18.0"
pretty_assertions = "1.3"
reqwest = "0.11.13"
rstest = "0.16"
rstest = "0.18"
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use blockscout_service_launcher::launcher::ConfigSettings;
use smart_contract_verifier_server::Settings;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let settings = Settings::new().expect("failed to read config");
let settings = Settings::build().expect("failed to read config");
smart_contract_verifier_server::run(settings).await
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
pub use smart_contract_verifier_proto::blockscout::smart_contract_verifier::v2::{
health_actix, health_check_response, health_server, solidity_verifier_actix,
solidity_verifier_server, source, sourcify_verifier_actix, sourcify_verifier_server,
verify_response, vyper_verifier_actix, vyper_verifier_server, BytecodeType, HealthCheckRequest,
HealthCheckResponse, ListCompilerVersionsRequest, ListCompilerVersionsResponse, Source,
health_actix, health_check_response, health_server, lookup_methods_response,
solidity_verifier_actix, solidity_verifier_server, source, sourcify_verifier_actix,
sourcify_verifier_server, verify_response, vyper_verifier_actix, vyper_verifier_server,
BytecodeType, HealthCheckRequest, HealthCheckResponse, ListCompilerVersionsRequest,
ListCompilerVersionsResponse, LookupMethodsRequest, LookupMethodsResponse, Source,
VerificationMetadata, VerifyFromEtherscanSourcifyRequest, VerifyResponse,
VerifySolidityMultiPartRequest, VerifySolidityStandardJsonRequest, VerifySourcifyRequest,
VerifyVyperMultiPartRequest, VerifyVyperStandardJsonRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
},
settings::Settings,
};
use blockscout_service_launcher::LaunchSettings;
use blockscout_service_launcher::launcher::{self, LaunchSettings};
use std::sync::Arc;
use tokio::sync::Semaphore;

Expand All @@ -24,7 +24,7 @@ struct HttpRouter {
health: Arc<HealthService>,
}

impl blockscout_service_launcher::HttpRouter for HttpRouter {
impl launcher::HttpRouter for HttpRouter {
fn register_routes(&self, service_config: &mut actix_web::web::ServiceConfig) {
let service_config =
service_config.configure(|config| route_health(config, self.health.clone()));
Expand Down Expand Up @@ -112,11 +112,11 @@ pub async fn run(settings: Settings) -> Result<(), anyhow::Error> {
metrics: settings.metrics,
};

blockscout_service_launcher::init_logs(
blockscout_service_launcher::tracing::init_logs(
&launch_settings.service_name,
&settings.tracing,
&settings.jaeger,
)?;

blockscout_service_launcher::launch(&launch_settings, http_router, grpc_router).await
launcher::launch(&launch_settings, http_router, grpc_router).await
}
Loading
Loading