Skip to content

Commit

Permalink
few updates and temporary stop auto calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
timotejvesel committed Nov 23, 2024
1 parent ed1d2ab commit 42984bd
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 76 deletions.
150 changes: 75 additions & 75 deletions .github/workflows/scheduled-commit.yaml
Original file line number Diff line number Diff line change
@@ -1,87 +1,87 @@
name: "Calculate rewards"
# name: "Calculate rewards"

on:
schedule:
- cron: '30 7 * * 1' # Every Monday at 07:30 UCT
- cron: '30 19 * * 4' # Every Thursday at 19:30 UCT
workflow_dispatch:
inputs:
first_reward_epoch:
description: "Reward epoch (Last epoch if of-four)"
type: number
reward_amount_epoch_wei:
description: "Reward amount (in wei)"
type: number
trigger_generate_report_workflow:
description: "Run github pages deployment workflow"
type: string
required: true
default: 'true'
# on:
# # schedule:
# # - cron: '30 7 * * 1' # Every Monday at 07:30 UCT
# # - cron: '30 19 * * 4' # Every Thursday at 19:30 UCT
# workflow_dispatch:
# inputs:
# first_reward_epoch:
# description: "Reward epoch (Last epoch if of-four)"
# type: number
# reward_amount_epoch_wei:
# description: "Reward amount (in wei)"
# type: number
# trigger_generate_report_workflow:
# description: "Run github pages deployment workflow"
# type: string
# required: true
# default: 'true'


permissions:
contents: write
actions: write
# permissions:
# contents: write
# actions: write

jobs:
process-staking-rewards:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Install jq
run: sudo apt update -y && sudo apt install jq moreutils -y
- name: Install node modules
run: yarn install --frozen-lockfile
- name: Calculate epoch vars
run: |
export REWARD_EPOCH_DEFINED="${{ github.event.inputs.first_reward_epoch }}"
export REWARD_EPOCH_CALCULATED="$(node .github/workflows/get-current-reward-epoch.js)"
export USE_REWARD_EPOCH="${REWARD_EPOCH_DEFINED:-$REWARD_EPOCH_CALCULATED}"
echo "USE_REWARD_EPOCH=$USE_REWARD_EPOCH" >> "$GITHUB_ENV"
# jobs:
# process-staking-rewards:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v3
# with:
# node-version: 20
# - name: Install jq
# run: sudo apt update -y && sudo apt install jq moreutils -y
# - name: Install node modules
# run: yarn install --frozen-lockfile
# - name: Calculate epoch vars
# run: |
# export REWARD_EPOCH_DEFINED="${{ github.event.inputs.first_reward_epoch }}"
# export REWARD_EPOCH_CALCULATED="$(node .github/workflows/get-current-reward-epoch.js)"
# export USE_REWARD_EPOCH="${REWARD_EPOCH_DEFINED:-$REWARD_EPOCH_CALCULATED}"
# echo "USE_REWARD_EPOCH=$USE_REWARD_EPOCH" >> "$GITHUB_ENV"

export USE_FIRST_REWARD_EPOCH="$((${USE_REWARD_EPOCH} - 3))"
echo "USE_FIRST_REWARD_EPOCH=${USE_FIRST_REWARD_EPOCH}" >> "$GITHUB_ENV"
# export USE_FIRST_REWARD_EPOCH="$((${USE_REWARD_EPOCH} - 3))"
# echo "USE_FIRST_REWARD_EPOCH=${USE_FIRST_REWARD_EPOCH}" >> "$GITHUB_ENV"

echo "EPOCH_OF4_if0=$(( $(( $USE_REWARD_EPOCH - 1 )) % 4 ))" >> "$GITHUB_ENV"
# echo "EPOCH_OF4_if0=$(( $(( $USE_REWARD_EPOCH - 1 )) % 4 ))" >> "$GITHUB_ENV"

- name: Set reward amount wei overwrite
if: github.event.inputs.reward_amount_epoch_wei != ''
run: jq --raw-output --monochrome-output --argjson amount "${{ github.event.inputs.reward_amount_epoch_wei }}" '.REWARD_AMOUNT_EPOCH_WEI = $amunt' configs/networks/flare.json | sponge configs/networks/flare.json
# - name: Set reward amount wei overwrite
# if: github.event.inputs.reward_amount_epoch_wei != ''
# run: jq --raw-output --monochrome-output --argjson amount "${{ github.event.inputs.reward_amount_epoch_wei }}" '.REWARD_AMOUNT_EPOCH_WEI = $amunt' configs/networks/flare.json | sponge configs/networks/flare.json

- name: Process staking rewards for ${{ env.USE_REWARD_EPOCH }}
run: |
jq --raw-output --monochrome-output '.NUM_EPOCHS = 1' configs/networks/flare.json | sponge configs/networks/flare.json
jq --raw-output --monochrome-output --argjson epoch "$USE_REWARD_EPOCH" '.REWARD_EPOCH = $epoch' configs/networks/flare.json | sponge configs/networks/flare.json
yarn run process-staking-rewards
# - name: Process staking rewards for ${{ env.USE_REWARD_EPOCH }}
# run: |
# jq --raw-output --monochrome-output '.NUM_EPOCHS = 1' configs/networks/flare.json | sponge configs/networks/flare.json
# jq --raw-output --monochrome-output --argjson epoch "$USE_REWARD_EPOCH" '.REWARD_EPOCH = $epoch' configs/networks/flare.json | sponge configs/networks/flare.json
# yarn run process-staking-rewards

