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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set/Update cct from blockchain. #821

Merged
merged 5 commits into from
Sep 13, 2022
Merged

Set/Update cct from blockchain. #821

merged 5 commits into from
Sep 13, 2022

Conversation

lpoli
Copy link
Contributor

@lpoli lpoli commented Sep 9, 2022

Changes

This PR will change setting of cct value from config file to api leveraged by blockchain.
Will fix #818

Tests

Tasks to complete before merging PR:

  • Ensure system tests are passing. If not Run them manually to check for any regressions 馃搵
  • Do any new system tests need added to test this change? do any existing system tests need updated? If so create a PR at 0chain/system_test
  • Merge your system tests PR to master AFTER merging this PR

Associated PRs (Link as appropriate):

  • 0chain:
  • gosdk:
  • system_test:
  • zboxcli:
  • zwalletcli:
  • Other: ...

@lpoli lpoli requested review from cnlangzi and Sriep September 9, 2022 14:47
@codecov-commenter
Copy link

codecov-commenter commented Sep 9, 2022

Codecov Report

Merging #821 (2a2b950) into staging (1ce9f4a) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff            @@
##           staging     #821   +/-   ##
========================================
  Coverage    24.28%   24.28%           
========================================
  Files           80       80           
  Lines         8095     8095           
========================================
  Hits          1966     1966           
  Misses        5854     5854           
  Partials       275      275           
Flag Coverage 螖
Unit-Tests 24.28% <酶> (酶)

Flags with carried forward coverage won't be shown. Click here to find out more.

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@Sriep Sriep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe get someone more familiar with the blobber to suggest the best place to set the challenge completion time.

config.Configuration.ChallengeCompletionTime = viper.GetDuration("challenge_completion_time")
err := setCCTFromChain()
if err != nil {
panic(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use a panic here? If I understand, an error here indicates an issue with 0chain rather than the blobber.

Maybe the problem here is that the challenge completion time does not belong in the configuration file anymore on account of being removed, and we should move the challenge completion time elsewhere.

https://github.com/0chain/blobber/blob/staging/code/go/0chain.net/blobber/main.go#L12 Looking at blobber/main.go, the first thing the blobber does is read the config file and use it to set the config object; Setting the challenge completion time in setupConfig seems out of place. Can we guarantee 0chain is reachable at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though it is not blobber error but of 0chain, we cannot start blobber with 0 cct.
What is better here?

Also the value is retrieved from storage-config endpoint. It is also termed as storageSCconfig and isn't it better to put in configuration file?

Don't understand what you mean by 0chain is reachable at this point. Basically it is only asking for storageSCConfig which is publicly available without wallet.

Copy link
Contributor

@Sriep Sriep Sep 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The challenge competition time is no longer in the configuration file, so it smells bad to keep it in the configuration file's model. And setting it in the method designed to read in the configuration file smells just as bad. Better create a sister method to setupConfig to get settings from 0chain.

If there is no object for settings read from 0chain yet then we should create one. We could create a parent object for config.Configuration, and have 0chain settings as a sister. Anyway, check with someone more familiar with the blobber.

@@ -171,7 +170,7 @@ type Config struct {
AutomaticUpdate bool
BlobberUpdateInterval time.Duration

ChallengeCompletionTime time.Duration
CCT time.Duration // challenge completion time // retrieved from storage SC config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change to CCT? ChallengeCompletionTime looks clearer to me.

You can remove the extra //.

// Upon updating cct, we only log error because cct is not 0
// We should try to submit challenge as soon as possible regardless
// of cct value.
err := setCCTFromChain()
Copy link
Contributor

@Sriep Sriep Sep 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we set the challenge completion time here, why do we need to set it in setupConfig where it does not seem to belong?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it is done to update CCT. It can have been changed dynamically (which is not the current case though).

Do you think it can be dynamic? Or will it be dead constant?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The challenge completion time can change with an update settings transaction. https://github.com/0chain/zwalletcli/blob/staging/cmd/sc-update-config.go#L14
So the blobber needs to be able to respond.

@lpoli lpoli requested a review from Sriep September 12, 2022 02:37
@@ -134,7 +134,10 @@ func setupConfig(configDir string, deploymentMode int) {
config.Configuration.Geolocation.Latitude = viper.GetFloat64("geolocation.latitude")
config.Configuration.Geolocation.Longitude = viper.GetFloat64("geolocation.longitude")

config.Configuration.ChallengeCompletionTime = viper.GetDuration("challenge_completion_time")
err := setCCTFromChain()
Copy link
Contributor

@Sriep Sriep Sep 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this outside of setupConfig, this has nothing to do with setting up the config file. Maybe have the main function call setupSettings that calls setupConfig and setCCTFromChain? Or alternately add a setupSettingsFrom0Chain method to the main funtion.

@lpoli lpoli merged commit fadc491 into staging Sep 13, 2022
@lpoli lpoli deleted the fix/minor-issues branch September 13, 2022 13:20
@service-0chain
Copy link
Collaborator

Manual system tests [success] with the following config

config value
tests skipped FALSE
system-tests master
gosdk NOT OVERRIDDEN
zboxcli staging
zwalletcli staging
0chain staging
blobber staging
authorizer staging
0box staging
0block staging
0dns staging
explorer master
0proxy staging
0search staging

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.

Remove challenge completion time.
4 participants