hswick / exw3

High level Ethereum RPC Client for Elixir

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Contract Manager can't access ExthCrypto library

timjp87 opened this issue · comments

Hi,

I'm using exw3 to deploy a ETH 2 Validator Deposit Contract via a Mix Task:
https://github.com/timjp87/panacea/blob/master/apps/beaconchain/lib/mix/tasks/deploy.ex

However, when I run "mix deploy" it can't access ExthCrypto.Hash.Keccak.kec/1 which should be available through the ethereumex dependency, right?

16:56:05.451 [info]  Deploying validator deposit contract.
16:56:05.493 [info]  Started Ethereumex Application.
16:56:05.595 [info]  Got list of accounts from RPC.
16:56:05.596 [info]  Started contract manager.
16:56:05.597 [info]  Loaded contract ABI.
16:56:05.597 [info]  Contract registered.

16:56:05.614 [error] GenServer ContractManager terminating
** (UndefinedFunctionError) function ExthCrypto.Hash.Keccak.kec/1 is undefined (module ExthCrypto.Hash.Keccak is not available)
    ExthCrypto.Hash.Keccak.kec("Deposit(bytes,bytes)")
    lib/exw3.ex:293: ExW3.encode_event/1
    lib/exw3.ex:587: anonymous fn/1 in ExW3.Contract.init_events/1
    (elixir) lib/enum.ex:1327: Enum."-map/2-lists^map/1-0-"/2
    lib/exw3.ex:583: ExW3.Contract.init_events/1
    lib/exw3.ex:720: ExW3.Contract.register_helper/1
    lib/exw3.ex:742: ExW3.Contract.handle_cast/2
    (stdlib) gen_server.erl:637: :gen_server.try_dispatch/4```

Hmmm, I haven't run into that issue before.

Based on the error message, my instinct would be to add ExthCrypto as an explicit dependency to exw3. Please feel free to fork and try this out, I am more than happy to merge a PR for this, since it should be a small change.

However, the fact that you are getting this error message at all is very strange. ExthCrypto requires c compilation, so if part of that build process messed up then I can see why it might fail. I would recommend trying ExthCrypto by itself on your machine, as a basic sanity check.

My other guess, is that maybe this C compilation step doesn't play nice with your monorepo setup.

I've released v0.4.4 on hex.pm which includes your patch. I'm going to close this issue, but please open if you run into any issues.