Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implemented batching of multiple getStakeSnapshot RPC calls #1218

Conversation

Yashk767
Copy link
Contributor

@Yashk767 Yashk767 commented Jun 19, 2024

Description

  • Implemented a generic batch call function where contract address, contract abi and function string input is expected as paramter.
  • Used the same generic batch call function to get stakeSnapshot values for all the stakers in calculating biggest staker.
  • Added tests for each error case for performing batch calls.

Fixes #1217

How Has This Been Tested?

Ran a staker on staging and compared the biggest staker stake and respective staker Id calculated from the current serial implementation of RPC calls.

  • Also added tests to get the biggest staker and associated Id.

@Yashk767 Yashk767 marked this pull request as ready for review June 19, 2024 18:17
cmd/propose.go Show resolved Hide resolved
cmd/propose.go Outdated Show resolved Hide resolved
@Yashk767 Yashk767 force-pushed the yash/raz-858-batch-getstakesnapshot-contract-calls-in-calculating-biggest branch from 3efcdaa to 0fe5306 Compare July 19, 2024 11:16
@Yashk767 Yashk767 changed the base branch from develop to feature/v1.2.0 July 19, 2024 11:17
@Yashk767
Copy link
Contributor Author

Updated the target branch from develop to new rebased feature/v1.2.0 branch.
So there was a need to rebase the base branch.
cc @ashish10677 @rajkharvar

@ashish10677
Copy link
Member

I think we should implement batch calls with retry @Yashk767 to avoid issues in future.

@Yashk767
Copy link
Contributor Author

I think we should implement batch calls with retry @Yashk767 to avoid issues in future.

yes okay makes sense, we can have a generic batch function with retry implemented in the same way we did at other place. @ashish10677

@Yashk767
Copy link
Contributor Author

I think we should implement batch calls with retry @Yashk767 to avoid issues in future.

Implemented with covering all test scenarios in 08edf3d
cc @ashish10677 @rajkharvar

