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

fix(zcncore): added MakeSCRestAPICall and fixed fast confirmation on GetInfo #718

Merged
merged 53 commits into from
Feb 1, 2023

Conversation

cnlangzi
Copy link
Contributor

@cnlangzi cnlangzi commented Jan 13, 2023

Changes

Fixes

  • speed up get info from sharders

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):

Copy link
Member

@peterlimg peterlimg left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@peterlimg peterlimg left a comment

Choose a reason for hiding this comment

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

Please fix the macos build error

Copy link
Member

@peterlimg peterlimg left a comment

Choose a reason for hiding this comment

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

For the FromConsensus, we actually don't have to do another process logic, we can do it in simliar way as the FromAll, but only send requests to part of the sharders, and collect the failed requets number as I suggested before.

zcncore/transaction_query_base.go Outdated Show resolved Hide resolved
zcncore/transaction_query_base.go Outdated Show resolved Hide resolved
zcncore/transaction_query_base.go Outdated Show resolved Hide resolved
@cnlangzi
Copy link
Contributor Author

cnlangzi commented Jan 18, 2023

For the FromConsensus, we actually don't have to do another process logic, we can do it in simliar way as the FromAll, but only send requests to part of the sharders, and collect the failed requets number as I suggested before.

the request with be cancelled by WithTimeout if the sharder is offline or slow. and next sharder will be pushed to next channel to fix minimal online sharders. success and sent are count instead of collect failed requests number. do you think it is ok?

@cnlangzi cnlangzi requested a review from peterlimg January 18, 2023 13:56
Copy link
Member

@peterlimg peterlimg left a comment

Choose a reason for hiding this comment

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

The first version of this PR is actually 90 percent ready, we only need to limit the request size in MakeSCRestAPICall and check the failed count, let's not overcomplicate it.

zcncore/transaction_query_base.go Outdated Show resolved Hide resolved
zcncore/transaction_query_base.go Outdated Show resolved Hide resolved
path := fmt.Sprintf("/v1/screst/%v/%v", scAddress, relativePath)
query := withParams(path, Params(params))

tq, err := NewTransactionQuery(util.Shuffle(_config.chain.Sharders))
Copy link
Member

Choose a reason for hiding this comment

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

The main changes we need is in this MakeSCRestAPICall function, that we limit the shaders number instead of passing all sharders to NewTransactionQuery. Then call the FromAll() to send requests to those selected sharders. We don't need the fromConsensus.

reqSharders := util.Shuffle(copyOf(_config.chain.Sharders))[:reqNum] // util.Shuffle(_config.chain.Sharders) // this shuffle will change the Sharders slice, it's not thread safe. 
tq, err := NewTransactionQuery(reqSharders)
...

zcncore/transaction_query_base.go Outdated Show resolved Hide resolved
@cnlangzi cnlangzi requested a review from peterlimg January 19, 2023 07:16
@service-0chain
Copy link
Contributor

Manual system tests [cancelled] with the following config

config value
tests skipped FALSE
system-tests fix/speed_up_txn_confirm
gosdk fix/speed_up_txn_confirm
zboxcli fix/speed_up_txn_confirm
zwalletcli staging
0chain staging
blobber staging
authorizer staging
0box staging
0block staging
0dns staging
explorer staging
0proxy staging
0search staging

@service-0chain
Copy link
Contributor

Manual system tests [failure] with the following config

config value
tests skipped FALSE
system-tests fix/speed_up_txn_confirm
gosdk fix/speed_up_txn_confirm
zboxcli fix/speed_up_txn_confirm
zwalletcli staging
0chain staging
blobber staging
authorizer staging
0box staging
0block staging
0dns staging
explorer staging
0proxy staging
0search staging

Copy link
Member

@peterlimg peterlimg left a comment

Choose a reason for hiding this comment

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

LGTM.

@cnlangzi can you create an issue for the refactoring I mentioned below, thanks.

@peterlimg peterlimg mentioned this pull request Jan 28, 2023
3 tasks
@cnlangzi cnlangzi mentioned this pull request Jan 29, 2023
@cnlangzi
Copy link
Contributor Author

@peterlimg please also check https://0chain.slack.com/archives/D02FLSUG42C/p1674110680380779?thread_ts=1673955258.028839&cid=D02FLSUG42C. I left a question about consensus checking

rate := consensus * 100 / float32(len(sharders))
						if rate >= consensusThresh {
							return nonce, winInfo, nil
						}

Copy link
Contributor

@boddumanohar boddumanohar left a comment

Choose a reason for hiding this comment

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

LGTM

@cnlangzi cnlangzi merged commit 7140de1 into staging Feb 1, 2023
@cnlangzi cnlangzi deleted the fix/speed_up_txn_confirm branch February 1, 2023 23:20
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.

6 participants