-
Notifications
You must be signed in to change notification settings - Fork 2.3k
compile/migrate with multiple solidity versions crashes ganache 2 #1607
Comments
Thanks for raising this concern! It's on the roadmap to support multiple solc versions natively, but there are some technical limitations that make this not immediately feasible. The component you are missing is that you need proper Truffle artifact files ( You might be able to achieve a workaround by way of using Truffle's new external compiler configuration. It should be flexible enough for this use case, but let me know. |
Thanks! I added https://github.com/projectchicago/gastoken as a git submodule at Then I added this to my truffle-config.json:
And now
I tried compiling myself with solidity 0.4.10, but I get the same deployment failed message:
Increasing the gas limit doesn't help.
Is "bytecode" different than what I get with --bin? This contract deployed successfully on mainnet with 1396556 gas limit: https://etherscan.io/tx/0x5de8a3c310eb8e1bd90fcbf1bde073efc2ed3750e60f207d75a993ac40a0dda6 |
It appears that
I've got something working, but I'm not sure how correct it is. I ended up making an input json which does allow the necessary output selection options:
Then I made a compile script:
And then I added this script to my
And now my migrations work! I think this would be a lot simpler if truffle could use the output of --bin. |
I was able to simplify my external compile script:
This would be simpler if truffle didn't require that bytecode started with "0x". Why does it require that? solc doesn't output it that way, so I'm having to modify its output. |
Where are the available "fileProperties" documented? I needed to add truffle-config.js:
While
|
I'm thinking of using https://sol-compiler.com/ instead of manually calling solc. They have support for compiling contracts with different versions of solidity. I don't see any clear way to convert from solc's combined json output to a truffle artifact though. Is there any existing tooling for that? I'd like to be able to keep using |
@wysenynja Let me see if I can locate some helpful material for you. From what I understand you are trying to build a truffle contract from scratch and want guidance, sound about right? Sorry for the delay in responding to you by the way. |
I think the schema for those artifacts can be found here --> https://github.com/trufflesuite/truffle/tree/develop/packages/truffle-contract-schema Also |
@eggplantzzz Thanks for the reply. I'm trying to let truffle build the truffle contract during the external compile step. I'm wanting to know the best way to convert solc's output to a truffle contract. I can see a couple ways of doing it. I thought using a truffle-config.js like this would put everything in the right place, but it only seems to setup the abi and bytecode:
I would much prefer to be able to use the combined json from solc instead of having to configure all those properties manually for each contract. To do that, it sounds like I need a script that reads solc's combined output json and builds something that Rather than an external script, I think it would be better for this code (both supporting more properties and reading solc's combined json) to be a part of the truffle external compiler step. Where in truffle's code is the abi and bytecode passed through? It seems like adding support for source maps and the others should be relatively simple. Loading the combined json would be more of a change, but it would certainly be helpful. |
@wysenynja just a drive-by response: you might be interested to look at the integration tests for this feature. They use Right now, the translation between Solidity standard JSON and a Truffle artifact is done by I would recommend maybe looking at the module.exports = {
/* ... */
compilers: {
external: {
command: "...",
targets: [{
path: ".../path/to/solc-outputs/*.solc.json"
command: "truffle run solc-standard-json-to-artifact"
}]
}
}
} |
https://github.com/trufflesuite/truffle/blob/develop/packages/truffle-compile/index.js#L194 |
I'm trying out @gnidan's suggestion and I think I am getting closer to what I need. Here is my truffle-config.js's external section:
Here is what I've come up with for an external compile target script so far:
Something is wrong about the abi though. Running
I don't understand why it thinks that "constant" is an additional property. Looking at the truffle artifact that truffle generated itself, the abi sections look pretty much the same to me. The order is different between them, but all the keys are the same. What sort of modifications do I need to make to abi? Is sharing my complete repo needed to debug this? If I set abi to |
Here is the full output I get when I try to include the abi as sol-compiler gives it to me: https://gist.github.com/WyseNynja/d1536bf19ff754c2bbc0f3d6aa0508e2 The good news is that I think fixing why the abi won't validate is the last step. If I set abi to Thanks for the help so far, everyone! |
The problem with https://gist.github.com/WyseNynja/d1536bf19ff754c2bbc0f3d6aa0508e2 was using After commenting out the method that was doing that, the abi validates. I guess I can work without that for now, but it was nice to have. |
Given that the rest of my issues seem to be in ganache, I'm going to continue this at trufflesuite/ganache#1117 |
Issue
I'm writing a contract with solidity 0.5 and wanting to call a contract written (and deployed by someone else on mainnet) with solidity 0.4 (and another with Vyper: #1623). How should I setup truffle+ganache in development to deploy the old contract with the old compiler and then deploy my new contracts? I don't want to update their contract to 0.5 because I want my tests to use the version they already have deployed on mainnet. I'm using an interface to interact with the old code as detailed at https://solidity.readthedocs.io/en/v0.5.0/050-breaking-changes.html#interoperability-with-older-contracts
The 0.4 contract (https://github.com/projectchicago/gastoken/blob/master/contract/GST2_ETH.sol) is using python tools for deployment. If it were using truffle, I could run
truffle migrate
from their directory and then runtruffle migrate
from mine, but then I'm not sure how I would useartifacts
.If I symlink their *.sols into my contracts directory, it fails with the expected "ParserError: Source file requires different compiler version"
Right now I'm just hard coding the gastoken contract address so I can test the other parts of my migrations, but that won't work once I actually want to test using the gastoken contract from inside my own contract.
Is there some way to deploy their .asm files directly? I feel like this should be a common need, but I'm not seeing any documentation about it.
And when I do get to putting my contracts on mainnet, what is the best practice for linking to the already deployed gastoken contract instead of deploying it myself?
The text was updated successfully, but these errors were encountered: