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

feat: Support multi nodes #98

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ WORKDIR /
# Copy over binaries from the build-env
COPY --from=build-env /go/src/github.com/evmos/ethermint/build/ethermintd /usr/bin/ethermintd

EXPOSE 26656 26657 9090 1317 8545 8546

# Run ethermintd by default
CMD ["ethermintd","start"]
12 changes: 4 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -457,17 +457,13 @@ localnet-build:
# Start a 4-node testnet locally
localnet-start: localnet-stop
ifeq ($(OS),Windows_NT)
mkdir localnet-setup &
@$(MAKE) localnet-build

IF not exist "build/node0/$(ETHERMINT_BINARY)/config/genesis.json" docker run --rm -v $(CURDIR)/build\ethermint\Z ethermintd/node "./ethermintd testnet --v 4 -o /ethermint --keyring-backend=test --ip-addresses ethermintdnode0,ethermintdnode1,ethermintdnode2,ethermintdnode3"
docker-compose up -d
IF not exist "build/node0/$(ETHERMINT_BINARY)/config/genesis.json" docker run --rm -v $(CURDIR)/build\ethermint\Z ethermintd/node "/usr/bin/ethermintd testnet init-files --v 4 -o /ethermint --keyring-backend=test --starting-ip-address 192.167.10.2"
docker-compose -f networks/local/ethermintnode/docker-compose.yml up -d
else
mkdir -p localnet-setup
@$(MAKE) localnet-build

if ! [ -f localnet-setup/node0/$(ETHERMINT_BINARY)/config/genesis.json ]; then docker run --rm -v $(CURDIR)/localnet-setup:/ethermint:Z ethermintd/node "./ethermintd testnet --v 4 -o /ethermint --keyring-backend=test --ip-addresses ethermintdnode0,ethermintdnode1,ethermintdnode2,ethermintdnode3"; fi
docker-compose up -d
if ! [ -f build/node0/$(ETHERMINT_BINARY)/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/ethermint:Z ethermintd/node "/usr/bin/ethermintd testnet init-files --v 4 -o /ethermint --keyring-backend=test --starting-ip-address 192.167.10.2"; fi
docker-compose -f networks/local/ethermintnode/docker-compose.yml up -d
endif

# Stop testnet
Expand Down
75 changes: 48 additions & 27 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,75 @@
version: "3"
version: '3'

services:
node0:
container_name: b2-node0
image: ${ETHERMINT_IMAGE}
ports:
- "26657:26657"
- "8545:8545"
- "8546:8546"
- "8125:8125"
- "26656-26657:26656-26657"
volumes:
- ./client-data/node0/ethermintd:/root/.ethermintd
- ./build/node0/ethermintd:/ethermint:Z
command:
- ethermintd
- start
- --home
- /ethermint
networks:
- ethermint
localnet:
ipv4_address: 192.167.10.2

node1:
container_name: b2-node1
image: ${ETHERMINT_IMAGE}
ports:
- "26658:26657"
- "8555:8545"
- "8556:8546"
- "8126:8125"
- "26659-26660:26656-26657"
volumes:
- /root/.ethermintd:/root/.ethermintd
# - ./client-data/node1/ethermintd:/root/.ethermintd
- ./build/node1/ethermintd:/ethermint:Z
command:
- ethermintd
- start
- --home
- /ethermint
networks:
- ethermint
localnet:
ipv4_address: 192.167.10.3

node2:
container_name: b2-node2
image: ${ETHERMINT_IMAGE}
ports:
- "26659:26657"
- "8565:8545"
- "8566:8546"
- "8127:8125"
- "26661-26662:26656-26657"
volumes:
- ./client-data/node2/ethermintd:/root/.ethermintd
- ./build/node2/ethermintd:/ethermint:Z
command:
- ethermintd
- start
- --home
- /ethermint
networks:
- ethermint
localnet:
ipv4_address: 192.167.10.4

node3:
container_name: b2-node3
image: ${ETHERMINT_IMAGE}
ports:
- "26660:26657"
- "8575:8545"
- "8576:8546"
- "8128:8125"
- "26663-26664:26656-26657"
volumes:
- ./client-data/node3/ethermintd:/root/.ethermintd
- ./build/node3/ethermintd:/ethermint:Z
command:
- ethermintd
- start
- --home
- /ethermint
networks:
- ethermint
localnet:
ipv4_address: 192.167.10.5

networks:
ethermint:
localnet:
driver: bridge
ipam:
driver: default
config:
-
subnet: 192.167.10.0/16
6 changes: 3 additions & 3 deletions networks/local/ethermintnode/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ COPY . .
RUN make build-linux

# Final image
FROM golang:1.19 as final
FROM golang:1.20 as final

WORKDIR /

RUN apt-get update

# Copy over binaries from the build-env
COPY --from=build-env /go/src/github.com/evmos/ethermint/build/ethermintd /
COPY --from=build-env /go/src/github.com/evmos/ethermint/build/ethermintd /usr/bin/ethermintd
COPY --from=build-env /go/src/github.com/evmos/ethermint/scripts/start-docker.sh /

EXPOSE 26656 26657 1317 8545 8546
EXPOSE 26656 26657 1317 9090 8545 8546

# Run ethermintd by default, omit entrypoint to ease using container with ethermintd
ENTRYPOINT ["/bin/bash", "-c"]
63 changes: 63 additions & 0 deletions networks/local/ethermintnode/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: '3'

services:
node0:
container_name: b2-node0
image: ethermintd/node
ports:
- "26656-26657:26656-26657"
volumes:
- ../../../build/node0/ethermintd:/ethermint:Z
command:
- ethermintd start --home /ethermint
networks:
localnet:
ipv4_address: 192.167.10.2

node1:
container_name: b2-node1
image: ethermintd/node
ports:
- "26659-26660:26656-26657"
volumes:
- ../../../build/node1/ethermintd:/ethermint:Z
command:
- ethermintd start --home /ethermint
networks:
localnet:
ipv4_address: 192.167.10.3

node2:
container_name: b2-node2
image: ethermintd/node
ports:
- "26661-26662:26656-26657"
volumes:
- ../../../build/node2/ethermintd:/ethermint:Z
command:
- ethermintd start --home /ethermint
networks:
localnet:
ipv4_address: 192.167.10.4

node3:
container_name: b2-node3
image: ethermintd/node
ports:
- "26663-26664:26656-26657"
volumes:
- ../../../build/node3/ethermintd:/ethermint:Z
command:
- ethermintd start --home /ethermint
networks:
localnet:
ipv4_address: 192.167.10.5

networks:
localnet:
driver: bridge
ipam:
driver: default
config:
-
subnet: 192.167.10.0/16
Loading