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

fix(docker for local development) #523

Merged
merged 6 commits into from
Aug 6, 2021
Merged

fix(docker for local development) #523

merged 6 commits into from
Aug 6, 2021

Conversation

mhalambek
Copy link
Contributor

No description provided.

@mhalambek mhalambek self-assigned this Mar 11, 2021
@mhalambek mhalambek added this to the SRE 01/03/2021 - 31/03/2021 milestone Mar 11, 2021
@mhalambek mhalambek force-pushed the mhala-docker branch 8 times, most recently from fc83035 to d1753cd Compare March 11, 2021 15:23
.buildkite/pipeline.yml Outdated Show resolved Hide resolved
Dockerfile Outdated Show resolved Hide resolved
@@ -4,4 +4,4 @@ set -euo pipefail
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" 2>&1 && pwd )"
cd ${SCRIPTS_DIR}/../../testing/vendor/ganache
ganache_block_time=${GANACHE_BLOCK_TIME:-12}
node_modules/.bin/ganache-cli --port 9545 --blockTime $ganache_block_time --gasLimit 10000000 --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,10000000000000000000000000000" --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,10000000000000000000000000000" --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202,10000000000000000000000000000"
node_modules/.bin/ganache-cli --port 9545 --blockTime $ganache_block_time --gasLimit 10000000 --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,10000000000000000000000000000" --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,10000000000000000000000000000" --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202,10000000000000000000000000000" --db localnet -h 0.0.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make Ganache listen on all interfaces? This may be undesirable, especially for those who are not using Docker.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I can connect to it from the host, use metamask for example

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that if someone is not using Docker, this will let anyone on the same network to connect. So this should be optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realise your concerns, but this is meant for local development purposes, so I don't see a need for high security measures

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be changed to only add this switch if run inside Docker?

./cli/index.js start eth2near-relay --metrics-port 8080
./cli/index.js start near2eth-relay --eth-master-sk 0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201 --metrics-port 8181
./cli/index.js start bridge-watchdog --eth-master-sk 0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202
nohup ./node_modules/.bin/http-server ~/.near/localnet/node0/ -p 9000 -d &
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the use for http-server?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Near explorer requires genesis URL, this is a neat hack to simply enable it

@mhalambek mhalambek force-pushed the mhala-docker branch 2 times, most recently from fc480ee to 2febe56 Compare March 15, 2021 19:18
@chefsale chefsale removed this from the SRE 01/03/2021 - 31/03/2021 milestone Apr 6, 2021
@ilyar
Copy link

ilyar commented May 21, 2021

docker build -t nearprotocol/bridge:new .
...
+ ./cli/index.js init-eth-ed25519
Deploying ETH contract
Error: ENOENT: no such file or directory, open '/usr/src/contracts/eth/nearbridge/artifacts/contracts/Ed25519.sol/Ed25519.json'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at EthContractInitializer.execute (/usr/src/cli/init/eth-contracts.js:33:44)
    at execute (/usr/src/cli/init/eth-contracts.js:71:50)
    at Command.<anonymous> (/usr/src/utils/config/index.js:38:37)
    at Command.listener [as _actionHandler] (/usr/src/node_modules/commander/index.js:413:31)
    at Command._parseCommand (/usr/src/node_modules/commander/index.js:914:14)
    at Command._dispatchSubcommand (/usr/src/node_modules/commander/index.js:865:18)
    at Command._parseCommand (/usr/src/node_modules/commander/index.js:882:12)
    at Command.parse (/usr/src/node_modules/commander/index.js:717:10)
    at Command.parseAsync (/usr/src/node_modules/commander/index.js:744:10)
    at /usr/src/cli/index.js:914:17
    at Object.<anonymous> (/usr/src/cli/index.js:915:3)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/usr/src/contracts/eth/nearbridge/artifacts/contracts/Ed25519.sol/Ed25519.json'
}
Can't deploy /usr/src/contracts/eth/nearbridge/artifacts/contracts/Ed25519.sol/Ed25519.json
The command '/bin/sh -c sh -c "./utils/scripts/docker_prepare.sh"' returned a non-zero code: 1

@idirall22
Copy link

docker build -t nearprotocol/bridge:new .
...
+ ./cli/index.js init-eth-ed25519
Deploying ETH contract
Error: ENOENT: no such file or directory, open '/usr/src/contracts/eth/nearbridge/artifacts/contracts/Ed25519.sol/Ed25519.json'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at EthContractInitializer.execute (/usr/src/cli/init/eth-contracts.js:33:44)
    at execute (/usr/src/cli/init/eth-contracts.js:71:50)
    at Command.<anonymous> (/usr/src/utils/config/index.js:38:37)
    at Command.listener [as _actionHandler] (/usr/src/node_modules/commander/index.js:413:31)
    at Command._parseCommand (/usr/src/node_modules/commander/index.js:914:14)
    at Command._dispatchSubcommand (/usr/src/node_modules/commander/index.js:865:18)
    at Command._parseCommand (/usr/src/node_modules/commander/index.js:882:12)
    at Command.parse (/usr/src/node_modules/commander/index.js:717:10)
    at Command.parseAsync (/usr/src/node_modules/commander/index.js:744:10)
    at /usr/src/cli/index.js:914:17
    at Object.<anonymous> (/usr/src/cli/index.js:915:3)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/usr/src/contracts/eth/nearbridge/artifacts/contracts/Ed25519.sol/Ed25519.json'
}
Can't deploy /usr/src/contracts/eth/nearbridge/artifacts/contracts/Ed25519.sol/Ed25519.json
The command '/bin/sh -c sh -c "./utils/scripts/docker_prepare.sh"' returned a non-zero code: 1

is it fixed?

@mfornet
Copy link
Contributor

mfornet commented Jun 9, 2021

@idirall22 it should be fixed now.

@ilyar @idirall22 can you share what is your use case for the bridge docker image?

@idirall22
Copy link

idirall22 commented Jun 9, 2021

@mfornet thank you for your quick response.
When I follow the deploying and using locally step here,
and run the following cmd:

- cli/index.js clean -> no error
- cli/index.js prepare -> no error
- cli/index.js start near-node -> no error
- cli/index.js start ganache  -> no error
- cli/index.js init-near-contracts -> no error
- cli/index.js init-eth-ed25519 -> ERROR

The error:
0222

Then when I try to build the Docker container using: docker build ., I get another error:
0111

@mfornet
Copy link
Contributor

mfornet commented Jun 9, 2021

@idirall22 regarding the first error, it was because after #564 compiled binaries of solidity contracts are not longer stored, but instructions or scripts were not updated accordingly. I added the compilation line here

If you want to run this locally, please compile ethereum contracts with:

(cd contracts/eth/nearbridge/ && yarn && yarn build)
(cd contracts/eth/nearprover/ && yarn && yarn build)

@mfornet
Copy link
Contributor

mfornet commented Jun 9, 2021

The second error is because you are using the outdated version of the Dockerfile. Please use the version of the Dockerfile included in this PR.

@idirall22
Copy link

idirall22 commented Jun 10, 2021

@mfornet
Finally, I get the bridge up and running using CLI, so I was able to send tokens from ether to near the validation is made after 25 blocks, then when I tried to send back from near to ether the transaction never succeed, from the Docs it says that the tx should succeed after 43K near nodes, s that the case for the local testing?
Also when I check the logs I see that the Near2Ether relayer exit and restart each time and gives an error related to a TX failed:

011111
0222222
033333333
Any Idea?

@mfornet mfornet disabled auto-merge August 6, 2021 10:37
@mfornet mfornet merged commit 656da3e into master Aug 6, 2021
@mfornet mfornet deleted the mhala-docker branch August 6, 2021 10:47
@ilyar
Copy link

ilyar commented Aug 6, 2021

@mfornet we plan to use it here https://github.com/4IRE-Labs/near-sdk/blob/main/docker-compose.yml for a local testing environment

karim-en pushed a commit that referenced this pull request Dec 20, 2021
* fix(docker for local development)

* Update Dockerfile

* Compile contracts

* Remove comment

Co-authored-by: Marcelo <mfornet94@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants