Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack traces unable to handle nodeType of FunctionTypeName #469

Closed
roderik opened this issue Mar 3, 2020 · 1 comment
Closed

Stack traces unable to handle nodeType of FunctionTypeName #469

roderik opened this issue Mar 3, 2020 · 1 comment

Comments

@roderik
Copy link

roderik commented Mar 3, 2020

When running my test, buidler reports: The Buidler EVM tracing engine could not be initialized. Run Buidler with --verbose to learn more.

This is the error:

 buidler:core:buidler-evm:node  TypeError: Cannot read property 'startsWith' of undefined
    at toCanonicalAbiType (/Users/roderik/Development/launchpad/packages/demo-enteth-complete/node_modules/@nomiclabs/buidler/src/internal/buidler-evm/stack-traces/compiler-to-model.ts:464:11)
    at astFunctionDefinitionToSelector (/Users/roderik/Development/launchpad/packages/demo-enteth-complete/node_modules/@nomiclabs/buidler/src/internal/buidler-evm/stack-traces/compiler-to-model.ts:442:10)
    at processFunctionDefinitionAstNode (/Users/roderik/Development/launchpad/packages/demo-enteth-complete/node_modules/@nomiclabs/buidler/src/internal/buidler-evm/stack-traces/compiler-to-model.ts:179:9)
    at processContractAstNode (/Users/roderik/Development/launchpad/packages/demo-enteth-complete/node_modules/@nomiclabs/buidler/src/internal/buidler-evm/stack-traces/compiler-to-model.ts:126:7)
    at createSourcesModelFromAst (/Users/roderik/Development/launchpad/packages/demo-enteth-complete/node_modules/@nomiclabs/buidler/src/internal/buidler-evm/stack-traces/compiler-to-model.ts:80:7)
    at Object.createModelsAndDecodeBytecodes (/Users/roderik/Development/launchpad/packages/demo-enteth-complete/node_modules/@nomiclabs/buidler/src/internal/buidler-evm/stack-traces/compiler-to-model.ts:32:3)
    at new BuidlerNode (/Users/roderik/Development/launchpad/packages/demo-enteth-complete/node_modules/@nomiclabs/buidler/src/internal/buidler-evm/provider/node.ts:303:25)
    at Function.create (/Users/roderik/Development/launchpad/packages/demo-enteth-complete/node_modules/@nomiclabs/buidler/src/internal/buidler-evm/provider/node.ts:222:18)
    at BuidlerEVMProvider._init (/Users/roderik/Development/launchpad/packages/demo-enteth-complete/node_modules/@nomiclabs/buidler/src/internal/buidler-evm/provider/provider.ts:267:28)
    at BuidlerEVMProvider._send (/Users/roderik/Development/launchpad/packages/demo-enteth-complete/node_modules/@nomiclabs/buidler/src/internal/buidler-evm/provider/provider.ts:186:5)
    at BuidlerEVMProvider.send (/Users/roderik/Development/launchpad/packages/demo-enteth-complete/node_modules/@nomiclabs/buidler/src/internal/buidler-evm/provider/provider.ts:80:14)
    at Web3HTTPProviderAdapter._sendJsonRpcRequest (/Users/roderik/Development/launchpad/packages/demo-enteth-complete/node_modules/@nomiclabs/buidler-web3/src/web3-provider-adapter.ts:80:22) +0ms

It happens when calling toCanonicalAbiType here: https://github.com/nomiclabs/buidler/blob/c3b10973740da1c9a44db05f82169bd0a6b1b95a/packages/buidler-core/src/internal/buidler-evm/stack-traces/compiler-to-model.ts#L439

After some debugging I found the culprit.

My contract has the following function:

  function addCallbackForState(bytes32 state, function(bytes32, bytes32) internal callback)
    internal
    doesStateExist(state)
  {
    states[state].callbacks.push(callback);
  }

Where the ast of the callback function looks like this:

{
  constant: false,
  id: 2945,
  name: 'callback',
  nodeType: 'VariableDeclaration',
  overrides: null,
  scope: 2960,
  src: '6513:44:8',
  stateVariable: false,
  storageLocation: 'default',
  typeDescriptions: {
    typeIdentifier: 't_function_internal_nonpayable$_t_bytes32_$_t_bytes32_$returns$__$',
    typeString: 'function (bytes32,bytes32)'
  },
  typeName: {
    id: 2944,
    nodeType: 'FunctionTypeName',
    parameterTypes: {
      id: 2942,
      nodeType: 'ParameterList',
      parameters: [Array],
      src: '6521:18:8'
    },
    returnParameterTypes: {
      id: 2943,
      nodeType: 'ParameterList',
      parameters: [],
      src: '6549:0:8'
    },
    src: '6513:44:8',
    stateMutability: 'nonpayable',
    typeDescriptions: {
      typeIdentifier: 't_function_internal_nonpayable$_t_bytes32_$_t_bytes32_$returns$__$',
      typeString: 'function (bytes32,bytes32)'
    },
    visibility: 'internal'
  },
  value: null,
  visibility: 'internal'
}

and you see that typeName does not have a name field.

@fvictorio
Copy link
Member

Hi @roderik. I'm cleaning up old issues so I'm going to close this one. Also, I think this was fixed at some point. Sorry for not responding before!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2022
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