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

Hardhat-ignition fails to deploy contracts #543

Open
CedarMist opened this issue Mar 25, 2024 · 2 comments
Open

Hardhat-ignition fails to deploy contracts #543

CedarMist opened this issue Mar 25, 2024 · 2 comments
Assignees
Labels
bug Something isn't working p:1 Priority: core feature

Comments

@CedarMist
Copy link
Member

It fails with the following error:

ProviderError: to address not specified

In rpc/eth/api.go it checks specifically for whether to parameter is passed when simulating a transaction, however this means that contract deployments can't be simulated in the way that hardhat-ignition expects.

See relevant code in hardhat-ignition: https://github.com/NomicFoundation/hardhat-ignition/blob/6a2bf9fba8cc2e4c64f8a65efbf8051f43e2fa0e/packages/core/src/internal/execution/future-processor/helpers/network-interaction-execution.ts#L167

    at HttpProvider.request (/src/demo-e2eproxy/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/hardhat/src/internal/core/providers/http.ts:90:21)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async EIP1193JsonRpcClient.call (/src/demo-e2eproxy/node_modules/.pnpm/@[email protected]/node_modules/@nomicfoundation/ignition-core/src/internal/execution/jsonrpc-client.ts:321:24)
    at async sendTransactionForOnchainInteraction (/src/demo-e2eproxy/node_modules/.pnpm/@[email protected]/node_modules/@nomicfoundation/ignition-core/src/internal/execution/future-processor/helpers/network-interaction-execution.ts:167:28)
    at async sendTransaction (/src/demo-e2eproxy/node_modules/.pnpm/@[email protected]/node_modules/@nomicfoundation/ignition-core/src/internal/execution/future-processor/handlers/send-transaction.ts:86:18)
    at async FutureProcessor.processFuture (/src/demo-e2eproxy/node_modules/.pnpm/@[email protected]/node_modules/@nomicfoundation/ignition-core/src/internal/execution/future-processor/future-processor.ts:114:9)
    at async ExecutionEngine._executeBatch (/src/demo-e2eproxy/node_modules/.pnpm/@[email protected]/node_modules/@nomicfoundation/ignition-core/src/internal/execution/execution-engine.ts:153:30)
    at async ExecutionEngine.executeModule (/src/demo-e2eproxy/node_modules/.pnpm/@[email protected]/node_modules/@nomicfoundation/ignition-core/src/internal/execution/execution-engine.ts:114:25)
    at async Deployer.deploy (/src/demo-e2eproxy/node_modules/.pnpm/@[email protected]/node_modules/@nomicfoundation/ignition-core/src/internal/deployer.ts:194:25)
    at async SimpleTaskDefinition.action (/src/demo-e2eproxy/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@nomicfoundation/hardhat-ignition/src/index.ts:220:24)
@CedarMist CedarMist added bug Something isn't working p:1 Priority: core feature labels Mar 25, 2024
@CedarMist CedarMist self-assigned this Mar 25, 2024
@CedarMist
Copy link
Member Author

CedarMist commented Mar 25, 2024

After fixing that bug, I encounter the next one:

ProviderError: invalid argument: unexpected integer size

Which comes from:

{"caller":"grpc.go:242","err":"invalid argument: unexpected integer size","level":"error","method":"/oasis-core.RuntimeClient/Query","module":"grpc/client","msg":"request failed","req_seq":658,"rsp":{"data":null},"ts":"2024-03-25T13:29:39.891166945Z"}

The request which triggers it is:

{
  jsonrpc: '2.0',
  method: 'eth_call',
  params: [
    {
      value: '0x0',
      data: '0x608060405234801561001057600080fd5b506101bc806100206000396000f3fe60806040526004361061001e5760003560e01c806323b872dd14610023575b600080fd5b6100366100313660046100e5565b610038565b005b604080516001600160a01b03858116602483015284166044820152606480820184905282518083039091018152608490910182526020810180516001600160e01b03166000356001600160e01b03191617905290517f998729e624ef59107d5781f8c021b04a5d7b5153dd0ef79e7a08a9f8ab40a5a3916100bc9133913491610121565b60405180910390a1505050565b80356001600160a01b03811681146100e057600080fd5b919050565b6000806000606084860312156100fa57600080fd5b610103846100c9565b9250610111602085016100c9565b9150604084013590509250925092565b60018060a01b038416815260006020848184015260606040840152835180606085015260005b8181101561016357858101830151858201608001528201610147565b506000608082860101526080601f19601f8301168501019250505094935050505056fea2646970667358221220fd6667e915f896f3ce18c5cb6d6753a873674e2380a080ec28379c887a0cc56564736f6c63430008120033',
      from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
      nonce: '0x0',
      gas: '0x24dd3',
      gasPrice: '0x174876e800'
    },
    'pending'
  ],
  id: 12
}

Result:

{
  jsonrpc: '2.0',
  id: 12,
  error: {
    code: -32000,
    message: 'invalid argument: unexpected integer size'
  }
}

This is likely because I fixed it by setting the To address as toBytes = []byte{} if no to field is supplied

@CedarMist
Copy link
Member Author

CedarMist commented Mar 25, 2024

Closing #544 as it's the wrong workaround. Have logged a ticket in clickup to add real support for simulating contract creation.

Performing an eth_call to simulate contract creation is currently not possible.

In oasis web3 gateway the EstimateGas function calls either evm.Create or evm.Call depending on if the to field is empty. I initially made a workaround in oasis-web3-gateway by setting the to field to the zero address, however this will erroneously succeed (as calls to unknown addresses succeed so transfers can be made to previously unknown EOAs). So while that silences the error in hardhat-ignition the behavior is incorrect.

For the correct behavior the evm.SimulateCall function would be modified to handle contract creation with EVM semantics (no to address = create contract & run init code). The evm.SimulateCall function could make the address parameter optional. This would then have to be invoked with a signed query to faithfully replicate EVM semantics.

Alternatively there could be an evm.SimulateCreate function which is invoked by oasis-web3-gateway if it detects the to field is empty and data is non-empty, again you'd have to use signed queries to fully emulate EVM semantics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p:1 Priority: core feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant