xpay: add a flag to indicate completion of initialization#9250
Open
Lagrang3 wants to merge 1 commit into
Open
Conversation
Collaborator
Author
|
I am not sure we should do this. We have never done this pattern before AFAIK. |
Add a "ready" flag that becomes true after the plugin has finished
initializing. Usually RPC calls during initialization are done using
synchronous communication but xpay uses hooks to bind itself to "pay".
For some reason registering to hooks and using rcp_scan at init cannot
be done. Therefore xpay's initialization is asynchronous which has the
downside of race conditions like: trying to make a payment while xpay
does not know yet the current node id. This is unlikely to happen in
real life but it breaks our tests randomly.
Fixes flake `tests/test_xpay.py:test_xpay_fake_channeld`
```
Valgrind error file: valgrind-errors.356233
==356233== Conditional jump or move depends on uninitialised value(s)
==356233== at 0x1116ED: handle_block_added (xpay.c:3159)
==356233== by 0x11D7A8: ld_command_handle (libplugin.c:2144)
==356233== by 0x11DB8A: ld_read_json (libplugin.c:2282)
==356233== by 0x15DAC1: next_plan (io.c:60)
==356233== by 0x15DF4C: do_plan (io.c:422)
==356233== by 0x15E005: io_ready (io.c:439)
==356233== by 0x15F99B: io_loop (poll.c:470)
==356233== by 0x11DFD6: plugin_main (libplugin.c:2481)
==356233== by 0x11876E: main (xpay.c:3412)
==356233==
{
<insert_a_suppression_name_here>
Memcheck:Cond
fun:handle_block_added
fun:ld_command_handle
fun:ld_read_json
fun:next_plan
fun:do_plan
fun:io_ready
fun:io_loop
fun:plugin_main
fun:main
}
```
Changelog-None
Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Collaborator
Author
|
Another way to solve this is to remove |
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a "ready" flag that becomes true after the plugin has finished initializing. Usually RPC calls during initialization are done using synchronous communication but xpay uses hooks to bind itself to "pay". For some reason registering to hooks and using rcp_scan at init cannot be done. Therefore xpay's initialization is asynchronous which has the downside of race conditions like: trying to make a payment while xpay does not know yet the current node id. This is unlikely to happen in real life but it breaks our tests randomly.
Fixes flake
tests/test_xpay.py:test_xpay_fake_channeldFixes #9248