- name: Combine rewards for [epoch ${{ env.USE_FIRST_REWARD_EPOCH }}-${{ env.USE_REWARD_EPOCH }}]
if: env.EPOCH_OF4_if0 == 0
run: |
jq --raw-output --monochrome-output '.NUM_EPOCHS = 4' configs/networks/flare.json | sponge configs/networks/flare.json
jq --raw-output --monochrome-output --argjson epoch "$USE_REWARD_EPOCH" '.REWARD_EPOCH = $epoch' configs/networks/flare.json | sponge configs/networks/flare.json
yarn sum-staking-rewards
# - name: Combine rewards for [epoch ${{ env.USE_FIRST_REWARD_EPOCH }}-${{ env.USE_REWARD_EPOCH }}]
# if: env.EPOCH_OF4_if0 == 0
# run: |
# jq --raw-output --monochrome-output '.NUM_EPOCHS = 4' configs/networks/flare.json | sponge configs/networks/flare.json
# jq --raw-output --monochrome-output --argjson epoch "$USE_REWARD_EPOCH" '.REWARD_EPOCH = $epoch' configs/networks/flare.json | sponge configs/networks/flare.json
# yarn sum-staking-rewards

- name: Commit generated-files
run: |
git config --global user.name 'Reward scripts automation'
git config --global user.email 'flare-foundation-reward-scripts-automation@users.noreply.github.com'
git add generated-files/reward-epoch-${{ env.USE_REWARD_EPOCH }}
if [ "$EPOCH_OF4_if0" -eq 0 ]; then git add generated-files/validator-rewards/epochs-${{ env.USE_FIRST_REWARD_EPOCH }}-${{ env.USE_REWARD_EPOCH }}.json; fi
git commit -m "Processed staking rewards for epoch ${{ env.USE_REWARD_EPOCH }}" && git push || echo "No changes were present, failed to commit, proceeding..."
# - name: Commit generated-files
# run: |
# git config --global user.name 'Reward scripts automation'
# git config --global user.email 'flare-foundation-reward-scripts-automation@users.noreply.github.com'
# git add generated-files/reward-epoch-${{ env.USE_REWARD_EPOCH }}
# if [ "$EPOCH_OF4_if0" -eq 0 ]; then git add generated-files/validator-rewards/epochs-${{ env.USE_FIRST_REWARD_EPOCH }}-${{ env.USE_REWARD_EPOCH }}.json; fi
# git commit -m "Processed staking rewards for epoch ${{ env.USE_REWARD_EPOCH }}" && git push || echo "No changes were present, failed to commit, proceeding..."

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: staking-rewards
path: |
generated-files/reward-epoch-${{ env.USE_REWARD_EPOCH }}
generated-files/validator-rewards/epochs-${{ env.USE_FIRST_REWARD_EPOCH }}-${{ env.USE_REWARD_EPOCH }}.json
# - name: Upload artifacts
# uses: actions/upload-artifact@v3
# with:
# name: staking-rewards
# path: |
# generated-files/reward-epoch-${{ env.USE_REWARD_EPOCH }}
# generated-files/validator-rewards/epochs-${{ env.USE_FIRST_REWARD_EPOCH }}-${{ env.USE_REWARD_EPOCH }}.json

- name: Trigger "generate report" workflow
if: github.event.inputs.trigger_generate_report_workflow == 'true' || github.event.inputs.trigger_generate_report_workflow == ''
env:
GH_TOKEN: ${{ github.token }}
run: gh workflow run "Generate report" -f first_reward_epoch=${{ env.USE_REWARD_EPOCH }}
# - name: Trigger "generate report" workflow
# if: github.event.inputs.trigger_generate_report_workflow == 'true' || github.event.inputs.trigger_generate_report_workflow == ''
# env:
# GH_TOKEN: ${{ github.token }}
# run: gh workflow run "Generate report" -f first_reward_epoch=${{ env.USE_REWARD_EPOCH }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ You can also run it with optional parameters from [file](./src/processProviders.

For each run output of the process is in folder `generated-files/reward-epochs-<REWARD_EPOCH>`.

### Verifying the results
To verify the official results posted in this repository one needs to update its configuration file with values from the `configFileData` object of a `data.json` file for some reward epoch.
To verify the results for the reward epochs from 126 to 243 inclusive one needs to use branch `version-1`.

### Data for distributing rewards
Rewards will be distributed every four reward epochs, which means that every 14 days reward amounts from the past four reward epochs will be summed. This is achieved by running the process
Expand Down
3 changes: 2 additions & 1 deletion ftso-address.csv
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,5 @@ Encode Club,0x1c2bb2ca14914a462ab7268de4a48ef6445116c2,NodeID-9fsCXCFJ7hzgsGK4FV
FlareFi,0x184DbC7F2D96aBDfDe5CDa8c56F3F13DbF138cdF,NodeID-8aGBxZssVWRvEr57YGRsWjZTHbnoWrfcc,235
Bifrost Wallet 2,0x9A46864A3b0a7805B266C445289C3fAD1E48f18e,NodeID-GZEWkCpn852hwKhbGNJgZvbjtvEfU6Ktg,238
Oracle Daemon,0xfe532cB6Fb3C47940aeA7BeAd4d61C5e041D950e,NodeID-GEC63GVfeYLG5UUBPSgiiN4YMvT71jdP,241
Oracle Daemon,0xfe532cB6Fb3C47940aeA7BeAd4d61C5e041D950e,NodeID-2miZhA7JAnyf9s5rYzDeNciwg4448LKsP,241
Oracle Daemon,0xfe532cB6Fb3C47940aeA7BeAd4d61C5e041D950e,NodeID-2miZhA7JAnyf9s5rYzDeNciwg4448LKsP,241
Poseidon FTSO,0xD3b3Bd5207687d43c9cCBBbca830dfe2A13EE5b7,NodeID-CtSfUZd8nvr4RDaQnKRiP9cae15Nrb1bX,244

0 comments on commit 42984bd

Please sign in to comment.