You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/4. repository/1. sourcify-database.mdx
+25-8Lines changed: 25 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,9 @@
2
2
3
3
Sourcify Database is the main storage backend for Sourcify. It is a PostgreSQL database that follows the [Verified Alliance Schema](https://github.com/verifier-alliance/database-specs) as its base with few modifications.
4
4
5
-
On a high level, these modifications are:
6
-
- Sourcify DB does accept contracts without the deployment details such as `block_number`, `transaction_hash` as well as without an onchain creation bytecode (`contracts.creation_code_hash`).
5
+
On a high level, these modifications are:
6
+
7
+
- Sourcify DB does accept contracts without the deployment details such as `block_number`, `transaction_hash` as well as without an onchain creation bytecode (`contracts.creation_code_hash`).
7
8
- Stores the [Solidity metadata](/docs/metadata) separately in the `sourcify_matches` table.
8
9
- Introduces tables for other purposes.
9
10
@@ -13,22 +14,29 @@ You can follow the [`services/database/migrations`](https://github.com/argotorg/
13
14
14
15
You can access the live schema of the database [here](https://dbdiagram.io/d/Sourcify-DB-67fcf5ee9cea640381a217d2) or in the embedded frame below.
- Every verified contract is a coupling between a deployed contract (`contract_deployments`) and a compilation (`compiled_contracts`)
20
-
-["Transformations"](https://verifieralliance.org/docs/transformations) are applied to reach the final matching onchain bytecode from a bytecode from a compilation.
27
+
-["Transformations"](https://verifieralliance.org/docs/transformations) are applied to reach the final matching onchain bytecode from a bytecode from a compilation.
21
28
- Bytecodes and sources are dedeplicated. The bytecode and the sources of a popular contract like `ERC20.sol` will only be stored once in `sources` and `code` respectively.
22
29
23
30
:::warning
24
-
If the contract has ["unlinked libraries"](https://docs.soliditylang.org/en/v0.8.30/using-the-compiler.html#library-linking), the placeholder strings like `__$53ae...a537$__` in bytecodes will be normalized to `0000...0000`s. This is required since the `code` column is a `bytea` type in the DB.
31
+
If the contract has ["unlinked libraries"](https://docs.soliditylang.org/en/v0.8.30/using-the-compiler.html#library-linking), the placeholder strings like `__$53ae...a537$__` in bytecodes will be normalized to `0000...0000`s. This is required since the `code` column is a `bytea` type in the DB.
25
32
26
33
Therefore, the bytecode string from the DB **will not be identical** to the output of the compilation. You can "de-normalize" these fields by looking at the library transformations and filling the placeholders with the library identifier.
27
34
:::
28
35
29
36
For more information about the schemas of the json fields below check the [Verifier Alliance repo](https://github.com/verifier-alliance/database-specs/tree/master/json-schemas).
30
37
31
38
JSON fields of `verified_contracts` table:
39
+
32
40
-`creation_values`
33
41
-`creation_transformations`
34
42
-`runtime_values`
@@ -37,6 +45,7 @@ JSON fields of `verified_contracts` table:
37
45
The [transformations](https://verifieralliance.org/docs/transformations) and values are the operations done on a bytecode from a compilation to reach the final matching onchain bytecode.
38
46
39
47
JSON fields of `compiled_contracts` table:
48
+
40
49
-`sources`: Source code files of a contract
41
50
-`compiler_settings`
42
51
-`compilation_artifacts`: Fields from the compilation output JSON. Fields: `abi`, `userdoc`, `devdoc`, `sources` (AST identifiers), `storageLayout`
@@ -45,7 +54,7 @@ JSON fields of `compiled_contracts` table:
45
54
46
55
### Notes on the data
47
56
48
-
For the issues on the data we are aware of and plan to fix, see this issue: https://github.com/argotorg/sourcify/issues/2276
57
+
For the issues on the data we are aware of and plan to fix, see this issue: https://github.com/argotorg/sourcify/issues/2276
49
58
50
59
Other known inconsistencies in the data below (not planned to fix) are documented below:
51
60
@@ -58,7 +67,6 @@ Other known inconsistencies in the data below (not planned to fix) are documente
58
67
59
68
We dump the whole database daily in [Parquet](https://en.wikipedia.org/wiki/Apache_Parquet) format and upload it to a Cloudflare R2 storage. You can access the manifest file at https://export.sourcify.dev ( `.dev` redirects to `.app` domain, which also belongs to Sourcify). The script that does the dump is at [sourcifyeth/parquet-export](https://github.com/sourcifyeth/parquet-export).
60
69
61
-
62
70
[export.sourcify.dev](https://export.sourcify.dev) will redirect to a `manifest.json` file:
63
71
64
72
<details>
@@ -103,11 +111,13 @@ We dump the whole database daily in [Parquet](https://en.wikipedia.org/wiki/Apac
103
111
}
104
112
}
105
113
```
114
+
106
115
</details>
107
116
108
117
You can download all the files and use a parquet client to query, inspect, or process the data.
109
118
110
119
1. Download the manifest file (`-L` to follow redirects):
0 commit comments