Repository navigation
Conversation
open_channel_inner created the channel and only then wrote the peer to the peer store. If that write failed, the API returned PersistenceFailed for a channel that was already live, and a caller retrying would open a second channel. Persist the peer first, so a persistence failure is returned before anything is initiated. If channel creation then fails and the peer was only stored for this attempt, remove it again so we don't keep reconnecting to it, unless we have a channel with it (a concurrent open_channel to the same peer may have succeeded in the meantime), as remove_peer_after_reconnect does. Co-authored-by: Claude <noreply@anthropic.com>
PeerWriteFailingStore wraps an InMemoryStore and fails writes of the persisted peer list while a flag is set. With the flag on, open_channel returns PersistenceFailed and no channel exists. Once the store recovers, a retry opens exactly one channel and the peer is persisted. Co-authored-by: Claude <noreply@anthropic.com>
|
I've assigned @tnull as a reviewer! |
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.
Fixes #1143. Supersedes #1149, rebased onto current
mainas two additive commits, as requested there.open_channel_innercreated the channel and only then wrote the peer to the peer store. If that write failed, the API returnedPersistenceFailedfor a channel that was already live, and a caller retrying would open a second channel (and push the amount again).This takes the first option from the issue: the peer is persisted before
create_channel, so a persistence failure is returned before anything is initiated, and before the fee-rate override is registered. If channel creation then fails and the peer was only stored for this attempt, it is removed again so we don't keep reconnecting to it, unless we have a channel with it: a concurrentopen_channelto the same peer may have stored it too and succeeded in the meantime. That check mirrorsremove_peer_after_reconnect(from @Camillarhi's review on #1149).The
PeerStore::add_peercaching issue the issue mentions is left to #1150, as agreed on #1149.Commits
Persist the peer before initiating a channel:src/lib.rs(+25/−1).Test that a failed peer write does not leave a live channel: integration test with aKVStorewrapper that fails writes of the peer list on demand. With the failure on,open_channelreturnsPersistenceFailedand no channel exists; once the store recovers, a retry opens exactly one channel and the peer is persisted.Testing on
main0fc5565:cargo test --lib483 passed, andcargo clippy --all-targetscompiles the integration tests. The only new clippy notes are in the new test and match constructs already used by the existing tests in that file (EsploraSyncConfig::default()then a field assignment,node_entropy.into()). rustfmt is clean. I couldn't run the bitcoind/electrs integration tests in my environment.🤖 Generated with Claude Code
https://claude.ai/code/session_014cRzwuyJe8BGwXowsQ3kpw