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

TIP-391: Optimize fetch block process #391

Closed
Vikingzzu opened this issue Mar 21, 2022 · 1 comment
Closed

TIP-391: Optimize fetch block process #391

Vikingzzu opened this issue Mar 21, 2022 · 1 comment

Comments

@Vikingzzu
Copy link
Contributor

Vikingzzu commented Mar 21, 2022

tip: 391
title: Optimize fetch block process
author: vikingzzu@163.com
discussions-to: https://github.com/tronprotocol/TIPs/issues/391
status: Final
type: Standards Track
category: Networking
created: 2022-03-21

Simple Summary

Optimize fetch block process between nodes

Abstract

During the process of broadcasting a block, sometimes timeouts occur between nodes fetching blocks, nodes will wait until it times out and then go through a P2P sync to fetch the block, the P2P block fetching process will send SyncBlockChainMessage, ChainInventoryMessage, FetchInvDataMessage, BlockMessage to get the block, this process is more time consuming, such a strategy is very inefficient, we should choose a new node to fetch the block, such a solution only needs to send a FetchInvDataMessage to fetch the latest block in the broadcast process, which will save a lot of time.

Motivation

Network fluctuations between nodes can cause block fetch timeouts, use a new strategy to prevent such scenarios from occurring.

Rationale

As a decentralized service, network fluctuations between nodes occur frequently, and network fluctuations can lead to very inefficient block acquisition between nodes, which can lead to a very inefficient service if such scenarios occur frequently, we should use a new strategy to prevent such scenarios from occurring.

Implementation

Add a new class to save fetch block info,

public class FetchBlockService{
  private PeerConnection peer;
  private Sha256Hash hash;
  private long fetchBlockTimeout;
  public void fetchBlock(Sha256Hash sha256Hash, PeerConnection peer){}
  private void reSendFetchTimeOutBlock(){}
  public void blockFetchSuccess(Sha256Hash sha256Hash){}
}

During the process of broadcasting a block, message service calls method fetchBlock of the FetchBlockService to record the current sha256Hash info and peer info.

After fetchBlockTimeout time, FetchBlockService calls method reSendFetchTimeOutBlock to check if it got the block information of sha256Hash, if not then we find a new connection to fetch the block.

When block service receive the block information of sha256Hash, block service calls method blockFetchSuccess of the FetchBlockService to remove the sha256Hash info and peer info, then the block will not be reacquired.

@Vikingzzu Vikingzzu changed the title Optimize fetch block process TIP-391: Optimize fetch block process Mar 21, 2022
@ethan1844
Copy link
Contributor

Close this issue as it is implemented by GreatVoyage-v4.5.0.
Check TIP detail at TIP-391
Check implementation PR at tronprotocol/java-tron#4326

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

No branches or pull requests

6 participants
@Vikingzzu @ethan1844 and others