Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

0x sol-compiler support. #128

Open
Freydal opened this issue Jun 3, 2019 · 7 comments
Open

0x sol-compiler support. #128

Freydal opened this issue Jun 3, 2019 · 7 comments

Comments

@Freydal
Copy link

Freydal commented Jun 3, 2019

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.

@cgewecke
Copy link
Owner

cgewecke commented Jun 3, 2019

@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.)

@Freydal
Copy link
Author

Freydal commented Jun 4, 2019

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:

  1. 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.
  2. 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.

@cgewecke
Copy link
Owner

cgewecke commented Jun 4, 2019

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.

@cgewecke
Copy link
Owner

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...

@cgewecke
Copy link
Owner

cgewecke commented Aug 8, 2019

Needs #171

@Freydal
Copy link
Author

Freydal commented Nov 19, 2019

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.

@Freydal
Copy link
Author

Freydal commented Nov 19, 2019

This is the config where I'm passing the artifacts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants