Conversation
docs/using-the-compiler.rst
Outdated
| abi: [ /* abi definition */ ], | ||
| userdoc: [], | ||
| devdoc: [], | ||
| natspec: [ /* user documentation comments */ ] |
There was a problem hiding this comment.
Removing natspec from here, only keeping userdoc / devdoc.
docs/using-the-compiler.rst
Outdated
| "dir/file.sol": {keccax: "0xabc..."}, | ||
| "xkcd": {swarm: "0x456..."} | ||
| }, | ||
| // This is a subset of the regular compiler input |
There was a problem hiding this comment.
settings is up to the intrepretation of the compiler defined by the language and compiler fields.
docs/using-the-compiler.rst
Outdated
| "official") at a registry contract. | ||
|
|
||
| { | ||
| version: "1", |
There was a problem hiding this comment.
Add comment: this is the version of the metadata spec.
docs/using-the-compiler.rst
Outdated
| { | ||
| version: "1", | ||
| language: "Solidity", | ||
| compiler: { |
There was a problem hiding this comment.
compiler is language specific.
docs/using-the-compiler.rst
Outdated
| language: "Solidity", | ||
| compiler: { | ||
| commit: "55db20e32c97098d13230ab7500758e8e3b31d64", | ||
| version: "soljson-2313-2016-12-12", |
There was a problem hiding this comment.
Must equal to the compiler semver version. Required field.
docs/using-the-compiler.rst
Outdated
| version: "1", | ||
| language: "Solidity", | ||
| compiler: { | ||
| commit: "55db20e32c97098d13230ab7500758e8e3b31d64", |
There was a problem hiding this comment.
Remove, the semver version includes the commit.
docs/using-the-compiler.rst
Outdated
| compiler: { | ||
| commit: "55db20e32c97098d13230ab7500758e8e3b31d64", | ||
| version: "soljson-2313-2016-12-12", | ||
| keccak: "0x123..." |
There was a problem hiding this comment.
keccak256 hash of the actual compiler. Optional field.
docs/using-the-compiler.rst
Outdated
|
|
||
| { | ||
| version: "1", | ||
| language: "Solidity", |
docs/using-the-compiler.rst
Outdated
| // This is a subset of the regular compiler input | ||
| sources: | ||
| { | ||
| "abc": {keccak: "0x456..."}, // here, sources are always given by hash |
There was a problem hiding this comment.
The supported fields are:
keccak256: a hash of the file. Recommended in every case, but ifcontentis specified it has very little benefit.content: the actual file content as a string.url: a way to retrieve the file. It can be (but not limited to):http://orhttps://(ie. github)bzz://orbzzr://ipfs:
There was a problem hiding this comment.
if you have url specified and content is not specified it should be mandated to have keccak256.
There was a problem hiding this comment.
The key (filename) is an identifier for a source file. Cannot contain a colon. It used by fields in the settings.
docs/using-the-compiler.rst
Outdated
| optimizer: {enabled: true, runs: 500}, | ||
| compilationTarget: "myFile.sol:MyContract", | ||
| libraries: { | ||
| "def:MyLib": "0x123123..." |
There was a problem hiding this comment.
Add comment that entries are source keys and contract names plus the on-chain address of the contract.
There was a problem hiding this comment.
Split out to be a map of key and library:
libraries: {
"def": {
"MyLib": "0x123123..."
}
}
There was a problem hiding this comment.
We currently do not have file-based libraries, that should be changed in the near future, but we might also just allow libraries: { "MyLib": "0x123"} for now.
docs/using-the-compiler.rst
Outdated
| { | ||
| sources: | ||
| { | ||
| // the keys here are the "global" names of the source files, imports can use other files via remappings (see below) |
There was a problem hiding this comment.
What applies to sources in metadata applies here. Two differences:
keccak256is used to verify the content after acquiring itfile:as a url is supported
There was a problem hiding this comment.
How about supporting keccak256 and urls. The compiler will then (in some defined order) query the caller for each url and hash, until the file is retrieved or the options are exhausted.
docs/using-the-compiler.rst
Outdated
| Input Description | ||
| ----------------- | ||
|
|
||
| QUESTION: How to specific file-reading callback? - probably not as part of json input |
There was a problem hiding this comment.
The read callback will receive the url as specified in the sources list.
docs/using-the-compiler.rst
Outdated
| message: "Invalid keyword" // mandatory | ||
| } | ||
| ] | ||
| contracts: { |
There was a problem hiding this comment.
This contains all the compiled outputs. It can be limited/filtered by the compilationTarget setting.
docs/using-the-compiler.rst
Outdated
| // (axic) what is remapping doing exactly? | ||
| optimizer: {enabled: true, runs: 500}, | ||
| // if given, only compiles this contract, can also be an array. If only a contract name is given, tries to find it if unique. | ||
| compilationTarget: "myFile.sol:MyContract", |
There was a problem hiding this comment.
compilationTarget:
- can be an array
- if no contract name is specified, all contracts in that file are considered
- it can refer to a key and contract name which is not part of the sources, but will be loaded during parsing the sources
There was a problem hiding this comment.
We remove this, as it is superseded by outputSelection.
docs/using-the-compiler.rst
Outdated
| }, | ||
| // The following can be used to restrict the fields the compiler will output. | ||
| // (axic) | ||
| outputSelection: [ |
There was a problem hiding this comment.
Merging compilation target and output selection:
"*": {
"*": [ "abi", "asm" ]
}
"def": {
"MyContract": [ "abi", "opcodes" ]
}
"*": {
"*": [ "srcmap" ]
}
"*": {
"": [ "ast", "formal" ]
}
Empty contract name refers to the file itself, while the star refers to all of the contracts.
outputSelection is a hashmap of the above. If no outputSelection is defined, then the compiler loads and does type checking, but will not generate any outputs apart from errors.
There was a problem hiding this comment.
ast and formal are file-level and if they are needed, an additional empty-string entry is needed.
docs/using-the-compiler.rst
Outdated
| sourceList: ["source1.sol", "source2.sol"], // this is important for source references both in the ast as well as in the srcmap in the contract | ||
| sources: { | ||
| "source1.sol": { | ||
| "AST": { ... } |
There was a problem hiding this comment.
The fields are:
keccak256id(used in source maps)ast
There was a problem hiding this comment.
@chriseth if the AST is a JSON object, what is the hash referring to?
docs/using-the-compiler.rst
Outdated
| formal: { | ||
| "why3": "..." | ||
| }, | ||
| sourceList: ["source1.sol", "source2.sol"], // this is important for source references both in the ast as well as in the srcmap in the contract |
There was a problem hiding this comment.
This is superseded by the id in sources.
docs/using-the-compiler.rst
Outdated
| "abi", "evm.assembly", "evm.bytecode", ..., "why3", "ewasm.wasm" | ||
| ] | ||
| outputSelection: { | ||
| abi,asm,ast,bin,bin-runtime,clone-bin,devdoc,interface,opcodes,srcmap,srcmap-runtime,userdoc |
There was a problem hiding this comment.
Output types:
abiast(as a JSON object)evm.assembly- ...
To be defined soon.
There was a problem hiding this comment.
ast- AST of all source fileswhy3- Translated source suitable for formalabi- ABIuserdoc- User Docdevdoc- Dev Docmetadata- Metadataevm.ir- New assembly format before desugaring (not supported atm)evm.assembly- New assembly format after desugaring (not supported atm)evm.asm- current asmevm.asmJSON- current asmjsonevm.opcodes- current opcodesevm.methodIdentifiers- the current "hashes" / "functionHashes"evm.gasEstimates- current --gas and "gasEstimates"evm.bytecode- current--binorbytecodeevm.deployedBytecode- current--bin-runtimeorruntimeBytecode
--clone-bin is removed.
docs/using-the-compiler.rst
Outdated
| { | ||
| remappings: [":g/dir"], | ||
| optimizer: {enabled: true, runs: 500}, | ||
| compilationTarget: "myFile.sol:MyContract", |
There was a problem hiding this comment.
Split out to a be a map of key and contract:
compilationTarget: { "myFile.sol": "MyContract }
docs/using-the-compiler.rst
Outdated
| Note that the actual bytecode is not part of the metadata because the hash | ||
| of the metadata structure will be included in the bytecode itself. | ||
|
|
||
| This requires the compiler to be able to compute the hash of its own binary, |
There was a problem hiding this comment.
This section should be removed.
docs/using-the-compiler.rst
Outdated
| } | ||
| }, | ||
| functionHashes: | ||
| metadata: // see below |
There was a problem hiding this comment.
Mention that, contrary to the rest of the fields, this is not a JSON object, but a stringified JSON. This is because serialisation differences might result in different output and thus metadata hash.
There was a problem hiding this comment.
I wonder if we should call this metadata (which is kind of vague) or come with an actual name for it.
There was a problem hiding this comment.
This should actually refer to the metadata section in miscellaneous.rst (once #1386 is merged).
docs/using-the-compiler.rst
Outdated
| { | ||
| "myFile.sol": { | ||
| "keccak256": "0x123...", | ||
| "url": "bzzr://0x56..." |
There was a problem hiding this comment.
I think this does usually not have a 0x prefix.
docs/using-the-compiler.rst
Outdated
| language: "Solidity", | ||
| // Required field, the contents are specific to the language | ||
| compiler: { | ||
| name: "solc", |
There was a problem hiding this comment.
This is not part of the implementation.
|
🎂 !!!! This is great. Thank you for all the work you've put into this. It's going to be a major improvement. |
Follow up #1129. (Moved from #645 to a common branch.)
Todo: