Skip to content

Commit

Permalink
chore: 11 merge develop to releases/v2.0.0 (#30)
Browse files Browse the repository at this point in the history
* feat: Github Migration  (#1146)

* feat: migrate to github actions

* chore: migrate from circle ci

* Update develop.yml (#1148)

* Update develop.yml (#1149)

* Update develop.yml

* Update develop.yml

* Update develop.yml

* Fix go mod tidy

* Replaced curve instance elliptic.P256() with crypto.S256() (#1150)

* fix: Update Dockerfile with version bumps (#1152)

* chore: hotfix missing workflow

* chore: fix dockerfile versions

* Feature/v1.1.0 (#1154)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Merged `v1.3.0-alpha` into `v1.0.5` (#973)

* Merged `v1` into `v1.3.0-aplha` with hotfixes (#966)

* Hotfix-proposed data (#913)

* Updated propose data global variables correctly

* Fixed tests

* Returned correct waitForBlockCompletion error

* coverage increase

* GetLocalData returns type types.ProposeFileData

* fixed benchmark

* Fetched Last proposed from contracts (#917)

* fetched getLastProposedEpoch from contracts and tests for it

* typo fix

* V1 propose hotfix (#918)

* Change propose.go to get sorted proposed block ids.
* Fix sorted proposed block issue.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* allow stakers to addStake < minSafeRazor (#928)

* Call claimStakerReward only if there reward to claim (#926)

* Make contract call only if there is commission to claim

* Add tests for claimCommission file

* update check

* Hotfix-giveSorted (#921)

* ResetDispute only done after FinalizeDispute

* Fixed tests

* Update README (#931)

* Update README

* Update logs path

* Fix home dir path

* Add logs to vote.go and commit.go

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Add logs for dispute and propose.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Fix tests.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Suppress unneccessary error logs. (#935)

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* changed http timeout to 30 sec (#943)

* saving commit data only after successfull commit (#947)

* Added password flag (#946)

* added password flag

* README updated

* Hotfix-giveSorted (new implementation) (#953)

* GiveSorted linear recursion

* Added backupNode flag

* Compilation success for tests

* Fixed tests

* removed recusrsion, called giveSorted linearly

* fixed tests

* Added leafId to giveSortedLeafIds[] on successful giveSorted

* Hotfix-sortedProposedBlocks (#957)

* Shuffled copied slice instead of original slice

* returned error from giveSorted when len(sortedValues)=0

* Fixed dispute tests

* Changed pending nonce at to nonce at. (#948)

* Changed pending nonce at to nonce at.
* Update mockery

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Hotfix -RPCTimeout (#955)

* Added a generic function with timeout for contract calls

* Moved generic function to utils and implemented to all contract getter calls

* Implemented timeout for contract setter functions

* rpc timeout custom error

* type asserting structs from contract mappings

* Shifted timeout to constants

* passed timeout in int in constants.go

* Added rpcTimeout as config

* Removed errorIndex paramter from CheckIfAnyError()

* Function renamed

* Fixed tests

* Unrequired change

* Added backup node info in readme (#963)

* Passed a initialized varible instead of nil value as a parameter

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>

* Updated `v1.3.0` branch to staging parameters for v1.3.0-alpha version (#967)

* Updated contract addresses and chainId to staging

* Updated razor-go version to v1.3.0-alpha

* Fixed `CheckIfAnyError()` on RPCTimeout. (#974)

* Added errorIndexInReturnedValues as a parameter in  function

* Fixed comparios of error data type from returned values

* Added a check if config key is present in yaml file before fetching value (#975)

* Added default values for config parameters

* Checked if config key is present in yaml file before fetching

* Fixed tests

* returned default values uniformly

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>

* updated version to v1.0.5-alpha (#978)

* Reduced wait for block completion to 1 second (#984)

* changed tolerance flag type to uint32 (#983)

* Removed ethBalanceCheck (#982)

* Moved constant values to constants.go (#987)

* moved gasLimitMultiplier as constant in constants.go

* Moved path.go strings to constants.go

* Replaced common.Hash{0x00} with core.NilHash

* Update geth version to v1.10.25 and updated depreciated bindings (#985)

* Updated geth version

* Updated depriciated bindings

* updated go.sum to fix tests

* Replaced errors package

* Validate contract calls (Changes from v1-audit) (#981)

* Added retry mechanism for fetchBalance

* Added ETA for unlockWithdraw

* Added check of staker is slashed for stake

* Added valid ERC20 check for addresses

* Changed name from IsValidErc20Address to IsValidAddress

* Functions Refactor (#989)

* changed state name to Buffer instead of -1

* CalculateBlockNumberAtEpochBeginning cleanup

* Renamed functions in array.go

* ApproveUnstake sends StakerTokenAddress instead of StakerStruct

* Returned error from getMerkleTree()

* Returned error from getMerkleRoot()

* Removed unused functions

* Added tree is nil condition in GetMerkleRoot()

* fixed BenchmarkGenerateTreeRevealData

* Code CleanUp (Issues from v1-audit) (#990)

* Renamed getDelayedState to getBufferedState

* remove uint64 from block time

* Renamed handleRevealState to CheckForLastCommitted

* CalculateBlockNumberAtEpochBeginning renamed to EstimateBlockNumberAtEpochBeginning

* Renamed claimStakeReward to ClaimStakerReward

* Renamed GetStatesAllowed to GetFormattedStateNames

* GetSalt clean up

* changed int64 to uint64 in constants

* Used block.Time directly instead of blockTime variable

* Txn hash made consistent in logging

* remove redundant uint64 typecast from GetEpoch()

* Rename coinContract to erc20contract

* Updated mocks after renaming coinContract to erc20Contract

* Removed redundant code in logger.go

* Removed space from xhtml job result (#991)

* Log changes from v1-audit (#994)

* Renamed eth balance to sFuel balance

* used log.Info instead of fmt.Println for contractAddresses

* Added do not mopdify note in constants.go

* Added a warning for low ethBalance

* replaced path.join with filepath.join (#992)

* Removed redundant cmd/utilsInterface (#997)

* Removed UtilsInterface in cmd package

* Compilation successful for tests

* replaced utils.UtilsInterface with razorUtils

* Included CheckAmountAndBalance in utils/utilsInterface

* Fixed tests

* Fixed benchmark

* Fixed MakeBlock benchmark

* Moved waitForAppropriateState after epoch check (#1008)

* Implemented timeout for logger on fetching blockNumber (#1009)

* Implemented timeout for logger on fethcing blockNumber

* Added comments

* updated dockerfile and readme for non-root user (#1014)

* Moved Lumberjack constants to config (#1011)

* Added logFile parameters to config

* Initialised logger with getting parameters from config

* Added logFile paramters in config set up script

* Added config as a parameter in AssignLogFile()

* Fixed tests

* Avoided passing nil types.Configurations{]

* Passed types.Configuations{} for setConfig

* updated readme for expose metric and running cmd in background (#1015)

* Cached API Response (#1016)

* Added cache package containing caching utils

* Used cache to get data from API

* Fixed tests

* Fixed test

* minor fixes

* removed unwanted test

* Added condition to fetch value only if the key is present in json (#1028)

* Added support for Post Requests (#1020)

* Added POST request support

* datasource URL struct support

* Updated createJob command and new format for assets.json file

* Fixed tests

* Fixed URlStruct in test

* Removed unwanted comment

* Backwards compatible

* Removed unwanted logs

* Merge `v1.0.5`into `v1.0.6` (#1031)

* Changes Requested in v1.0.5 Review (#1006)

* updated logs and readMe for v1.0.5

* Canges string formater for errors to %v

* Inserted Logs in the entire codebase (#1018)

* Inserted Logs

* Corrected logs

* Modified lumberJack constants

* V1.0.5-alpha-patch1 Ready (#1022)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Log corrections

* updated release

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

Co-authored-by: Shrikant upadhyay <[email protected]>

* Calculated blockNumber in a separate go-routine for logging (#1025)

* Cached block number in logger

* Revert "Cached block number in logger"

This reverts commit 760e3adf38f106bd444ef2d64494565d9bd6dae1.

* Added block/block.go for calculating latestBlock in a seperate goroutine

* Fetched block number from block package

* log corrections

* Increased max size of file to 182MB (#1027)

* renamed variable correctly

Co-authored-by: Shrikant upadhyay <[email protected]>

* Refactor utilsInterface (#1024)

* FileUtils, GasUtils, ClientUtils

* Added test_utils.go to initialiase all the mocked interface

* test_utils.go support for all tests

* Initialised new utils interfaces

* Fetched v1.0.5 updates to v1.0.6 (#1045)

* Fetched the updated changes from v1.0.5

* Staging deployement parameters (#1046)

* Added http timeout as a config parameter (#1055)

* added http timeout as a config parameter

* Fixed and Added tests

* added httpTimeout in config

* Added logFile config parameters to readMe

* Fixed comments

* Fetched API key from env file (#1048)

* Added dot env file utils

* Fetched API key from .env file when required

* updated dependencies

* Changed API key regex

* Added name field in customJob struct

* Replaced content-type field with headers in dataSourceURLStruct

* Updated post request creation

* picked API Regex from constants.go

* Removed unwanted field from header

* returned error as well from GetkeywordAndAPIKey

* replaces regexp.Match() with strings.Contains()

* support for headers in GET requests

* Refactored GetDataFromAPI

* Added processRequest retry constants

* Added condition to check if there was a value in previous block (#1056)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

* Merge v1.0.5 to main (#1038)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Merged `v1.3.0-alpha` into `v1.0.5` (#973)

* Merged `v1` into `v1.3.0-aplha` with hotfixes (#966)

* Hotfix-proposed data (#913)

* Updated propose data global variables correctly

* Fixed tests

* Returned correct waitForBlockCompletion error

* coverage increase

* GetLocalData returns type types.ProposeFileData

* fixed benchmark

* Fetched Last proposed from contracts (#917)

* fetched getLastProposedEpoch from contracts and tests for it

* typo fix

* V1 propose hotfix (#918)

* Change propose.go to get sorted proposed block ids.
* Fix sorted proposed block issue.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* allow stakers to addStake < minSafeRazor (#928)

* Call claimStakerReward only if there reward to claim (#926)

* Make contract call only if there is commission to claim

* Add tests for claimCommission file

* update check

* Hotfix-giveSorted (#921)

* ResetDispute only done after FinalizeDispute

* Fixed tests

* Update README (#931)

* Update README

* Update logs path

* Fix home dir path

* Add logs to vote.go and commit.go

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Add logs for dispute and propose.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Fix tests.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Suppress unneccessary error logs. (#935)

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* changed http timeout to 30 sec (#943)

* saving commit data only after successfull commit (#947)

* Added password flag (#946)

* added password flag

* README updated

* Hotfix-giveSorted (new implementation) (#953)

* GiveSorted linear recursion

* Added backupNode flag

* Compilation success for tests

* Fixed tests

* removed recusrsion, called giveSorted linearly

* fixed tests

* Added leafId to giveSortedLeafIds[] on successful giveSorted

* Hotfix-sortedProposedBlocks (#957)

* Shuffled copied slice instead of original slice

* returned error from giveSorted when len(sortedValues)=0

* Fixed dispute tests

* Changed pending nonce at to nonce at. (#948)

* Changed pending nonce at to nonce at.
* Update mockery

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Hotfix -RPCTimeout (#955)

* Added a generic function with timeout for contract calls

* Moved generic function to utils and implemented to all contract getter calls

* Implemented timeout for contract setter functions

* rpc timeout custom error

* type asserting structs from contract mappings

* Shifted timeout to constants

* passed timeout in int in constants.go

* Added rpcTimeout as config

* Removed errorIndex paramter from CheckIfAnyError()

* Function renamed

* Fixed tests

* Unrequired change

* Added backup node info in readme (#963)

* Passed a initialized varible instead of nil value as a parameter

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>

* Updated `v1.3.0` branch to staging parameters for v1.3.0-alpha version (#967)

* Updated contract addresses and chainId to staging

* Updated razor-go version to v1.3.0-alpha

* Fixed `CheckIfAnyError()` on RPCTimeout. (#974)

* Added errorIndexInReturnedValues as a parameter in  function

* Fixed comparios of error data type from returned values

* Added a check if config key is present in yaml file before fetching value (#975)

* Added default values for config parameters

* Checked if config key is present in yaml file before fetching

* Fixed tests

* returned default values uniformly

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>

* updated version to v1.0.5-alpha (#978)

* Changes Requested in v1.0.5 Review (#1006)

* updated logs and readMe for v1.0.5

* Canges string formater for errors to %v

* Inserted Logs in the entire codebase (#1018)

* Inserted Logs

* Corrected logs

* Modified lumberJack constants

* V1.0.5-alpha-patch1 Ready (#1022)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Log corrections

* updated release

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

Co-authored-by: Shrikant upadhyay <[email protected]>

* Calculated blockNumber in a separate go-routine for logging (#1025)

* Cached block number in logger

* Revert "Cached block number in logger"

This reverts commit 760e3adf38f106bd444ef2d64494565d9bd6dae1.

* Added block/block.go for calculating latestBlock in a seperate goroutine

* Fetched block number from block package

* log corrections

* Increased max size of file to 182MB (#1027)

* V1.0.5 beta ready (#1032)

* Production support

* Updated release version

* Updated maxSize of log file to 200MB

* Added mutex lock in blockNumber calculation (#1035)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

* Added mutex lock in blockNumber calculation

* Added new staging addresses and chainId

* updated version

Co-authored-by: Shrikant upadhyay <[email protected]>

* v1.0.5-beta-patch1 (#1037)

* Updated depolyment paramters to prod

* updated version to v1.0.5-beta-patch1

* Updated version to v1.0.5 (#1033)

* Made v1.0.5 branch in sync with main branch (#1039)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

Co-authored-by: Shrikant upadhyay <[email protected]>

* Deleted password file (#1040)

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>
Co-authored-by: Shrikant upadhyay <[email protected]>

* Releases/v1.0.5 (#1043)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Merged `v1.3.0-alpha` into `v1.0.5` (#973)

* Merged `v1` into `v1.3.0-aplha` with hotfixes (#966)

* Hotfix-proposed data (#913)

* Updated propose data global variables correctly

* Fixed tests

* Returned correct waitForBlockCompletion error

* coverage increase

* GetLocalData returns type types.ProposeFileData

* fixed benchmark

* Fetched Last proposed from contracts (#917)

* fetched getLastProposedEpoch from contracts and tests for it

* typo fix

* V1 propose hotfix (#918)

* Change propose.go to get sorted proposed block ids.
* Fix sorted proposed block issue.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* allow stakers to addStake < minSafeRazor (#928)

* Call claimStakerReward only if there reward to claim (#926)

* Make contract call only if there is commission to claim

* Add tests for claimCommission file

* update check

* Hotfix-giveSorted (#921)

* ResetDispute only done after FinalizeDispute

* Fixed tests

* Update README (#931)

* Update README

* Update logs path

* Fix home dir path

* Add logs to vote.go and commit.go

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Add logs for dispute and propose.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Fix tests.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Suppress unneccessary error logs. (#935)

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* changed http timeout to 30 sec (#943)

* saving commit data only after successfull commit (#947)

* Added password flag (#946)

* added password flag

* README updated

* Hotfix-giveSorted (new implementation) (#953)

* GiveSorted linear recursion

* Added backupNode flag

* Compilation success for tests

* Fixed tests

* removed recusrsion, called giveSorted linearly

* fixed tests

* Added leafId to giveSortedLeafIds[] on successful giveSorted

* Hotfix-sortedProposedBlocks (#957)

* Shuffled copied slice instead of original slice

* returned error from giveSorted when len(sortedValues)=0

* Fixed dispute tests

* Changed pending nonce at to nonce at. (#948)

* Changed pending nonce at to nonce at.
* Update mockery

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Hotfix -RPCTimeout (#955)

* Added a generic function with timeout for contract calls

* Moved generic function to utils and implemented to all contract getter calls

* Implemented timeout for contract setter functions

* rpc timeout custom error

* type asserting structs from contract mappings

* Shifted timeout to constants

* passed timeout in int in constants.go

* Added rpcTimeout as config

* Removed errorIndex paramter from CheckIfAnyError()

* Function renamed

* Fixed tests

* Unrequired change

* Added backup node info in readme (#963)

* Passed a initialized varible instead of nil value as a parameter

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>

* Updated `v1.3.0` branch to staging parameters for v1.3.0-alpha version (#967)

* Updated contract addresses and chainId to staging

* Updated razor-go version to v1.3.0-alpha

* Fixed `CheckIfAnyError()` on RPCTimeout. (#974)

* Added errorIndexInReturnedValues as a parameter in  function

* Fixed comparios of error data type from returned values

* Added a check if config key is present in yaml file before fetching value (#975)

* Added default values for config parameters

* Checked if config key is present in yaml file before fetching

* Fixed tests

* returned default values uniformly

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>

* updated version to v1.0.5-alpha (#978)

* Changes Requested in v1.0.5 Review (#1006)

* updated logs and readMe for v1.0.5

* Canges string formater for errors to %v

* Inserted Logs in the entire codebase (#1018)

* Inserted Logs

* Corrected logs

* Modified lumberJack constants

* V1.0.5-alpha-patch1 Ready (#1022)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Log corrections

* updated release

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

Co-authored-by: Shrikant upadhyay <[email protected]>

* Calculated blockNumber in a separate go-routine for logging (#1025)

* Cached block number in logger

* Revert "Cached block number in logger"

This reverts commit 760e3adf38f106bd444ef2d64494565d9bd6dae1.

* Added block/block.go for calculating latestBlock in a seperate goroutine

* Fetched block number from block package

* log corrections

* Increased max size of file to 182MB (#1027)

* V1.0.5 beta ready (#1032)

* Production support

* Updated release version

* Updated maxSize of log file to 200MB

* Added mutex lock in blockNumber calculation (#1035)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

* Added mutex lock in blockNumber calculation

* Added new staging addresses and chainId

* updated version

Co-authored-by: Shrikant upadhyay <[email protected]>

* v1.0.5-beta-patch1 (#1037)

* Updated depolyment paramters to prod

* updated version to v1.0.5-beta-patch1

* Updated version to v1.0.5 (#1033)

* Made v1.0.5 branch in sync with main branch (#1039)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

Co-authored-by: Shrikant upadhyay <[email protected]>

* Deleted password file (#1040)

* Added sleep time to reduce amount of RPC calls to get blockNumber (#1042)

add sleep after client call to get blockNumber

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Yashk767 <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>
Co-authored-by: Shrikant upadhyay <[email protected]>
Co-authored-by: YashK <[email protected]>

* updated CI for dockerhub token. (#1052)

* added condition to check if there was a value in previous block

* changed error messaged

---------

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shrikant upadhyay <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>

* Checked password is correct at the immediate start of command (#1069)

* Added function CheckPassword()

* Checked password at immediate start of command

* Added CheckPassword in UtilsInterface

* fixed tests

* Fetch `main` branch into `v1.0.6` (#1076)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

* Merge v1.0.5 to main (#1038)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Merged `v1.3.0-alpha` into `v1.0.5` (#973)

* Merged `v1` into `v1.3.0-aplha` with hotfixes (#966)

* Hotfix-proposed data (#913)

* Updated propose data global variables correctly

* Fixed tests

* Returned correct waitForBlockCompletion error

* coverage increase

* GetLocalData returns type types.ProposeFileData

* fixed benchmark

* Fetched Last proposed from contracts (#917)

* fetched getLastProposedEpoch from contracts and tests for it

* typo fix

* V1 propose hotfix (#918)

* Change propose.go to get sorted proposed block ids.
* Fix sorted proposed block issue.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* allow stakers to addStake < minSafeRazor (#928)

* Call claimStakerReward only if there reward to claim (#926)

* Make contract call only if there is commission to claim

* Add tests for claimCommission file

* update check

* Hotfix-giveSorted (#921)

* ResetDispute only done after FinalizeDispute

* Fixed tests

* Update README (#931)

* Update README

* Update logs path

* Fix home dir path

* Add logs to vote.go and commit.go

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Add logs for dispute and propose.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Fix tests.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Suppress unneccessary error logs. (#935)

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* changed http timeout to 30 sec (#943)

* saving commit data only after successfull commit (#947)

* Added password flag (#946)

* added password flag

* README updated

* Hotfix-giveSorted (new implementation) (#953)

* GiveSorted linear recursion

* Added backupNode flag

* Compilation success for tests

* Fixed tests

* removed recusrsion, called giveSorted linearly

* fixed tests

* Added leafId to giveSortedLeafIds[] on successful giveSorted

* Hotfix-sortedProposedBlocks (#957)

* Shuffled copied slice instead of original slice

* returned error from giveSorted when len(sortedValues)=0

* Fixed dispute tests

* Changed pending nonce at to nonce at. (#948)

* Changed pending nonce at to nonce at.
* Update mockery

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Hotfix -RPCTimeout (#955)

* Added a generic function with timeout for contract calls

* Moved generic function to utils and implemented to all contract getter calls

* Implemented timeout for contract setter functions

* rpc timeout custom error

* type asserting structs from contract mappings

* Shifted timeout to constants

* passed timeout in int in constants.go

* Added rpcTimeout as config

* Removed errorIndex paramter from CheckIfAnyError()

* Function renamed

* Fixed tests

* Unrequired change

* Added backup node info in readme (#963)

* Passed a initialized varible instead of nil value as a parameter

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>

* Updated `v1.3.0` branch to staging parameters for v1.3.0-alpha version (#967)

* Updated contract addresses and chainId to staging

* Updated razor-go version to v1.3.0-alpha

* Fixed `CheckIfAnyError()` on RPCTimeout. (#974)

* Added errorIndexInReturnedValues as a parameter in  function

* Fixed comparios of error data type from returned values

* Added a check if config key is present in yaml file before fetching value (#975)

* Added default values for config parameters

* Checked if config key is present in yaml file before fetching

* Fixed tests

* returned default values uniformly

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>

* updated version to v1.0.5-alpha (#978)

* Changes Requested in v1.0.5 Review (#1006)

* updated logs and readMe for v1.0.5

* Canges string formater for errors to %v

* Inserted Logs in the entire codebase (#1018)

* Inserted Logs

* Corrected logs

* Modified lumberJack constants

* V1.0.5-alpha-patch1 Ready (#1022)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Log corrections

* updated release

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

Co-authored-by: Shrikant upadhyay <[email protected]>

* Calculated blockNumber in a separate go-routine for logging (#1025)

* Cached block number in logger

* Revert "Cached block number in logger"

This reverts commit 760e3adf38f106bd444ef2d64494565d9bd6dae1.

* Added block/block.go for calculating latestBlock in a seperate goroutine

* Fetched block number from block package

* log corrections

* Increased max size of file to 182MB (#1027)

* V1.0.5 beta ready (#1032)

* Production support

* Updated release version

* Updated maxSize of log file to 200MB

* Added mutex lock in blockNumber calculation (#1035)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

* Added mutex lock in blockNumber calculation

* Added new staging addresses and chainId

* updated version

Co-authored-by: Shrikant upadhyay <[email protected]>

* v1.0.5-beta-patch1 (#1037)

* Updated depolyment paramters to prod

* updated version to v1.0.5-beta-patch1

* Updated version to v1.0.5 (#1033)

* Made v1.0.5 branch in sync with main branch (#1039)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

Co-authored-by: Shrikant upadhyay <[email protected]>

* Deleted password file (#1040)

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>
Co-authored-by: Shrikant upadhyay <[email protected]>

* Releases/v1.0.5 (#1043)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Merged `v1.3.0-alpha` into `v1.0.5` (#973)

* Merged `v1` into `v1.3.0-aplha` with hotfixes (#966)

* Hotfix-proposed data (#913)

* Updated propose data global variables correctly

* Fixed tests

* Returned correct waitForBlockCompletion error

* coverage increase

* GetLocalData returns type types.ProposeFileData

* fixed benchmark

* Fetched Last proposed from contracts (#917)

* fetched getLastProposedEpoch from contracts and tests for it

* typo fix

* V1 propose hotfix (#918)

* Change propose.go to get sorted proposed block ids.
* Fix sorted proposed block issue.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* allow stakers to addStake < minSafeRazor (#928)

* Call claimStakerReward only if there reward to claim (#926)

* Make contract call only if there is commission to claim

* Add tests for claimCommission file

* update check

* Hotfix-giveSorted (#921)

* ResetDispute only done after FinalizeDispute

* Fixed tests

* Update README (#931)

* Update README

* Update logs path

* Fix home dir path

* Add logs to vote.go and commit.go

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Add logs for dispute and propose.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Fix tests.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Suppress unneccessary error logs. (#935)

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* changed http timeout to 30 sec (#943)

* saving commit data only after successfull commit (#947)

* Added password flag (#946)

* added password flag

* README updated

* Hotfix-giveSorted (new implementation) (#953)

* GiveSorted linear recursion

* Added backupNode flag

* Compilation success for tests

* Fixed tests

* removed recusrsion, called giveSorted linearly

* fixed tests

* Added leafId to giveSortedLeafIds[] on successful giveSorted

* Hotfix-sortedProposedBlocks (#957)

* Shuffled copied slice instead of original slice

* returned error from giveSorted when len(sortedValues)=0

* Fixed dispute tests

* Changed pending nonce at to nonce at. (#948)

* Changed pending nonce at to nonce at.
* Update mockery

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Hotfix -RPCTimeout (#955)

* Added a generic function with timeout for contract calls

* Moved generic function to utils and implemented to all contract getter calls

* Implemented timeout for contract setter functions

* rpc timeout custom error

* type asserting structs from contract mappings

* Shifted timeout to constants

* passed timeout in int in constants.go

* Added rpcTimeout as config

* Removed errorIndex paramter from CheckIfAnyError()

* Function renamed

* Fixed tests

* Unrequired change

* Added backup node info in readme (#963)

* Passed a initialized varible instead of nil value as a parameter

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>

* Updated `v1.3.0` branch to staging parameters for v1.3.0-alpha version (#967)

* Updated contract addresses and chainId to staging

* Updated razor-go version to v1.3.0-alpha

* Fixed `CheckIfAnyError()` on RPCTimeout. (#974)

* Added errorIndexInReturnedValues as a parameter in  function

* Fixed comparios of error data type from returned values

* Added a check if config key is present in yaml file before fetching value (#975)

* Added default values for config parameters

* Checked if config key is present in yaml file before fetching

* Fixed tests

* returned default values uniformly

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>

* updated version to v1.0.5-alpha (#978)

* Changes Requested in v1.0.5 Review (#1006)

* updated logs and readMe for v1.0.5

* Canges string formater for errors to %v

* Inserted Logs in the entire codebase (#1018)

* Inserted Logs

* Corrected logs

* Modified lumberJack constants

* V1.0.5-alpha-patch1 Ready (#1022)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Log corrections

* updated release

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

Co-authored-by: Shrikant upadhyay <[email protected]>

* Calculated blockNumber in a separate go-routine for logging (#1025)

* Cached block number in logger

* Revert "Cached block number in logger"

This reverts commit 760e3adf38f106bd444ef2d64494565d9bd6dae1.

* Added block/block.go for calculating latestBlock in a seperate goroutine

* Fetched block number from block package

* log corrections

* Increased max size of file to 182MB (#1027)

* V1.0.5 beta ready (#1032)

* Production support

* Updated release version

* Updated maxSize of log file to 200MB

* Added mutex lock in blockNumber calculation (#1035)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

* Added mutex lock in blockNumber calculation

* Added new staging addresses and chainId

* updated version

Co-authored-by: Shrikant upadhyay <[email protected]>

* v1.0.5-beta-patch1 (#1037)

* Updated depolyment paramters to prod

* updated version to v1.0.5-beta-patch1

* Updated version to v1.0.5 (#1033)

* Made v1.0.5 branch in sync with main branch (#1039)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

Co-authored-by: Shrikant upadhyay <[email protected]>

* Deleted password file (#1040)

* Added sleep time to reduce amount of RPC calls to get blockNumber (#1042)

add sleep after client call to get blockNumber

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Yashk767 <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>
Co-authored-by: Shrikant upadhyay <[email protected]>
Co-authored-by: YashK <[email protected]>

* updated CI for dockerhub token. (#1052)

* updated CI for tests (#1075)

* updated CI for tests

* removed docker from test ci

* Merge `v1.0.5-patch2` to main  (#1073)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Merged `v1.3.0-alpha` into `v1.0.5` (#973)

* Merged `v1` into `v1.3.0-aplha` with hotfixes (#966)

* Hotfix-proposed data (#913)

* Updated propose data global variables correctly

* Fixed tests

* Returned correct waitForBlockCompletion error

* coverage increase

* GetLocalData returns type types.ProposeFileData

* fixed benchmark

* Fetched Last proposed from contracts (#917)

* fetched getLastProposedEpoch from contracts and tests for it

* typo fix

* V1 propose hotfix (#918)

* Change propose.go to get sorted proposed block ids.
* Fix sorted proposed block issue.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* allow stakers to addStake < minSafeRazor (#928)

* Call claimStakerReward only if there reward to claim (#926)

* Make contract call only if there is commission to claim

* Add tests for claimCommission file

* update check

* Hotfix-giveSorted (#921)

* ResetDispute only done after FinalizeDispute

* Fixed tests

* Update README (#931)

* Update README

* Update logs path

* Fix home dir path

* Add logs to vote.go and commit.go

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Add logs for dispute and propose.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Fix tests.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Suppress unneccessary error logs. (#935)

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* changed http timeout to 30 sec (#943)

* saving commit data only after successfull commit (#947)

* Added password flag (#946)

* added password flag

* README updated

* Hotfix-giveSorted (new implementation) (#953)

* GiveSorted linear recursion

* Added backupNode flag

* Compilation success for tests

* Fixed tests

* removed recusrsion, called giveSorted linearly

* fixed tests

* Added leafId to giveSortedLeafIds[] on successful giveSorted

* Hotfix-sortedProposedBlocks (#957)

* Shuffled copied slice instead of original slice

* returned error from giveSorted when len(sortedValues)=0

* Fixed dispute tests

* Changed pending nonce at to nonce at. (#948)

* Changed pending nonce at to nonce at.
* Update mockery

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Hotfix -RPCTimeout (#955)

* Added a generic function with timeout for contract calls

* Moved generic function to utils and implemented to all contract getter calls

* Implemented timeout for contract setter functions

* rpc timeout custom error

* type asserting structs from contract mappings

* Shifted timeout to constants

* passed timeout in int in constants.go

* Added rpcTimeout as config

* Removed errorIndex paramter from CheckIfAnyError()

* Function renamed

* Fixed tests

* Unrequired change

* Added backup node info in readme (#963)

* Passed a initialized varible instead of nil value as a parameter

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>

* Updated `v1.3.0` branch to staging parameters for v1.3.0-alpha version (#967)

* Updated contract addresses and chainId to staging

* Updated razor-go version to v1.3.0-alpha

* Fixed `CheckIfAnyError()` on RPCTimeout. (#974)

* Added errorIndexInReturnedValues as a parameter in  function

* Fixed comparios of error data type from returned values

* Added a check if config key is present in yaml file before fetching value (#975)

* Added default values for config parameters

* Checked if config key is present in yaml file before fetching

* Fixed tests

* returned default values uniformly

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>

* updated version to v1.0.5-alpha (#978)

* Changes Requested in v1.0.5 Review (#1006)

* updated logs and readMe for v1.0.5

* Canges string formater for errors to %v

* Inserted Logs in the entire codebase (#1018)

* Inserted Logs

* Corrected logs

* Modified lumberJack constants

* V1.0.5-alpha-patch1 Ready (#1022)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Log corrections

* updated release

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

Co-authored-by: Shrikant upadhyay <[email protected]>

* Calculated blockNumber in a separate go-routine for logging (#1025)

* Cached block number in logger

* Revert "Cached block number in logger"

This reverts commit 760e3adf38f106bd444ef2d64494565d9bd6dae1.

* Added block/block.go for calculating latestBlock in a seperate goroutine

* Fetched block number from block package

* log corrections

* Increased max size of file to 182MB (#1027)

* V1.0.5 beta ready (#1032)

* Production support

* Updated release version

* Updated maxSize of log file to 200MB

* Added mutex lock in blockNumber calculation (#1035)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

* Added mutex lock in blockNumber calculation

* Added new staging addresses and chainId

* updated version

Co-authored-by: Shrikant upadhyay <[email protected]>

* v1.0.5-beta-patch1 (#1037)

* Updated depolyment paramters to prod

* updated version to v1.0.5-beta-patch1

* Updated version to v1.0.5 (#1033)

* Made v1.0.5 branch in sync with main branch (#1039)

* Merge `v1.0.4` release to main branch  (#977)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Updated user in dockerfile (#1012)

* updating user in dockerfile

* updating readme for non-root user

* Revert "Updated user in dockerfile (#1012)" (#1021)

This reverts commit 7f95edbdc1c2963077805a9da6b0b5aa7e4c0f22.

Co-authored-by: Shrikant upadhyay <[email protected]>

* Deleted password file (#1040)

* Added sleep time to reduce amount of RPC calls to get blockNumber (#1042)

add sleep after client call to get blockNumber

* Merge `V1.0.5-gasLimitFix` to `releases/v1.0.5` (#1062)

* Hardcoded gas limit for reveal (#1060)

* Updated version to v1.0.5-patch2 (#1061)

* Added gasLimit to override as a config parameter (#1063)

* Added gasLimitOverride config parameter

* Taking the gas limit value from config if present

* Added tests

* Added default gas limit override value

* Added gas limit overridr in readMe

* Updated deployment parameters to staging for `v1.0.5-patch2-alpha` (#1065)

* Updated deployment parameters to staging

* updated version

* Updated to v1.0.5-patch2-beta (#1066)

* Updated version to v1.0.5-patch2-beta

* Updated deployement parameters to prod

* Updated version to `v1.0.5-patch2` release (#1067)

* Merge v1.0.5 to main (#1038)

* v1.2.0 (#965)

* Hotfix-logImprovements (#952)

* Set up blocknumber and epoch in logs

* updated blocknumber and epoch logger info in every command

* Hotfix-getDataFromAPI (#951)

* Changed numm of retry attempts

* removed redundant retry attempts

* corrected tests

* changed http timeout and logged time elapsed to fetch data (#954)

* Updated version (#960)

* Updated version

* updated version to v1.2.0

* version update (#972)

* Merged `v1.3.0-alpha` into `v1.0.5` (#973)

* Merged `v1` into `v1.3.0-aplha` with hotfixes (#966)

* Hotfix-proposed data (#913)

* Updated propose data global variables correctly

* Fixed tests

* Returned correct waitForBlockCompletion error

* coverage increase

* GetLocalData returns type types.ProposeFileData

* fixed benchmark

* Fetched Last proposed from contracts (#917)

* fetched getLastProposedEpoch from contracts and tests for it

* typo fix

* V1 propose hotfix (#918)

* Change propose.go to get sorted proposed block ids.
* Fix sorted proposed block issue.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* allow stakers to addStake < minSafeRazor (#928)

* Call claimStakerReward only if there reward to claim (#926)

* Make contract call only if there is commission to claim

* Add tests for claimCommission file

* update check

* Hotfix-giveSorted (#921)

* ResetDispute only done after FinalizeDispute

* Fixed tests

* Update README (#931)

* Update README

* Update logs path

* Fix home dir path

* Add logs to vote.go and commit.go

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Add logs for dispute and propose.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Fix tests.

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Suppress unneccessary error logs. (#935)

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* changed http timeout to 30 sec (#943)

* saving commit data only after successfull commit (#947)

* Added password flag (#946)

* added password flag

* README updated

* Hotfix-giveSorted (new implementation) (#953)

* GiveSorted linear recursion

* Added backupNode flag

* Compilation success for tests

* Fixed tests

* removed recusrsion, called giveSorted linearly

* fixed tests

* Added leafId to giveSortedLeafIds[] on successful giveSorted

* Hotfix-sortedProposedBlocks (#957)

* Shuffled copied slice instead of original slice

* returned error from giveSorted when len(sortedValues)=0

* Fixed dispute tests

* Changed pending nonce at to nonce at. (#948)

* Changed pending nonce at to nonce at.
* Update mockery

Signed-off-by: Ashish Kumar Mishra <[email protected]>

* Hotfix -RPCTimeout (#955)

* Added a generic function with timeout for contract calls

* Moved generic function to utils and implemented to all contract getter calls

* Implemented timeout for contract setter functions

* rpc timeout custom error

* type asserting structs from contract mappings

* Shifted timeout to constants

* passed timeout in int in constants.go

* Added rpcTimeout as config

* Removed errorIndex paramter from CheckIfAnyError()

* Function renamed

* Fixed tests

* Unrequired change

* Added backup node info in readme (#963)

* Passed a initialized varible instead of nil value as a parameter

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shyam Patel <[email protected]>
Co-authored-by: Raj Kharvar <[email protected]>
Co-authored-by: Skanda Bhat <[email protected]>

* Updated `v1.3.0` branch to staging parameters for v1.3.0-alpha version (#967)

* Updated contract addresses and chainId to staging

* Updated razor-go version to v1.3.0-alpha

* Fixed `CheckIfAnyError()` on RPCTimeout. (#974)

* Added errorIndexInReturnedValues as a parameter in  function

* Fixed comparios of error data type from returned values

* Added a check if config key is present in yaml file before fetching value (#975)

* Added default values for config parameters

* Checked if config key is present in yaml file before fetching

* Fixed tests

* returned default values uniformly

Signed-off-by: Ashish Kumar Mishra <[email protected]>
Co-authored-by: Shekhar Gaur <[email protected]>
Co-authored-by: Ashish Kumar…
  • Loading branch information
9 people authored Sep 17, 2024
1 parent 40f5b82 commit fc1172e
Show file tree
Hide file tree
Showing 29 changed files with 9,113 additions and 9,650 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
- name: Setup Go
uses: actions/setup-go@v2
with:
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"

- name: Setup Go
uses: actions/setup-go@v2
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"

- name: Setup Go
uses: actions/setup-go@v2
Expand Down Expand Up @@ -194,7 +194,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"

- name: Download Artifacts AMD
uses: actions/download-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
- name: Setup Go
uses: actions/setup-go@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
- name: Setup Go
uses: actions/setup-go@v2
with:
Expand Down
20 changes: 10 additions & 10 deletions addresses/mainnet.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"Governance": "0xAc40E8dA38B5a381008059a38bb9bf45f0D3C4e2",
"BlockManager": "0x11aB70d78f1Dd2c3F967180d8A64858Db03A0aBa",
"CollectionManager": "0x367962d1462C568A0dDd0e2448311469451bF5a3",
"StakeManager": "0xe0bC695203d9C9f379bcdE9260B9F71B64B85298",
"RewardManager": "0x301779E4c95f951D2E17B4c3EdDC717551df2EBb",
"VoteManager": "0x641BAD0641eB5B94B19568C0a22a55AEbDAF1870",
"Delegator": "0xC74745eA5a3fac1864FAcd8f48d72C21A4ab883D",
"RAZOR": "0xcbf70914Fae03B3acB91E953De60CfDAaCA8145f",
"StakedTokenFactory": "0xEffA78888Dc1b6033286E5dF9b170bc5223178AB",
"RandomNoManager": "0xC6eF45F5Add040800D30FE6dEe01b4EBC4BfC467"
"Governance": "0x4a33c6f8CEc5a8D8A5Dca2ec43bc0f78f132d31b",
"BlockManager": "0x2B28f0C3c74ADf9c5C6B3e1a998Ed37BDfF64f53",
"CollectionManager": "0xFe8627C79E85447c3ea643F388613D5E69C8Ca4a",
"StakeManager": "0xC5d2795324B40475F99739017DeA9eD946008006",
"RewardManager": "0x161F55f7019B67D24E05D0f018cc7f9ba2cdFC22",
"VoteManager": "0xeDA9a9c1F7E36cB2F90f902dF06acE880EC18e83",
"Delegator": "0x7e325b078Cee5De7795672EE59b7Cd7DF4e7a79b",
"RAZOR": "0xCA46B70cA3c510Ce9D0c43D25817032e2F5354c0",
"StakedTokenFactory": "0x24f11293993f71CAcA17bD182F3351E5c46910c5",
"RandomNoManager": "0x59AE1bE01C74ABCBb4AE0c24CCF9C30d7f638A0F"
}
21 changes: 10 additions & 11 deletions addresses/testnet.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"Governance": "0x0b9CC11E7f7D3D4f9bBc0cCaB85b73B96C322c78",
"BlockManager": "0x076df1c2d81C40D30DF115Ab68A13251fBD3FFA4",
"CollectionManager": "0x83f4D7ad6dD366c3F04Af45a1437c77636b03388",
"StakeManager": "0xf99a873a6afdF1b24388ac02ea0f1CFE3c70A80b",
"RewardManager": "0x522d2A51639332388dA4788DF59fB4E598278fAd",
"VoteManager": "0x2399D4d92b4D8762971605d0bC9597F780852CC4",
"Delegator": "0x81c72fB60d19Bfc3A0adDfE394501150d290cd66",
"RAZOR": "0x504C6635af1e7E6fdc586c8A89973783b9281A77",
"StakedTokenFactory": "0xf271bd91104946Cb8e43BC0e83423ed073ab136e",
"RandomNoManager": "0x2dc9E4663675c933f78D97cDD44463ee9C43144c",
"DelegatorV2": "0x4e9E5AE58Fb6d7Ca5b79A196b8d0FCF7CA15C100"
"Governance": "0x0C91e21D91510A1e95cd3507474c0ac1F620389d",
"BlockManager": "0x1eB1aD4C24cf2CA2027C05a28e78A117fDACD9F9",
"CollectionManager": "0xAFC593871Ab8EE89fd79B2ebd9F1f502268732b9",
"StakeManager": "0x7ce95141358FeF127d3F79f7a5C21C6c2afa1cA3",
"RewardManager": "0xbaa2e7509AdB5762f33064Ad762dF1136184Ef7D",
"VoteManager": "0x57a996015D831F6f4818ff962ffE405b6c6d4B21",
"Delegator": "0x63F82745aBe00c43a71ff2A48E65B281f72Bb54D",
"RAZOR": "0x91d07a181e2Fb787204Ae82B28c69e278C05ac70",
"StakedTokenFactory": "0x047f5865e666DCc278ad3bd8de8503D35d5278Ea",
"RandomNoManager": "0x3A6bbfBBe24F5F5D20F6a7265A0F602d155C2471"
}
65 changes: 26 additions & 39 deletions cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,17 @@ type cachedData struct {
}

type LocalCache struct {
stop chan struct{}

wg sync.WaitGroup
mu sync.RWMutex
URLs map[string]cachedData //URLs
}

func NewLocalCache(cleanupInterval time.Duration) *LocalCache {
lc := &LocalCache{
// NewLocalCache creates a new LocalCache instance
func NewLocalCache() *LocalCache {
return &LocalCache{
URLs: make(map[string]cachedData),
stop: make(chan struct{}),
}

lc.wg.Add(1)
go func(cleanupInterval time.Duration) {
defer lc.wg.Done()
lc.cleanupLoop(cleanupInterval)
}(cleanupInterval)

return lc
}

func (lc *LocalCache) cleanupLoop(interval time.Duration) {
t := time.NewTicker(interval)
defer t.Stop()

for {
select {
case <-lc.stop:
return
case <-t.C:
lc.mu.Lock()
for url, cu := range lc.URLs {
if cu.expireAtTimestamp <= time.Now().Unix() {
delete(lc.URLs, url)
}
}
lc.mu.Unlock()
}
}
}

func (lc *LocalCache) StopCleanup() {
close(lc.stop)
lc.wg.Wait()
}

func (lc *LocalCache) Update(data []byte, url string, expireAtTimestamp int64) {
lc.mu.Lock()
defer lc.mu.Unlock()
Expand All @@ -80,3 +44,26 @@ func (lc *LocalCache) Read(url string) ([]byte, bool) {

return cacheData.Result, true
}

// ClearAll deletes all entries in the cache
func (lc *LocalCache) ClearAll() {
lc.mu.Lock()
defer lc.mu.Unlock()

for key := range lc.URLs {
delete(lc.URLs, key)
}
}

// Cleanup removes expired cache entries
func (lc *LocalCache) Cleanup() {
lc.mu.Lock()
defer lc.mu.Unlock()

for url, data := range lc.URLs {
// Remove expired data after the expireAtTimestamp is passed
if data.expireAtTimestamp <= time.Now().Unix() {
delete(lc.URLs, url)
}
}
}
4 changes: 4 additions & 0 deletions cmd/cmd-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ func (*UtilsStruct) GetEpochAndState(client *ethclient.Client) (uint32, int64, e
if err != nil {
return 0, 0, err
}
err = ValidateBufferPercentLimit(client, bufferPercent)
if err != nil {
return 0, 0, err
}
latestHeader, err := clientUtils.GetLatestBlockWithRetry(client)
if err != nil {
log.Error("Error in fetching block: ", err)
Expand Down
31 changes: 31 additions & 0 deletions cmd/cmd-utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ func TestGetEpochAndState(t *testing.T) {
latestHeaderErr error
bufferPercent int32
bufferPercentErr error
stateBuffer uint64
stateBufferErr error
state int64
stateErr error
stateName string
Expand All @@ -37,6 +39,7 @@ func TestGetEpochAndState(t *testing.T) {
epoch: 4,
latestHeader: &Types.Header{},
bufferPercent: 20,
stateBuffer: 5,
state: 0,
stateName: "commit",
},
Expand All @@ -50,6 +53,7 @@ func TestGetEpochAndState(t *testing.T) {
epochErr: errors.New("epoch error"),
latestHeader: &Types.Header{},
bufferPercent: 20,
stateBuffer: 5,
state: 0,
stateName: "commit",
},
Expand All @@ -76,6 +80,7 @@ func TestGetEpochAndState(t *testing.T) {
epoch: 4,
latestHeader: &Types.Header{},
bufferPercent: 20,
stateBuffer: 5,
stateErr: errors.New("state error"),
},
wantEpoch: 0,
Expand All @@ -88,20 +93,46 @@ func TestGetEpochAndState(t *testing.T) {
epoch: 4,
latestHeaderErr: errors.New("header error"),
bufferPercent: 20,
stateBuffer: 5,
state: 0,
stateName: "commit",
},
wantEpoch: 0,
wantState: 0,
wantErr: errors.New("header error"),
},
{
name: "Test 6: When validating buffer percent limit fails",
args: args{
epoch: 4,
latestHeader: &Types.Header{},
bufferPercent: 50,
stateBuffer: 10,
},
wantEpoch: 0,
wantState: 0,
wantErr: errors.New("buffer percent exceeds limit"),
},
{
name: "Test 7: When there is an error in validating buffer percent limit",
args: args{
epoch: 4,
latestHeader: &Types.Header{},
bufferPercent: 50,
stateBufferErr: errors.New("state buffer error"),
},
wantEpoch: 0,
wantState: 0,
wantErr: errors.New("state buffer error"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
SetUpMockInterfaces()

utilsMock.On("GetEpoch", mock.AnythingOfType("*ethclient.Client")).Return(tt.args.epoch, tt.args.epochErr)
cmdUtilsMock.On("GetBufferPercent").Return(tt.args.bufferPercent, tt.args.bufferPercentErr)
utilsMock.On("GetStateBuffer", mock.Anything).Return(tt.args.stateBuffer, tt.args.stateBufferErr)
clientUtilsMock.On("GetLatestBlockWithRetry", mock.Anything).Return(tt.args.latestHeader, tt.args.latestHeaderErr)
utilsMock.On("GetBufferedState", mock.Anything, mock.Anything, mock.Anything).Return(tt.args.state, tt.args.stateErr)

Expand Down
12 changes: 3 additions & 9 deletions cmd/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ package cmd
import (
"encoding/hex"
"errors"
Types "github.com/ethereum/go-ethereum/core/types"
"math/big"
"razor/cache"
"razor/core"
"razor/core/types"
"razor/pkg/bindings"
"razor/utils"
"sync"
"time"

Types "github.com/ethereum/go-ethereum/core/types"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
Expand Down Expand Up @@ -79,8 +76,8 @@ func (*UtilsStruct) HandleCommitState(client *ethclient.Client, epoch uint32, se

var wg sync.WaitGroup

log.Debug("Creating a local cache which will store API result and expire at the end of commit state")
commitParams.LocalCache = cache.NewLocalCache(time.Second * time.Duration(core.StateLength))
// Clean up any expired API results cache data before performing the commit
commitParams.LocalCache.Cleanup()

log.Debug("Iterating over all the collections...")
for i := 0; i < int(numActiveCollections); i++ {
Expand Down Expand Up @@ -129,7 +126,6 @@ func (*UtilsStruct) HandleCommitState(client *ethclient.Client, epoch uint32, se
if err != nil {
// Returning the first error from the error channel
log.Error("Error in getting collection data: ", err)
commitParams.LocalCache.StopCleanup()
return types.CommitData{}, err
}
}
Expand All @@ -139,8 +135,6 @@ func (*UtilsStruct) HandleCommitState(client *ethclient.Client, epoch uint32, se
log.Debug("HandleCommitState: SeqAllottedCollections: ", seqAllottedCollections)
log.Debug("HandleCommitState: Leaves: ", leavesOfTree)

commitParams.LocalCache.StopCleanup()

return types.CommitData{
AssignedCollections: assignedCollections,
SeqAllottedCollections: seqAllottedCollections,
Expand Down
5 changes: 2 additions & 3 deletions cmd/commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"razor/utils"
"reflect"
"testing"
"time"
)

func TestCommit(t *testing.T) {
Expand Down Expand Up @@ -226,7 +225,7 @@ func TestHandleCommitState(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
localCache := cache.NewLocalCache(time.Second * 10)
localCache := cache.NewLocalCache()
commitParams := &types.CommitParams{
LocalCache: localCache,
}
Expand Down Expand Up @@ -396,7 +395,7 @@ func BenchmarkHandleCommitState(b *testing.B) {
for _, v := range table {
b.Run(fmt.Sprintf("Number_Of_Active_Collections%d", v.numActiveCollections), func(b *testing.B) {
for i := 0; i < b.N; i++ {
localCache := cache.NewLocalCache(time.Second * 10)
localCache := cache.NewLocalCache()
commitParams := &types.CommitParams{
LocalCache: localCache,
}
Expand Down
Loading

0 comments on commit fc1172e

Please sign in to comment.