Skip to content

Commit

Permalink
build: localnet for Apple Silicon (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
inon-man authored Feb 14, 2023
1 parent 7a01af3 commit 56eda11
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ jobs:
if: env.GIT_DIFF
- name: test liveness
run: |
./contrib/localnet_liveness.sh 100 5 50 localhost
./contrib/localnet/localnet_liveness.sh 100 3 30 localhost
if: env.GIT_DIFF
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
# Changelog

## [Unreleased]
### Features
* (build) [#118](https://github.com/classic-terra/core/pull/118) localnet for Apple Silicon

### Features
* (ante) [#103](https://github.com/classic-terra/core/pull/103) Add burn tax split logic
Expand Down
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ endif

build-linux:
mkdir -p $(BUILDDIR)
docker build --no-cache --tag classic-terra/core ./
docker create --name temp classic-terra/core:latest
docker build --platform linux/amd64 --no-cache --tag classic-terra/core ./
docker create --platform linux/amd64 --name temp classic-terra/core:latest
docker cp temp:/usr/local/bin/terrad $(BUILDDIR)/
docker rm temp

build-linux-with-shared-library:
mkdir -p $(BUILDDIR)
docker build --tag classic-terra/core-shared ./ -f ./shared.Dockerfile
docker create --name temp classic-terra/core-shared:latest
docker build --platform linux/amd64 --no-cache --tag classic-terra/core-shared ./ -f ./shared.Dockerfile
docker create --platform linux/amd64 --name temp classic-terra/core-shared:latest
docker cp temp:/usr/local/bin/terrad $(BUILDDIR)/
docker cp temp:/lib/libwasmvm.so $(BUILDDIR)/
docker rm temp
Expand Down Expand Up @@ -241,18 +241,18 @@ proto-check-breaking:
###############################################################################

# Run a 4-node testnet locally
localnet-start: build-linux localnet-stop
$(if $(shell $(DOCKER) inspect -f '{{ .Id }}' terramoney/terrad-env 2>/dev/null),$(info found image terramoney/terrad-env),$(MAKE) -C contrib/images terrad-env)
if ! [ -f build/node0/terrad/config/genesis.json ]; then $(DOCKER) run --rm \
localnet-start: localnet-stop build-linux
$(if $(shell $(DOCKER) inspect -f '{{ .Id }}' classic-terra/terrad-env 2>/dev/null),$(info found image classic-terra/terrad-env),$(MAKE) -C contrib/localnet terrad-env)
if ! [ -f build/node0/terrad/config/genesis.json ]; then $(DOCKER) run --platform linux/amd64 --rm \
--user $(shell id -u):$(shell id -g) \
-v $(BUILDDIR):/terrad:Z \
-v /etc/group:/etc/group:ro \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/shadow:/etc/shadow:ro \
terramoney/terrad-env testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
classic-terra/terrad-env testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
docker-compose up -d

localnet-stop:
docker-compose down

.PHONY: localnet-start localnet-stop
.PHONY: localnet-start localnet-stop
6 changes: 3 additions & 3 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ func interBlockCacheOpt() func(*baseapp.BaseApp) {
return baseapp.SetInterBlockCache(store.NewCommitKVStoreCacheManager())
}

//// TODO: Make another test for the fuzzer itself, which just has noOp txs
//// and doesn't depend on the application.
// TODO: Make another test for the fuzzer itself, which just has noOp txs
// and doesn't depend on the application.
func TestAppStateDeterminism(t *testing.T) {
if !simapp.FlagEnabledValue {
t.Skip("skipping application simulation")
Expand All @@ -95,7 +95,7 @@ func TestAppStateDeterminism(t *testing.T) {
config.ChainID = helpers.SimAppChainID

numSeeds := 3
numTimesToRunPerSeed := 5
numTimesToRunPerSeed := 3
appHashList := make([]json.RawMessage, numTimesToRunPerSeed)

for i := 0; i < numSeeds; i++ {
Expand Down
6 changes: 0 additions & 6 deletions contrib/images/Makefile

This file was deleted.

6 changes: 6 additions & 0 deletions contrib/localnet/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
all: terrad-env

terrad-env:
docker build --platform linux/amd64 --no-cache --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag classic-terra/terrad-env terrad-env

.PHONY: all terrad-env
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ while [ ${CNT} -lt $ITER ]; do

# Emulate network chaos:
#
# Every 10 blocks, pick a random container and restart it.
# Every 10th iteration, pick a random container and restart it.
if ! ((${CNT} % 10)); then
rand_container=${docker_containers["$[RANDOM % ${#docker_containers[@]}]"]};
echo "Restarting random docker container ${rand_container}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ USER ${UID}:${GID}
VOLUME /terrad
WORKDIR /terrad
EXPOSE 26656 26657
ENTRYPOINT ["/usr/bin/wrapper.sh"]
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
CMD ["start", "--log_format", "plain"]
STOPSIGNAL SIGTERM

COPY wrapper.sh /usr/bin/wrapper.sh
COPY entrypoint.sh /usr/bin/entrypoint.sh
File renamed without changes.
12 changes: 8 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ version: '3.8'

services:
terradnode0:
platform: linux/amd64
container_name: terradnode0
image: "terramoney/terrad-env"
image: classic-terra/terrad-env
ports:
- "9090:9090"
- "26656-26657:26656-26657"
Expand All @@ -17,8 +18,9 @@ services:
ipv4_address: 192.168.10.2

terradnode1:
platform: linux/amd64
container_name: terradnode1
image: "terramoney/terrad-env"
image: classic-terra/terrad-env
ports:
- "9091:9090"
- "26659-26660:26656-26657"
Expand All @@ -32,8 +34,9 @@ services:
ipv4_address: 192.168.10.3

terradnode2:
platform: linux/amd64
container_name: terradnode2
image: "terramoney/terrad-env"
image: classic-terra/terrad-env
environment:
- ID=2
- LOG=$${LOG:-terrad.log}
Expand All @@ -47,8 +50,9 @@ services:
ipv4_address: 192.168.10.4

terradnode3:
platform: linux/amd64
container_name: terradnode3
image: "terramoney/terrad-env"
image: classic-terra/terrad-env
environment:
- ID=3
- LOG=$${LOG:-terrad.log}
Expand Down
4 changes: 2 additions & 2 deletions sims.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ SIMAPP = ./app
test-sim-nondeterminism:
@echo "Running non-determinism test..."
@go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \
-NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h
-NumBlocks=50 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h

test-sim-custom-genesis-fast:
@echo "Running custom genesis simulation..."
@echo "By default, ${HOME}/.terra/config/genesis.json will be used."
@go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation -Genesis=${HOME}/.terra/config/genesis.json \
-Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h
-Enabled=true -NumBlocks=50 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h

test-sim-import-export: runsim
@echo "Running application import/export simulation. This may take several minutes..."
Expand Down

0 comments on commit 56eda11

Please sign in to comment.