cmd/propose.go Outdated Show resolved Hide resolved
@Yashk767 Yashk767 merged commit 2ded12a into feature/v1.2.0 Jul 30, 2024
3 checks passed
@Yashk767 Yashk767 deleted the yash/raz-858-batch-getstakesnapshot-contract-calls-in-calculating-biggest branch July 31, 2024 13:27
Yashk767 added a commit to Yashk767/razor-go that referenced this pull request Aug 9, 2024
* refactor: used the same keystore instance to fetch pKey everytime  (razor-network#1200)

* refactor: used regex instead of ks.Accounts to match keystore file

* refactor: added more extensive realistic testing for fetching of private key

* ci: ignore test-accounts directory in coverage

* refactor: added test when multiple timestamps keystore file present for same account

* refactor: covered lower and upper case addresses

* revert: optimised fetching key from keystore dir

* fix: reused same keystore instance for fetching pkey every time

* refactor: added realistic tests for fetching of pKey

* refactor: removed unused accounts() from interface

* refactor: used AccountManager struct with a keystore as a method caller

* refactor: fix tests

* refactor: removed commented test code

* refactor: returned interface instead of type struct instance from AccountManagerForKeystore()

* refactor: fixed create tests

* refactor: compared expected and returned pKey values in tests

* refactor: requested changes

* fix: changed keyword to const for defining constants (razor-network#1206)

* fix: changed keyword to const for defining constants

* fix: fixed lint error by adding explicit type for ProcessRequestRetryDelay

* refactor: updated RPC to op sepolia in testing post request

* refactor: used a common http client for all the requests (razor-network#1201)

* refactor: used a common http client throughout for all the APIs

* fix: handled goroutine exit

* refactor: golangci-lint fix

* refactor: defined http client fields in constants.go

* refactor: defined http client as a field to HttpClient struct used as a method caller

* refactor: revert InvokeFunctionWithTimeout() changes

* refator: fixed tests

* refactor: moved httpClient as the first parameter in api.go functions signature

* refactor: removed exporting of client field from HttpClient struct

* refactor: changed var to const keyword for http client constants

* refactor: Optimised number of `GetBlockNumber` and `GetStakerId` eth calls (razor-network#1204)

* refactor: Used getStakerId() only once

* refactor: used exisiting blockNumber from Vote() in dependent functions

* refactor: fixed tests after header being passed as a parameter

* fix: removed continous retries if error in fetching block number in logger

* refactor: added tests when context is cancelled for Vote()

* refactor: fixed vote tests

* fix: updated default config values to support both 20 min and shorter 5 min epoch  (razor-network#1209)

* fix: updated config default max, min values to support longer epoch

* fix: updated default config values in config.sh if builded from source

* feat: Implemented batching of multiple getStakeSnapshot RPC calls (razor-network#1218)

* feat: Implemented batching of multiple getStakeSnapshot RPC calls

* refactor: added method caller to batch call functions and added it to interface

* refactor: added new and fixed exisiting tests

* refactor: fixed log with correct staker Id associated for stake

* refactor: moved getStakeSnapshot string to constants

* refactor: implemented generic batch call function

* refactor: used generic batch call for getStakeSnapshot

* refactor: removed timeout and address parameter from GetBiggestStakeAnId()

* refactor: fetching jobs and collections from asset caches (razor-network#1207)

* feat: added jobs/collections cache structs

* feat: added support for using jobs/collections caches

* refactor: added time constants required for job/collection cache updates

* fix: fixed resetting of cache every expiry interval

* refactor: fixed error log

* refactor: fix utils tests

* refactor: added httpClient instance in commitParams struct

* refactor: removed resetting of cache as its not required

* feat: checked for job/collection events at the start of commit state in main go routine

* refactor: used FilterLogswithRetry and fixed other tests

* refactor: fixed benchmark

* refactor: moved all the event names to constants

* refactor: requested changes

* refactor: removed custom http client struct and directly used inbuilt http.Client

* refcator: updated default logFileMaxAge and logFileMaxBackups (razor-network#1221)

* chore: updated default deployment parameters and version for `v1.2.0` (razor-network#1222)

* chore: updated default addresses and chainId to mainnet addresses and chainId

* chore: updated testnet addresses to staging europa 20 min epoch

* chore: updated version to v1.2.0

* refactor: fixed tests due to state length change to 1200
Yashk767 added a commit that referenced this pull request Aug 9, 2024
* refactor: used the same keystore instance to fetch pKey everytime  (#1200)

* refactor: used regex instead of ks.Accounts to match keystore file

* refactor: added more extensive realistic testing for fetching of private key

* ci: ignore test-accounts directory in coverage

* refactor: added test when multiple timestamps keystore file present for same account

* refactor: covered lower and upper case addresses

* revert: optimised fetching key from keystore dir

* fix: reused same keystore instance for fetching pkey every time

* refactor: added realistic tests for fetching of pKey

* refactor: removed unused accounts() from interface

* refactor: used AccountManager struct with a keystore as a method caller

* refactor: fix tests

* refactor: removed commented test code

* refactor: returned interface instead of type struct instance from AccountManagerForKeystore()

* refactor: fixed create tests

* refactor: compared expected and returned pKey values in tests

* refactor: requested changes

* fix: changed keyword to const for defining constants (#1206)

* fix: changed keyword to const for defining constants

* fix: fixed lint error by adding explicit type for ProcessRequestRetryDelay

* refactor: updated RPC to op sepolia in testing post request

* refactor: used a common http client for all the requests (#1201)

* refactor: used a common http client throughout for all the APIs

* fix: handled goroutine exit

* refactor: golangci-lint fix

* refactor: defined http client fields in constants.go

* refactor: defined http client as a field to HttpClient struct used as a method caller

* refactor: revert InvokeFunctionWithTimeout() changes

* refator: fixed tests

* refactor: moved httpClient as the first parameter in api.go functions signature

* refactor: removed exporting of client field from HttpClient struct

* refactor: changed var to const keyword for http client constants

* refactor: Optimised number of `GetBlockNumber` and `GetStakerId` eth calls (#1204)

* refactor: Used getStakerId() only once

* refactor: used exisiting blockNumber from Vote() in dependent functions

* refactor: fixed tests after header being passed as a parameter

* fix: removed continous retries if error in fetching block number in logger

* refactor: added tests when context is cancelled for Vote()

* refactor: fixed vote tests

* fix: updated default config values to support both 20 min and shorter 5 min epoch  (#1209)

* fix: updated config default max, min values to support longer epoch

* fix: updated default config values in config.sh if builded from source

* feat: Implemented batching of multiple getStakeSnapshot RPC calls (#1218)

* feat: Implemented batching of multiple getStakeSnapshot RPC calls

* refactor: added method caller to batch call functions and added it to interface

* refactor: added new and fixed exisiting tests

* refactor: fixed log with correct staker Id associated for stake

* refactor: moved getStakeSnapshot string to constants

* refactor: implemented generic batch call function

* refactor: used generic batch call for getStakeSnapshot

* refactor: removed timeout and address parameter from GetBiggestStakeAnId()

* refactor: fetching jobs and collections from asset caches (#1207)

* feat: added jobs/collections cache structs

* feat: added support for using jobs/collections caches

* refactor: added time constants required for job/collection cache updates

* fix: fixed resetting of cache every expiry interval

* refactor: fixed error log

* refactor: fix utils tests

* refactor: added httpClient instance in commitParams struct

* refactor: removed resetting of cache as its not required

* feat: checked for job/collection events at the start of commit state in main go routine

* refactor: used FilterLogswithRetry and fixed other tests

* refactor: fixed benchmark

* refactor: moved all the event names to constants

* refactor: requested changes

* refactor: removed custom http client struct and directly used inbuilt http.Client

* refcator: updated default logFileMaxAge and logFileMaxBackups (#1221)

* chore: updated default deployment parameters and version for `v1.2.0` (#1222)

* chore: updated default addresses and chainId to mainnet addresses and chainId

* chore: updated testnet addresses to staging europa 20 min epoch

* chore: updated version to v1.2.0

* refactor: fixed tests due to state length change to 1200

* refactor: removed redundant and incorrect log for staker id (#1226)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants