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

refactor(rpc-server): Tweaks and clean up around query.call_function method implementation #258

Merged
merged 3 commits into from
May 23, 2024

Conversation

khorolets
Copy link
Member

@khorolets khorolets commented May 22, 2024

I am thoroughly reviewing the logic around query.call_function method implementation to find a way to improve the usage of ScyllaDB here. This work is related to the #236

While I am here and noticing some areas for improvement, I am also implementing them (Boy Scout Rule in action).

High-level changes

  • Extract the logic of contract execution to a separate module contract_runner within the query one
  • Small improvement for avoiding the clone of block_reference for fetch_block_from_cache_or_get function (this actually went a bit beyond the query module tbh)
  • Simplified the logic of optimistic/final data fetch in query:: function_call (dropped two similar functions, moved the code to the function_call body, it seems like it belongs there to me)

@khorolets khorolets added WIP work in progress performance labels May 22, 2024
@khorolets khorolets force-pushed the refactor/query-call-function-tweaks branch from 09624a0 to 2f04337 Compare May 22, 2024 14:33
@khorolets khorolets marked this pull request as ready for review May 23, 2024 12:22
@khorolets khorolets added housekeeping and removed WIP work in progress performance labels May 23, 2024
@khorolets khorolets requested a review from kobayurii May 23, 2024 12:22
@khorolets khorolets changed the title refactor(rpc-server): Tweaks and clean up around query.call_function method implementation method implementation refactor(rpc-server): Tweaks and clean up around query.call_function method implementation May 23, 2024
Copy link
Member

@kobayurii kobayurii left a comment

Choose a reason for hiding this comment

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

Grate! Thank you! I've left a few requests to make it better.

validators: HashMap<near_primitives::types::AccountId, near_primitives::types::Balance>,
data_count: u64,
is_optimistic: bool,
prefetched_data:
Copy link
Member

Choose a reason for hiding this comment

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

This is already deleted in #259. Observations have shown that it is not efficient to request the whole stack. Therefore, this functionality was removed.

}

fn get_state_key_data(&self, key: &[u8]) -> readnode_primitives::StateValue {
if let Some(prefetched_data) = &self.prefetched_data {
Copy link
Member

Choose a reason for hiding this comment

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

It is not needed according to the comment above.


// TODO: Refactor this part. It's a temporary solution to fetch state keys from DB for the poolv1.near contracts
// https://github.com/near/read-rpc/issues/150
let contract_state = if account_id.to_string().ends_with("poolv1.near") {
Copy link
Member

Choose a reason for hiding this comment

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

It is not needed according to the comment above.

Copy link
Member

@kobayurii kobayurii left a comment

Choose a reason for hiding this comment

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

This is a great improvement! Thank you!

@khorolets khorolets force-pushed the refactor/query-call-function-tweaks branch from 3d45641 to 358814c Compare May 23, 2024 12:58
@khorolets khorolets merged commit b8d8fcf into develop May 23, 2024
3 checks passed
@kobayurii kobayurii deleted the refactor/query-call-function-tweaks branch May 31, 2024 06:18
kobayurii added a commit that referenced this pull request Jun 5, 2024
* fix(near-state-indexer): Fix the TypeError in communication with Redis leading to spam of warnings (#254)

* (rpc_server): metrics refactoring and improvements (#255)

* merics reffactoring and imrovements

* metrics improvements according pr comments

* improvement tracing instrument logs (#257)

* (database): Implement metrics to count requests for each table (#259)

* Implement metrics to count request for each database table

* remove logic to fetch all state before contract call

* add issue to implement metrics for postgres

* rename mentric DATABASE_QUERIES to DATABASE_READ_QUERIES

* refactor(rpc-server): Tweaks and clean up around query.call_function method implementation (#258)

* refactor(rpc-server): Tweaks and clean up around query.call_function method implementation

* Follow the clippy suggestion

* Drop redundant pieces of code

* fix tx different results (#261)

* Metrics(rpc-server): Extend metrics (#263)

* extend metrics to collect block category

* fmt

* code improvement according git comments

* Revert "fix tx different results" (#265)

This reverts commit 2e4dc30.

* feat: added `view_receipt_record` rpc endpoint (#266)

* feat: added `view_receipt_record` rpc endpoint

* chore: removed leftovers

* feat: used appropriate metrics

* feat: added proper response structure

* docs(view_receipt_record): added new custom method

* hook for poolv1.near (#267)

* chore: relese v0.2.9 (#268)

* proxy next_light_client_block to regular rpc (#269)

* fix changelog.md (#270)

---------

Co-authored-by: Bohdan Khorolets <[email protected]>
Co-authored-by: Ivan Frolov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants