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): stop tx broadcasting if block cannot solidified #5643

Merged
merged 3 commits into from
Jan 3, 2024

Conversation

xxo1shine
Copy link
Contributor

What does this PR do?
Stop broadcasting transactions when the block cannot be solidified, refer to issue: #5562

Why are these changes required?

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details

@xxo1shine xxo1shine closed this Dec 28, 2023
@xxo1shine xxo1shine reopened this Dec 28, 2023
@xxo1shine xxo1shine changed the title feat(net): stop broadcasting transactions when the block cannot be solidified feat(net): stop tx broadcasting if block cannot solidified Dec 28, 2023
if (tronNetDelegate.unsolidifiedBlockCheck()) {
logger.warn("Broadcast transaction {} has failed, block unsolidified.", txID);
return builder.setResult(false).setCode(response_code.BLOCK_UNSOLIDIFIED)
.setMessage(ByteString.copyFromUtf8("Bock unsolidified."))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please optimize the prompt message to make the user aware of the specific reason for the failure, such as too many blocks not being finalized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bock unsolidified means this. It would be better to shorten this prompt message.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please check spelling, Block, not Bock.


PARAMETER.maxUnsolidifiedBlocks =
config.hasPath(Constant.MAX_UNSOLIDIFIED_BLOCKS) ? config
.getInt(Constant.MAX_UNSOLIDIFIED_BLOCKS) : 1000;
Copy link
Contributor

Choose a reason for hiding this comment

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

The default value is determined how?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Referring to the issue test data, I personally think 1000 is OK.

if (tronNetDelegate.unsolidifiedBlockCheck()) {
logger.warn("Broadcast transaction {} has failed, block unsolidified.", txID);
return builder.setResult(false).setCode(response_code.BLOCK_UNSOLIDIFIED)
.setMessage(ByteString.copyFromUtf8("Bock unsolidified."))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please check spelling, Block, not Bock.

long solidNum = chainBaseManager.getSolidBlockId().getNum();
return headNum - solidNum >= maxUnsolidifiedBlocks;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename the method unsolidifiedBlockCheck. It should not be the same as varible, it is confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well, done!

@@ -1051,6 +1051,8 @@ message Return {
SERVER_BUSY = 9;
NO_CONNECTION = 10;
NOT_ENOUGH_EFFECTIVE_CONNECTION = 11;
BLOCK_UNSOLIDIFIED = 12;
Copy link
Contributor

Choose a reason for hiding this comment

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

May be the reason TOO_MANY_BLOCK_UNSOLIDIFIED more clearful ? We generally believe that less than a certain number of unsodlified blocks is normal. It's tiny.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Briefly describe what happened, too many doesn't make much sense.

@xxo1shine xxo1shine merged commit 1e2986a into tronprotocol:develop Jan 3, 2024
7 checks passed
@halibobo1205 halibobo1205 added this to the GreatVoyage-v4.7.4 milestone Jan 30, 2024
@halibobo1205 halibobo1205 linked an issue Feb 2, 2024 that may be closed by this pull request
@xxo1shine xxo1shine deleted the block_unsolid_solution branch May 28, 2024 01:16
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.

Stop broadcasting transactions when the block cannot be solidified
4 participants