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

chore(ci): daily ci backup of test2 and test3 networks #7

Merged
merged 41 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
232895c
chore(ci): auto backup
albttx Nov 21, 2023
40cd237
chore: fix interval test2
albttx Nov 21, 2023
9ea7c5d
fix: fetch-all
albttx Nov 21, 2023
272ef00
chore(ci): update ci jobs
albttx Nov 21, 2023
a4ee5e1
chore: fix rule 0 paddings
albttx Nov 22, 2023
0a0a3de
chore: git mv txexport -> archive
albttx Nov 24, 2023
60a433e
chore: remove legacy flag
albttx Nov 24, 2023
32bfab0
chore: add test2 non-legacy
albttx Nov 24, 2023
c5dd579
chore: add test3 non-legacy
albttx Nov 24, 2023
ac2155b
chore: setup github-ci
albttx Nov 24, 2023
521217d
chore: update test2.gno.land backup
albttx Nov 24, 2023
35c85cb
chore: update test3.gno.land backup
albttx Nov 24, 2023
10fdd9e
chore: update test2.gno.land backup
albttx Nov 25, 2023
36bc60d
chore: update test3.gno.land backup
albttx Nov 25, 2023
a8de7d6
chore: update test2.gno.land backup
albttx Nov 26, 2023
7a649c4
chore: update test3.gno.land backup
albttx Nov 26, 2023
1cc25eb
chore: update test2.gno.land backup
albttx Nov 27, 2023
5ca76ea
chore: update test3.gno.land backup
albttx Nov 27, 2023
29abe44
chore: update test2.gno.land backup
albttx Nov 28, 2023
1cf87aa
chore: update test3.gno.land backup
albttx Nov 28, 2023
38bdcd9
chore: update test2.gno.land backup
albttx Nov 29, 2023
995ae5a
chore: update test3.gno.land backup
albttx Nov 29, 2023
e8e2e60
chore: update test2.gno.land backup
albttx Nov 30, 2023
e2c81ee
chore: update test3.gno.land backup
albttx Nov 30, 2023
5f33030
chore: update test2.gno.land backup
albttx Dec 1, 2023
dccc79a
chore: update test3.gno.land backup
albttx Dec 1, 2023
9f84233
chore: update test2.gno.land backup
albttx Dec 2, 2023
3735af7
chore: update test3.gno.land backup
albttx Dec 2, 2023
32a99e0
chore: update test2.gno.land backup
albttx Dec 3, 2023
029f209
chore: update test3.gno.land backup
albttx Dec 3, 2023
1faad5b
chore: update test2.gno.land backup
albttx Dec 4, 2023
4a1ed97
chore: update test3.gno.land backup
albttx Dec 4, 2023
ee81427
chore: update test2.gno.land backup
albttx Dec 5, 2023
14abd35
chore: update test3.gno.land backup
albttx Dec 5, 2023
3fdebf6
chore: update test2.gno.land backup
albttx Dec 6, 2023
de58a6b
chore: update test3.gno.land backup
albttx Dec 6, 2023
d552716
chore: update test2.gno.land backup
albttx Dec 7, 2023
b24f899
chore: update test3.gno.land backup
albttx Dec 7, 2023
e7ead91
chore: fix stats scripts
albttx Dec 7, 2023
801c863
chore: update test2.gno.land backup
albttx Dec 7, 2023
ab618c5
chore: update test3.gno.land backup
albttx Dec 7, 2023
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
42 changes: 42 additions & 0 deletions .github/workflows/txs-exporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Backup testnets

on:
# allow to run workflow manually
workflow_dispatch: {}

# Triggers the workflow every day at 1am
schedule:
- cron: "0 1 * * *"

jobs:
backup:
name: "backup ${{ matrix.testnet }}"
runs-on: ubuntu-latest
timeout-minutes: 30

permissions:
contents: write

strategy:
fail-fast: false
max-parallel: 1
matrix:
testnet:
- test2.gno.land
- test3.gno.land

steps:
- uses: actions/checkout@v4

- name: Run backup script
run: make -C ${{ matrix.testnet }} fetch

- name: Run stats script
run: make -C ${{ matrix.testnet }} stats

- name: Run git pull
run: git pull

- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: update ${{ matrix.testnet }} backup"
2 changes: 1 addition & 1 deletion deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

package deps

import _ "github.com/gnolang/gno/gno.land/cmd/gnotxsync"
import _ "github.com/gnolang/tx-archive/cmd"
26 changes: 14 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
module github.com/gnolang/txports

go 1.21.0
go 1.20

require github.com/gnolang/gno v0.0.0-20231002124245-28455d8ffc5b
require (
github.com/gnolang/gno v0.0.0-20231112174927-b1a53c018ea4 // indirect
github.com/gnolang/tx-archive v0.1.1
)

