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

feat(net): improve chain inventory generating logic #5393

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

jwrct
Copy link
Contributor

@jwrct jwrct commented Aug 2, 2023

What does this PR do?
Retrying inventory generating if first blockId does not match the chain summary.

Why are these changes required?

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details

@jwrct jwrct linked an issue Aug 2, 2023 that may be closed by this pull request
@jwrct jwrct changed the title feat(net):improve chain inventory generating logic feat(net): improve chain inventory generating logic Aug 2, 2023
@jwrct jwrct requested a review from xxo1shine August 3, 2023 03:11
LinkedList<BlockId> ids = getBlockIds(unForkId.getNum());

if (ids.isEmpty() || !unForkId.equals(ids.peekFirst())) {
unForkId = getUnForkId(blockIds);
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm not mistaken, is it just a retry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it can be solved by retrying.

@halibobo1205 halibobo1205 added this to the GreatVoyage-v4.7.3 milestone Aug 9, 2023
@@ -64,6 +65,21 @@ public void testProcessMessage() throws Exception {
method.setAccessible(true);
boolean f = (boolean)method.invoke(handler, peer, message);
Assert.assertTrue(!f);

Method method1 = handler.getClass().getDeclaredMethod(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to reproduce this scenario without using reflection?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, further optimization.

@tomatoishealthy
Copy link
Contributor

It only happened with the forks which are not finalized?

If so, all the blocks on both(or more) forks are stored in memory?

If all the above is right, just sending the corresponding blocks can solve this thoroughly?

@jwrct
Copy link
Contributor Author

jwrct commented Aug 11, 2023

It only happened with the forks which are not finalized?

yes

If so, all the blocks on both(or more) forks are stored in memory?

This problem will only involve non-solidified blocks.

If all the above is right, just sending the corresponding blocks can solve this thoroughly?

After the chain switch is completed, the generated inventory is without any problems.

@tomatoishealthy
Copy link
Contributor

After the chain switch is completed, the generated inventory is without any problems.

I mean generating the inventory by iterating the specified fork instead of using tronNetDelegate.getBlockIdByNum(i) may solve this thoroughly, but seems an interface for querying the fork chain doesn't exist.

Copy link
Contributor

@tomatoishealthy tomatoishealthy left a comment

Choose a reason for hiding this comment

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

Approved, @wubin01 should do a double check

@halibobo1205 halibobo1205 merged commit 83151aa into tronprotocol:develop Aug 17, 2023
7 checks passed
@@ -87,6 +87,18 @@ private boolean check(PeerConnection peer, SyncBlockChainMessage msg) throws P2p

private LinkedList<BlockId> getLostBlockIds(List<BlockId> blockIds) throws P2pException {

Choose a reason for hiding this comment

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

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.

Improve chain inventory generating logic
5 participants