-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Allow executing smart contract functions in arbitrarily sized batches #1560
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8d7312f
to
d6f81ad
Compare
Pull Request Test Coverage Report for Build 6ed15908-5ac3-4a1b-942c-2bc9ba88278a
💛 - Coveralls |
zachdaniel
approved these changes
Mar 13, 2019
ayrat555
reviewed
Mar 13, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are some other not batched methods. We should check it. Great work!
ayrat555
approved these changes
Mar 13, 2019
# Problem There are a lot of `getBalanceOf` token function calls during indexing blockchain. Each of them is sent as a separate JSONRPC request, which creates a lot of unnecessary overhead and clogs archive node workers, which could otherwise be busy performing other JSONRPC queries. Moreover, function name is used as the `id` parameter of JSONRPC queries, which doesn't allow us to simply put multiple requests into one batch. # Solution * Change `EthereumJSONRPC.execute_contract_functions` to accept a list of arbitrary function calls and return a list of results. * Handle `id` field generation in the `EthereumJSONRPC` package instead of leaking implementation details to `Explorer.SmartContract.Reader`. * Change `Token.BalanceReader.get_balance_of` to accept a list of parameter sets and return a list of balances. * Make one batch request instead of launching multiple concurrent tasks in `Indexer.TokenBalances.fetch_token_balances_from_blockchain` # Notes * Protocol details of calling smart contract functions is now fully encapsulated in `EthereumJSONRPC` package. * `SmartContract.Reader.query_contract` is left for backwards compatibility with other existing applications of smart contract requests, but can be fully deprecated at some later time.
2938b8c
to
65547b5
Compare
65547b5
to
3060264
Compare
vbaranov
approved these changes
Mar 13, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
There are a lot of
getBalanceOf
token function calls during indexing blockchain. Each of them is sent as a separate JSONRPC request, which creates a lot of unnecessary overhead and clogs archive node workers, which could otherwise be busy performing other JSONRPC queries.Moreover, function name is used as the
id
parameter of JSONRPC queries, which doesn't allow us to simply put multiple requests into one batch.Changelog
EthereumJSONRPC.execute_contract_functions
to accept a list of arbitrary function calls and return a list of results.id
field generation in theEthereumJSONRPC
package instead of leaking implementation details toExplorer.SmartContract.Reader
.Token.BalanceReader.get_balance_of
to accept a list of parameter sets and return a list of balances.Indexer.TokenBalances.fetch_token_balances_from_blockchain
Notes
EthereumJSONRPC
package.SmartContract.Reader.query_contract
is left for backwards compatibility with other existing applications of smart contract requests, but can be fully deprecated at some later time.