forked from ethereum/sourcify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
specification.txt
65 lines (55 loc) · 2.55 KB
/
specification.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Components:
- local geth node
- Monitor
- recompiler
Monitor:
- connect to local geth node, on each new block b:
for each transaction t in b:
if t is a creation transaction:
- retrieve bytecode of newly created contract
- extract metadata hash and append address and metadata hash to source retrieval queue
Metadata retrieval:
loop:
- remove all items from the queue that are older than a week
- for each item, try to download the metadata (either from swarm or ipfs)
if retrieved:
remove from queue and store in filesystem (structure see below)
add source to source retrieval queue (together with address)
update ipns
Source retrieval:
loop:
- remove all items from the queue that are older than a week
- for each item, try to download the source (either from swarm or ipfs)
if retrieved:
remove from queue and store in filesystem (structure see below)
(unless file already exists)
update ipns
Problem: We need to recompile, otherwise people can use this to store arbitrary data by modifying the metadata hash,
although this can be the case already by adding "data" into solidity comments.
This colud be mitigated by limiting the size of source and metadata files.
Source injection:
Source and address provided from outside. recompile, check for equality and store
in filesystem
Filessystem structure:
/contract/<chainid>/<address>/
abi.json
devdocs.json
userdocs.json
input.json
output.json
metadata.json
sources/<path_to_filename_escaped_if_needed>
/contract/<chainid>/<address>_maybe/
same as above just that the metadata.json does not
match the hash in the bytecode and thus
the source could be different (especially the natspec!)
/swarm/bzzr0/<hash>
/swarm/bzzr1/<hash>
/ipfs/<hash>
Rationale for the files:
We need 'input.json' so that it is clear what the source files mean and how they may be remapped.
abi, devdocs and userdocs are the files we need for the main use-case (could be retrieved from the metadata.json, though)
output.json may be the least useful.
metadata.json is needed somewhere, so why not put it here.
The bzzr0/1 directories allow swarm files to be persisted and retrieved from their swarm hash via ipfs.
If this is hosted via swarm, we use the /ipfs files instead.