From c8d93c6aef7f92446f085270f23a5e705f470ed3 Mon Sep 17 00:00:00 2001 From: Yashk767 <76935991+Yashk767@users.noreply.github.com> Date: Mon, 17 Apr 2023 11:57:19 +0530 Subject: [PATCH] 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 * 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 * Add logs for dispute and propose. Signed-off-by: Ashish Kumar Mishra * Fix tests. Signed-off-by: Ashish Kumar Mishra * Suppress unneccessary error logs. (#935) Signed-off-by: Ashish Kumar Mishra * 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 * 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 Co-authored-by: Shekhar Gaur <65169767+shekhar2807@users.noreply.github.com> Co-authored-by: Ashish Kumar Mishra Co-authored-by: Shyam Patel Co-authored-by: Raj Kharvar Co-authored-by: Skanda Bhat * 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 Co-authored-by: Shekhar Gaur <65169767+shekhar2807@users.noreply.github.com> Co-authored-by: Ashish Kumar Mishra Co-authored-by: Shyam Patel Co-authored-by: Raj Kharvar Co-authored-by: Skanda Bhat * 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 * 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 * 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 * 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 * 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 * Add logs for dispute and propose. Signed-off-by: Ashish Kumar Mishra * Fix tests. Signed-off-by: Ashish Kumar Mishra * Suppress unneccessary error logs. (#935) Signed-off-by: Ashish Kumar Mishra * 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 * 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 Co-authored-by: Shekhar Gaur <65169767+shekhar2807@users.noreply.github.com> Co-authored-by: Ashish Kumar Mishra Co-authored-by: Shyam Patel Co-authored-by: Raj Kharvar Co-authored-by: Skanda Bhat * 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 Co-authored-by: Shekhar Gaur <65169767+shekhar2807@users.noreply.github.com> Co-authored-by: Ashish Kumar Mishra Co-authored-by: Shyam Patel Co-authored-by: Raj Kharvar Co-authored-by: Skanda Bhat * 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 * 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 * 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 * Deleted password file (#1040) Signed-off-by: Ashish Kumar Mishra Co-authored-by: Shekhar Gaur <65169767+shekhar2807@users.noreply.github.com> Co-authored-by: Ashish Kumar Mishra Co-authored-by: Shyam Patel Co-authored-by: Raj Kharvar Co-authored-by: Skanda Bhat Co-authored-by: Shrikant upadhyay * 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 * 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 * Add logs for dispute and propose. Signed-off-by: Ashish Kumar Mishra * Fix tests. Signed-off-by: Ashish Kumar Mishra * Suppress unneccessary error logs. (#935) Signed-off-by: Ashish Kumar Mishra * 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 * 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 Co-authored-by: Shekhar Gaur <65169767+shekhar2807@users.noreply.github.com> Co-authored-by: Ashish Kumar Mishra Co-authored-by: Shyam Patel Co-authored-by: Raj Kharvar Co-authored-by: Skanda Bhat * 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 Co-authored-by: Shekhar Gaur <65169767+shekhar2807@users.noreply.github.com> Co-authored-by: Ashish Kumar Mishra Co-authored-by: Shyam Patel Co-authored-by: Raj Kharvar Co-authored-by: Skanda Bhat * 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 * 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 * 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 * 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 Co-authored-by: Yashk767 <76935991+Yashk767@users.noreply.github.com> Co-authored-by: Shekhar Gaur <65169767+shekhar2807@users.noreply.github.com> Co-authored-by: Shyam Patel Co-authored-by: Raj Kharvar Co-authored-by: Skanda Bhat Co-authored-by: Shrikant upadhyay Co-authored-by: YashK * updated CI for dockerhub token. (#1052) * updated version to * Revert import change --------- Signed-off-by: Ashish Kumar Mishra Co-authored-by: Shekhar Gaur <65169767+shekhar2807@users.noreply.github.com> Co-authored-by: Ashish Kumar Mishra Co-authored-by: Shyam Patel Co-authored-by: Raj Kharvar Co-authored-by: Skanda Bhat Co-authored-by: Shrikant upadhyay --------- Signed-off-by: Ashish Kumar Mishra Co-authored-by: Shekhar Gaur <65169767+shekhar2807@users.noreply.github.com> Co-authored-by: Ashish Kumar Mishra Co-authored-by: Shyam Patel Co-authored-by: Raj Kharvar Co-authored-by: Skanda Bhat Co-authored-by: Shrikant upadhyay --- README.md | 1 + cmd/config-utils.go | 22 ++++++ cmd/config-utils_test.go | 120 +++++++++++++++++++++++++------ cmd/interface.go | 3 + cmd/mocks/flag_set_interface.go | 42 +++++++++++ cmd/mocks/utils_cmd_interface.go | 21 ++++++ cmd/reveal.go | 1 + cmd/root.go | 3 + cmd/setConfig.go | 12 +++- cmd/setConfig_test.go | 18 +++++ cmd/struct-utils.go | 11 +++ core/constants.go | 1 + core/types/configurations.go | 1 + core/version.go | 8 +-- utils/options.go | 4 ++ 15 files changed, 240 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 31f1e36a..bb7abf3c 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ There are a set of parameters that are configurable. These include: - Gas Price: The value of gas price if you want to set manually. If you don't provide any value or simply keep it to 1, the razor client will automatically calculate the optimum gas price and send it. - Log Level: Normally debug logs are not logged into the log file. But if you want you can set `logLevel` to `debug` and fetch the debug logs. - Gas Limit: The value with which the gas limit will be multiplied while sending every transaction. +- Gas Limit Override: This value would be used as a gas limit for all the transactions instead of estimating for each transaction. - RPC Timeout: This is the threshold number of seconds after which any contract and client calls will time out. The config is set while the build is generated, but if you need to change any of the above parameter, you can use the `setConfig` command. diff --git a/cmd/config-utils.go b/cmd/config-utils.go index 17d533e2..7b424645 100644 --- a/cmd/config-utils.go +++ b/cmd/config-utils.go @@ -49,6 +49,10 @@ func (*UtilsStruct) GetConfigData() (types.Configurations, error) { if err != nil { return config, err } + gasLimitOverride, err := cmdUtils.GetGasLimitOverride() + if err != nil { + return config, err + } rpcTimeout, err := cmdUtils.GetRPCTimeout() if err != nil { return config, err @@ -60,6 +64,7 @@ func (*UtilsStruct) GetConfigData() (types.Configurations, error) { config.GasPrice = gasPrice config.LogLevel = logLevel config.GasLimitMultiplier = gasLimit + config.GasLimitOverride = gasLimitOverride config.RPCTimeout = rpcTimeout utils.RPCTimeout = rpcTimeout @@ -189,6 +194,23 @@ func (*UtilsStruct) GetGasLimit() (float32, error) { return gasLimit, nil } +//This function returns the gas limit to override +func (*UtilsStruct) GetGasLimitOverride() (uint64, error) { + gasLimitOverride, err := flagSetUtils.GetRootUint64GasLimitOverride() + if err != nil { + return uint64(core.DefaultGasLimitOverride), err + } + if gasLimitOverride == 0 { + if viper.IsSet("gasLimitOverride") { + gasLimitOverride = viper.GetUint64("gasLimitOverride") + } else { + gasLimitOverride = uint64(core.DefaultGasLimitOverride) + log.Debug("GasLimitOverride is not set, taking its default value ", gasLimitOverride) + } + } + return gasLimitOverride, nil +} + //This function returns the RPC timeout func (*UtilsStruct) GetRPCTimeout() (int64, error) { rpcTimeout, err := flagSetUtils.GetRootInt64RPCTimeout() diff --git a/cmd/config-utils_test.go b/cmd/config-utils_test.go index 957329c4..4dfff5e3 100644 --- a/cmd/config-utils_test.go +++ b/cmd/config-utils_test.go @@ -26,26 +26,29 @@ func TestGetConfigData(t *testing.T) { WaitTime: 1, LogLevel: "debug", GasLimitMultiplier: 3, + GasLimitOverride: 1000000, RPCTimeout: 10, } type args struct { - provider string - providerErr error - gasMultiplier float32 - gasMultiplierErr error - bufferPercent int32 - bufferPercentErr error - waitTime int32 - waitTimeErr error - gasPrice int32 - gasPriceErr error - logLevel string - logLevelErr error - gasLimit float32 - rpcTimeout int64 - rpcTimeoutErr error - gasLimitErr error + provider string + providerErr error + gasMultiplier float32 + gasMultiplierErr error + bufferPercent int32 + bufferPercentErr error + waitTime int32 + waitTimeErr error + gasPrice int32 + gasPriceErr error + logLevel string + logLevelErr error + gasLimit float32 + gasLimitOverride uint64 + gasLimitOverrideErr error + rpcTimeout int64 + rpcTimeoutErr error + gasLimitErr error } tests := []struct { name string @@ -56,13 +59,14 @@ func TestGetConfigData(t *testing.T) { { name: "Test 1: When GetConfigData function executes successfully", args: args{ - provider: "", - gasMultiplier: 1, - bufferPercent: 20, - waitTime: 1, - logLevel: "debug", - gasLimit: 3, - rpcTimeout: 10, + provider: "", + gasMultiplier: 1, + bufferPercent: 20, + waitTime: 1, + logLevel: "debug", + gasLimit: 3, + gasLimitOverride: 1000000, + rpcTimeout: 10, }, want: configData, wantErr: nil, @@ -131,6 +135,14 @@ func TestGetConfigData(t *testing.T) { want: config, wantErr: errors.New("rpcTimeout error"), }, + { + name: "When there is an error in getitng gasLimitOverride", + args: args{ + gasLimitOverrideErr: errors.New("gasLimitOverride error"), + }, + want: config, + wantErr: errors.New("gasLimitOverride error"), + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -143,6 +155,7 @@ func TestGetConfigData(t *testing.T) { cmdUtilsMock.On("GetGasPrice").Return(tt.args.gasPrice, tt.args.gasPriceErr) cmdUtilsMock.On("GetLogLevel").Return(tt.args.logLevel, tt.args.logLevelErr) cmdUtilsMock.On("GetGasLimit").Return(tt.args.gasLimit, tt.args.gasLimitErr) + cmdUtilsMock.On("GetGasLimitOverride").Return(tt.args.gasLimitOverride, tt.args.gasLimitOverrideErr) cmdUtilsMock.On("GetBufferPercent").Return(tt.args.bufferPercent, tt.args.bufferPercentErr) cmdUtilsMock.On("GetRPCTimeout").Return(tt.args.rpcTimeout, tt.args.rpcTimeoutErr) @@ -287,6 +300,67 @@ func TestGetGasLimit(t *testing.T) { } } +func TestGetGasLimitOverride(t *testing.T) { + type args struct { + gasLimitOverride uint64 + gasLimitOverrideErr error + } + tests := []struct { + name string + args args + want uint64 + wantErr error + }{ + { + name: "Test 1: When getGasLimitOverride function executes successfully", + args: args{ + gasLimitOverride: 5000000, + }, + want: 5000000, + wantErr: nil, + }, + { + name: "Test 2: When gasLimitOverride is 0", + args: args{ + gasLimitOverride: 0, + }, + want: 0, + wantErr: nil, + }, + { + name: "Test 3: When there is an error in getting gasLimitOverride", + args: args{ + gasLimitOverrideErr: errors.New("gasLimitOverride error"), + }, + want: 0, + wantErr: errors.New("gasLimitOverride error"), + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + flagSetUtilsMock := new(mocks.FlagSetInterface) + flagSetUtils = flagSetUtilsMock + + flagSetUtilsMock.On("GetRootUint64GasLimitOverride").Return(tt.args.gasLimitOverride, tt.args.gasLimitOverrideErr) + utils := &UtilsStruct{} + + got, err := utils.GetGasLimitOverride() + if got != tt.want { + t.Errorf("getGasLimitOverride() got = %v, want %v", got, tt.want) + } + if err == nil || tt.wantErr == nil { + if err != tt.wantErr { + t.Errorf("Error for getGasLimitOverride function, got = %v, want = %v", err, tt.wantErr) + } + } else { + if err.Error() != tt.wantErr.Error() { + t.Errorf("Error for getGasLimitOverride function, got = %v, want = %v", err, tt.wantErr) + } + } + }) + } +} + func TestGetGasPrice(t *testing.T) { type args struct { gasPrice int32 diff --git a/cmd/interface.go b/cmd/interface.go index 500bb926..7278a08a 100644 --- a/cmd/interface.go +++ b/cmd/interface.go @@ -194,6 +194,7 @@ type FlagSetInterface interface { GetInt32Wait(flagSet *pflag.FlagSet) (int32, error) GetInt32GasPrice(flagSet *pflag.FlagSet) (int32, error) GetFloat32GasLimit(flagSet *pflag.FlagSet) (float32, error) + GetUint64GasLimitOverride(flagSet *pflag.FlagSet) (uint64, error) GetStringLogLevel(flagSet *pflag.FlagSet) (string, error) GetInt64RPCTimeout(flagSet *pflag.FlagSet) (int64, error) GetUint32BountyId(flagSet *pflag.FlagSet) (uint32, error) @@ -204,6 +205,7 @@ type FlagSetInterface interface { GetRootInt32GasPrice() (int32, error) GetRootStringLogLevel() (string, error) GetRootFloat32GasLimit() (float32, error) + GetRootUint64GasLimitOverride() (uint64, error) GetRootInt64RPCTimeout() (int64, error) GetStringFrom(flagSet *pflag.FlagSet) (string, error) GetStringTo(flagSet *pflag.FlagSet) (string, error) @@ -241,6 +243,7 @@ type UtilsCmdInterface interface { GetGasPrice() (int32, error) GetLogLevel() (string, error) GetGasLimit() (float32, error) + GetGasLimitOverride() (uint64, error) GetBufferPercent() (int32, error) GetRPCTimeout() (int64, error) GetConfigData() (types.Configurations, error) diff --git a/cmd/mocks/flag_set_interface.go b/cmd/mocks/flag_set_interface.go index 1260493d..9788347a 100644 --- a/cmd/mocks/flag_set_interface.go +++ b/cmd/mocks/flag_set_interface.go @@ -369,6 +369,27 @@ func (_m *FlagSetInterface) GetRootStringProvider() (string, error) { return r0, r1 } +// GetRootUint64GasLimitOverride provides a mock function with given fields: +func (_m *FlagSetInterface) GetRootUint64GasLimitOverride() (uint64, error) { + ret := _m.Called() + + var r0 uint64 + if rf, ok := ret.Get(0).(func() uint64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(uint64) + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // GetStringAddress provides a mock function with given fields: flagSet func (_m *FlagSetInterface) GetStringAddress(flagSet *pflag.FlagSet) (string, error) { ret := _m.Called(flagSet) @@ -835,6 +856,27 @@ func (_m *FlagSetInterface) GetUint32Tolerance(flagSet *pflag.FlagSet) (uint32, return r0, r1 } +// GetUint64GasLimitOverride provides a mock function with given fields: flagSet +func (_m *FlagSetInterface) GetUint64GasLimitOverride(flagSet *pflag.FlagSet) (uint64, error) { + ret := _m.Called(flagSet) + + var r0 uint64 + if rf, ok := ret.Get(0).(func(*pflag.FlagSet) uint64); ok { + r0 = rf(flagSet) + } else { + r0 = ret.Get(0).(uint64) + } + + var r1 error + if rf, ok := ret.Get(1).(func(*pflag.FlagSet) error); ok { + r1 = rf(flagSet) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // GetUint8Commission provides a mock function with given fields: flagSet func (_m *FlagSetInterface) GetUint8Commission(flagSet *pflag.FlagSet) (uint8, error) { ret := _m.Called(flagSet) diff --git a/cmd/mocks/utils_cmd_interface.go b/cmd/mocks/utils_cmd_interface.go index 21a44d96..960bbbd9 100644 --- a/cmd/mocks/utils_cmd_interface.go +++ b/cmd/mocks/utils_cmd_interface.go @@ -665,6 +665,27 @@ func (_m *UtilsCmdInterface) GetGasLimit() (float32, error) { return r0, r1 } +// GetGasLimitOverride provides a mock function with given fields: +func (_m *UtilsCmdInterface) GetGasLimitOverride() (uint64, error) { + ret := _m.Called() + + var r0 uint64 + if rf, ok := ret.Get(0).(func() uint64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(uint64) + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // GetGasPrice provides a mock function with given fields: func (_m *UtilsCmdInterface) GetGasPrice() (int32, error) { ret := _m.Called() diff --git a/cmd/reveal.go b/cmd/reveal.go index 0558bc87..af8e1a97 100644 --- a/cmd/reveal.go +++ b/cmd/reveal.go @@ -61,6 +61,7 @@ func (*UtilsStruct) Reveal(client *ethclient.Client, config types.Configurations Parameters: []interface{}{epoch, treeRevealData, signature}, }) log.Debugf("Executing Reveal transaction wih epoch = %d, treeRevealData = %v, signature = %v", epoch, treeRevealData, signature) + txnOpts.GasLimit = 50000000 txn, err := voteManagerUtils.Reveal(client, txnOpts, epoch, treeRevealData, signature) if err != nil { log.Error(err) diff --git a/cmd/root.go b/cmd/root.go index 833d7792..494dd28f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -20,6 +20,7 @@ var ( GasPrice int32 LogLevel string GasLimitMultiplier float32 + GasLimitOverride uint64 LogFile string RPCTimeout int64 ) @@ -61,6 +62,7 @@ func init() { rootCmd.PersistentFlags().Int32VarP(&GasPrice, "gasprice", "", -1, "gas price") rootCmd.PersistentFlags().StringVarP(&LogLevel, "logLevel", "", "", "log level") rootCmd.PersistentFlags().Float32VarP(&GasLimitMultiplier, "gasLimit", "", -1, "gas limit percentage increase") + rootCmd.PersistentFlags().Uint64VarP(&GasLimitOverride, "gasLimitOverride", "", 0, "gas limit to be over ridden for a transaction") rootCmd.PersistentFlags().StringVarP(&LogFile, "logFile", "", "", "name of log file") rootCmd.PersistentFlags().Int64VarP(&RPCTimeout, "rpcTimeout", "", 0, "RPC timeout if its not responding") rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") @@ -110,5 +112,6 @@ func setLogLevel() { log.Debugf("Gas Price: %d", config.GasPrice) log.Debugf("Log Level: %s", config.LogLevel) log.Debugf("Gas Limit: %.2f", config.GasLimitMultiplier) + log.Debugf("Gas Limit Override: %d", config.GasLimitOverride) log.Debugf("RPC Timeout: %d", config.RPCTimeout) } diff --git a/cmd/setConfig.go b/cmd/setConfig.go index bc91acfd..bd7ed9ad 100644 --- a/cmd/setConfig.go +++ b/cmd/setConfig.go @@ -54,6 +54,10 @@ func (*UtilsStruct) SetConfig(flagSet *pflag.FlagSet) error { if err != nil { return err } + gasLimitOverride, err := flagSetUtils.GetUint64GasLimitOverride(flagSet) + if err != nil { + return err + } gasLimit, err := flagSetUtils.GetFloat32GasLimit(flagSet) if err != nil { return err @@ -117,10 +121,13 @@ func (*UtilsStruct) SetConfig(flagSet *pflag.FlagSet) error { if gasLimit != -1 { viper.Set("gasLimit", gasLimit) } + if gasLimitOverride != 0 { + viper.Set("gasLimitOverride", gasLimitOverride) + } if rpcTimeout != 0 { viper.Set("rpcTimeout", rpcTimeout) } - if provider == "" && gasMultiplier == -1 && bufferPercent == 0 && waitTime == -1 && gasPrice == -1 && logLevel == "" && gasLimit == -1 && rpcTimeout == 0 { + if provider == "" && gasMultiplier == -1 && bufferPercent == 0 && waitTime == -1 && gasPrice == -1 && logLevel == "" && gasLimit == -1 && gasLimitOverride == 0 && rpcTimeout == 0 { viper.Set("provider", core.DefaultProvider) viper.Set("gasmultiplier", core.DefaultGasMultiplier) viper.Set("buffer", core.DefaultBufferPercent) @@ -128,6 +135,7 @@ func (*UtilsStruct) SetConfig(flagSet *pflag.FlagSet) error { viper.Set("gasprice", core.DefaultGasPrice) viper.Set("logLevel", core.DefaultLogLevel) viper.Set("gasLimit", core.DefaultGasLimit) + viper.Set("gasLimitOverride", core.DefaultGasLimitOverride) viper.Set("rpcTimeout", core.DefaultRPCTimeout) //viper.Set("exposeMetricsPort", "") log.Info("Config values set to default. Use setConfig to modify the values.") @@ -152,6 +160,7 @@ func init() { GasPrice int32 LogLevel string GasLimitMultiplier float32 + GasLimitOverride uint64 RPCTimeout int64 ExposeMetrics string CertFile string @@ -164,6 +173,7 @@ func init() { setConfig.Flags().Int32VarP(&GasPrice, "gasprice", "", -1, "custom gas price") setConfig.Flags().StringVarP(&LogLevel, "logLevel", "", "", "log level") setConfig.Flags().Float32VarP(&GasLimitMultiplier, "gasLimit", "", -1, "gas limit percentage increase") + setConfig.Flags().Uint64VarP(&GasLimitOverride, "gasLimitOverride", "", 0, "gas limit to be over ridden for a transaction") setConfig.Flags().Int64VarP(&RPCTimeout, "rpcTimeout", "", 0, "RPC timeout if its not responding") setConfig.Flags().StringVarP(&ExposeMetrics, "exposeMetrics", "", "", "port number") setConfig.Flags().StringVarP(&CertFile, "certFile", "", "", "ssl certificate path") diff --git a/cmd/setConfig_test.go b/cmd/setConfig_test.go index 23c32b80..d08a08d3 100644 --- a/cmd/setConfig_test.go +++ b/cmd/setConfig_test.go @@ -31,6 +31,8 @@ func TestSetConfig(t *testing.T) { configErr error gasLimitMultiplier float32 gasLimitMultiplierErr error + gasLimitOverride uint64 + gasLimitOverrideErr error rpcTimeout int64 rpcTimeoutErr error isFlagPassed bool @@ -282,6 +284,21 @@ func TestSetConfig(t *testing.T) { }, wantErr: errors.New("rpcTimeout error"), }, + { + name: "Test 17: When there is an error in getting gas limit to overrride", + args: args{ + provider: "http://127.0.0.1", + gasmultiplier: 2, + buffer: 20, + waitTime: 2, + gasPrice: 1, + logLevel: "debug", + path: "/home/config", + gasLimitMultiplier: -1, + gasLimitOverrideErr: errors.New("gasLimitOverride error"), + }, + wantErr: errors.New("gasLimitOverride error"), + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -304,6 +321,7 @@ func TestSetConfig(t *testing.T) { flagSetUtilsMock.On("GetInt32GasPrice", flagSet).Return(tt.args.gasPrice, tt.args.gasPriceErr) flagSetUtilsMock.On("GetStringLogLevel", flagSet).Return(tt.args.logLevel, tt.args.logLevelErr) flagSetUtilsMock.On("GetFloat32GasLimit", flagSet).Return(tt.args.gasLimitMultiplier, tt.args.gasLimitMultiplierErr) + flagSetUtilsMock.On("GetUint64GasLimitOverride", flagSet).Return(tt.args.gasLimitOverride, tt.args.gasLimitOverrideErr) flagSetUtilsMock.On("GetInt64RPCTimeout", flagSet).Return(tt.args.rpcTimeout, tt.args.rpcTimeoutErr) flagSetUtilsMock.On("GetStringExposeMetrics", flagSet).Return(tt.args.port, tt.args.portErr) flagSetUtilsMock.On("GetStringCertFile", flagSet).Return(tt.args.certFile, tt.args.certFileErr) diff --git a/cmd/struct-utils.go b/cmd/struct-utils.go index 5d93faab..f1b300ed 100644 --- a/cmd/struct-utils.go +++ b/cmd/struct-utils.go @@ -860,10 +860,16 @@ func (flagSetUtils FLagSetUtils) GetStringLogLevel(flagSet *pflag.FlagSet) (stri return flagSet.GetString("logLevel") } +//This function returns RPC timeout in Int64 func (flagSetUtils FLagSetUtils) GetInt64RPCTimeout(flagSet *pflag.FlagSet) (int64, error) { return flagSet.GetInt64("rpcTimeout") } +//This function returns GasLimit to override in Uint64 +func (flagSetUtils FLagSetUtils) GetUint64GasLimitOverride(flagSet *pflag.FlagSet) (uint64, error) { + return flagSet.GetUint64("gasLimitOverride") +} + //This function returns Gas Limit in Float32 func (flagSetUtils FLagSetUtils) GetFloat32GasLimit(flagSet *pflag.FlagSet) (float32, error) { return flagSet.GetFloat32("gasLimit") @@ -909,6 +915,11 @@ func (flagSetUtils FLagSetUtils) GetRootFloat32GasLimit() (float32, error) { return rootCmd.PersistentFlags().GetFloat32("gasLimit") } +//This function returns the gas limit to overridr of root in Uint64 +func (flagSetUtils FLagSetUtils) GetRootUint64GasLimitOverride() (uint64, error) { + return rootCmd.PersistentFlags().GetUint64("gasLimitOverride") +} + //This function returns the gas limit of root in Float32 func (flagSetUtils FLagSetUtils) GetRootInt64RPCTimeout() (int64, error) { return rootCmd.PersistentFlags().GetInt64("rpcTimeout") diff --git a/core/constants.go b/core/constants.go index 0bab7877..42de1291 100644 --- a/core/constants.go +++ b/core/constants.go @@ -21,6 +21,7 @@ var DefaultBufferPercent = 20 var DefaultGasPrice = 1 var DefaultWaitTime = 1 var DefaultGasLimit = 2 +var DefaultGasLimitOverride = 0 var DefaultRPCTimeout = 10 var DefaultLogLevel = "" diff --git a/core/types/configurations.go b/core/types/configurations.go index 4a8a0b7c..3cff2e4e 100644 --- a/core/types/configurations.go +++ b/core/types/configurations.go @@ -7,6 +7,7 @@ type Configurations struct { WaitTime int32 GasPrice int32 LogLevel string + GasLimitOverride uint64 GasLimitMultiplier float32 RPCTimeout int64 } diff --git a/core/version.go b/core/version.go index c4e88c5c..b323cf5a 100644 --- a/core/version.go +++ b/core/version.go @@ -3,10 +3,10 @@ package core import "fmt" const ( - VersionMajor = 1 // Major version component of the current release - VersionMinor = 0 // Minor version component of the current release - VersionPatch = 5 // Patch version component of the current release - VersionMeta = "" // Version metadata to append to the version string + VersionMajor = 1 // Major version component of the current release + VersionMinor = 0 // Minor version component of the current release + VersionPatch = 5 // Patch version component of the current release + VersionMeta = "patch2" // Version metadata to append to the version string ) // Version holds the textual version string. diff --git a/utils/options.go b/utils/options.go index d3e18cb3..4c21ba19 100644 --- a/utils/options.go +++ b/utils/options.go @@ -88,6 +88,10 @@ func (*UtilsStruct) GetGasPrice(client *ethclient.Client, config types.Configura } func (*UtilsStruct) GetGasLimit(transactionData types.TransactionOptions, txnOpts *bind.TransactOpts) (uint64, error) { + if transactionData.Config.GasLimitOverride != 0 { + log.Debugf("Taking the gas limit value = %d from config", transactionData.Config.GasLimitOverride) + return transactionData.Config.GasLimitOverride, nil + } if transactionData.MethodName == "" { return 0, nil }