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

[WIP] Add basic full sync info + Add Snapshot Full sync for 2000k + height #1459

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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
12 changes: 12 additions & 0 deletions .github/workflows/fullsync-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ jobs:
stop: 1850000
- start: 1850000
stop: 1900000
- start: 1900000
stop: 1950000
- start: 1950000
stop: 2000000
- start: 2000000
stop: 2050000
- start: 2050000
stop: 2100000
- start: 2100000
stop: 2150000

runs-on: [self-hosted, linux, x64]
needs: build-binaries
if: contains(github.event.pull_request.labels.*.name, 'ci/sync')
Expand All @@ -106,6 +117,7 @@ jobs:
image : gcr.io/br-blockchains-dev/datadir-${{matrix.datadir.start}}
options: --privileged
env:
START_BLOCK: ${{matrix.datadir.start}}
STOP_BLOCK: ${{matrix.datadir.stop}}
DEFID_BIN: ./defid
DEFI_CLI_BIN: ./defi-cli
Expand Down
126 changes: 126 additions & 0 deletions .github/workflows/fullsync-tip-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Full Sync Tip Tests
on:
pull_request:
branches:
- master
types: [labeled, opened, reopened, synchronize]

jobs:
build-binaries:
if: contains(github.event.pull_request.labels.*.name, 'ci/sync-tip')
runs-on: [self-hosted, linux, x64,server-2]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Build Node
run: ./make.sh build
- name: Upload Binaries
uses: actions/upload-artifact@v3
with:
name: defibins
path: |
src/defid
src/defi-cli
- name: Archive Binaries
uses: actions/upload-artifact@v3
with:
name: defibins
path: |
src/defid
src/defi-cli
- name: Archive Shell Commands
uses: actions/upload-artifact@v3
with:
name: sync
path: |
ci/parallel_sync/sync_then_diff.sh
- name: Archive Sync to Tip Shell Command
uses: actions/upload-artifact@v3
with:
name: sync-to-tip
path: |
ci/parallel_sync/sync_to_tip.sh

sync:
strategy:
matrix:
datadir:
- start: 1900000
stop: 1950000
- start: 1950000
stop: 2000000
- start: 2000000
stop: 2050000
- start: 2050000
stop: 2100000
- start: 2100000
stop: 2150000
- start: 2150000
stop: 2232254

