Open krisc opened 4 years ago
Hi, Kris - thanks for checking out this repo! I think you may be experiencing this problem because you either did not run the npm install
command or it did not succeed. From the logs you provided, I can tell that the error is occurring when your Solidity contracts are being compiled, and in particular the error is that the compiler is not able to locate the Chainlink client smart contract dependencies; these dependencies should be pulled down when you run npm install
. The only way I am able to reproduce this error is by trying to start the project without installing the dependencies first.
Ah, I think that was it haha. Maybe that first step in 'Usage' can be in the 'Dependencies' section to avoid ambiguity? Just an idea.
Hmm, actually, it might be something else. I ran npm i
and still get the same error. I did notice though that the Ganache window (after creating the new Workspace) hangs on the loading screen (the Ganache logo with spinning circle thing).
Running Ganache on command line, I notice this warning:
(node:16058) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 2 server-started listeners added. Use emitter.setMaxListeners() to increase limit
Hm, I am not sure about the problems with Ganache, but running npm i
should take care of the errors you shared above. Can you share the output you're getting after running npm i
? Whether or not Ganache is running shouldn't impact whether or not you can compile the contracts, which is what the error you shared above is telling me.
hey, I appreciate your taking the time to help me with this!
So after completing npm i
, I get this when I run npm start
with no Ganache running:
> delivery-link@1.0.0 start /run/media/kris/storage/delivery-link
> npm stop ; npm run truffle:migrate-ganache && HOST_IP=$(ip -4 addr show $(docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}') | grep -Po 'inet \K[\d.]+') docker-compose up -d && npm run truffle:init-setup
> delivery-link@1.0.0 stop /run/media/kris/storage/delivery-link
> docker-compose down
WARNING: The HOST_IP variable is not set. Defaulting to a blank string.
ERROR: Couldn't find env file: /run/media/kris/storage/delivery-link/truffle/build/addrs.env
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! delivery-link@1.0.0 stop: `docker-compose down`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the delivery-link@1.0.0 stop script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kris/.npm/_logs/2019-11-25T22_06_00_709Z-debug.log
> delivery-link@1.0.0 truffle:migrate-ganache /run/media/kris/storage/delivery-link
> cd ./truffle/ && npx truffle migrate --network ganache && cd ..
Compiling your contracts...
===========================
> Compiling ./contracts/DeliveryLink.sol
> Compiling ./contracts/LinkToken.sol
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/Oracle.sol
> Compiling chainlink/contracts/Chainlink.sol
> Compiling chainlink/contracts/ChainlinkClient.sol
> Compiling chainlink/contracts/Oracle.sol
> Compiling chainlink/contracts/interfaces/ChainlinkRequestInterface.sol
> Compiling chainlink/contracts/interfaces/ENSInterface.sol
> Compiling chainlink/contracts/interfaces/LinkTokenInterface.sol
> Compiling chainlink/contracts/interfaces/OracleInterface.sol
> Compiling chainlink/contracts/interfaces/PointerInterface.sol
> Compiling chainlink/contracts/vendor/Buffer.sol
> Compiling chainlink/contracts/vendor/CBOR.sol
> Compiling chainlink/contracts/vendor/ENSResolver.sol
> Compiling chainlink/contracts/vendor/Ownable.sol
> Compiling chainlink/contracts/vendor/SafeMath.sol
> Compiling link_token/contracts/ERC677Token.sol
> Compiling link_token/contracts/LinkToken.sol
> Compiling link_token/contracts/math/linkSafeMath.sol
> Compiling link_token/contracts/token/ERC677.sol
> Compiling link_token/contracts/token/ERC677Receiver.sol
> Compiling link_token/contracts/token/linkBasicToken.sol
> Compiling link_token/contracts/token/linkERC20.sol
> Compiling link_token/contracts/token/linkERC20Basic.sol
> Compiling link_token/contracts/token/linkStandardToken.sol
> compilation warnings encountered:
link_token/contracts/token/linkStandardToken.sol:27:5: Warning: Use of the "var" keyword is deprecated.
var _allowance = allowed[_from][msg.sender];
^------------^
,link_token/contracts/LinkToken.sol:15:3: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
function LinkToken()
^ (Relevant source part starts here and spans across multiple lines).
,/run/media/kris/storage/delivery-link/truffle/contracts/DeliveryLink.sol:13:3: Warning: Variable is shadowed in inline assembly by an instruction of the same name
uint256 public timestamp;
^----------------------^
,link_token/contracts/ERC677Token.sol:21:5: Warning: Invoking events without "emit" prefix is deprecated.
Transfer(msg.sender, _to, _value, _data);
^--------------------------------------^
,link_token/contracts/token/linkBasicToken.sol:25:5: Warning: Invoking events without "emit" prefix is deprecated.
Transfer(msg.sender, _to, _value);
^-------------------------------^
,link_token/contracts/token/linkStandardToken.sol:35:5: Warning: Invoking events without "emit" prefix is deprecated.
Transfer(_from, _to, _value);
^--------------------------^
,link_token/contracts/token/linkStandardToken.sol:46:5: Warning: Invoking events without "emit" prefix is deprecated.
Approval(msg.sender, _spender, _value);
^------------------------------------^
,link_token/contracts/token/linkStandardToken.sol:69:5: Warning: Invoking events without "emit" prefix is deprecated.
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
^-----------------------------------------------------------^
,link_token/contracts/token/linkStandardToken.sol:81:5: Warning: Invoking events without "emit" prefix is deprecated.
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
^-----------------------------------------------------------^
,link_token/contracts/token/linkERC20Basic.sol:11:3: Warning: No visibility specified. Defaulting to "public".
function balanceOf(address who) constant returns (uint256);
^---------------------------------------------------------^
,link_token/contracts/token/linkERC20Basic.sol:12:3: Warning: No visibility specified. Defaulting to "public".
function transfer(address to, uint256 value) returns (bool);
^----------------------------------------------------------^
,link_token/contracts/token/linkERC20.sol:12:3: Warning: No visibility specified. Defaulting to "public".
function allowance(address owner, address spender) constant returns (uint256);
^----------------------------------------------------------------------------^
,link_token/contracts/token/linkERC20.sol:13:3: Warning: No visibility specified. Defaulting to "public".
function transferFrom(address from, address to, uint256 value) returns (bool);
^----------------------------------------------------------------------------^
,link_token/contracts/token/linkERC20.sol:14:3: Warning: No visibility specified. Defaulting to "public".
function approve(address spender, uint256 value) returns (bool);
^--------------------------------------------------------------^
,link_token/contracts/token/ERC677.sol:6:3: Warning: No visibility specified. Defaulting to "public".
function transferAndCall(address to, uint value, bytes data) returns (bool success);
^----------------------------------------------------------------------------------^
,link_token/contracts/token/ERC677Receiver.sol:5:3: Warning: No visibility specified. Defaulting to "public".
function onTokenTransfer(address _sender, uint _value, bytes _data);
^------------------------------------------------------------------^
,link_token/contracts/token/linkBasicToken.sol:22:3: Warning: No visibility specified. Defaulting to "public".
function transfer(address _to, uint256 _value) returns (bool) {
^ (Relevant source part starts here and spans across multiple lines).
,link_token/contracts/token/linkBasicToken.sol:34:3: Warning: No visibility specified. Defaulting to "public".
function balanceOf(address _owner) constant returns (uint256 balance) {
^ (Relevant source part starts here and spans across multiple lines).
,link_token/contracts/token/linkStandardToken.sol:26:3: Warning: No visibility specified. Defaulting to "public".
function transferFrom(address _from, address _to, uint256 _value) returns (bool) {
^ (Relevant source part starts here and spans across multiple lines).
,link_token/contracts/token/linkStandardToken.sol:44:3: Warning: No visibility specified. Defaulting to "public".
function approve(address _spender, uint256 _value) returns (bool) {
^ (Relevant source part starts here and spans across multiple lines).
,link_token/contracts/token/linkStandardToken.sol:56:3: Warning: No visibility specified. Defaulting to "public".
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
^ (Relevant source part starts here and spans across multiple lines).
,link_token/contracts/token/linkStandardToken.sol:66:3: Warning: No visibility specified. Defaulting to "public".
function increaseApproval (address _spender, uint _addedValue)
^ (Relevant source part starts here and spans across multiple lines).
,link_token/contracts/token/linkStandardToken.sol:73:3: Warning: No visibility specified. Defaulting to "public".
function decreaseApproval (address _spender, uint _subtractedValue)
^ (Relevant source part starts here and spans across multiple lines).
,link_token/contracts/ERC677Token.sol:38:3: Warning: Function state mutability can be restricted to view
function isContract(address _addr)
^ (Relevant source part starts here and spans across multiple lines).
,link_token/contracts/math/linkSafeMath.sol:9:3: Warning: Function state mutability can be restricted to pure
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
^ (Relevant source part starts here and spans across multiple lines).
,link_token/contracts/math/linkSafeMath.sol:15:3: Warning: Function state mutability can be restricted to pure
function div(uint256 a, uint256 b) internal constant returns (uint256) {
^ (Relevant source part starts here and spans across multiple lines).
,link_token/contracts/math/linkSafeMath.sol:22:3: Warning: Function state mutability can be restricted to pure
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
^ (Relevant source part starts here and spans across multiple lines).
,link_token/contracts/math/linkSafeMath.sol:27:3: Warning: Function state mutability can be restricted to pure
function add(uint256 a, uint256 b) internal constant returns (uint256) {
^ (Relevant source part starts here and spans across multiple lines).
> Artifacts written to /run/media/kris/storage/delivery-link/truffle/build/contracts
> Compiled successfully using:
- solc: 0.4.24+commit.e67f0147.Emscripten.clang
> Something went wrong while attempting to connect to the network. Check your network configuration.
Could not connect to your Ethereum client with the following parameters:
- host > 127.0.0.1
- port > 7545
- network_id > *
Please check that your Ethereum client:
- is running
- is accepting RPC connections (i.e., "--rpc" option is used in geth)
- is accessible over the network
- is properly configured in your Truffle configuration file (truffle-config.js)
Truffle v5.0.43 (core: 5.0.43)
Node v10.12.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! delivery-link@1.0.0 truffle:migrate-ganache: `cd ./truffle/ && npx truffle migrate --network ganache && cd ..`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the delivery-link@1.0.0 truffle:migrate-ganache script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kris/.npm/_logs/2019-11-25T22_06_21_369Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! delivery-link@1.0.0 start: `npm stop ; npm run truffle:migrate-ganache && HOST_IP=$(ip -4 addr show $(docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}') | grep -Po 'inet \K[\d.]+') docker-compose up -d && npm run truffle:init-setup`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the delivery-link@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kris/.npm/_logs/2019-11-25T22_06_21_432Z-debug.log
Totally happy to help and really appreciate the same from you :grin: The error you shared above makes perfect sense if Ganache is not running. What is happening is that the contracts compiled successfully and then they are attempting to be deployed to the local Ganache network. Since that is not running, you're getting this error: Something went wrong while attempting to connect to the network. Check your network configuration.
I don't really have any experience with the Ganache CLI and the GUI has always "just worked" for me :persevere:
At the workshop at the brewery, I noticed that the Ganache GUI you were using was different than the one I was using, and realized I was using an old version (which didn't have that workspace setup on startup). So I upgraded to the version you were using, but I may just try the CLI for now.
Don't forget to get it to listen on all interfaces! (0.0.0.0
)
running this to start ganache-cli
:
ganache-cli -h 0.0.0.0 -p 7545
looks like it compiled and migrated, but npm start
still giving an error. looks like it's docker related:
https://gist.github.com/krisc/8da0dae2cdac03e1c39bc410a7083783
Not sure if I should do this, but maybe this is helpful. So I ran these series of commands:
ganache-cli -h 0.0.0.0 -p 7545
sudo dockerd
sudo npm start
And it went a little further along, but still got an error: https://gist.github.com/krisc/fe448b8bbe4cb3dc95fd57a7aef64566
Are you running on Mac or Linux? This seems to point to HOST_IP env var not getting set.
WARNING: The HOST_IP variable is not set. Defaulting to a blank string.
This seems be a problem on Mac as the command ip
will not work. This bug is particularly pervasive as it only shows as a warning, but the actual effect is that the Chainlink node is unable to connect to Ganache.
If you are a Mac user, I'd suggest replacing in package.json:
HOST_IP=$(ip -4 addr show docker0 | grep -Po 'inet \\K[\\d.]+')
With:
HOST_IP=$(ipconfig getifaddr en0)
This seems to be the only Linux OS-specific bug in the workshop as Docker will work on any platform. Tbh, my solution is also kinda a OSX-specific hack. I think it would be better practice if HOST_IP was set as an environment variable.
@leovigna hmm yeah, we overlooked that WARNING. But I'm actually on Manjaro Linux ...
So did you find a way to set HOST_IP? Are the docker instances able to connect?
Hi @leovigna, I have the same issue
''' Using network 'ganache'.
Transfering 100 LINK to 0xB62EA3D281c48BFd6A0D058Dc905Acf585BF697a... Transfer succeeded! Transaction ID: 0xfd2a501c9dc674137de9ab62f0db25b84eaec1deea3c4a723e2939b9365b26a1.
delivery-link@1.0.0 truffle:prep-node /Users/mv/Documents/Workspace/develop/delivery-Link cd ./truffle && npx truffle exec ./scripts/prep-node.js --network ganache && cd .. '''
Using network 'ganache'.
/Users/mv/Documents/Workspace/develop/delivery-Link/chainlink/cl-utils.js:54
resolve(JSON.parse(resBody).data[0].id);
^
SyntaxError: Unexpected end of JSON input
at JSON.parse (
I've also got the warning for not setting the HOST_IP but when I echo it does show the IP. Also from the video from the workshop, you can see this is the same behavior as when Dan ran it, so not sure this is the issue.
Seems it has an issue with 'cl-utils.js' and as can be seen above fails in the prep-node.js script
can this be related to web3 version?
Thanks!
Hi @leovigna, I have the same issue
''' Using network 'ganache'.
Transfering 100 LINK to 0xB62EA3D281c48BFd6A0D058Dc905Acf585BF697a... Transfer succeeded! Transaction ID: 0xfd2a501c9dc674137de9ab62f0db25b84eaec1deea3c4a723e2939b9365b26a1.
delivery-link@1.0.0 truffle:prep-node /Users/mv/Documents/Workspace/develop/delivery-Link cd ./truffle && npx truffle exec ./scripts/prep-node.js --network ganache && cd .. '''
Using network 'ganache'.
/Users/mv/Documents/Workspace/develop/delivery-Link/chainlink/cl-utils.js:54 resolve(JSON.parse(resBody).data[0].id); ^ SyntaxError: Unexpected end of JSON input at JSON.parse () at IncomingMessage. (/Users/mv/Documents/Workspace/develop/delivery-Link/chainlink/cl-utils.js:54:22) at IncomingMessage.emit (events.js:323:22) at endReadableNT (_stream_readable.js:1204:12) at processTicksAndRejections (internal/process/task_queues.js:84:21)
I've also got the warning for not setting the HOST_IP but when I echo it does show the IP. Also from the video from the workshop, you can see this is the same behavior as when Dan ran it, so not sure this is the issue.
Seems it has an issue with 'cl-utils.js' and as can be seen above fails in the prep-node.js script
can this be related to web3 version?
Thanks!
Hey, I've struggled to set the whole thing locally as well, which it has not been as "plug & play" as in the video (but in fairness nothing never is).
My approach has been a bit bottom up after GORM wasn't able to connect to my local PostgreSQL instance (not containarised) on he first attempt using this repository.
A summary of what I've done is (for local development purposes):
postgresql.conf
and pg_hba.conf
for being able to be reached from a container.Now I'm blocked at the same point than you: prep-node.js
fails at clUtils.getAcctAddr()
, because this function is unable to send the GET request (http://localhost:6688/v2/user/balances
). I've isolated the request in a minimal Truffle script and it does not work either. The funny thing is the request works both via browser and Postman.
Shell script call:
npx truffle exec scripts/smoke_test.js
Shell response (socket hangs because there is no response):
Using network 'ganache'.
Error: socket hang up
at connResetException (internal/errors.js:609:14)
at Socket.socketOnEnd (_http_client.js:453:23)
at Socket.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1221:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
{
"data": [
{
"type": "accountBalances",
"id": "0xda280e62e9C8c60D90dDA58a49928d5a2B1002b2",
"attributes": {
"address": "0xda280e62e9C8c60D90dDA58a49928d5a2B1002b2",
"ethBalance": "0",
"linkBalance": "0"
}
}
]
}
I will keep investigating what is going on. Any help appreciated @danforbes, otherwise I will ask at Discord.
Thanks
P.S.: the HOST_IP
warn you get on npm start
is because this command calls first npm stop
, which calls docker-compose down
, and the HOST_IP
environment variable is not being passed.
Morning, quick follow up on the matter!
I was wrong and the function to blame is getSessionCookie()
. I'm running Chainlink Node 0.8.12
(because it wasn't locked in the docker-compose.yml
), and with this version the statement const cookie = res.headers["set-cookie"][0]
assigns a wrong cookie. There are two items in the set-cookie
Array and the one that matters starts with clsession=
. As I can't assure their positions my quick fix is:
res.on("end", () => {
const clsessionIdx = res.headers["set-cookie"].findIndex((c) =>
c.startsWith("clsession")
);
cookie = res.headers["set-cookie"][clsessionIdx];
resolve(cookie);
});
@Mvilsht hope it helps, but probably you have already sorted it out.
Sorry for the very delayed reply, @vnavascues. I'm glad you were able to make progress on this. Since this repo clearly isn't being maintained I am going to archive it.
I'm getting errors when I run
npm start
: