|
1 | 1 | # <h1 align="center"> Smart-contract Verifier </h1>
|
2 | 2 |
|
3 |
| -**Smart-contract-verifier** - service for verification of EVM based contracts. Ideologically, it accepts bytecode to be verified and potential source files as input and returns whether those files and bytecode correspond to each other. |
4 |
| - |
5 |
| -The service consists of 2 parts, a verification library and a transport layer that serves requests: |
6 |
| - |
7 |
| -+ [smart-contract-verifier](./smart-contract-verifier) - implements actual verification logic as a library and exposes an interface to be used by the transport layer; |
8 |
| -+ A transport layer that implements some APIs over the service ([smart-contract-verifier-server](./smart-contract-verifier-server/)). |
9 |
| - |
10 |
| -For now, GRPC and REST API over HTTP services are available as the transport layer. However, the transport protocol is not limited to our implementation, and you could implement your own APIs using the library crate. |
11 |
| - |
12 |
| -## Build |
13 |
| -There are several ways to run the service discussed below. |
14 |
| - |
15 |
| -**Note:** for our description we will use an HTTP/GRPC server implementation; in case of a custom API implementation, you should change `smart-contract-verifier-server` to your values. |
16 |
| - |
17 |
| - |
18 |
| -### Using docker |
19 |
| -You can build the provided sources using [Dockerfile](./smart-contract-verifier-server/Dockerfile) or [docker-compose](./smart-contract-verifier-server/docker-compose.yml) files. |
20 |
| - |
21 |
| -Alternatively, you can use docker images from our [registry](https://github.com/blockscout/blockscout-rs/pkgs/container/smart-contract-verifier) |
22 |
| - |
23 |
| -### Building from source |
24 |
| - |
25 |
| -**Preparation:** |
26 |
| - |
27 |
| -1. Install rustup from rustup.rs. |
28 |
| - |
29 |
| -1. Make sure that openssl is installed: |
30 |
| - |
31 |
| - - macOS: |
32 |
| - |
33 |
| - `$ brew install [email protected]` |
34 |
| - |
35 |
| - - Arch Linux |
36 |
| - |
37 |
| - `$ sudo pacman -S pkg-config openssl` |
38 |
| - |
39 |
| - - Debian and Ubuntu |
40 |
| - |
41 |
| - `$ sudo apt-get install pkg-config libssl-dev` |
42 |
| - |
43 |
| - - Fedora |
44 |
| - |
45 |
| - `$ sudo dnf install pkg-config openssl-devel` |
46 |
| - |
47 |
| -1. Make sure protobuf is installed and the version (`$ protoc --version`) is at least `v3.15.0`. |
48 |
| - |
49 |
| - If protobuf version is too old, you may see the following error: `Explicit 'optional' labels are disallowed in the Proto3 syntax.` |
50 |
| - |
51 |
| -1. Install [`protoc-gen-openapiv2`](https://github.com/grpc-ecosystem/grpc-gateway#installation). |
52 |
| - You may find useful the following [Action](https://github.com/blockscout/blockscout-rs/blob/main/.github/actions/deps/action.yml#L21) |
53 |
| - we use in our Github pipeline. |
54 |
| - |
55 |
| - If not installed, you may see the following error: `Error: Custom { kind: Other, error: "protoc failed: Unknown flag: --openapiv2_opt\n" }` |
56 |
| - |
57 |
| ---- |
58 |
| - |
59 |
| -Build blockscout smart-contract-verifier: |
60 |
| - |
61 |
| -```console |
62 |
| -git clone [email protected]:blockscout/blockscout-rs.git |
63 |
| -cd blockscout-rs/smart-contract-verifier |
64 |
| -cargo build --release --bin smart-contract-verifier-server |
65 |
| -``` |
66 |
| - |
67 |
| -You can find the built binary in `target/release/` folder. |
68 |
| - |
69 |
| -### Installing through cargo |
70 |
| - |
71 |
| -Another way to install the binary without cloning the repository is to use cargo straightway: |
72 |
| - |
73 |
| -```console |
74 |
| -cargo install --git https://github.com/blockscout/blockscout-rs smart-contract-verifier-server |
75 |
| -``` |
76 |
| - |
77 |
| -In that case, you can run the binary using just `smart-contract-verifier-server`. |
78 |
| - |
79 |
| -## Start |
80 |
| -For the details of how to run the service, go into corresponding |
81 |
| -transport protocol layer description: |
82 |
| -- [smart-contract-verifier-server](./smart-contract-verifier-server/README.md) |
| 3 | +**Smart-contract verifier** is a service for verifying EVM-based contracts. The primary function of this service is to receive bytecode and potential source files as inputs and determine whether the files and the bytecode correspond to each other. |
| 4 | + |
| 5 | +This service serves as the core component for all activities related to smart-contract verification in BlockScout. It is essential for enabling smart-contract verification functionality on your instance. |
| 6 | + |
| 7 | +## Requirements |
| 8 | +No additional dependencies |
| 9 | + |
| 10 | +## How to enable |
| 11 | +Set the following ENVs on blockscout instance: |
| 12 | +- `MICROSERVICE_SC_VERIFIER_ENABLED=true` |
| 13 | +- `MICROSERVICE_SC_VERIFIER_URL={service_url}` |
| 14 | +- `MICROSERVICE_SC_VERIFIER_TYPE=sc_verifier` |
| 15 | + |
| 16 | +## Envs |
| 17 | +Here, we describe variables specific to this service. Variables common to all services can be found [here](../docs/common-envs.md). |
| 18 | + |
| 19 | +[anchor]: <> (anchors.envs.start) |
| 20 | + |
| 21 | +| Variable | Required | Description | Default value | |
| 22 | +|----------------------------------------------------------------|----------|-------------------------------------------------------------------------|------------------------------------------------------------------------------| |
| 23 | +| `SMART_CONTRACT_VERIFIER__SOLIDITY__ENABLED` | | Enable Solidity verification endpoints | `true` | |
| 24 | +| `SMART_CONTRACT_VERIFIER__SOLIDITY__FETCHER__LIST__LIST_URL` | | Url that contains a list available Solidity compilers | `https://solc-bin.ethereum.org/linux-amd64/list.json` | |
| 25 | +| `SMART_CONTRACT_VERIFIER__SOLIDITY__REFRESH_VERSIONS_SCHEDULE` | | Cron-format schedule to update the list of available Solidity compilers | `0 0 * * * * *` | |
| 26 | +| `SMART_CONTRACT_VERIFIER__SOLIDITY__COMPILERS_DIR` | | Directory where Solidity compilers will be downloaded | `/tmp/solidity-compilers` | |
| 27 | +| `SMART_CONTRACT_VERIFIER__VYPER__ENABLED` | | Enable Vyper verification endpoints | `true` | |
| 28 | +| `SMART_CONTRACT_VERIFIER__VYPER__FETCHER__LIST__LIST_URL` | | Url that contains a list of available Vyper compilers | `https://raw.githubusercontent.com/blockscout/solc-bin/main/vyper.list.json` | |
| 29 | +| `SMART_CONTRACT_VERIFIER__VYPER__REFRESH_VERSIONS_SCHEDULE` | | Cron-format schedule to update the list of available Vyper compilers | `0 0 * * * * *` | |
| 30 | +| `SMART_CONTRACT_VERIFIER__VYPER__COMPILERS_DIR` | | Directory where Vyper compilers will be downloaded | `/tmp/vyper-compilers` | |
| 31 | +| `SMART_CONTRACT_VERIFIER__SOURCIFY__ENABLED` | | Enable Soucify verification endpoint | `true` | |
| 32 | +| `SMART_CONTRACT_VERIFIER__SOURCIFY__API_URL` | | Sourcify API url | `https://sourcify.dev/server/` | |
| 33 | +| `SMART_CONTRACT_VERIFIER__SOURCIFY__VERIFICATION_ATTEMPTS` | | Number of attempts the server makes to Sourcify API. Must be at least 1 | `3` | |
| 34 | +| `SMART_CONTRACT_VERIFIER__SOURCIFY__REQUEST_TIMEOUT` | | Timeout in seconds for a single request to Sourcify API | `15` | |
| 35 | +| `SMART_CONTRACT_VERIFIER__COMPILERS__MAX_THREADS` | | Maximum number of concurrent compilations | `8` | |
| 36 | + |
| 37 | +[anchor]: <> (anchors.envs.end) |
| 38 | + |
| 39 | +## Links |
| 40 | +- Demo - https://http.sc-verifier.services.blockscout.com |
| 41 | +- [Swagger](https://blockscout.github.io/swaggers/services/smart-contract-verifier/index.html) |
| 42 | +- [Packages](https://github.com/blockscout/blockscout-rs/pkgs/container/smart-contract-verifier) |
| 43 | +- [Releases](https://github.com/blockscout/blockscout-rs/releases?q=smart-contract-verifier&expanded=true) |
0 commit comments