require (
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c // indirect
Expand All @@ -22,7 +25,7 @@ require (
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/gorilla/websocket v1.5.1 // 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
Expand All @@ -32,15 +35,14 @@ require (
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.etcd.io/bbolt v1.3.8 // indirect
go.opencensus.io v0.22.5 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/term v0.12.0 // indirect
golang.org/x/tools v0.6.0 // 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.14.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)
63 changes: 24 additions & 39 deletions go.sum

Large diffs are not rendered by default.

30 changes: 21 additions & 9 deletions rules.mk
Original file line number Diff line number Diff line change
@@ -1,35 +1,47 @@

fetch:
go run github.com/gnolang/gno/gno.land/cmd/gnotxsync export --remote $(REMOTE)
wc -l txexport.log
tail -n 1 txexport.log
rm -f txexport-*.log
split --lines=1000 --additional-suffix=.log txexport.log txexport-
@echo "Backup from: $(FROM_BLOCK) to $(TO_BLOCK)"
go run github.com/gnolang/tx-archive/cmd backup \
--remote $(REMOTE) \
--from-block $(FROM_BLOCK) \
--to-block $(TO_BLOCK) \
--output-path backup_$(shell printf '%07d' $(FROM_BLOCK))-$(shell printf '%07d' $(TO_BLOCK)).jsonl

# Update metadata
@cat metadata.json | jq -a '.latest_block_height = $(TO_BLOCK)' > /tmp/aa.json
@mv /tmp/aa.json metadata.json


fetch-all:
@for i in `seq $(FROM_BLOCK) $(MAX_INTERVAL) $(LATEST_BLOCK_HEIGHT)`; do \
make -C . fetch FROM_BLOCK="$$i"; \
done

stats:
echo "# $(REMOTE)" > README.md
echo >> README.md

echo "## TXs" >> README.md
echo '```' >> README.md
cat txexport-*.log | wc -l >> README.md
cat backup_*.jsonl | wc -l >> README.md
echo '```' >> README.md
echo >> README.md

echo "## addpkgs" >> README.md
echo '```' >> README.md
cat txexport-*.log | jq '.msg[].package.Path' | sort | uniq -c | sort -n >> README.md
cat backup_*.jsonl | jq '.msg[].package.Path' | sort | uniq -c | sort -n >> README.md
echo '```' >> README.md
echo >> README.md

echo "## top realm calls" >> README.md
echo '```' >> README.md
cat txexport-*.log | jq '.msg[].pkg_path' | sort | uniq -c | sort -n >> README.md
cat backup_*.jsonl | jq '.msg[].pkg_path' | sort | uniq -c | sort -n >> README.md
echo '```' >> README.md
echo >> README.md

echo "## top faucet requesters" >> README.md
echo '```' >> README.md
cat txexport*.log | jq -r '.msg[] | select(.["@type"]=="/bank.MsgSend") | select(.["from_address"]=="g127jydsh6cms3lrtdenydxsckh23a8d6emqcvfa") | .to_address + " " + .amount' | sed 's/ugnot$$//' | awk 'NR == 1 {next} {a[$$1] += $$2} {b[$$1] += 1} END {for (i in a) {if (a[i] >= 500000000){printf "%-15s\t%s\t%s\n", i, b[i], a[i]}}}' | sort -rnk2 >> README.md
cat backup_*.jsonl | jq -r '.msg[] | select(.["@type"]=="/bank.MsgSend") | select(.["from_address"]=="g127jydsh6cms3lrtdenydxsckh23a8d6emqcvfa") | .to_address + " " + .amount' | sed 's/ugnot$$//' | awk 'NR == 1 {next} {a[$$1] += $$2} {b[$$1] += 1} END {for (i in a) {if (a[i] >= 500000000){printf "%-15s\t%s\t%s\n", i, b[i], a[i]}}}' | sort -rnk2 >> README.md
echo '```' >> README.md
echo >> README.md

Expand Down
9 changes: 9 additions & 0 deletions test1.gno.land/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@ REMOTE = test1.gno.land:36657
SHORTNAME = test1
LOOP_DURATION = 50000


FROM_BLOCK = $(shell cat metadata.json | jq -r '.latest_block_height')
LATEST_BLOCK_HEIGHT = $(shell curl -s $(REMOTE)/status | jq -r '.result.sync_info.latest_block_height')
TO_BLOCK = $(LATEST_BLOCK_HEIGHT)

ifeq ($(shell echo "$(TO_BLOCK) - $(FROM_BLOCK) > $(MAX_INTERVAL)" | bc ), 1)
TO_BLOCK = $(shell echo "$(FROM_BLOCK) + $(MAX_INTERVAL)" | bc)
endif

-include ../rules.mk
1 change: 1 addition & 0 deletions test1.gno.land/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "latest_block_height": 1 }
10 changes: 10 additions & 0 deletions test2.gno.land/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,14 @@ REMOTE = test2.gno.land:36657
SHORTNAME = test2
LOOP_DURATION = 50000

MAX_INTERVAL = 10000

FROM_BLOCK = $(shell cat metadata.json | jq -r '.latest_block_height')
LATEST_BLOCK_HEIGHT = $(shell curl -s $(REMOTE)/status | jq -r '.result.sync_info.latest_block_height')
TO_BLOCK = $(LATEST_BLOCK_HEIGHT)

ifeq ($(shell echo "$(TO_BLOCK) - $(FROM_BLOCK) > $(MAX_INTERVAL)" | bc ), 1)
TO_BLOCK = $(shell echo "$(FROM_BLOCK) + $(MAX_INTERVAL)" | bc)
endif

-include ../rules.mk
2 changes: 1 addition & 1 deletion test2.gno.land/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## TXs
```
36890
36968
```

## addpkgs
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading