Skip to content

Commit

Permalink
Sprint 1.11 (#1279)
Browse files Browse the repository at this point in the history
* Debug (#1232)

* Revert "Debug (#1232)" (#1240)

This reverts commit 49a5c9e.

* Fix phase locking (#1230) (#1241)

* add logs for 2 phase lock

* add update log

* add root in log

* add update log

* use update lock

* add log in update repo

* use save

* use exec

* log rows affected

* use no key update

* use repo update

* cleanup

* add defer

* add defer

* increase timeout by 5 mins

* Case 3 and case 4 (#1198)

* Send WM commit status to conductor

* Rename file

* Modify log type

* Add state for stopping blobber from committing WM

* Send file meta root to rpc server

* Export function to use it in conductor client

* Modify field type

* Add code to get file meta root

* Modify file meta root retrieval

* Add field

* Apply rename for conductor test based on conductor state

* Add comment

* Log error

---------

Co-authored-by: Ebrahim Gomaa <[email protected]>

* Feature/ Challenge based on rounds (#1226)

* Fix

* Updated gosdk

* Fix

* Fix

* Fix

* Logging

* Debug

* Fix

* Fix

* Debug

* Debug

* Debug

* Fix unit tests

* Logigng

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Fix

* Fix

* Updated gosdk

* Fix

* Fix

* log config too

* Fix phase locking (#1230)

* add logs for 2 phase lock

* add update log

* add root in log

* add update log

* use update lock

* add log in update repo

* use save

* use exec

* log rows affected

* use no key update

* use repo update

* cleanup

* add defer

* add defer

* Fix

* Added logging

* Debug

* Debug

* Added reference to logs

* Fix

* Fix

* Updated gosdk

* Use slice instead of ll

* Validator last 5 transactions

* Fix

* Fix

* Updated gosdk

* Resolved comments

* Updated gosdk

---------

Co-authored-by: Hitenjain14 <[email protected]>

* Increase limit on number of open challenges per fetching (#1249)

* Fix

* Updated gosdk

* Fix

* Fix

* Fix

* Logging

* Debug

* Fix

* Fix

* Debug

* Debug

* Debug

* Fix unit tests

* Logigng

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Fix

* Fix

* Updated gosdk

* Fix

* Fix

* log config too

* Fix phase locking (#1230)

* add logs for 2 phase lock

* add update log

* add root in log

* add update log

* use update lock

* add log in update repo

* use save

* use exec

* log rows affected

* use no key update

* use repo update

* cleanup

* add defer

* add defer

* Fix

* Added logging

* Debug

* Debug

* Added reference to logs

* Fix

* Fix

* Updated gosdk

* Use slice instead of ll

* Validator last 5 transactions

* Fix

* Fix

* Updated gosdk

* Resolved comments

* Updated gosdk

* Fix

* Increase time limit

* Increase time limit

* Fix

* Fix

* Fix

* Fix

* Debug

* Debug

* Debug

* Fix

* Fix

* Fix

* Cleanup logging

---------

Co-authored-by: Hitenjain14 <[email protected]>

* Refactor commit (#1239)

* add szwg to commit

* lock for query

* aggregate queries

* check len

* rmv debug

* only update file ref

* move update fields to ref

* fix numBlock download stats

* rmv log

* rmv commented collector code

* Error on renaming dir (#1250)

* throw err when renaming dir

* fix unit test

* Fix replace blobber (#1251)

* Async processing (#1225)

* fix pre download

* rmv hash

* add async processing

* use range

* fix unit test

* fix delete change

* add logs

* fix unit test

* fix delete cmd

* save file ref

* add conn timing logs

* set default to 32MB

* fix timing log

* add inner lock

* fix test

* add ctx to cancel go routine

* parallel write to file

* fix connection

* revert storage changes

* empty commit

* Fix phase locking (#1230)

* add logs for 2 phase lock

* add update log

* add root in log

* add update log

* use update lock

* add log in update repo

* use save

* use exec

* log rows affected

* use no key update

* use repo update

* cleanup

* add defer

* add defer

* rmv allocObj from connObj

* Download block limit (#1254)

* add limit as 500 to numBlocks

* add daily and req limit

* fix test

* fix test

* Fix download stats (#1256)

* fix download stats

* fix typo

* Fix empty alloc cleanup (#1252)

* Fix replace blobber

* Fix empty alloc cleanup

* Debug Rounds fetch (#1255)

* Fix

* Updated gosdk

* Fix

* Fix

* Fix

* Logging

* Debug

* Fix

* Fix

* Debug

* Debug

* Debug

* Fix unit tests

* Logigng

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Updated gosdk

* Fix

* Fix

* Updated gosdk

* Fix

* Fix

* log config too

* Fix phase locking (#1230)

* add logs for 2 phase lock

* add update log

* add root in log

* add update log

* use update lock

* add log in update repo

* use save

* use exec

* log rows affected

* use no key update

* use repo update

* cleanup

* add defer

* add defer

* Fix

* Added logging

* Debug

* Debug

* Added reference to logs

* Fix

* Fix

* Updated gosdk

* Use slice instead of ll

* Validator last 5 transactions

* Fix

* Fix

* Updated gosdk

* Resolved comments

* Updated gosdk

* Fix

* Increase time limit

* Increase time limit

* Fix

* Fix

* Fix

* Fix

* Debug

* Debug

* Debug

* Fix

* Fix

* Fix

* Cleanup logging

* Fix

* Debug

* Fix

---------

Co-authored-by: Hitenjain14 <[email protected]>

* remove prefix (#1257)

* remove .gpg file if already exist

* introduce flock to apt commands

* check on docker context existance and install git

* change buildx to action

* refine buildx build name based on runner name

* create docker context based on runner name

* increase blobber and validator job timeout

* Refine docker buildx creation and usage

* Create Unique buildx per job per runner

* remove qemu and upgrade go action version to v4

* changed runners labels build-&-publish-docker-image.yml

* added server cleanup along with blobber build

* ADD disk cleanup for conductor test

* fix cleanup script

* fix cleanup script

* added sudo to perform cleanup

* bypassing cleanup failure

* bypassing cleanup failure for validators

* Fix Save change (#1263)

* add and update change

* fix empty allocation id in change

* add rename dir

* Fix move change when srcPath is same as destPath (#1270)

* fix move change when dest is same as src

* add fileID for new ref

* fix unit test

* Fix challenge timing issue (#1277)

* Fix challenge timing issue

* Fix challenge timing issue

* Fix challenge timing issue

* bypass cleanup if it is already running (#1280)

* Revert "Fix challenge timing issue (#1277)" (#1283)

* Limit Max File Size on blobber (#1274)

* Added update in config

* 5TB config

* Reverted max_file_size config on blobber and fetching from 0chain

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix unit tests

---------

Co-authored-by: dabasov <[email protected]>

* add l2 caching for alloc (#1258)

* add l2 caching for alloc

* rmv return from commit repo

* use update

* fix update

* add log

* rmv update object

* add log for allocation

* move lock to middleware

* fix save alloc update

* empty commit

* fix blobber size update

* fix unit test

* cleanup

* rmv commit in initMap

* fix unit test

* fix renamefile mock db

* add commit method to enhancedDB

---------

Co-authored-by: Yury <[email protected]>

* add list query param (#1273)

* Optimize GetRefs, correct and add indexes on ref table (#1284)

* Correct index on ref table, add path index for get refs optimization

* Fix gorm tags on ref table

* Fix typo

* fix goose migration tags

* add pg_trgm extension

* sharder keep list (#1266)

* changed get round

* updated version

* Fix/finalize (#1285)

* Debug finalize

* Debug finalize

* Debug finalize

* Debug finalize

* Debug finalize

* Fix finalize

* Debug

* Fix

* FIX

* Fixed

* Fixed

* fix list file (#1288)

* Cleanup worker for challenge tables (#1278)

* add cleanup worker for challenge tables

* move cleanupGap to config

---------

Co-authored-by: Yury <[email protected]>

* add err check and increase wait time (#1289)

* Client stats and blacklist (#1286)

* add client stats and blacklist

* add client stats check

* fix goose migration

* fix migration

* fix typo

---------

Co-authored-by: Yury <[email protected]>

* Fix nested rename dir (#1295)

* add log for rootRef

* add objTreePath

* fix rename nested dir

* use save (#1297)

* fix retry redeem wm check (#1299)

* Use rename in place of copy buffer (#1298)

* use rename than copy buffer

* fix storage tests

* fix update latest wm (#1301)

* Fix blobber stats (#1305)

* fix blobber stats

* add stats worker

* rmv listAlloc

* build stats on start

* Feat/remove native sc calls (#1306)

* removed native MakeSCRestAPICall

* removed native MakeSCRestAPICall

---------

Co-authored-by: Jayash Satolia <[email protected]>

* WM cleanup (#1296)

* add cleanup worker for wm

* add hdd tablespace

* add log for hdd path

* update default hdd path

* update owner

* add init db script

* we are already creating with tablespace in initdb.sh

* update initdb script.sh

* update sql for write_markers_archive table

---------

Co-authored-by: Manohar Reddy <[email protected]>
Co-authored-by: Yury <[email protected]>

* Fix/max file size updateWorker and added config for storagesc update interval (#1308)

* Added worker for max file size

* Added config for update worker

* Debug

* Added logs for update worker

* Added fix for worker timings =

* Debug

* Debug

* Debug

* Debug

* Debug

* Removed logging

* Removed logging

* Refactor =

* Refactor

* fix tablespace permission issue in conductor test b0docker-compose.yml

* Fix/cond tablespace (#1309)

* updated docker-compose wrt conductor test tablspace

* updated docker-compose wrt conductor test tablspace

* updated docker-compose wrt conductor test tablspace

* updated blobber env

* update gosdk version to latest of sprint-1.11 (#1310)

* fix blobber stats (#1314)

* race condition fix (#1316)

* Node recovery conductor tests (#1259)

* notify on validator tickert generatd

* fix race condition

* Added changes for fail upload commit (#1318)

* Feat/download verify ct (#1317)

* notify on validator tickert generatd

* fix race condition

* miss up download for CT

* debug logs

* Improve download performance (#1315)

* improve download file

* write data

* rmv content length

* fix unit test

* add new db snapshot migration (#1312)

Co-authored-by: Yury <[email protected]>

* fix commit error (#1320)

* update gosdk (#1319)

Co-authored-by: Yaroslav Svitlytskyi <[email protected]>

* fix where statement (#1321)

* Fix/loop break (#1322)

* updated gosdk

* add mutex

* updated gosdk

* merged changes

* merged changes

---------

Co-authored-by: Hitenjain14 <[email protected]>

* Fix blobber stats panic (#1324)

* Fix blobber stats panic

* Fix

* Fix

* fix break in switch (#1326)

* change hasher to blake3 (#1325)

* change hasher to blake3

* add blake hash

* fix lint

* fix lint for hash write

* update gosdk

* Fix challenge worker (#1327)

* revert changes

* fix challenge worker

* fix lint

* add goto for accept case

---------

Co-authored-by: Yury <[email protected]>

* Config watcher (#1329)

* add watch config

* add on config change

* Remove min lock demand from blobber (#1332)

* fix alloc lock (#1334)

* Feature: implement fork per run strategy (#1335)

* feature: added fork creation

* feature: improved Tenderly fork creation flow

* Merge pull request #1336

* rmv wm lock table

* fix unit tests

* rmv write_locks table

* rmv gorm tag

* empty commit

* Fix mem usage (#1337)

* updated gosdk to blobber

* change hasher to sha2 256

* fix unit test

* changed runner for lint tests.yml

---------

Co-authored-by: shahnawaz-creator <[email protected]>
Co-authored-by: shahnawaz-creator <[email protected]>

* fix rb for failed marker (#1342)

* Fix lwm (#1338)

* add wm log

* fix log

* fix update allocation

* fix log

* lru of value

* fix alloc update

* Fix auth ticket (#1341)

* fix read auth ticket

* fix unit test

* convert to base64

* Fix expiration column name (#1343)

* Fix expiration column name

* Fix size param

* merged changes

* Revert "merged changes"

This reverts commit 39f717a.

* feature: added custom block number during Tenderly fork creation (#1345)

* fix update alloc (#1347)

* extended field for mimetype

* add aws secrets for blobbers (#1349)

* add aws secrets for blobbers

* add validator secrets

* typo

* update logs

---------

Co-authored-by: sanchit <sanchit4242.com>

* Fix root hash (#1346)

* add root logs

* check alloc root

* fix lint

* rmv wm cleanup

* fix lint

* fix encrypted key point (#1350)

* fix encrypted key point

* check root ref precommit

* update min-submit to 20% (#1348)

* update gosdk to v1.11.0 (#1351)

* fix wm retries (#1352)

---------

Co-authored-by: Jayash Satolia <[email protected]>
Co-authored-by: Hitenjain14 <[email protected]>
Co-authored-by: Kishan Dhakan <[email protected]>
Co-authored-by: Kishan Dhakan <[email protected]>
Co-authored-by: Laxmi Prasad Oli <[email protected]>
Co-authored-by: Ebrahim Gomaa <[email protected]>
Co-authored-by: Amr Amin <[email protected]>
Co-authored-by: shahnawaz-creator <[email protected]>
Co-authored-by: shahnawaz-creator <[email protected]>
Co-authored-by: tapishsinha-rs <[email protected]>
Co-authored-by: Dinmukhammed Kambarov <[email protected]>
Co-authored-by: Manohar Reddy <[email protected]>
Co-authored-by: Yaroslav Svitlytskyi <[email protected]>
Co-authored-by: Hitenjain14 <[email protected]>
Co-authored-by: Sanchit Sharma <[email protected]>
  • Loading branch information
16 people authored Dec 19, 2023
1 parent d0bc790 commit fdde95b
Show file tree
Hide file tree
Showing 118 changed files with 3,090 additions and 1,409 deletions.
103 changes: 97 additions & 6 deletions .github/workflows/build-&-publish-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
steps:
- name: Cleanup before restarting conductor tests.
run: |
echo 'y' | docker system prune -a
echo 'y' | docker system prune -a || true
cd /tmp
sudo rm -rf ./*
Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:
steps:
- name: Cleanup before restarting conductor tests.
run: |
echo 'y' | docker system prune -a
echo 'y' | docker system prune -a || true
cd /tmp
sudo rm -rf ./*
Expand Down Expand Up @@ -204,6 +204,90 @@ jobs:
echo "NETWORK_URL=$(echo dev-${RUNNER_NAME:(-1)}.devnet-0chain.net)" >> $GITHUB_ENV
echo "RUNNER_NUMBER=${RUNNER_NAME:(-1)}" >> $GITHUB_ENV
- name: 'Setup jq'
uses: dcarbone/[email protected]
with:
version: '1.7'
force: 'false'

- name: "Create Tenderly fork"
run: |
echo "TENDERLY_CREATION_INFO=$(curl -X POST \
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
-H "Content-Type: application/json" \
-d '{"alias":"mainnet-dev-${{ env.RUNNER_NUMBER }}-${{ github.run_id }}${{ github.run_attempt }}", "description":"", "block_number": 18539779, "network_id":"1"}' \
https://api.tenderly.co/api/v1/account/zus_network/project/project/fork)" >> $GITHUB_ENV
- name: "Parse Tenderly fork creation transaction result"
run: |
echo "TENDERLY_FORK_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.simulation_fork.id')" >> $GITHUB_ENV
echo "TENDERLY_ROOT_TRANSACTION_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.root_transaction.id')" >> $GITHUB_ENV
- name: "Retrieve Tenderly fork block number"
run: |
echo "TENDERLY_FORK_BLOCK_NUMBER=$(curl -X GET \
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
-H "Content-Type: application/json" \
https://api.tenderly.co/api/v1/network/1/block-number | jq -r '.block_number')" >> $GITHUB_ENV
echo "TENDERLY_FORK_BLOCK_NUMBER=$((${{ env.TENDERLY_FORK_BLOCK_NUMBER }} + 1))" >> GITHUB_ENV
- name: "Transfer Bridge ownership in Tenderly fork"
run: |
echo "TENDERLY_ROOT_TRANSACTION_ID=$(curl -X POST \
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
-H "Content-Type: application/json" \
-d '{
"network_id": "1",
"block_number": ${{ env.TENDERLY_FORK_BLOCK_NUMBER }},
"transaction_index": null,
"from": "0xed8f3170db6d1a71c8fa6d8d73cc2c51db95d5a4",
"input": "0xf2fde38b0000000000000000000000008e25cfd9bd6c0ca67a5522cd920b3c66d39d6e97",
"to": "0x7700d773022b19622095118fadf46f7b9448be9b",
"gas": 8000000,
"gas_price": "0",
"value": "0",
"access_list": [],
"generate_access_list": true,
"save": true,
"source": "dashboard",
"block_header": null,
"root": "${{ env.TENDERLY_ROOT_TRANSACTION_ID }}",
"skip_fork_head_update": false,
"alias": "",
"description": "Transfer ownership to 0x8E25cfd9bd6c0ca67a5522cd920b3c66D39d6E97"
}' \
https://api.tenderly.co/api/v1/account/zus_network/project/project/fork/${{ env.TENDERLY_FORK_ID }}/simulate | jq -r '.simulation.id')" >> $GITHUB_ENV
echo "TENDERLY_FORK_BLOCK_NUMBER=$((${{ env.TENDERLY_FORK_BLOCK_NUMBER }} + 1))" >> GITHUB_ENV
- name: "Transfer Authorizers ownership in Tenderly fork"
run: |
curl -X POST \
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
-H "Content-Type: application/json" \
-d '{
"network_id": "1",
"block_number": ${{ env.TENDERLY_FORK_BLOCK_NUMBER }},
"transaction_index": null,
"from": "0xed8f3170db6d1a71c8fa6d8d73cc2c51db95d5a4",
"input": "0xf2fde38b0000000000000000000000008e25cfd9bd6c0ca67a5522cd920b3c66d39d6e97",
"to": "0x481dab4407b9880de0a68dc62e6af611c4949e42",
"gas": 8000000,
"gas_price": "0",
"value": "0",
"access_list": [],
"generate_access_list": true,
"save": true,
"source": "dashboard",
"block_header": null,
"root": "${{ env.TENDERLY_ROOT_TRANSACTION_ID }}",
"skip_fork_head_update": false,
"alias": "",
"description": "Transfer ownership to 0x8E25cfd9bd6c0ca67a5522cd920b3c66D39d6E97"
}' \
https://api.tenderly.co/api/v1/account/zus_network/project/project/fork/${{ env.TENDERLY_FORK_ID }}/simulate
- name: "Deploy 0Chain"
uses: 0chain/actions/deploy-0chain@master
with:
Expand All @@ -213,13 +297,12 @@ jobs:
blobber_image: ${{ env.TAG }}-${{ env.SHORT_SHA }}
validator_image: ${{ env.TAG }}-${{ env.SHORT_SHA }}
SUBGRAPH_API_URL: ${{ secrets.SUBGRAPH_API_URL }}
TENDERLY_FORK_ID: ${{ secrets.TENDERLY_FORK_ID }}
TENDERLY_FORK_ID: ${{ env.TENDERLY_FORK_ID }}
graphnode_sc: ${{ secrets.GRAPHNODE_SC }}
graphnode_network: ${{ secrets.GRAPHNODE_NETWORK }}
graphnode_ethereum_node_url: https://rpc.tenderly.co/fork/${{ secrets.TENDERLY_FORK_ID }}
graphnode_ethereum_node_url: https://rpc.tenderly.co/fork/${{ env.TENDERLY_FORK_ID }}
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}


- name: "Run System tests"
uses: 0chain/actions/run-system-tests@master
with:
Expand All @@ -231,11 +314,19 @@ jobs:
run_flaky_tests: false
retry_failures: true
run_smoke_tests: ${{ github.ref != 'refs/heads/staging' && github.base_ref != 'staging' && github.ref != 'refs/heads/master' && github.base_ref != 'master' }}
TENDERLY_FORK_ID: ${{ secrets.TENDERLY_FORK_ID }}
TENDERLY_FORK_ID: ${{ env.TENDERLY_FORK_ID }}
DEVOPS_CHANNEL_WEBHOOK_URL: ${{ secrets.DEVOPS_CHANNEL_WEBHOOK_URL }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}

- name: "Remove Tenderly fork"
if: always()
run: |
curl -X DELETE \
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
-H "Content-Type: application/json" \
https://api.tenderly.co/api/v1/account/zus_network/project/project/fork/${{ env.TENDERLY_FORK_ID }}
- name: "Set PR status as ${{ job.status }}"
if: ${{ (success() || failure()) && steps.findPr.outputs.number }}
uses: 0chain/actions/set-pr-status@master
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/system_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ jobs:
DEV8KC: ${{ secrets.DEV8KC }}
DEV9KC: ${{ secrets.DEV9KC }}
SUBGRAPH_API_URL: ${{ secrets.SUBGRAPH_API_URL }}
TENDERLY_FORK_ID: ${{ secrets.TENDERLY_FORK_ID }}
TENDERLY_SECRET: ${{ secrets.TENDERLY_SECRET }}
GRAPHNODE_NETWORK: ${{ secrets.GRAPHNODE_NETWORK }}
GRAPHNODE_ETHEREUM_NODE_URL: https://rpc.tenderly.co/fork/${{ secrets.TENDERLY_FORK_ID }}
DEVOPS_CHANNEL_WEBHOOK_URL: ${{ secrets.DEVOPS_CHANNEL_WEBHOOK_URL }}
GRAPHNODE_SC: ${{ secrets.GRAPHNODE_SC }}
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
linter:
name: Lints
runs-on: [self-hosted,arc-runner]
runs-on: [self-hosted,blobber-runner]
steps:
- name: Setup go
uses: actions/setup-go@v3
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ Sample Response:
terms:
read_price: 26.874 mZCN / GB
write_price: 26.874 mZCN / GB / time_unit
min_lock_demand: 0.1
cct: 2m0s
max_offer_duration: 744h0m0s
- id: 7a90e6790bcd3d78422d7a230390edc102870fe58c15472073922024985b1c7d
Expand All @@ -176,7 +175,6 @@ Sample Response:
terms:
read_price: 10.000 mZCN / GB
write_price: 100.000 mZCN / GB / time_unit
min_lock_demand: 0.1
cct: 2m0s
max_offer_duration: 744h0m0s
- id: f65af5d64000c7cd2883f4910eb69086f9d6e6635c744e62afcfab58b938ee25
Expand All @@ -186,7 +184,6 @@ Sample Response:
terms:
read_price: 10.000 mZCN / GB
write_price: 100.000 mZCN / GB / time_unit
min_lock_demand: 0.1
cct: 2m0s
max_offer_duration: 744h0m0s
- id: f8dc4aaf3bb32ae0f4ed575dd6931a42b75e546e07cb37a6e1c6aaf1225891c5
Expand All @@ -196,7 +193,6 @@ Sample Response:
terms:
read_price: 26.874 mZCN / GB
write_price: 26.865 mZCN / GB / time_unit
min_lock_demand: 0.1
cct: 2m0s
max_offer_duration: 744h0m0s
```
Expand Down
72 changes: 1 addition & 71 deletions code/go/0chain.net/blobber/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package main
import (
"context"
"fmt"
"log"
"time"

"github.com/0chain/blobber/code/go/0chain.net/blobbercore/config"
"github.com/0chain/blobber/code/go/0chain.net/blobbercore/datastore"
Expand All @@ -29,76 +27,8 @@ func setupConfig(configDir string, deploymentMode int) {
if config.Configuration.MountPoint == "" {
panic("Please specify mount point in flag or config file")
}
config.Configuration.AllocDirLevel = viper.GetIntSlice("storage.alloc_dir_level")
config.Configuration.FileDirLevel = viper.GetIntSlice("storage.file_dir_level")
config.Configuration.DeploymentMode = byte(deploymentMode)
config.Configuration.ChainID = viper.GetString("server_chain.id")
config.Configuration.SignatureScheme = viper.GetString("server_chain.signature_scheme")

config.Configuration.OpenConnectionWorkerFreq = viper.GetInt64("openconnection_cleaner.frequency")
config.Configuration.OpenConnectionWorkerTolerance = viper.GetInt64("openconnection_cleaner.tolerance")

config.Configuration.WMRedeemFreq = viper.GetInt64("writemarker_redeem.frequency")
config.Configuration.WMRedeemNumWorkers = viper.GetInt("writemarker_redeem.num_workers")

config.Configuration.RMRedeemFreq = viper.GetInt64("readmarker_redeem.frequency")
config.Configuration.RMRedeemNumWorkers = viper.GetInt("readmarker_redeem.num_workers")

config.Configuration.HealthCheckWorkerFreq = viper.GetDuration("healthcheck.frequency")

config.Configuration.ChallengeResolveFreq = viper.GetInt64("challenge_response.frequency")
config.Configuration.ChallengeResolveNumWorkers = viper.GetInt("challenge_response.num_workers")
config.Configuration.ChallengeMaxRetires = viper.GetInt("challenge_response.max_retries")

config.Configuration.AutomaticUpdate = viper.GetBool("disk_update.automatic_update")
blobberUpdateIntrv := viper.GetDuration("disk_update.blobber_update_interval")
if blobberUpdateIntrv <= 0 {
blobberUpdateIntrv = 5 * time.Minute
}
config.Configuration.BlobberUpdateInterval = blobberUpdateIntrv

config.Configuration.PGUserName = viper.GetString("pg.user")
config.Configuration.PGPassword = viper.GetString("pg.password")
config.Configuration.DBHost = viper.GetString("db.host")
config.Configuration.DBName = viper.GetString("db.name")
config.Configuration.DBPort = viper.GetString("db.port")
config.Configuration.DBUserName = viper.GetString("db.user")
config.Configuration.DBPassword = viper.GetString("db.password")
config.Configuration.DBTablesToKeep = viper.GetStringSlice("db.keep_tables")

config.Configuration.PriceInUSD = viper.GetBool("price_in_usd")

config.Configuration.WriteMarkerLockTimeout = viper.GetDuration("write_marker_lock_timeout")

config.Configuration.UpdateAllocationsInterval =
viper.GetDuration("update_allocations_interval")

config.Configuration.MaxAllocationDirFiles =
viper.GetInt("max_dirs_files")
if config.Configuration.MaxAllocationDirFiles < 50000 {
config.Configuration.MaxAllocationDirFiles = 50000
}

config.Configuration.DelegateWallet = viper.GetString("delegate_wallet")
if w := config.Configuration.DelegateWallet; len(w) != 64 {
log.Fatal("invalid delegate wallet:", w)
}

config.Configuration.MinSubmit = viper.GetInt("min_submit")
if config.Configuration.MinSubmit < 1 {
config.Configuration.MinSubmit = 50
} else if config.Configuration.MinSubmit > 100 {
config.Configuration.MinSubmit = 100
}
config.Configuration.MinConfirmation = viper.GetInt("min_confirmation")
if config.Configuration.MinConfirmation < 1 {
config.Configuration.MinConfirmation = 50
} else if config.Configuration.MinConfirmation > 100 {
config.Configuration.MinConfirmation = 100
}

transaction.MinConfirmation = config.Configuration.MinConfirmation

config.ReadConfig(deploymentMode)
fmt.Print(" [OK]\n")
}

Expand Down
3 changes: 1 addition & 2 deletions code/go/0chain.net/blobber/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func setupDatabase() error {

time.Sleep(1 * time.Second)
}

if err := migrateDatabase(pgDB); err != nil {
return fmt.Errorf("error while migrating schema: %v", err)
}
Expand All @@ -49,7 +48,7 @@ func migrateDatabase(db *gorm.DB) error {
if err != nil {
return err
}

goose.Migrate(sqlDB)
return nil
}
8 changes: 4 additions & 4 deletions code/go/0chain.net/blobber/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func startHttpServer() {
}

r := mux.NewRouter()
initHandlers(r)
initHandlers(r, config.Development())

var wg sync.WaitGroup

Expand All @@ -36,7 +36,7 @@ func startHttpServer() {
// start https server
go startServer(&wg, r, mode, httpsPort, true)

logging.Logger.Info("Ready to listen to the requests")
logging.Logger.Info("Ready to listen to the requests with development mode: " + mode)
fmt.Print("> start http server [OK]\n")

wg.Wait()
Expand Down Expand Up @@ -104,12 +104,12 @@ func startServer(wg *sync.WaitGroup, r *mux.Router, mode string, port int, isTls
}
}

func initHandlers(r *mux.Router) {
func initHandlers(r *mux.Router, devMode bool) {
handler.StartTime = time.Now().UTC()
r.HandleFunc("/", handler.HomepageHandler)
handler.SetupHandlers(r)
handler.SetupSwagger()
common.SetAdminCredentials()
common.SetAdminCredentials(devMode)
}

func initProfHandlers(mux *http.ServeMux) {
Expand Down
4 changes: 2 additions & 2 deletions code/go/0chain.net/blobber/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func main() {
panic(err)
}

err := setCCTFromChain()
if err != nil {
if err := setStorageScConfigFromChain(); err != nil {
logging.Logger.Error("Error setStorageScConfigFromChain" + err.Error())
panic(err)
}

Expand Down
Loading

0 comments on commit fdde95b

Please sign in to comment.