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 to allow reconnection to SHiP endpoints after connection lost. #3

Merged
merged 3 commits into from
Aug 9, 2023

Conversation

yarkinwho
Copy link
Contributor

Resolve eosnetworkfoundation/eos-evm-contract#579

The changes:
1 Connection is moved from plugin_init to plugin_startup
2 Most network related errors will result in reset_connection() instead of sys::error()
3 Some errors such as cannot read block from db will still cause sys::error()
4 reset_connection() will send a close frame to existing connection (regardless success or not) and try resetting the connection.
a it will delay a configurable time before trying reconnection (default 10s)
b it will try at most a configurable times (default 0, means it will not try reconnection at all), after reaching the limit it will call sys::error() to exit
c If the system successfully reconnect to SHiP and read blocks properly, the reconnection count will be reset to 0

The PR also include a minor fix to work around the issue:
eosio::json_token_stream will fail if the input string is not zero terminated.
Fixed by adding the terminating zero.

Copy link
Contributor

@taokayan taokayan left a comment

Choose a reason for hiding this comment

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

looks good to me

@arhag
Copy link
Member

arhag commented Jul 25, 2023

@yarkinwho
Copy link
Contributor Author

For eosnetworkfoundation/silkworm#39

It is decided that we should fix it by not calling insert and verify for blocks that are already in canonical chain. Need update this PR.

@yarkinwho
Copy link
Contributor Author

Updated the logic.

Now incoming duplicated eos blocks will be discarded instead of triggering the fork logic.

@yarkinwho yarkinwho requested a review from elmato July 28, 2023 03:05
@yarkinwho yarkinwho merged commit ca81bb1 into main Aug 9, 2023
6 checks passed
@yarkinwho yarkinwho deleted the yarkin/ship_reconnection branch August 9, 2023 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants