Skip to content

Commit

Permalink
feat: add containerized localnet (#439)
Browse files Browse the repository at this point in the history
* chore: remove deprecated localnet script

this script is no longer working and has been deprecated by scripts/localnet.sh

* feat: update localnet.sh to support container deployments

- change to use bash script instead of sh to allow more refined syntax
- set archwayd process to listen all addresses instead of localhost
- set BINARY path dependent on whether using containers or local

* fix: docker-compose update

- use image based on TAG env variable, make file will set the tag automatically
- enable 26656 also
- change to use the new scripts path

* feat: update Dockerfile for devs

- Update image version to alpine 3.18
- rename the debug image to dev
- add bash and jq for dev purposes

* feat: update makefile to enable containerized localnet deployment

* feat: rename debug image to dev image

* chore: update changelog

* fix: untag the correct compose command

* chore: moving localnet CHANGELOGS to correct place, waiting a release

* feat: readme part how to run containerized localnet

* feat: add comments to makefile to clarify how localnet commands work

* fix: add build to run step in the makefile to fix missing binary'
  • Loading branch information
jlehtimaki authored Sep 1, 2023
1 parent 2606ed9 commit 6e03b38
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 80 deletions.
14 changes: 7 additions & 7 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ dockers:
- use: buildx
goos: linux
goarch: amd64
dockerfile: Dockerfile.debug
dockerfile: Dockerfile.dev
image_templates:
- 'ghcr.io/archway-network/{{ .ProjectName }}d-debug:{{if eq .Env.RELEASE "true"}}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}-amd64'
- 'ghcr.io/archway-network/{{ .ProjectName }}d-dev{{if eq .Env.RELEASE "true"}}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}-amd64'
build_flag_templates:
- "--pull"
- "--platform=linux/amd64"
Expand All @@ -211,9 +211,9 @@ dockers:
- use: buildx
goos: linux
goarch: arm64
dockerfile: Dockerfile.debug
dockerfile: Dockerfile.dev
image_templates:
- 'ghcr.io/archway-network/{{ .ProjectName }}d-debug:{{if eq .Env.RELEASE "true"}}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}-arm64v8'
- 'ghcr.io/archway-network/{{ .ProjectName }}d-dev{{if eq .Env.RELEASE "true"}}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}-arm64v8'
build_flag_templates:
- "--pull"
- "--platform=linux/arm64"
Expand All @@ -230,7 +230,7 @@ docker_manifests:
image_templates:
- 'ghcr.io/archway-network/{{ .ProjectName }}d:{{if eq .Env.RELEASE "true"}}v{{ .Version }}-amd64{{else}}{{ .ShortCommit }}-amd64{{end}}'
- 'ghcr.io/archway-network/{{ .ProjectName }}d:{{if eq .Env.RELEASE "true"}}v{{ .Version }}-arm64v8{{else}}{{ .ShortCommit }}-arm64v8{{end}}'
- name_template: 'ghcr.io/archway-network/{{ .ProjectName }}d-debug:{{if eq .Env.RELEASE "true" }}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}'
- name_template: 'ghcr.io/archway-network/{{ .ProjectName }}d-dev{{if eq .Env.RELEASE "true" }}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}'
image_templates:
- 'ghcr.io/archway-network/{{ .ProjectName }}d-debug:{{if eq .Env.RELEASE "true"}}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}-amd64'
- 'ghcr.io/archway-network/{{ .ProjectName }}d-debug:{{if eq .Env.RELEASE "true"}}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}-arm64v8'
- 'ghcr.io/archway-network/{{ .ProjectName }}d-dev:{{if eq .Env.RELEASE "true"}}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}-amd64'
- 'ghcr.io/archway-network/{{ .ProjectName }}d-dev:{{if eq .Env.RELEASE "true"}}v{{ .Version }}{{else}}{{ .ShortCommit }}{{end}}-arm64v8'
14 changes: 7 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,21 @@ Contains all the PRs that improved the code without changing the behaviours.

### Added

- [#439](https://github.com/archway-network/archway/pull/439) - adding containerized localnet
- [#445](https://github.com/archway-network/archway/pull/445) - Adding Archway logo and version number to upgrade logs

### Changed

### Deprecated

- [#439](https://github.com/archway-network/archway/pull/439) - renaming `debug` image to `dev`

### Removed

### Fixed

### Improvements


## [v4.0.2](https://github.com/archway-network/archway/releases/tag/v4.0.2)

### Changed
Expand All @@ -66,7 +68,7 @@ Contains all the PRs that improved the code without changing the behaviours.
### Added

- [#429](https://github.com/archway-network/archway/pull/429) - Adding `cosmwasm_1_3` capabilities by bumping wasmd to v0.33.0
- [#430](https://github.com/archway-network/archway/pull/430) - Added gh workflow to run chain upgarde test on PRs
- [#430](https://github.com/archway-network/archway/pull/430) - Added gh workflow to run chain upgrade test on PRs

### Changed

Expand Down Expand Up @@ -106,14 +108,12 @@ Contains all the PRs that improved the code without changing the behaviours.

Archway Network - Capture the value you create!


## [v1.0.0-rc.4](https://github.com/archway-network/archway/releases/tag/v1.0.0-rc.4)

### Added

- [#409](https://github.com/archway-network/archway/pull/409) - Add cosmwasm_1_1,cosmwasm_1_2 Cosmwasm capabilities


## [v1.0.0-rc.3](https://github.com/archway-network/archway/releases/tag/v1.0.0-rc.3)

### Removed
Expand All @@ -128,7 +128,7 @@ Archway Network - Capture the value you create!
- [#402](https://github.com/archway-network/archway/pull/402) - Bump wasmvm version to 1.2.4
- [#403](https://github.com/archway-network/archway/pull/403) - Update libwasmvm version to correct one for wasmvm 1.2.4
- [#404](https://github.com/archway-network/archway/pull/403) - Fix typo in rewards query cli
- [#406](https://github.com/archway-network/archway/pull/406) - Add upgrade hanlder for v0.6.0 back to prevent downgrade check from panic / consensus failure;
- [#406](https://github.com/archway-network/archway/pull/406) - Add upgrade handler for v0.6.0 back to prevent downgrade check from panic / consensus failure;

## [v1.0.0-rc.1](https://github.com/archway-network/archway/releases/tag/v1.0.0-rc.1)

Expand Down Expand Up @@ -227,7 +227,7 @@ Archway Network - Capture the value you create!

### Fixed

- [#338](https://github.com/archway-network/archway/pull/338) - fixed issue where contract premium was not completly being sent to the rewards address
- [#338](https://github.com/archway-network/archway/pull/338) - fixed issue where contract premium was not completely being sent to the rewards address

## [v0.3.1](https://github.com/archway-network/archway/releases/tag/v0.3.1)

Expand Down Expand Up @@ -278,7 +278,7 @@ Archway Network - Capture the value you create!

### Fixed

- [#191](https://github.com/archway-network/archway/pull/191) - make localnet ovveride entrypoint
- [#191](https://github.com/archway-network/archway/pull/191) - make localnet override entrypoint
- [#205](https://github.com/archway-network/archway/pull/205) - fix go.mod
- [#216](https://github.com/archway-network/archway/pull/216) - fix dry-run cmd and bump cosmos-sdk do v0.45.8
- [#218](https://github.com/archway-network/archway/pull/218) - x/rewards unique ID genesis export/import
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile.debug → Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
FROM alpine:3.17
FROM alpine:3.18

COPY ./archwayd /usr/bin/archwayd

WORKDIR /root/.archway

# Install dev packages
RUN apk add --no-cache bash jq

# rest server
EXPOSE 1317
# tendermint p2p
Expand Down
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ BUF_IMAGE=bufbuild/buf@sha256:9dc5d6645f8f8a2d5aaafc8957fbbb5ea64eada98a84cb0965
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(BUF_IMAGE)
HTTPS_GIT := https://github.com/archway-network/archway.git
CURRENT_DIR := $(shell pwd)
SHORT_SHA := $(shell git rev-parse --short HEAD)
LATEST_TAG := $(shell git describe --tags --abbrev=0)

# library versions
LIBWASM_VERSION = $(shell go list -m -f '{{ .Version }}' github.com/CosmWasm/wasmvm)
Expand Down Expand Up @@ -207,9 +209,6 @@ proto-lint:
proto-check-breaking:
@$(DOCKER_BUF) breaking --against-input $(HTTPS_GIT)#branch=master

localnet:
docker-compose up

docker-build:
$(DOCKER) run \
--rm \
Expand Down Expand Up @@ -261,9 +260,17 @@ check-vuln-deps:
### Run Localnet ###
###############################################################################

# Run localnet in a containerized environment, starts new localnet
localnet:
TAG=$(LATEST_TAG) docker-compose up

# Continue the stopped containerized localnet, starts the stopped containers
localnet-continue:
TAG=$(LATEST_TAG) CONTINUE="continue" docker-compose up

# Run a new localnet
run:
./scripts/localnet.sh
run: build
./scripts/localnet.sh

# Continue the existing localnet
run-continue:
Expand Down
35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
![](https://github.com/archway-network/archway/blob/main/banner.png)

# Archway

[![Version](https://img.shields.io/github/v/tag/archway-network/archway.svg?sort=semver&style=flat-square)](https://github.com/archway-network/archway/releases/latest)
Expand All @@ -7,15 +8,14 @@
[![codecov](https://codecov.io/gh/archway-network/archway/branch/master/graph/badge.svg)](https://codecov.io/gh/archway-network/archway)
[![License:Apache-2.0](https://img.shields.io/github/license/archway-network/archway.svg?style=flat-square)](https://github.com/archway-network/archway/LICENSE)


The core implementation of the Archway protocol leverages the [Cosmos SDK](https://cosmos.network) and [CosmWasm](https://cosmwasm.com) to reward validators and creators for their contributions to the network.

## System Requirements

The following specifications have been found to work well:

- An x86-64 (amd64) multi-core CPU (AMD / Intel);
- Higher clock speeds are preferred as Tendermint is mostly single-threaded;
- Higher clock speeds are preferred as Tendermint is mostly single-threaded;
- 64GB RAM;
- 1TB NVMe SSD Storage (disk i/o is crucial);
- 100Mbps bi-directional Internet connection;
Expand All @@ -24,10 +24,10 @@ The following specifications have been found to work well:

The following software should be installed on the target system:

- The Go Programming Language (https://go.dev)
- Git Distributed Version Control (https://git-scm.com)
- Docker (https://www.docker.com)
- GNU Make (https://www.gnu.org/software/make)
- The Go Programming Language (<https://go.dev>)
- Git Distributed Version Control (<https://git-scm.com>)
- Docker (<https://www.docker.com>)
- GNU Make (<https://www.gnu.org/software/make>)

## Build from Source

Expand All @@ -49,7 +49,28 @@ A docker image for production purposes (no shell access):

A docker image is also provided for test setups (shell access):

[Packages: archwayd-debug](https://github.com/orgs/archway-network/packages/container/package/archwayd-debug)
[Packages: archwayd-debug](https://github.com/orgs/archway-network/packages/container/package/archwayd-dev)

## Running localnet

There are two ways to run a localnet, local and containerized

### Containerized

This solution uses docker-compose and docker on the backend.
To setup new localnet use:

```
make localnet
```

To continue last localnet used:

```
make localnet-continue
```

### Local

## Documentation

Expand Down
37 changes: 0 additions & 37 deletions contrib/localnet/localnet.sh

This file was deleted.

9 changes: 5 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
---
version: "3"

services:
node:
image: archwaynetwork/archwayd:latest
build:
context: .
image: ghcr.io/archway-network/archwayd-dev:${TAG}
entrypoint:
- sh
- /opt/localnet.sh
- ${CONTINUE}
ports:
- 9090:9090
- 26657:26657
- 26656:26656
volumes:
- ./contrib/localnet:/opt:z
- ./scripts:/opt:z
- ./contracts:/contracts:z
working_dir: /opt
31 changes: 19 additions & 12 deletions scripts/localnet.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/bin/sh
#!/bin/bash


# Console log text colour
red=`tput setaf 9`
green=`tput setaf 10`
blue=`tput setaf 12`
reset=`tput sgr0`

echo_info () {
echo "${blue}"
Expand All @@ -25,7 +21,16 @@ echo_success () {
}

# Set localnet settings
BINARY=./build/archwayd
if [[ -f "build/archwayd" ]] ;then
BINARY=build/archwayd
# Console log text colour
red=`tput setaf 9`
green=`tput setaf 10`
blue=`tput setaf 12`
reset=`tput sgr0`
else
BINARY=archwayd
fi
CHAIN_ID=localnet-1
CHAIN_DIR=./data
VALIDATOR_MNEMONIC="guard cream sadness conduct invite crumble clock pudding hole grit liar hotel maid produce squeeze return argue turtle know drive eight casino maze host"
Expand Down Expand Up @@ -56,8 +61,10 @@ setup_chain () {
# Modify config for development
config="$CHAIN_DIR/$CHAIN_ID/config/config.toml"
if [ "$(uname)" = "Linux" ]; then
sed -i "s/cors_allowed_origins = \[\]/cors_allowed_origins = [\"*\"]/g" $config
sed -i "s/127.0.0.1/0.0.0.0/g" $config
sed -i "s/cors_allowed_origins = \[\]/cors_allowed_origins = [\"*\"]/g" $config
else
sed -i '' "s/127.0.0.1/0.0.0.0/g" $config
sed -i '' "s/cors_allowed_origins = \[\]/cors_allowed_origins = [\"*\"]/g" $config
fi
# modify genesis params for localnet ease of use
Expand All @@ -69,7 +76,7 @@ setup_chain () {
# reduce minimum deposit amount to 10stake
contents="$(jq '.app_state.gov.deposit_params.min_deposit[0].amount = "10"' $genesis)" && echo "${contents}" > $genesis
echo_info "Set x/gov proposal min deposit amount to 10 stake"
# reduce deposit period to 20seconds
# reduce deposit period to 20seconds
contents="$(jq '.app_state.gov.deposit_params.max_deposit_period = "20s"' $genesis)" && echo "${contents}" > $genesis
echo_info "Set x/gov proposal max deposit period to 20 seconds"

Expand Down Expand Up @@ -109,11 +116,11 @@ setup_chain () {
echo_error "Failed to validate genesis"
fi
}

if [ "$1" != "continue" ] ;then
setup_chain
setup_chain
fi

# Starting chain
echo_info "Starting chain..."
$BINARY --home $CHAIN_DIR/$CHAIN_ID start
$BINARY --home $CHAIN_DIR/$CHAIN_ID start

0 comments on commit 6e03b38

Please sign in to comment.