Skip to content

Commit

Permalink
feat: add local dev setup script (gnolang#1237)
Browse files Browse the repository at this point in the history
## Description

This PR introduces a bash script and simple Makefile to control local
development.
It starts a node instance, along with the appropriate backup / restore
processes.

Parent task: gnolang#1131 

Docker equivalent: gnolang#1238

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

---------

Co-authored-by: Guilhem Fanton <8671905+gfanton@users.noreply.github.com>
  • Loading branch information
2 people authored and moul committed Nov 14, 2023
1 parent 9255c3a commit b5fc16a
Show file tree
Hide file tree
Showing 5 changed files with 370 additions and 0 deletions.
44 changes: 44 additions & 0 deletions misc/loop/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# The startup delay (waits until the node is "ready")
DELAY ?= 10 # seconds
# The temporary backup file for transactions
BACKUP_FILE ?= $(abspath ./txs_backup.log)
# The entire txs history across all iterations
HISTORY_OUTPUT := $(abspath ./txs_history.log)

# The gnoland binary
gnoland_bin := go run github.com/gnolang/gno/gno.land/cmd/gnoland
# The tx archive binary
tx_bin := go run github.com/gnolang/tx-archive/cmd

# The relative gno.land directory
gnoland_dir := $(abspath ../../gno.land)

all: loop

gnoland.start:
cd $(gnoland_dir) && $(gnoland_bin) start -skip-failing-genesis-txs -genesis-txs-file $(HISTORY_OUTPUT)
gnoland.clean:
make -C $(gnoland_dir) fclean
.PHONY: gnoland.start gnoland.clean

# Starts the backup service
# and backs up transactions into a file
# that is wiped on every loop
tx.backup:
sleep $(DELAY)
$(tx_bin) backup -legacy -watch -overwrite -output-path "$(BACKUP_FILE)"
.PHONY: tx.backup

# Saves the history from previous iterations into
# a temporary transactions log
save.history:
@test -e $(BACKUP_FILE) || (echo "No existing backup file not found: '$(BACKUP_FILE)'"; exit 1)
cat $(BACKUP_FILE) >> $(HISTORY_OUTPUT)
.PHONY: save.history

loop: gnoland.clean
# backup history, if needed
$(MAKE) save.history || true
# run our dev loop
./run_loop.sh
.PHONY: loop
51 changes: 51 additions & 0 deletions misc/loop/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module loop

go 1.20

require (
github.com/gnolang/gno v0.0.0-20231011111011-b34816b491bb
github.com/gnolang/tx-archive v0.1.0
)

require (
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c // indirect
github.com/btcsuite/btcd/btcutil v1.0.0 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cockroachdb/apd v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgraph-io/badger/v3 v3.2103.4 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/gnolang/goleveldb v0.0.9 // indirect
github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/flatbuffers v1.12.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.12.3 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.8.4 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/peterbourgon/ff/v3 v3.4.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
go.etcd.io/bbolt v1.3.7 // indirect
go.opencensus.io v0.22.5 // indirect
go.uber.org/multierr v1.10.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)

replace github.com/gnolang/gno => ../../
Loading

0 comments on commit b5fc16a

Please sign in to comment.