runs-on: [self-hosted, linux, x64]
needs: build-binaries
if: contains(github.event.pull_request.labels.*.name, 'ci/sync-tip')
continue-on-error: true
container:
image : gcr.io/br-blockchains-dev/datadir-${{matrix.datadir.start}}
options: --privileged
env:
START_BLOCK: ${{matrix.datadir.start}}
STOP_BLOCK: ${{matrix.datadir.stop}}
DEFID_BIN: ./defid
DEFI_CLI_BIN: ./defi-cli
timeout-minutes: 4320
steps:
- name: Download Binaries
uses: actions/download-artifact@v3
with:
name: defibins
- name: Download Shell Commands
uses: actions/download-artifact@v3
with:
name: sync
- name: Set Permissions
run: |
chmod 777 defid
chmod 777 defi-cli
chmod 777 sync_then_diff.sh
- name: Sync and Diff
run: ./sync_then_diff.sh
- name: Show Debug Log
run: cat $DATADIR/debug.log
if: ${{ failure() || success() }}
sync-to-tip:
runs-on: [self-hosted, linux, x64]
needs: build-binaries
if: contains(github.event.pull_request.labels.*.name, 'ci/sync-tip')
continue-on-error: true
container:
image : gcr.io/br-blockchains-dev/datadir-${{matrix.datadir.start}}
options: --privileged
env:
START_BLOCK: 2150000
STOP_BLOCK: 2232254
DEFID_BIN: ./defid
DEFI_CLI_BIN: ./defi-cli
timeout-minutes: 4320
steps:
- name: Download Binaries
uses: actions/download-artifact@v3
with:
name: defibins
- name: Download Shell Commands
uses: actions/download-artifact@v3
with:
name: sync-to-tip
- name: Set Permissions
run: |
chmod 777 defid
chmod 777 defi-cli
chmod 777 sync_to_tip.sh
- name: Sync to Tip
run: ./sync_to_tip.sh
- name: Show Debug Log
run: cat $DATADIR/debug.log
if: ${{ failure() || success() }}
26 changes: 21 additions & 5 deletions ci/parallel_sync/sync_then_diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ setup_vars() {
# Files and directories
DATADIR=${DATADIR:-".defi"}
DEBUG_FILE="$DATADIR/debug.log"
CONF_FILE="$DATADIR/defi.conf"
TMP_LOG=debug-tmp-$STOP_BLOCK.log
BASE_PATH=https://storage.googleapis.com
BUCKET=team-drop
Expand All @@ -30,11 +31,26 @@ setup_vars() {

BLOCK=0
ATTEMPTS=0
START_BLOCK=${START_BLOCK:-0}
STOP_BLOCK=${STOP_BLOCK:-0}
MAX_ATTEMPTS=10
MAX_NODE_RESTARTS=5
NODE_RESTARTS=0
}

echo "======== Sync Test Info ==========
- Block range: ${START_BLOCK} - ${STOP_BLOCK}
- Base snapshot: https://gcr.io/br-blockchains-dev/datadir-${START_BLOCK}
- Reference logs:
- debug.log: $REF_LOG_PATH
- Commands used:
- $ACCOUNT_BALANCES_CMD
- $LIST_ANCHORS_CMD
- defid cmd: ${DEFI_CLI_CMD}
- defi.conf:
$(cat "$CONF_FILE")
----------------------------------
"
Comment on lines +41 to +53
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar adaptations to the other code block

# Start defid
start_node () {
echo "Syncing to block height: $STOP_BLOCK"
Expand Down Expand Up @@ -74,17 +90,17 @@ main() {
done

# Create temporary log file
$GREP "AccountChange:" $DEBUG_FILE | cut -d" " -f2- > $TMP_LOG
$ACCOUNT_BALANCES_CMD >> $TMP_LOG
$LIST_ANCHORS_CMD >> $TMP_LOG
$GREP "AccountChange:" "$DEBUG_FILE" | cut -d" " -f2- > "$TMP_LOG"
$ACCOUNT_BALANCES_CMD >> "$TMP_LOG"
$LIST_ANCHORS_CMD >> "$TMP_LOG"

$DEFI_CLI_CMD stop
# Download reference log file
echo "Downloading reference log file : $REF_LOG_PATH"
$FETCH $REF_LOG_PATH
$FETCH "$REF_LOG_PATH"

echo "diff $TMP_LOG $REF_LOG"
diff $TMP_LOG $REF_LOG
diff "$TMP_LOG" "$REF_LOG"
}

main "$@"
Expand Down
110 changes: 110 additions & 0 deletions ci/parallel_sync/sync_to_tip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/bash

export LC_ALL=C
set -Eeuo pipefail

setup_vars() {
# Binaries
DEFID_BIN=${DEFID_BIN:-"./defid"}
DEFI_CLI_BIN=${DEFI_CLI_BIN:-"./defi-cli"}

# Files and directories
DATADIR=${DATADIR:-".defi"}
DEBUG_FILE="$DATADIR/debug.log"
CONF_FILE="$DATADIR/defi.conf"
TMP_LOG=debug-tmp-$STOP_BLOCK.log
BASE_PATH=https://storage.googleapis.com
BUCKET=team-drop
REF_LOG_DIR=master-logs-full
REF_LOG=debug-$STOP_BLOCK.log
REF_LOG_PATH=$BASE_PATH/$BUCKET/$REF_LOG_DIR/$REF_LOG

# Commands
DEFID_CMD="$DEFID_BIN -datadir=$DATADIR -daemon -debug=accountchange"
DEFI_CLI_CMD="$DEFI_CLI_BIN -datadir=$DATADIR"
ACCOUNT_BALANCES_CMD="$DEFI_CLI_CMD logaccountbalances"
LIST_ANCHORS_CMD="$DEFI_CLI_CMD spv_listanchors"
GREP="grep"

BLOCK=0
ATTEMPTS=0
START_BLOCK=${START_BLOCK:-0}
STOP_BLOCK=${STOP_BLOCK:-0}
MAX_ATTEMPTS=10
MAX_NODE_RESTARTS=5
NODE_RESTARTS=0
}

echo "======== Sync Test Info ==========
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this into a function and call it from main, so its cleaner.

- Block range: ${START_BLOCK} - ${STOP_BLOCK}
- Base snapshot: https://gcr.io/br-blockchains-dev/datadir-${START_BLOCK}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get a direct link for this? I assume this leads to a dir.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its the link to snapshot(tar) file

- Reference logs:
- debug.log: $REF_LOG_PATH
- Commands used:
- $ACCOUNT_BALANCES_CMD
- $LIST_ANCHORS_CMD
- defid cmd: ${DEFI_CLI_CMD}
- defi.conf:
$(cat "$CONF_FILE")
----------------------------------
"
# Start defid
start_node () {
echo "Syncing to block height: $STOP_BLOCK"
$DEFID_CMD
sleep 30
update_tip_node
}

update_tip () {
CUR_TIP=$($DEFI_CLI_CMD "$DEFI_CLI_CMD" getblockchaininfo | jq .headers || echo "$STOP_BLOCK")
if [ "$CUR_TIP" -gt "$STOP_BLOCK" ]; then
echo "New Tip: $STOP_BLOCK"
STOP_BLOCK=${CUR_TIP:-$STOP_BLOCK}
fi
}

main() {
setup_vars
start_node

$DEFI_CLI_CMD clearbanned || true

# Sync to target block height
while [ "$BLOCK" -lt "$STOP_BLOCK" ]; do
if [ "$ATTEMPTS" -gt "$MAX_ATTEMPTS" ]; then
if [ "$NODE_RESTARTS" -lt "$MAX_NODE_RESTARTS" ]; then
echo "Node Stuck After $ATTEMPTS attempts, restarting node"
$DEFI_CLI_CMD stop
sleep 20
start_node
NODE_RESTARTS=$((NODE_RESTARTS + 1))
ATTEMPTS=0
else
exit 1
fi
fi
CUR_BLOCK=$($DEFI_CLI_CMD getblockcount || echo $BLOCK)
if [ "$CUR_BLOCK" -eq "$BLOCK" ]; then
ATTEMPTS=$((ATTEMPTS + 1))
else
ATTEMPTS=0
fi
BLOCK=${CUR_BLOCK:-$BLOCK}
echo "Current block: $BLOCK / $STOP_BLOCK"
sleep 20
update_tip
done

# Create temporary log file
$GREP "AccountChange:" "$DEBUG_FILE" | cut -d" " -f2- > "$TMP_LOG"
$ACCOUNT_BALANCES_CMD >> "$TMP_LOG"
$LIST_ANCHORS_CMD >> "$TMP_LOG"
$DEFI_CLI_CMD stop
cat "$TMP_LOG"
}

main "$@"