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

[resharding] Add pytest for checking RPC calls after resharding #10296

Merged

Conversation

shreyan-gupta
Copy link
Contributor

This PR adds a basic pytest to check if the RPC calls to tx endpoint work after a resharding event.

Note that this test currently works under the assumption that the node is tracking all shards and future improvements to the tests where we may need to redirect the request to a node tracking the specific shard we are interested in, would come later.

Resolving #5047

@shreyan-gupta shreyan-gupta requested a review from a team as a code owner December 5, 2023 09:50
@shreyan-gupta shreyan-gupta requested a review from nikurt December 5, 2023 09:50
@shreyan-gupta shreyan-gupta requested a review from wacban December 5, 2023 10:02
@shreyan-gupta
Copy link
Contributor Author

Waiting for successful run https://nayduck.near.org/#/run/3306

@shreyan-gupta
Copy link
Contributor Author

Copy link

codecov bot commented Dec 5, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (21851d2) 71.77% compared to head (96e99ae) 71.82%.
Report is 12 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10296      +/-   ##
==========================================
+ Coverage   71.77%   71.82%   +0.04%     
==========================================
  Files         712      712              
  Lines      142859   143055     +196     
  Branches   142859   143055     +196     
==========================================
+ Hits       102540   102744     +204     
+ Misses      35611    35596      -15     
- Partials     4708     4715       +7     
Flag Coverage Δ
backward-compatibility 0.08% <ø> (-0.01%) ⬇️
db-migration 0.08% <ø> (-0.01%) ⬇️
genesis-check 1.25% <ø> (-0.01%) ⬇️
integration-tests 36.25% <ø> (+0.06%) ⬆️
linux 71.65% <ø> (+0.04%) ⬆️
linux-nightly 71.38% <ø> (+0.01%) ⬆️
macos 53.89% <ø> (-1.13%) ⬇️
pytests 1.48% <ø> (-0.01%) ⬇️
sanity-checks 1.28% <ø> (-0.01%) ⬇️
unittests 68.18% <ø> (+0.05%) ⬆️
upgradability 0.13% <ø> (-0.01%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@wacban wacban left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 155 to 156
pytest --timeout=120 sanity/rpc_tx_resharding.py
pytest --timeout=120 sanity/rpc_tx_resharding.py --features nightly
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I would rename to resharding_* so that the files are close to each other in IDE

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Umm, yeah, I had thought about this, but I had the consideration the primary test was actually closer to RPC than resharding. I can change if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed name

@@ -15,7 +15,7 @@
from configured_logger import logger
from cluster import get_binary_protocol_version, init_cluster, load_config, spin_up_node
from utils import MetricsTracker, poll_blocks
from resharding_lib import append_shard_layout_config_changes, get_epoch_offset, get_genesis_num_shards, get_genesis_shard_layout_version, get_target_num_shards, get_target_shard_layout_version
import resharding_lib
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: how about from resharding_lib import *?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Personally don't think it's a great idea to do import *, it's considered as bad practice due to potential collision of namespace and difficulty in locating the import module.

In case you don't like the resharding_lib.abc, I can change this back to from resharding_lib import abc, pqr etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I prefer having the actual code as short as possible and I don't care about long imports.


def __setup_account(self, account_id, nonce):
encoded_block_hash = self.node.get_latest_block().hash_bytes
account = key.Key.from_random(account_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Creates two different accounts with some specific balance in shard3 and (future) shard4

assert response == transfer_response, response
pass

def test_rcp_tx_resharding(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: rpc

client_config_changes=client_config_changes)
self.node = nodes[0]

# The shard boundries are at "kkuuue2akv_1630967379.near" and "tge-lockup.sweat" for shard 4 and 5
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: boundaries

Comment on lines 81 to 82
# The first account before and after resharding is in shard 4
# The second account after resharding is in shard 5
Copy link
Contributor

Choose a reason for hiding this comment

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

shards are indexed from 0; it should be 3 and 4 respectively

@shreyan-gupta shreyan-gupta added this pull request to the merge queue Dec 5, 2023
Merged via the queue into near:master with commit 6ce6eb2 Dec 5, 2023
16 checks passed
@shreyan-gupta shreyan-gupta deleted the shreyan/resharding/rpc_tx_resharding branch December 5, 2023 12:01
@wacban wacban mentioned this pull request Dec 14, 2023
2 tasks
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.

Querying historical transaction status should be compatible with re-sharding
2 participants