eth-gas-reporter
eth-gas-reporter copied to clipboard
0x sol-compiler support.
I have started using @0x/sol-compiler and other 0x tooling. I feel like this is one of the largest losses in the transition. I would like to see support for sol-compiler and non truffle test suites.
I will considering forking and attempting to address this if I am able to get something working in the future.
@Freydal Sweet, great idea. Very interested in moving in this direction and there's been recent work here to generalize compilation artifact handling and make the tool truffle-neutral.
Couple questions...
- Do you have a public repo / test suite built with the 0x stack I could test against? Or know of a small/medium sized project I could target?
- What is your experience with the 0x gas profiler? (Looks kind of amazing.)
I do not currently have a public repo, but I will try to remember to let you know when it becomes public.
I tried out sol-profiler first when I was starting to address a gas issue. I have two major complains regarding its usage:
- The massive amount of console output makes it difficult to analyze on a full test suite which contains 100s of tests and 1000's of transactions.
- The Istanbul output displays totals which makes it difficult to ascertain the individual costs.
The SubProvider architecture makes it pretty easy to use and very convenient to integrate into the test system via process flags.
Thanks for the profiler review.
Just found 0x's metacoin example project and think that should suffice. I will try to get this working, publish it in the next patch and ping you here.
Just leaving some notes here...
Artifact format
// In lib/artifactor.js have something like...
_0xArtifactor(contractName){
const contract = {};
const artifact = require(`./artifacts/${contractName}.json`);
contract.abi = artifact.compilerOutput.abi;
contract.bytecode = artifact.compilerOutput.evm.bytecode.object;
contract.deployedBytecode = artifact.compilerOutput.evm.deployedBytecode;
this.config.metadata = {
compiler: {
version: artifact.compiler.version
},
settings: {
optimizer: {
enabled: artifact.compiler.settings.optimizer.enabled,
runs: artifact.compiler.settings.optimizer.runs
}
}
};
return contract;
}
In-process provider
0x's default provider is an in-process ganache-core instance. Unfortunately the provider needs to be shelled out (like truffle's default blockchain) or launched separately at the command line (ganache-cli etc
) so the reporter can connect to it and make its own synchronous calls (b/c mocha's reporter hooks are sync).
Obviously the provider is configurable but atm do not have an example of an 0x project that launches the client this way...
Needs #171
I was finally able to address this again and kind of hacked together something that works. All the repo's are public now, so I will be able to share what I have done and why.
The project is arranged in a monorepo and the tests are currently separated from solidity source. This caused an issue with your well prepared 0xProject artifactor. The artifacts are effectively a node module. To address this and other issues I converted the tests into a programatic mocha execution. This helped easily address the artifact issue by injecting the import, but the conversion was also done to attempt to address the issue with the in memory ganache subProvider and need for synchronous calls for reporters (which I haven't worked out). I roughly updated eth-gas-reporter
to support this.
This is the config where I'm passing the artifacts.