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

external compile step erring for vyper contract #1623

Closed
BlinkyStitt opened this issue Jan 8, 2019 · 13 comments
Closed

external compile step erring for vyper contract #1623

BlinkyStitt opened this issue Jan 8, 2019 · 13 comments

Comments

@BlinkyStitt
Copy link

BlinkyStitt commented Jan 8, 2019

Issue

Similar to #1607

I am trying to use the external compile step to build artifacts for a contract external to my truffle project that is written in vyper (https://github.com/Uniswap/contracts-vyper). The contract bytecode and abi were compiled and checked into the external repo for me, so I don't think I need to run vyper myself.

Steps to Reproduce

truffle-config.js that looks something like this:

module.exports = {
  ...
  compilers: {
    ...
    external: {
      command: "true",
      targets: [
        {
          properties: {
            contractName: "UniswapExchange",
          },
          fileProperties: {
            abi: "external/uniswap-contracts-vyper/abi/uniswap_exchange.json",
            bytecode: "external/uniswap-contracts-vyper/bytecode/exchange.txt",
          },
        },
        {
          properties: {
            contractName: "UniswapFactory",
          },
          fileProperties: {
            abi: "external/uniswap-contracts-vyper/abi/uniswap_factory.json",
            bytecode: "external/uniswap-contracts-vyper/bytecode/factory.txt",
          },
        },
      ],
    },
  },

Expected Behavior

Running truffle compile should create a json file with the abi and bytecode included.

Actual Results

Error: Schema validation failed. Errors:

should NOT have additional properties (additionalProperties):
{ dataPath: '.abi[6]',
  schemaPath: '#/additionalProperties',
  params: { additionalProperty: 'outputs' },
  data:
   { name: 'setup',
     outputs: [],
     inputs: [ { type: 'address', name: 'token_addr' } ],
     constant: false,
     payable: false,
     type: 'function',
     gas: 175875 },
  parentSchema:
   { type: 'object',
     properties:
      { type: { type: 'string', enum: [ 'event' ] },
        name: { '$ref': '#/definitions/Name' },
        inputs:
         { type: 'array',
           items: { '$ref': '#/definitions/EventParameter' } },
        anonymous: { type: 'boolean' } },
     required: [ 'type', 'name', 'inputs', 'anonymous' ],
     additionalProperties: false } }

should NOT have additional properties (additionalProperties):
{ dataPath: '.abi[6]',
  schemaPath: '#/additionalProperties',
  params: { additionalProperty: 'name' },
  data:
   { name: 'setup',
     outputs: [],
     inputs: [ { type: 'address', name: 'token_addr' } ],
     constant: false,
     payable: false,
     type: 'function',
     gas: 175875 },
  parentSchema:
   { type: 'object',
     properties:
      { type: { type: 'string', enum: [ 'constructor' ] },
        inputs:
         { type: 'array', items: { '$ref': '#/definitions/Parameter' } },
        stateMutability: { '$ref': '#/definitions/StateMutability' },
        constant: { type: 'boolean' },
        payable: { type: 'boolean', default: false } },
     required: [ 'type', 'inputs', 'stateMutability' ],
     additionalProperties: false } }

should NOT have additional properties (additionalProperties):
{ dataPath: '.abi[6]',
  schemaPath: '#/additionalProperties',
  params: { additionalProperty: 'name' },
  data:
   { name: 'setup',
     outputs: [],
     inputs: [ { type: 'address', name: 'token_addr' } ],
     constant: false,
     payable: false,
     type: 'function',
     gas: 175875 },
  parentSchema:
   { type: 'object',
     properties:
      { type: { type: 'string', enum: [ 'fallback' ] },
        stateMutability: { '$ref': '#/definitions/StateMutability' },
        constant: { type: 'boolean' },
        payable: { type: 'boolean', default: false } },
     required: [ 'type', 'stateMutability' ],
     additionalProperties: false } }

should NOT have additional properties (additionalProperties):
{ dataPath: '.abi[6]',
  schemaPath: '#/additionalProperties',
  params: { additionalProperty: 'gas' },
  data:
   { name: 'setup',
     outputs: [],
     inputs: [ { type: 'address', name: 'token_addr' } ],
     constant: false,
     payable: false,
     type: 'function',
     gas: 175875 },
  parentSchema:
   { type: 'object',
     properties:
      { type:
         { type: 'string', enum: [ 'function' ], default: 'function' },
        name: { '$ref': '#/definitions/Name' },
        inputs:
         { type: 'array', items: { '$ref': '#/definitions/Parameter' } },
        outputs:
         { type: 'array',
           items: { '$ref': '#/definitions/Parameter' },
           default: [] },
        stateMutability: { '$ref': '#/definitions/StateMutability' },
        constant: { type: 'boolean' },
        payable: { type: 'boolean', default: false } },
     required: [ 'name', 'inputs', 'stateMutability' ],
     additionalProperties: false } }

should match exactly one schema in oneOf (oneOf):
{ dataPath: '.abi[6]',
  schemaPath: '#/items/oneOf',
  params: {},
  data:
   { name: 'setup',
     outputs: [],
     inputs: [ { type: 'address', name: 'token_addr' } ],
     constant: false,
     payable: false,
     type: 'function',
     gas: 175875 },
  parentSchema:
   { oneOf:
      [ { '$ref': '#/definitions/Event' },
        { '$ref': '#/definitions/ConstructorFunction' },
        { '$ref': '#/definitions/FallbackFunction' },
        { '$ref': '#/definitions/NormalFunction' } ] } }

    at Object.validate (/usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-contract-schema/index.js:197:1)
    at processTargets (/usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-external-compile/index.js:154:1)
Truffle v5.0.1 (core: 5.0.1)
Node v10.14.2
error Command failed with exit code 1.

I'm guessing truffle is expecting output from solc and not vyper. Any suggestions for how to deploy this contract to my test blockchain during truffle migrate?

Environment

  • Operating System: Alpine Linux
  • Ethereum client: ganache
  • Truffle version (truffle version): v5.0.1
  • node version (node --version): v10.14.2
  • npm version (npm --version): 6.4.1
@eggplantzzz
Copy link
Contributor

eggplantzzz commented Jan 14, 2019

@wysenynja You know, at this point I believe that Truffle will compile vyper files for you without having to use the external setup if you have them in your contracts directory.
Let me know how it goes for you.

@BlinkyStitt
Copy link
Author

BlinkyStitt commented Jan 14, 2019 via email

@BlinkyStitt
Copy link
Author

I was told to use the external compile step in #1607. Was that incorrect?

@eggplantzzz
Copy link
Contributor

It is possible to use the external property to do this...BUT Truffle will compile Vyper contracts as well as Solidity contracts "side-by-side".

In the issue you linked to, @gnidan is referring to the current limitation of only being able to use one single version of the Solidity compiler. However, you can have a project that includes both Solidity and Vyper files and Truffle will deal with them.

@eggplantzzz
Copy link
Contributor

@wysenynja Did you successfully get your vyper contracts compiling?

@BlinkyStitt
Copy link
Author

I’ve been working on my own solidity contract interacting with 0x and haven’t done any more work with Uniswap yet.

I think dropping the Vyper contracts into the main contracts directory will work for me though. Hopefully I won’t need multiple versions of the Vyper compiler if I add another project.

@eggplantzzz
Copy link
Contributor

Ok, let me know if you have any more questions on the way. Closing this for now.

@BlinkyStitt
Copy link
Author

I copied uniswap's contracts into my contracts directory, but it fails with this error:

$ truffle compile
Compiling ./contracts/external/uniswap/uniswap_exchange.vy...
Compiling ./contracts/external/uniswap/uniswap_factory.vy...
/root/.local/venvs/vyper/lib/python3.6/site-packages/vyper/types/types.py:347: DeprecationWarning: Mapping definitions using subscript have deprecated (see VIP564). Use map(type1, type2) instead.
  DeprecationWarning
vyper.exceptions.InvalidTypeException: line 8: Unknown list type.
token_to_exchange: address[address]
-------------------^

Compilation of /usr/src/app/contracts/external/uniswap/uniswap_factory.vy failed. See above.
Truffle v5.0.4 (core: 5.0.4)
Node v11.9.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I'm guessing this is because uniswap expects vyper==0.1.0b4, but truffle is using a newer version. I don't want to modify the contracts at all since I am trying to interact with them the same way they are deployed on mainnet.

How can I tell truffle to use an old version of vyper? Or is the error something else?

@BlinkyStitt
Copy link
Author

BlinkyStitt commented Feb 18, 2019

If I create a truffle artifact myself with the bytecode that is included in the git checkout and an empty list for abi, I am able to truffle migrate, but I really need the abi in order to do my testing.

EDIT: Got around not having the abi by making an interface in solidity and using that.

@eggplantzzz
Copy link
Contributor

@wysenynja Concerning the Vyper compiler...I'll have to look into adding functionality in the config for specifying the version.

@samajammin
Copy link
Contributor

@eggplantzzz any progress on this? Or should I create a separate issue? I'm having the same issue @wysenynja mentioned trying to add Uniswap's contracts: #1623 (comment)

I am writing vyper contracts in my Truffle project. Running vyper --version yields 0.1.0b10 - is this what Truffle is using? Or how can I see which version Truffle uses? Is there a way to specify the vyper version in Truffle?

Ideally, I could use the latest version for my own contracts (0.1.0b10) & the older version (0.1.0b4) on the Uniswap contracts.

Thanks!

@mesozoic-technology
Copy link

This is a problem for me as well. Is there a way to tell truffle which compiler to use?

@PfanP
Copy link

PfanP commented Jun 30, 2020

Is this issue resolved?

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

5 participants