Git Product home page Git Product logo

nakamoto's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nakamoto's Issues

debug_assertion trigger inside the popol

Opening it because I was able to trigger the assertion here
https://github.com/cloudhead/nakamoto/blob/master/net/poll/src/reactor.rs#L247-L249

This is the log with my core lightning plugin, we should put an option to log into a file, otherwise we can lose some useful information

2023-04-06T20:31:25.735Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: Version(VersionMessage { version: 70016, services: ServiceFlags(0), timestamp: 1680813085, receiver: Address {services: ServiceFlags(NONE), address: 35.210.226.46, port: 18333}, sender: Address {services: ServiceFlags(NONE), address: 192.168.1.69, port: 58466}, nonce: 15750071166389877797, user_agent: \"/nakamoto:0.3.0/\", start_height: 2427722, relay: false }) } to 35.210.226.46
2023-04-06T20:31:25.736Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 133ms..
2023-04-06T20:31:25.738Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.739Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:25.741Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Socket is writable
2023-04-06T20:31:25.742Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 133ms..
2023-04-06T20:31:25.767Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.768Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:25.768Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Socket is readable
2023-04-06T20:31:25.769Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Read 198 bytes
2023-04-06T20:31:25.770Z DEBUG   plugin-satoshi_plugin: Received \"version\" from 35.210.226.46:18333
2023-04-06T20:31:25.771Z INFO    plugin-satoshi_plugin: Peer address = 35.210.226.46:18333, version = 70016, height = 2427722, agent = /Satoshi:24.0.1/, services = ServiceFlags(NETWORK|WITNESS|COMPACT_FILTERS|NETWORK_LIMITED), timestamp = 1680813085
2023-04-06T20:31:25.773Z DEBUG   plugin-satoshi_plugin: Sending \"wtxidrelay\" to 35.210.226.46:18333
2023-04-06T20:31:25.774Z DEBUG   plugin-satoshi_plugin: Sending \"verack\" to 35.210.226.46:18333
2023-04-06T20:31:25.776Z DEBUG   plugin-satoshi_plugin: Sending \"sendheaders\" to 35.210.226.46:18333
2023-04-06T20:31:25.777Z DEBUG   plugin-satoshi_plugin: Received \"wtxidrelay\" from 35.210.226.46:18333
2023-04-06T20:31:25.778Z DEBUG   plugin-satoshi_plugin: Received \"sendaddrv2\" from 35.210.226.46:18333
2023-04-06T20:31:25.779Z UNUSUAL plugin-satoshi_plugin: Ignoring \"sendaddrv2\" from 35.210.226.46:18333
2023-04-06T20:31:25.780Z DEBUG   plugin-satoshi_plugin: Received \"verack\" from 35.210.226.46:18333
2023-04-06T20:31:25.781Z INFO    plugin-satoshi_plugin: 35.210.226.46:18333: Peer negotiated with services ServiceFlags(NETWORK|WITNESS|COMPACT_FILTERS|NETWORK_LIMITED) and height 2427722..
2023-04-06T20:31:25.782Z DEBUG   plugin-satoshi_plugin: Sending \"getaddr\" to 35.210.226.46:18333
2023-04-06T20:31:25.783Z DEBUG   plugin-satoshi_plugin: Sending \"ping\" to 35.210.226.46:18333
2023-04-06T20:31:25.784Z INFO    plugin-satoshi_plugin: Filter header chain is out of sync by 24 header(s) (2427698 to 2427722)
2023-04-06T20:31:25.785Z DEBUG   plugin-satoshi_plugin: Sending \"getcfheaders\" to 18.159.254.80:18333
2023-04-06T20:31:25.786Z INFO    plugin-satoshi_plugin: Syncing filter headers with 18.159.254.80:18333 from height 2427699 to 2427722 (block hash 000000000000b99ab1ea0ac9b90371bbd6798cfa7ab034ff459f1357d5922065)
2023-04-06T20:31:25.787Z INFO    plugin-satoshi_plugin: Headers synced up to height 2427722 with hash 000000000000b99ab1ea0ac9b90371bbd6798cfa7ab034ff459f1357d5922065
2023-04-06T20:31:25.789Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: WtxidRelay } to 35.210.226.46
2023-04-06T20:31:25.790Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: Verack } to 35.210.226.46
2023-04-06T20:31:25.792Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: SendHeaders } to 35.210.226.46
2023-04-06T20:31:25.793Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: GetAddr } to 35.210.226.46
2023-04-06T20:31:25.794Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: Ping(16519156167466251763) } to 35.210.226.46
2023-04-06T20:31:25.795Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: GetCFHeaders(GetCFHeaders { filter_type: 0, start_height: 2427699, stop_hash: 000000000000b99ab1ea0ac9b90371bbd6798cfa7ab034ff459f1357d5922065 }) } to 18.159.254.80
2023-04-06T20:31:25.796Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 95ms..
2023-04-06T20:31:25.797Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.797Z DEBUG   plugin-satoshi_plugin: Woke up with 2 source(s) ready
2023-04-06T20:31:25.798Z DEBUG   plugin-satoshi_plugin: 18.159.254.80:18333: Socket is writable
2023-04-06T20:31:25.799Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Socket is writable
2023-04-06T20:31:25.800Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 94ms..
2023-04-06T20:31:25.800Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.801Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:25.802Z DEBUG   plugin-satoshi_plugin: 18.159.254.80:18333: Socket is readable
2023-04-06T20:31:25.803Z DEBUG   plugin-satoshi_plugin: 18.159.254.80:18333: Read 858 bytes
2023-04-06T20:31:25.804Z DEBUG   plugin-satoshi_plugin: Received \"cfheaders\" from 18.159.254.80:18333
2023-04-06T20:31:25.805Z DEBUG   plugin-satoshi_plugin: Received 24 filter header(s) from 18.159.254.80:18333
2023-04-06T20:31:25.806Z UNUSUAL plugin-satoshi_plugin: Error receiving filter headers: ignoring message from 18.159.254.80:18333: previous filter header does not match local tip
2023-04-06T20:31:25.808Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 65ms..
2023-04-06T20:31:25.809Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.810Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:25.811Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Socket is readable
2023-04-06T20:31:25.812Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Read 97 bytes
2023-04-06T20:31:25.813Z DEBUG   plugin-satoshi_plugin: Received \"sendcmpct\" from 35.210.226.46:18333
2023-04-06T20:31:25.814Z UNUSUAL plugin-satoshi_plugin: Ignoring \"sendcmpct\" from 35.210.226.46:18333
2023-04-06T20:31:25.814Z DEBUG   plugin-satoshi_plugin: Received \"ping\" from 35.210.226.46:18333
2023-04-06T20:31:25.815Z DEBUG   plugin-satoshi_plugin: Sending \"pong\" to 35.210.226.46:18333
2023-04-06T20:31:25.816Z DEBUG   plugin-satoshi_plugin: Received \"feefilter\" from 35.210.226.46:18333
2023-04-06T20:31:25.817Z UNUSUAL plugin-satoshi_plugin: Ignoring \"feefilter\" from 35.210.226.46:18333
2023-04-06T20:31:25.817Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: Pong(16626389158376543858) } to 35.210.226.46
2023-04-06T20:31:25.818Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 60ms..
2023-04-06T20:31:25.819Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.820Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:25.821Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Socket is writable
2023-04-06T20:31:25.822Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 60ms..
2023-04-06T20:31:25.823Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.824Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:25.825Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Socket is readable
2023-04-06T20:31:25.826Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Read 2920 bytes
2023-04-06T20:31:25.827Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 58ms..
2023-04-06T20:31:25.838Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.839Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:25.840Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Socket is readable
2023-04-06T20:31:25.841Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Read 15528 bytes
2023-04-06T20:31:25.842Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 25ms..
2023-04-06T20:31:25.842Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.844Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:25.845Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Socket is readable
2023-04-06T20:31:25.846Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Read 4224 bytes
2023-04-06T20:31:25.847Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 24ms..
2023-04-06T20:31:25.848Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.848Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:25.849Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Socket is readable
2023-04-06T20:31:25.851Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Read 7040 bytes
2023-04-06T20:31:25.852Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 23ms..
2023-04-06T20:31:25.864Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.864Z DEBUG   plugin-satoshi_plugin: Received wake
2023-04-06T20:31:25.865Z DEBUG   plugin-satoshi_plugin: Requesting block 0000000000000010b5d664ab80d1d10d62053b223d37d143e79c1f333f792328 from 54.81.216.122:18333
2023-04-06T20:31:25.867Z DEBUG   plugin-satoshi_plugin: Sending \"getdata\" to 54.81.216.122:18333
2023-04-06T20:31:25.868Z INFO    plugin-satoshi_plugin: Filter header chain is out of sync by 24 header(s) (2427698 to 2427722)
2023-04-06T20:31:25.869Z DEBUG   plugin-satoshi_plugin: Sending \"getcfheaders\" to 18.159.254.80:18333
2023-04-06T20:31:25.871Z INFO    plugin-satoshi_plugin: Syncing filter headers with 18.159.254.80:18333 from height 2427699 to 2427722 (block hash 000000000000b99ab1ea0ac9b90371bbd6798cfa7ab034ff459f1357d5922065)
2023-04-06T20:31:25.872Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: GetData([Block(0000000000000010b5d664ab80d1d10d62053b223d37d143e79c1f333f792328)]) } to 54.81.216.122
2023-04-06T20:31:25.874Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: GetCFHeaders(GetCFHeaders { filter_type: 0, start_height: 2427699, stop_hash: 000000000000b99ab1ea0ac9b90371bbd6798cfa7ab034ff459f1357d5922065 }) } to 18.159.254.80
2023-04-06T20:31:25.875Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.12s..
2023-04-06T20:31:25.876Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.877Z DEBUG   plugin-satoshi_plugin: Woke up with 2 source(s) ready
2023-04-06T20:31:25.879Z DEBUG   plugin-satoshi_plugin: 54.81.216.122:18333: Socket is writable
2023-04-06T20:31:25.880Z DEBUG   plugin-satoshi_plugin: 18.159.254.80:18333: Socket is writable
2023-04-06T20:31:25.881Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.12s..
2023-04-06T20:31:25.881Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.882Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:25.883Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Socket is readable
2023-04-06T20:31:25.885Z DEBUG   plugin-satoshi_plugin: 35.210.226.46:18333: Read 347 bytes
2023-04-06T20:31:25.886Z DEBUG   plugin-satoshi_plugin: Received \"addr\" from 35.210.226.46:18333
2023-04-06T20:31:25.887Z INFO    plugin-satoshi_plugin: received 1000 addresse(s) from source `35.210.226.46:18333`
2023-04-06T20:31:25.888Z DEBUG   plugin-satoshi_plugin: Received \"pong\" from 35.210.226.46:18333
2023-04-06T20:31:25.889Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.1s..
2023-04-06T20:31:25.894Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.896Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:25.897Z DEBUG   plugin-satoshi_plugin: 18.159.254.80:18333: Socket is readable
2023-04-06T20:31:25.897Z DEBUG   plugin-satoshi_plugin: 18.159.254.80:18333: Read 858 bytes
2023-04-06T20:31:25.898Z DEBUG   plugin-satoshi_plugin: Received \"cfheaders\" from 18.159.254.80:18333
2023-04-06T20:31:25.900Z DEBUG   plugin-satoshi_plugin: Received 24 filter header(s) from 18.159.254.80:18333
2023-04-06T20:31:25.902Z UNUSUAL plugin-satoshi_plugin: Error receiving filter headers: ignoring message from 18.159.254.80:18333: previous filter header does not match local tip
2023-04-06T20:31:25.903Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.09s..
2023-04-06T20:31:25.982Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.983Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:25.984Z DEBUG   plugin-satoshi_plugin: 54.81.216.122:18333: Socket is readable
2023-04-06T20:31:25.986Z DEBUG   plugin-satoshi_plugin: 54.81.216.122:18333: Read 24 bytes
2023-04-06T20:31:25.987Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.002s..
2023-04-06T20:31:25.989Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.990Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:25.991Z DEBUG   plugin-satoshi_plugin: 54.81.216.122:18333: Socket is readable
2023-04-06T20:31:25.993Z DEBUG   plugin-satoshi_plugin: 54.81.216.122:18333: Read 1448 bytes
2023-04-06T20:31:25.994Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.001s..
2023-04-06T20:31:25.996Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:25.997Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:25.998Z DEBUG   plugin-satoshi_plugin: 54.81.216.122:18333: Socket is readable
2023-04-06T20:31:25.999Z DEBUG   plugin-satoshi_plugin: 54.81.216.122:18333: Read 11584 bytes
2023-04-06T20:31:26.000Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1s..
2023-04-06T20:31:26.148Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:26.149Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:26.150Z DEBUG   plugin-satoshi_plugin: 54.81.216.122:18333: Socket is readable
2023-04-06T20:31:26.150Z DEBUG   plugin-satoshi_plugin: 54.81.216.122:18333: Read 4676 bytes
2023-04-06T20:31:26.152Z DEBUG   plugin-satoshi_plugin: Received \"block\" from 54.81.216.122:18333
2023-04-06T20:31:26.153Z INFO    plugin-satoshi_plugin: 54.81.216.122:18333: Received block #2427712
2023-04-06T20:31:26.167Z INFO    plugin-satoshi_plugin: Processed block #2427712
2023-04-06T20:31:26.169Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 815ms..
2023-04-06T20:31:26.176Z DEBUG   lightningd: Adding block 2427712: 0000000000000010b5d664ab80d1d10d62053b223d37d143e79c1f333f792328
2023-04-06T20:31:26.195Z DEBUG   plugin-satoshi_plugin: call get chain info
2023-04-06T20:31:26.196Z INFO    plugin-satoshi_plugin: cln request {\"height\":2427713}
2023-04-06T20:31:26.197Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:26.197Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:26.198Z DEBUG   plugin-satoshi_plugin: Woken up by waker (1 command(s))
2023-04-06T20:31:26.199Z DEBUG   plugin-satoshi_plugin: Received command: GetBlockByHeight(2427713)
2023-04-06T20:31:26.200Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 789ms..
2023-04-06T20:31:26.201Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:26.202Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:26.202Z DEBUG   plugin-satoshi_plugin: Woken up by waker (1 command(s))
2023-04-06T20:31:26.203Z DEBUG   plugin-satoshi_plugin: Received command: GetBlock(00000000000000011df16f3a7eb5808414aa68bd0623d92a073935ae85b5607a)
2023-04-06T20:31:26.204Z DEBUG   plugin-satoshi_plugin: Queueing block 00000000000000011df16f3a7eb5808414aa68bd0623d92a073935ae85b5607a to be requested
2023-04-06T20:31:26.205Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 788ms..
2023-04-06T20:31:26.985Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:26.986Z DEBUG   plugin-satoshi_plugin: Received wake
2023-04-06T20:31:26.986Z DEBUG   plugin-satoshi_plugin: Requesting block 00000000000000011df16f3a7eb5808414aa68bd0623d92a073935ae85b5607a from 54.81.216.122:18333
2023-04-06T20:31:26.987Z DEBUG   plugin-satoshi_plugin: Sending \"getdata\" to 54.81.216.122:18333
2023-04-06T20:31:26.988Z INFO    plugin-satoshi_plugin: Filter header chain is out of sync by 24 header(s) (2427698 to 2427722)
2023-04-06T20:31:26.989Z DEBUG   plugin-satoshi_plugin: Sending \"getcfheaders\" to 35.207.3.50:18333
2023-04-06T20:31:26.990Z INFO    plugin-satoshi_plugin: Syncing filter headers with 35.207.3.50:18333 from height 2427699 to 2427722 (block hash 000000000000b99ab1ea0ac9b90371bbd6798cfa7ab034ff459f1357d5922065)
2023-04-06T20:31:26.991Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: GetData([Block(00000000000000011df16f3a7eb5808414aa68bd0623d92a073935ae85b5607a)]) } to 54.81.216.122
2023-04-06T20:31:26.991Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: GetCFHeaders(GetCFHeaders { filter_type: 0, start_height: 2427699, stop_hash: 000000000000b99ab1ea0ac9b90371bbd6798cfa7ab034ff459f1357d5922065 }) } to 35.207.3.50
2023-04-06T20:31:26.992Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.128s..
2023-04-06T20:31:26.993Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:26.994Z DEBUG   plugin-satoshi_plugin: Woke up with 2 source(s) ready
2023-04-06T20:31:26.995Z DEBUG   plugin-satoshi_plugin: 35.207.3.50:18333: Socket is writable
2023-04-06T20:31:26.995Z DEBUG   plugin-satoshi_plugin: 54.81.216.122:18333: Socket is writable
2023-04-06T20:31:26.996Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.127s..
2023-04-06T20:31:27.173Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:27.174Z DEBUG   plugin-satoshi_plugin: Woke up with 2 source(s) ready
2023-04-06T20:31:27.175Z DEBUG   plugin-satoshi_plugin: 35.207.3.50:18333: Socket is readable
2023-04-06T20:31:27.176Z DEBUG   plugin-satoshi_plugin: 35.207.3.50:18333: Read 24 bytes
2023-04-06T20:31:27.177Z DEBUG   plugin-satoshi_plugin: 54.81.216.122:18333: Socket is readable
2023-04-06T20:31:27.178Z DEBUG   plugin-satoshi_plugin: 54.81.216.122:18333: Read 388 bytes
2023-04-06T20:31:27.179Z DEBUG   plugin-satoshi_plugin: Received \"block\" from 54.81.216.122:18333
2023-04-06T20:31:27.180Z INFO    plugin-satoshi_plugin: 54.81.216.122:18333: Received block #2427713
2023-04-06T20:31:27.181Z INFO    plugin-satoshi_plugin: Processed block #2427713
2023-04-06T20:31:27.182Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 938ms..
2023-04-06T20:31:27.183Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:27.184Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:27.186Z DEBUG   plugin-satoshi_plugin: 35.207.3.50:18333: Socket is readable
2023-04-06T20:31:27.187Z DEBUG   plugin-satoshi_plugin: 35.207.3.50:18333: Read 834 bytes
2023-04-06T20:31:27.188Z DEBUG   plugin-satoshi_plugin: Received \"cfheaders\" from 35.207.3.50:18333
2023-04-06T20:31:27.190Z DEBUG   plugin-satoshi_plugin: Received 24 filter header(s) from 35.207.3.50:18333
2023-04-06T20:31:27.191Z UNUSUAL plugin-satoshi_plugin: Error receiving filter headers: ignoring message from 35.207.3.50:18333: previous filter header does not match local tip
2023-04-06T20:31:27.193Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 937ms..
2023-04-06T20:31:27.195Z DEBUG   lightningd: Adding block 2427713: 00000000000000011df16f3a7eb5808414aa68bd0623d92a073935ae85b5607a
2023-04-06T20:31:27.208Z DEBUG   plugin-satoshi_plugin: call get chain info
2023-04-06T20:31:27.209Z INFO    plugin-satoshi_plugin: cln request {\"height\":2427714}
2023-04-06T20:31:27.211Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:27.212Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:27.213Z DEBUG   plugin-satoshi_plugin: Woken up by waker (1 command(s))
2023-04-06T20:31:27.214Z DEBUG   plugin-satoshi_plugin: Received command: GetBlockByHeight(2427714)
2023-04-06T20:31:27.215Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 905ms..
2023-04-06T20:31:27.216Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:27.217Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:27.219Z DEBUG   plugin-satoshi_plugin: Woken up by waker (1 command(s))
2023-04-06T20:31:27.220Z DEBUG   plugin-satoshi_plugin: Received command: GetBlock(000000000000001aa4924835ae85e2223cd7ffa59860499964c9f15aeb3046be)
2023-04-06T20:31:27.221Z DEBUG   plugin-satoshi_plugin: Queueing block 000000000000001aa4924835ae85e2223cd7ffa59860499964c9f15aeb3046be to be requested
2023-04-06T20:31:27.223Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 904ms..
2023-04-06T20:31:28.114Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:28.115Z DEBUG   plugin-satoshi_plugin: Received wake
2023-04-06T20:31:28.116Z DEBUG   plugin-satoshi_plugin: Requesting block 000000000000001aa4924835ae85e2223cd7ffa59860499964c9f15aeb3046be from 204.16.241.203:18333
2023-04-06T20:31:28.117Z DEBUG   plugin-satoshi_plugin: Sending \"getdata\" to 204.16.241.203:18333
2023-04-06T20:31:28.118Z INFO    plugin-satoshi_plugin: Filter header chain is out of sync by 24 header(s) (2427698 to 2427722)
2023-04-06T20:31:28.118Z DEBUG   plugin-satoshi_plugin: Sending \"getcfheaders\" to 18.159.254.80:18333
2023-04-06T20:31:28.119Z INFO    plugin-satoshi_plugin: Syncing filter headers with 18.159.254.80:18333 from height 2427699 to 2427722 (block hash 000000000000b99ab1ea0ac9b90371bbd6798cfa7ab034ff459f1357d5922065)
2023-04-06T20:31:28.120Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: GetData([Block(000000000000001aa4924835ae85e2223cd7ffa59860499964c9f15aeb3046be)]) } to 204.16.241.203
2023-04-06T20:31:28.121Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: GetCFHeaders(GetCFHeaders { filter_type: 0, start_height: 2427699, stop_hash: 000000000000b99ab1ea0ac9b90371bbd6798cfa7ab034ff459f1357d5922065 }) } to 18.159.254.80
2023-04-06T20:31:28.123Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.267s..
2023-04-06T20:31:28.124Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:28.126Z DEBUG   plugin-satoshi_plugin: Woke up with 2 source(s) ready
2023-04-06T20:31:28.127Z DEBUG   plugin-satoshi_plugin: 204.16.241.203:18333: Socket is writable
2023-04-06T20:31:28.129Z DEBUG   plugin-satoshi_plugin: 18.159.254.80:18333: Socket is writable
2023-04-06T20:31:28.129Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.266s..
2023-04-06T20:31:28.147Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:28.148Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:28.150Z DEBUG   plugin-satoshi_plugin: 18.159.254.80:18333: Socket is readable
2023-04-06T20:31:28.151Z DEBUG   plugin-satoshi_plugin: 18.159.254.80:18333: Read 858 bytes
2023-04-06T20:31:28.153Z DEBUG   plugin-satoshi_plugin: Received \"cfheaders\" from 18.159.254.80:18333
2023-04-06T20:31:28.154Z DEBUG   plugin-satoshi_plugin: Received 24 filter header(s) from 18.159.254.80:18333
2023-04-06T20:31:28.156Z UNUSUAL plugin-satoshi_plugin: Error receiving filter headers: ignoring message from 18.159.254.80:18333: previous filter header does not match local tip
2023-04-06T20:31:28.157Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.234s..
2023-04-06T20:31:28.246Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:28.247Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:28.249Z DEBUG   plugin-satoshi_plugin: 204.16.241.203:18333: Socket is readable
2023-04-06T20:31:28.250Z DEBUG   plugin-satoshi_plugin: 204.16.241.203:18333: Read 4368 bytes
2023-04-06T20:31:28.251Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.135s..
2023-04-06T20:31:28.252Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:28.254Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:28.255Z DEBUG   plugin-satoshi_plugin: 204.16.241.203:18333: Socket is readable
2023-04-06T20:31:28.256Z DEBUG   plugin-satoshi_plugin: 204.16.241.203:18333: Read 2824 bytes
2023-04-06T20:31:28.257Z DEBUG   plugin-satoshi_plugin: Received \"block\" from 204.16.241.203:18333
2023-04-06T20:31:28.258Z INFO    plugin-satoshi_plugin: 204.16.241.203:18333: Received block #2427714
2023-04-06T20:31:28.259Z INFO    plugin-satoshi_plugin: Processed block #2427714
2023-04-06T20:31:28.260Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.126s..
2023-04-06T20:31:28.264Z DEBUG   lightningd: Adding block 2427714: 000000000000001aa4924835ae85e2223cd7ffa59860499964c9f15aeb3046be
2023-04-06T20:31:28.280Z DEBUG   plugin-satoshi_plugin: call get chain info
2023-04-06T20:31:28.281Z INFO    plugin-satoshi_plugin: cln request {\"height\":2427715}
2023-04-06T20:31:28.282Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:28.283Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:28.284Z DEBUG   plugin-satoshi_plugin: Woken up by waker (1 command(s))
2023-04-06T20:31:28.285Z DEBUG   plugin-satoshi_plugin: Received command: GetBlockByHeight(2427715)
2023-04-06T20:31:28.286Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.101s..
2023-04-06T20:31:28.288Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:28.289Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:28.290Z DEBUG   plugin-satoshi_plugin: Woken up by waker (1 command(s))
2023-04-06T20:31:28.292Z DEBUG   plugin-satoshi_plugin: Received command: GetBlock(0000000000000005501f8769d90e3ec9d8e23a6dbbc6f6a49db9527e87e0c3bc)
2023-04-06T20:31:28.293Z DEBUG   plugin-satoshi_plugin: Queueing block 0000000000000005501f8769d90e3ec9d8e23a6dbbc6f6a49db9527e87e0c3bc to be requested
2023-04-06T20:31:28.295Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.1s..
2023-04-06T20:31:29.382Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:29.383Z DEBUG   plugin-satoshi_plugin: Received wake
2023-04-06T20:31:29.384Z DEBUG   plugin-satoshi_plugin: Requesting block 0000000000000005501f8769d90e3ec9d8e23a6dbbc6f6a49db9527e87e0c3bc from [2401:d002:3902:700:8708:37c4:e231:d3d8]:18333
2023-04-06T20:31:29.385Z DEBUG   plugin-satoshi_plugin: Sending \"getdata\" to [2401:d002:3902:700:8708:37c4:e231:d3d8]:18333
2023-04-06T20:31:29.387Z INFO    plugin-satoshi_plugin: Filter header chain is out of sync by 24 header(s) (2427698 to 2427722)
2023-04-06T20:31:29.388Z DEBUG   plugin-satoshi_plugin: Sending \"getcfheaders\" to 35.207.3.50:18333
2023-04-06T20:31:29.390Z INFO    plugin-satoshi_plugin: Syncing filter headers with 35.207.3.50:18333 from height 2427699 to 2427722 (block hash 000000000000b99ab1ea0ac9b90371bbd6798cfa7ab034ff459f1357d5922065)
2023-04-06T20:31:29.392Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: GetData([Block(0000000000000005501f8769d90e3ec9d8e23a6dbbc6f6a49db9527e87e0c3bc)]) } to 2401:d002:3902:700:8708:37c4:e231:d3d8
2023-04-06T20:31:29.393Z DEBUG   plugin-satoshi_plugin: Write RawNetworkMessage { magic: 118034699, payload: GetCFHeaders(GetCFHeaders { filter_type: 0, start_height: 2427699, stop_hash: 000000000000b99ab1ea0ac9b90371bbd6798cfa7ab034ff459f1357d5922065 }) } to 35.207.3.50
2023-04-06T20:31:29.395Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.315s..
2023-04-06T20:31:29.396Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:29.397Z DEBUG   plugin-satoshi_plugin: Woke up with 2 source(s) ready
2023-04-06T20:31:29.399Z DEBUG   plugin-satoshi_plugin: [2401:d002:3902:700:8708:37c4:e231:d3d8]:18333: Socket is writable
2023-04-06T20:31:29.400Z DEBUG   plugin-satoshi_plugin: 35.207.3.50:18333: Socket is writable
2023-04-06T20:31:29.402Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.315s..
2023-04-06T20:31:29.510Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:29.511Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:29.512Z DEBUG   plugin-satoshi_plugin: 35.207.3.50:18333: Socket is readable
2023-04-06T20:31:29.514Z DEBUG   plugin-satoshi_plugin: 35.207.3.50:18333: Read 858 bytes
2023-04-06T20:31:29.516Z DEBUG   plugin-satoshi_plugin: Received \"cfheaders\" from 35.207.3.50:18333
2023-04-06T20:31:29.517Z DEBUG   plugin-satoshi_plugin: Received 24 filter header(s) from 35.207.3.50:18333
2023-04-06T20:31:29.519Z UNUSUAL plugin-satoshi_plugin: Error receiving filter headers: ignoring message from 35.207.3.50:18333: previous filter header does not match local tip
2023-04-06T20:31:29.520Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.187s..
2023-04-06T20:31:29.639Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:29.640Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:29.640Z DEBUG   plugin-satoshi_plugin: [2401:d002:3902:700:8708:37c4:e231:d3d8]:18333: Socket is readable
2023-04-06T20:31:29.641Z DEBUG   plugin-satoshi_plugin: [2401:d002:3902:700:8708:37c4:e231:d3d8]:18333: Read 3948 bytes
2023-04-06T20:31:29.642Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.058s..
2023-04-06T20:31:29.643Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:29.643Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:29.644Z DEBUG   plugin-satoshi_plugin: [2401:d002:3902:700:8708:37c4:e231:d3d8]:18333: Socket is readable
2023-04-06T20:31:29.645Z DEBUG   plugin-satoshi_plugin: [2401:d002:3902:700:8708:37c4:e231:d3d8]:18333: Read 2737 bytes
2023-04-06T20:31:29.646Z DEBUG   plugin-satoshi_plugin: Received \"block\" from [2401:d002:3902:700:8708:37c4:e231:d3d8]:18333
2023-04-06T20:31:29.646Z INFO    plugin-satoshi_plugin: [2401:d002:3902:700:8708:37c4:e231:d3d8]:18333: Received block #2427715
2023-04-06T20:31:29.647Z INFO    plugin-satoshi_plugin: Processed block #2427715
2023-04-06T20:31:29.650Z DEBUG   plugin-satoshi_plugin: Log pruned 2539 entries (mem 10497812 -> 701254)
2023-04-06T20:31:29.651Z DEBUG   lightningd: Adding block 2427715: 0000000000000005501f8769d90e3ec9d8e23a6dbbc6f6a49db9527e87e0c3bc
2023-04-06T20:31:29.667Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.05s..
thread '<unnamed>' panicked at 'assertion failed: !commands.is_empty()', /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/17bbdab/net/poll/src/reactor.rs:249:33
stack backtrace:
2023-04-06T20:31:29.682Z DEBUG   plugin-satoshi_plugin: call get chain info
2023-04-06T20:31:29.685Z INFO    plugin-satoshi_plugin: cln request {\"height\":2427716}
2023-04-06T20:31:29.686Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:29.688Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:29.688Z DEBUG   plugin-satoshi_plugin: Woken up by waker (1 command(s))
2023-04-06T20:31:29.689Z DEBUG   plugin-satoshi_plugin: Received command: GetBlockByHeight(2427716)
2023-04-06T20:31:29.689Z DEBUG   plugin-satoshi_plugin: Received command: GetBlock(0000000000000021f491dae5b5fcb2c11c5b7948971961a79e8ae1ef470ec3b2)
2023-04-06T20:31:29.690Z DEBUG   plugin-satoshi_plugin: Queueing block 0000000000000021f491dae5b5fcb2c11c5b7948971961a79e8ae1ef470ec3b2 to be requested
2023-04-06T20:31:29.690Z DEBUG   plugin-satoshi_plugin: Polling 10 source(s) and 49 timeout(s), waking up in 1.028s..
2023-04-06T20:31:29.691Z DEBUG   plugin-satoshi_plugin: Received tick
2023-04-06T20:31:29.691Z DEBUG   plugin-satoshi_plugin: Woke up with 1 source(s) ready
2023-04-06T20:31:29.692Z DEBUG   plugin-satoshi_plugin: Woken up by waker (0 command(s))
   0: rust_begin_unwind
             at /rustc/0599b6b931816ab46ab79072189075f543931cbd/library/std/src/panicking.rs:577:5
   1: core::panicking::panic_fmt
             at /rustc/0599b6b931816ab46ab79072189075f543931cbd/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/0599b6b931816ab46ab79072189075f543931cbd/library/core/src/panicking.rs:117:5
   3: <nakamoto_net_poll::reactor::Reactor<std::net::tcp::TcpStream,Id> as nakamoto_net::Reactor<Id>>::run
             at /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/17bbdab/net/poll/src/reactor.rs:249:33
   4: nakamoto_client::client::ClientRunner<R>::run
             at /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/17bbdab/client/src/client.rs:183:9
   5: nakamoto_client::client::Client<R>::run
             at /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/17bbdab/client/src/client.rs:402:9
   6: satoshi_nakamoto::Nakamoto::new::{{closure}}
             at /home/vincent/Github/coffee/satoshi/satoshi-nakamoto/src/lib.rs:41:45
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Client doesn't run anymore

It permanently gets stuck on

[INFO  nakamoto_client::client] Filters height = 0
[INFO  nakamoto_client::client] Loading filter headers from store..
[INFO  nakamoto_client::client] Verifying filter headers..

Clearing the data directory doesn't help. Revision e74e83d6271f063d53b1e67231c17819d8800649.

BIP 133: Support feefilter messages, and protocol version 70014

From the test in my local machine of the PR #51 that increase the protocol version to 70014, the feefilter (BIP133) is included in the protocol version

As the debug log shows

2021-09-29T13:57:52.306+02:00 DEBUG nakamoto_p2p::protocol 78.98.15.147:8333: Received "feefilter"
2021-09-29T13:57:52.306+02:00 DEBUG nakamoto_p2p::protocol::channel Received unknown feefilter from peer 78.98.15.147:8333
2021-09-29T13:57:52.306+02:00 DEBUG nakamoto_p2p::protocol::channel 78.98.15.147:8333: Sending "unknown"
2021-09-29T13:57:52.370+02:00 DEBUG nakamoto_p2p::protocol 78.98.15.147:8333: Received "pong"
2021-09-29T13:57:53.257+02:00 DEBUG nakamoto_p2p::protocol 97.120.18.239:8333: Received "addr

I think it is easy to support it in nakamoto, if you like I can take care of this issue if the #51 will be merge.

Slow block cache loading and filter header verification

The following two calls:

.load_with(|height| loading.send(Loading::BlockHeaderLoaded { height }))?;

filters.verify_with(network, |height| {

Are painfully slow in debug mode with the situation somewhat improving in release mode (thought not great). Both take upward of tens of seconds to complete for the current testnet blockchain. Are these potentially doing lots of real time disk IO instead of loading in chunks? That might not be it but both seem to call iter().enumerate() on a store, which seems to be backed by a File.

Prefer low-latency peers

Currently, peer latency is measured in the PingManager, but not used.

  • We should keep track of latencies, persist them (either in the client::peer::Cache or some where else.
  • Use it to decide which peers to connect to
  • Use it to decide which peers to download headers/blocks from

Some notes:

  • We should generally not compromise geo-diveristy when looking for low-latency peers, but having a few low-latency peers is desired
  • Low-latency peer selection can either be via AddressManager::sample being biased towards low-latency peers, or by simply calling sample 2-3 times and picking the peer with the lowest latency.

Persistent peers

Peers that are passed in via the the --connect flag, or the client::Config { connect } configuration or connected to via Command::Connect should be considered "persistent", and:

  1. Always retry-ed on disconnect, with exponential backoff
  2. Disconnections from these peers should be treated/logged as errors
  3. Failing to establish an initial connection should be an error (but the client shouldn't exit)
  4. These peers should be connected to when the client starts

Currently there's a retry field in the connection manager config. This should be renamed to persistent.

How do I know if the node is synced?

Hi,
I'm building a wallet-like application using nakamoto. The structure is a bit weird, but basically, I need to sync with the blockchain only when the user triggers the sync command. Every time the user calls sync, I block everything I'm doing, I start nakamoto, and I shut it down when I'm "synced", i.e., I received all the last block mined by the Bitcoin network.
As far as I can understand, I have no way of knowing when I'm synced from the Events, is that correct? At the moment I'm thinking of shutting down the node when I haven't received a BlockConnected event in a while (~30 seconds?), is there a better way of accomplishing the same result?

Publish latest release in crates.io

Currently the version available for crates.io is v0.2.0. https://crates.io/crates/nakamoto

Which is a old revision and doesn't fit with the latest examples usage API in the wallet crate.. I am currently working with a local snapshot at commit b17f93cdb3fa824cd1601809ab5ddefa32f2757b.

It would be really helpful if we can get the v0.3.0 in crates.io..

Handle race condition with fast rescan and low gap limit

It's likely that a fast rescan combined with a normal or low gap limit will miss some blocks. The reason is that the rescan process doesn't pause when a block is matched, and it never backtracks; so if a block is matched at some height H, while the rescan process is at height H+100, and the matched block at H adds more than the gap-limit worth of new scripts, those will be missed between blocks H and H+100.

This was found out by @straylight-orbit

Futures-based client API

Currently, the client API is channel based, via crossbeam-channel. It would be worth exploring what a futures-based API might look like around Client and client::Handle.

`get_cfilters` panics if no peers are connected

Hello,I seem to be having issues running the wallet program, I get a crash when running wallet program

cargo run --release -p nakamoto-wallet -- --debug --genesis 0 --connect 37.143.9.107:8333       
    Finished release [optimized] target(s) in 0.04s
     Running `target/release/nakamoto-wallet --debug --genesis 0 --connect '37.143.9.107:8333'`
2021-02-03T17:36:14.777+01:00 Rescanning wallet
2021-02-03T17:36:14.777+01:00 Waiting for peers..
2021-02-03T17:36:14.777+01:00 Initializing client (Mainnet)..
2021-02-03T17:36:14.777+01:00 Genesis block hash is 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
2021-02-03T17:36:14.777+01:00 Found existing store "/Users/michael/.nakamoto/mainnet/headers.db"
2021-02-03T17:36:14.777+01:00 Store height = 668930
2021-02-03T17:36:14.777+01:00 Loading block headers from store..
2021-02-03T17:36:16.510+01:00 Initializing block filters..
2021-02-03T17:36:16.510+01:00 Found existing store "/Users/michael/.nakamoto/mainnet/filters.db"
2021-02-03T17:36:16.510+01:00 Filters height = 14000
2021-02-03T17:36:16.510+01:00 Loading filter headers from store..
2021-02-03T17:36:16.531+01:00 Verifying filter headers..
2021-02-03T17:36:16.544+01:00 Loading peer addresses..
2021-02-03T17:36:16.545+01:00 Found existing peer cache "/Users/michael/.nakamoto/mainnet/peers.json"
2021-02-03T17:36:16.563+01:00 2807 peer(s) found..
2021-02-03T17:36:16.563+01:00 Initializing protocol..
2021-02-03T17:36:16.568+01:00 tip = 00000000000000000006b5d831c8db1f82c265113c849a49920c26c169174712, height = 668930/668930 (100.0%), outbound = 0/1
2021-02-03T17:36:17.003+01:00 37.143.9.107:8333: Peer connected (Outbound)
2021-02-03T17:36:17.005+01:00 37.143.9.107:8333: Sending "version"
2021-02-03T17:36:17.619+01:00 37.143.9.107:8333: Received "version"
2021-02-03T17:36:17.619+01:00 [peer] 37.143.9.107:8333: Peer version = 70015, height = 668932, agent = /Satoshi:0.20.1/, services = ServiceFlags(NETWORK|WITNESS|NETWORK_LIMITED), timestamp = 1612370173
2021-02-03T17:36:17.619+01:00 37.143.9.107:8333: Sending "verack"
2021-02-03T17:36:17.619+01:00 37.143.9.107:8333: Received "verack"
2021-02-03T17:36:17.619+01:00 [peer] 37.143.9.107:8333: Peer negotiated..
2021-02-03T17:36:17.619+01:00 37.143.9.107:8333: Sending "getaddr"
2021-02-03T17:36:17.620+01:00 37.143.9.107:8333: Sending "ping"
2021-02-03T17:36:17.620+01:00 37.143.9.107:8333: Sending "sendheaders"
2021-02-03T17:36:17.620+01:00 37.143.9.107:8333: Sending "getheaders"
2021-02-03T17:36:17.620+01:00 [sync] Syncing headers with 37.143.9.107:8333
2021-02-03T17:36:17.621+01:00 37.143.9.107:8333: Received "alert"
2021-02-03T17:36:18.613+01:00 37.143.9.107:8333: Ignoring "alert"
2021-02-03T17:36:18.613+01:00 37.143.9.107:8333: Received "sendheaders"
2021-02-03T17:36:18.613+01:00 37.143.9.107:8333: Ignoring "sendheaders"
2021-02-03T17:36:18.613+01:00 37.143.9.107:8333: Received "ping"
2021-02-03T17:36:18.613+01:00 37.143.9.107:8333: Sending "pong"
2021-02-03T17:36:18.613+01:00 37.143.9.107:8333: Received "addr"
2021-02-03T17:36:18.613+01:00 [addr] received 1 addresse(s) from source `37.143.9.107:8333`
2021-02-03T17:36:20.535+01:00 37.143.9.107:8333: Received "pong"
2021-02-03T17:36:20.722+01:00 37.143.9.107:8333: Received "headers"
2021-02-03T17:36:20.722+01:00 [sync] 37.143.9.107:8333: Received 2 header(s)
2021-02-03T17:36:20.724+01:00 [sync] Headers imported: TipChanged(0000000000000000000612e531b3bc72118340cea221acbce2cdc11d5583f180, 668932, [])
2021-02-03T17:36:20.724+01:00 Import result: TipChanged(0000000000000000000612e531b3bc72118340cea221acbce2cdc11d5583f180, 668932, [])
2021-02-03T17:36:20.725+01:00 Chain height = 668932, tip = 0000000000000000000612e531b3bc72118340cea221acbce2cdc11d5583f180
2021-02-03T17:36:20.725+01:00 [sync] Headers synced up to hash=0000000000000000000612e531b3bc72118340cea221acbce2cdc11d5583f180 height=668932
2021-02-03T17:36:20.807+01:00 Fetching filters in range 0..668932
2021-02-03T17:36:20.807+01:00 Received command: GetFilters(0..668932)
thread '<unnamed>' panicked at 'SpvManager::get_cfilters: called without any available peers!', /Users/michael/Desktop/Programming/Rust/nakamoto/p2p/src/protocol/spvmgr.rs:278:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Empty waker commands crashing the process

Experiencing a crash that seems to originate from the fact that the number of waker commands should never be zero. Is this caused by popol?

[TRACE nakamoto_net_poll::reactor] Woke up with 2 source(s) ready
[TRACE nakamoto_net_poll::reactor] Woken up by waker (0 command(s))
thread '<unnamed>' panicked at 'assertion failed: !commands.is_empty()', /home/[redacted]/.cargo/git/checkouts/nakamoto-7d1fe53db3dde129/e3b1cf9/net/poll/src/reactor.rs:249:33

better access to the fee estimation

Currently, if we want to estimate a fee in Nakamoto, we need to require a block, and Nakamoto keeps track of the fee with an estimation logic. In this PR (#139), I added a naive fee estimation, but some work needs to be done, such as:

  • Not storing all the estimated fees for all blocks in memory: after a certain limit, we should cut the hash map.
  • Being able to persist the calculated fee: We should be able to store the calculated fee to enable quick responses across restarts. See coffee-tools/folgore#20 for a use case.

Client isn't Broadcasting transactions properly

This is a little hard to reproduce directly from this issue description as I discovered it inside the BDK testing framework. But the gist of the story is, it seems client::Handle::submit_transaction() isn't properly broadcasting transactions to connected peer.

To test this I have the following code that creates a BDK wallet, a bitcoind regtest node, and a nakamoto client that connects to the bitcoind as its peer to the p2p port.

fn test_broadcast() {
                let (wallet, nakamoto, descriptors, mut bitcoind) = init_single_sig();
                let target_addr = bitcoind.get_node_address(None);

                // Create and broadcast funding transaction
                let tx = bitcoind.receive(testutils! {
                    @tx ( (@external descriptors, 0) => 50_000 )
                });
                let _ = nakamoto.broadcast(&tx).unwrap();

                wallet.sync(&nakamoto, SyncOptions::default()).unwrap();

                // Create and broadcast spending transaction
                let mut builder = wallet.build_tx();
                builder.add_recipient(target_addr.script_pubkey(), 5_000);
                let (mut psbt, _) = builder.finish().unwrap();
                let _ = wallet.sign(&mut psbt, Default::default()).unwrap();
                let tx = psbt.extract_tx();
                let _ = nakamoto.broadcast(&tx).unwrap();

                // Check whats in the mempool
                println!("Mempool : {:?}", bitcoind.get_raw_mempool().unwrap());
            }

The code is straight forward and does the following

  • bitcoind.receive() creates a funding transaction of 50k sats to the wallet address. Broadcast this transaction via the rpc call submit_raw_transaction.
  • nakamoto.broadcast() calls the Handle::submit_transaction() and tries to broadcast the same transaction again via the p2p port.
  • Then we create and broadcast a spending transaction, spending from the initial funding utxo. But this time only via nakamoto_broadcast().
  • We print the the mempool of the bitcoind, to see what got included.

Expectation:

  • We expect both the funding and spending transaction to be included in the bitcoind mempool.

Observation:

  • After running the code we only see one transaction in the mempool.
Broadcasting txid : 479d99664deacc8987d9b8069cf55c521d56d7884425019403fb6f661104b8e8
Broacasted to : NonEmpty { head: 127.0.0.1:44941, tail: [] }
Broadcasting txid : 180e00af318f9d6ed77f74082fdadaf0c9aebc12902455a85355d20592305361
Broacasted to : NonEmpty { head: 127.0.0.1:44941, tail: [] }
Mempool : [479d99664deacc8987d9b8069cf55c521d56d7884425019403fb6f661104b8e8]

The Broadcasted to : NonEmpty .. log is coming from internal of the nakamoto.broadcast() which signifies the Handle::submit_transaction() call returned without any error.

The mempool contains only 1 transaction, which is the initial funding transaction, and that is included because of the submit_raw_tranbsaction() call of the bitcoind RPC. Not because of the nakamoto.braodacast().

To verify this I printed the debug.log of bitcoind, with debug=[net, mempool, mempoolrej]. And it seems there is no record of transaction being received by the bitcoind in p2p port.. The debug log is pasted here https://hackmd.io/@raj/HyKH0tgZi
You can search for net logging, and can verify that there isn't any record of receiving anything through the network. Yet it successfully added a peer connection with the nakamoto client. 2022-09-15T11:17:20Z connection from 127.0.0.1:51678 accepted in debug log..

Conclusion:

For some reason transactions being sent by nakamoto to p2p network isn't being registered by bitcoin core.. I tried to debug as much as possible inside nakamoto, but everything seems to be working as intended.. Any help regarding this would be much appreciated..

Update protocol version & improve handling

Since rust-bitcoin cannot serialize txs without witness data, we should be requiring at least 70013, and sending the highest possible version that we support.

This wasn't done previously due to missing sendcmpct support, though that is probably fixed.

We should also split the protocol version into what we offer, vs. what we require from peers.

Can't compile from scratch on MacOs

This happens on latest master: 89a18ec.

cargo build
work/nakamoto ยป cargo build                                                                                                                                                                        โ€นmasterโ€บ
   Compiling autocfg v1.0.0
   Compiling proc-macro2 v1.0.18
   Compiling unicode-xid v0.2.0
   Compiling syn v1.0.33
   Compiling libc v0.2.71
   Compiling cc v1.0.41
   Compiling cfg-if v0.1.10
   Compiling log v0.4.8
   Compiling maybe-uninit v2.0.0
   Compiling lazy_static v1.4.0
   Compiling bech32 v0.7.2
   Compiling bitcoin_hashes v0.7.6
   Compiling nonempty v0.5.0
   Compiling unicode-segmentation v1.6.0
   Compiling argh_shared v0.1.1
   Compiling fastrand v1.2.4
   Compiling crossbeam-utils v0.7.2
   Compiling num-traits v0.2.12
   Compiling num-integer v0.1.43
   Compiling heck v0.3.1
   Compiling secp256k1-sys v0.1.2
   Compiling popol v0.2.0
   Compiling time v0.1.43
   Compiling atty v0.2.14
   Compiling colored v1.9.3
   Compiling quote v1.0.7
   Compiling crossbeam-channel v0.4.2
   Compiling secp256k1 v0.17.2
   Compiling chrono v0.4.13
   Compiling thiserror-impl v1.0.20
   Compiling argh_derive v0.1.1
   Compiling thiserror v1.0.20
   Compiling argh v0.1.3
   Compiling bitcoin v0.23.0
   Compiling nakamoto-chain v0.1.0 (/Users/rudolfs/work/nakamoto/nakamoto-chain)
error[E0658]: use of unstable library feature 'assoc_int_consts': recently added
   --> nakamoto-chain/src/block/store/io.rs:147:24
    |
147 |         assert!(len <= usize::MAX as u64);
    |                        ^^^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/68490
    = help: add `#![feature(assoc_int_consts)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'assoc_int_consts': recently added
   --> nakamoto-chain/src/block/store/io.rs:170:24
    |
170 |         assert!(len <= usize::MAX as u64);
    |                        ^^^^^^^^^^
    |
    = note: for more information, see https://github.com/rust-lang/rust/issues/68490
    = help: add `#![feature(assoc_int_consts)]` to the crate attributes to enable

error[E0277]: the trait bound `K: std::cmp::Eq` is not satisfied
   --> nakamoto-chain/src/block/time.rs:159:5
    |
156 | #[derive(Debug, Clone)]
    |          ----- consider adding a `where K: std::cmp::Eq` bound
...
159 |     sources: HashSet<K>,
    |     ^^^^^^^^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `K`
    |
    = note: required because of the requirements on the impl of `std::fmt::Debug` for `std::collections::HashSet<K>`
    = note: required because of the requirements on the impl of `std::fmt::Debug` for `&std::collections::HashSet<K>`
    = note: required for the cast to the object type `dyn std::fmt::Debug`

error[E0277]: the trait bound `K: std::hash::Hash` is not satisfied
   --> nakamoto-chain/src/block/time.rs:159:5
    |
156 | #[derive(Debug, Clone)]
    |          ----- consider adding a `where K: std::hash::Hash` bound
...
159 |     sources: HashSet<K>,
    |     ^^^^^^^^^^^^^^^^^^^ the trait `std::hash::Hash` is not implemented for `K`
    |
    = note: required because of the requirements on the impl of `std::fmt::Debug` for `std::collections::HashSet<K>`
    = note: required because of the requirements on the impl of `std::fmt::Debug` for `&std::collections::HashSet<K>`
    = note: required for the cast to the object type `dyn std::fmt::Debug`

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0277, E0658.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `nakamoto-chain`.
warning: build failed, waiting for other jobs to finish...
error: build failed

Support service bit filtering

To have a higher chance to connect to peers with NODE_COMPACT_FILTERS support, we could use the service bit filtering functionality of DNS seeds.

This is not a very well documented feature, but there is some information here:
https://bitcoin.stackexchange.com/questions/60373/dns-seeder-options

The filter we'd be interested in is NODE_NETWORK | NODE_COMPACT_FILTERS, so 1 << 0 | 1 << 6 = 65.

Since not all seeds support this functionality, we should fall back on a regular DNS query if we're unable to retrieve addresses from the seeds.

Track transaction submission status

One of the most important functions of a light client is to submit transactions to the network and track their status.

The status of a transaction can be represented with the following enum:

enum TransactionStatus {
  /// The transaction was sent to one or more peers on the network, and is unconfirmed.
  Pending {
    /// Number of announcements of this transaction from other peers.
    announcements: usize
  },
  /// The transaction was included in a block.
  Confirmed {
    /// Height of the block.
    height: Height,
    /// Hash of the block.
    block: BlockHash
  },
  /// The transaction is not likely to confirm, as another transaction has spent its output.
  Stale { replaced_by: TxId }
}

When a transaction is sent to a peer, the status starts as Pending.

There are then a few ways that a wallet can track transaction status with the client:

(a) By scanning cfilters, the wallet can check whether a tx was included in a block (confirmed)
(b) By listening for transaction announcements which include the sent transaction, the wallet can gain confidence that the tx will soon be included in a block, since other nodes consider it valid. The status is still pending, but it is more likely to be confirmed.
(c) By sending a getdata message to random peers, requesting the tx. This could be useful when re-connecting to the network or when the client is restarting and may have missed some messages, and we don't want to wait for the next block to be mined. Note that this only returns txs still in the mempool.

For (b) to work, I believe we will have to set relay: true in our version message, but this means we will receive all transactions, which is a significant amount of bandwidth. This needs to be further researched.

The most reliable method is of course (a) and that's what should be made possible first if it isn't already.

In terms of APIs, we could imagine a Handle::submit_transaction(tx: Transaction, chan::Receiver<TransactionStatus>) function. The client can then send transaction updates over the channel to the wallet.

Most of the logic for transaction tracking should be in the Client, not the protocol.

Peer banning

Peers that misbehave or shouldn't be connected to / retry-ed for a while should be banned. We're mainly interested in saving time and bandwidth by doing this.

The banned peers should be stored in the client::peer::Cache with the ban duration and start time.

It probably makes sense to create a BanManager for this alongside the other sub-protocols in p2p/src/protocol/.

Consequtive sync is not working

Problem

Consequitve syncing of 100 blocks in regtest isn't working. When we create a sequence of blocks from height 0:102 and sync the client, it works as expected. Then create another new 100 blocks in regtest, height 102:202, and sync the client, the sync halts at an intermediate height.

Test Code

            fn test_sequential_sync() {
                // Initiate everything
                let (wallet, nakamoto, descriptors, mut bitcoind) = init_single_sig();
                println!("Tip Height : {}", bitcoind.get_height());

                // Start the first sync
                println!("Sync 1");
                wallet.sync(&nakamoto, SyncOptions::default()).unwrap();

                // Create another 100 blocks
                bitcoind.generate(100, None);
                println!("Tip Height : {}", bitcoind.get_height());
                
               // Sync again
                println!("Sync 2");
                wallet.sync(&nakamoto, SyncOptions::default()).unwrap();
            }

Extra logging

To debug internally I set an extra log println!("Asking filters : {} : {}", range.start(), range.end()); at

match self.get_cfilters(range, tree) {

Output

Tip Height : 102
Sync 1
Asking filters : 0 : 102
Sync complete at : 102
Tip Height : 202
Sync 2
Asking filters : 0 : 199

The sync is paused at this stage because the client asked till 199, while the tip at core node is at 202.

Observations

This ask height for Sync 2 is also sporadically changing on different runs. Same code with the next run is giving different number.

Tip Height : 102
Sync 1
Asking filters : 0 : 102
Sync complete at : 102
Tip Height : 202
Sync 2
Asking filters : 0 : 200

Now its halted after asking till height 200.
So for some reason the client is confused on whats the tip height till which it needs to ask filters for.

[usage question] How to get `block`, `filters` and `transaction` from the `client`?

I am currently trying to use nakamoto client to create a CBF backend for BDK. I am looking for ways to get the following stuffs from the client..

  • Given a BlockHash, get the full Block. There is a method get_block() but its not returning anything. So how can I get the block result after sending the command to the client?

    fn get_block(&self, hash: &BlockHash) -> Result<(), handle::Error> {
    self.command(Command::GetBlock(*hash))?;
    Ok(())
    }

  • Given a range get some filter: Same question for Filters. gert_filters() doesn't return anything. How can I get the filters?

    fn get_filters(&self, range: RangeInclusive<Height>) -> Result<(), handle::Error> {
    assert!(
    !range.is_empty(),
    "client::Handle::get_filters: range cannot be empty"
    );
    let (transmit, receive) = chan::bounded(1);
    self.command(Command::GetFilters(range, transmit))?;
    receive.recv()?.map_err(handle::Error::GetFilters)
    }

  • Given a txid, get the transaction. IIUC the node contains all the confirmed and unconfirmed transactions in the Inventory manager.

    fn get_filters(&self, range: RangeInclusive<Height>) -> Result<(), handle::Error> {
    assert!(
    !range.is_empty(),
    "client::Handle::get_filters: range cannot be empty"
    );
    let (transmit, receive) = chan::bounded(1);
    self.command(Command::GetFilters(range, transmit))?;
    receive.recv()?.map_err(handle::Error::GetFilters)
    }
    . Is it possible to expose a Handle api to get one of those transaction given a txid?

Thanks in advanced.. :)

panic after receiving a new block

Hey, I was running nakamoto in signet, while printing all the block events I would receive. Right after receiving a new block, nakamoto panicked:

[bdk_cbf_example/src/cbf.rs:75] &event = BlockConnected {
    header: BlockHeader {
        version: 536870912,
        prev_blockhash: 00000008aba684fca566d94ef5837809c2e75bf9eb7ed8eb3c7f372a6d384bcd,
        merkle_root: a1ca3310554f5ac5a2458035d6f03ac7e864e0fc9f70b868d856a7f8b1d34f62,
        time: 1672147416,
        bits: 503401653,
        nonce: 7327687,
    },
    hash: 000000c227872bade53ff0abca1e1dd9f5097db1f6947517b7d98a8500f213b8,
    height: 123040,
}
thread '<unnamed>' panicked at 'assertion failed: height <= tree.height()', /home/daniela/Developer/nakamoto/p2p/src/fsm/cbfmgr.rs:666:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I commented this line and restarted the program:

assert!(filter_height <= block_height);

I received a Ready event like this one (note that the tip is less than the filter_tip):

[bdk_cbf_example/src/cbf.rs:75] &event = Ready {
    tip: 123041,
    filter_tip: 123042,
}

and now everything seems to work normally.

Transaction management & Rescan

Keeping track of everything needed for transaction management.

  • Announcing/broadcasting transactions to the network
  • Sending transactions when receiving a getdata(txid)
  • Re-broadcasting inventories
  • Retry block getdata
  • Add unconfirmed txs to mempool
  • Confirmed transactions are removed from mempool
  • Transactions removed from mempool are no longer re-broadcast
  • Monitor incoming and outgoing transactions from specific addresses
  • Monitor transaction inclusion
  • Chain re-scan for addresses, using start block (forward-scan)
  • Handle re-orgs

Crash on First Run

Running the node for the first time results in a crash. The root of the issue lies in the logic for determining the success of the event::Subscriber::publish function.

impl<T: Clone> Subscriber<T> {
    pub fn publish(&self, event: T) -> bool {
        let mut subs = self.subscribers.lock().unwrap();
        subs.retain(|s| s.try_send(event.clone()).is_ok());
        subs.is_empty().not()
    }
}

If there are no subscribers at the time of this call, then failure is returned. This is the case for the loading subscriber in the client.

Workaround:

impl<T: Clone> Subscriber<T> {
    pub fn publish(&self, event: T) -> bool {
        let mut subs = self.subscribers.lock().unwrap();
+++     if subs.is_empty() {
+++         return true;
+++     }
        subs.retain(|s| s.try_send(event.clone()).is_ok());
        subs.is_empty().not()
    }
}

Node fails to look up DNS seeds

hunter@hematite ~/P/c/nakamoto (master) [1]> cargo run --release -p nakamoto-node -- --root /run/media/hunter/SDXC/nakamoto/
    Finished release [optimized] target(s) in 0.03s
     Running `target/release/nakamoto-node --root /run/media/hunter/SDXC/nakamoto/`
2021-05-16T00:59:29.756-06:00 INFO nakamoto_client::client Initializing client (Mainnet)..
2021-05-16T00:59:29.756-06:00 INFO nakamoto_client::client Genesis block hash is 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
2021-05-16T00:59:29.756-06:00 INFO nakamoto_client::client Found existing store "/run/media/hunter/SDXC/nakamoto/.nakamoto/mainnet/headers.db"
2021-05-16T00:59:29.756-06:00 INFO nakamoto_client::client Store height = 0
2021-05-16T00:59:29.756-06:00 INFO nakamoto_client::client Loading block headers from store..
2021-05-16T00:59:29.756-06:00 INFO nakamoto_client::client Initializing block filters..
2021-05-16T00:59:29.756-06:00 INFO nakamoto_client::client Found existing store "/run/media/hunter/SDXC/nakamoto/.nakamoto/mainnet/filters.db"
2021-05-16T00:59:29.756-06:00 INFO nakamoto_client::client Filters height = 0
2021-05-16T00:59:29.756-06:00 INFO nakamoto_client::client Loading filter headers from store..
2021-05-16T00:59:29.756-06:00 INFO nakamoto_client::client Verifying filter headers..
2021-05-16T00:59:29.756-06:00 INFO nakamoto_client::client Loading peer addresses..
2021-05-16T00:59:29.756-06:00 INFO nakamoto_client::client Found existing peer cache "/run/media/hunter/SDXC/nakamoto/.nakamoto/mainnet/peers.json"
2021-05-16T00:59:29.756-06:00 INFO nakamoto_client::client 0 peer(s) found..
2021-05-16T00:59:29.756-06:00 INFO nakamoto_client::client Address book is empty. Trying DNS seeds..
2021-05-16T00:59:29.789-06:00 ERROR nakamoto_node Exiting: failed to lookup address information: Name or service not known

Rust: 1.52 (stable)
OS: Arch Linux

I'd, uh, say more stuff, but I'm not sure what more else to say. I got my fork of murmel working, though! Very fast to sync, DB is about 140MB on-disk. (Murmel uses Hammersbald)

Multi-peer IBD

Initial block (header) download can be made faster by syncing from multiple peers. To do this, we can use the hard-coded checkpoints to request multiple block ranges.

Cargo.toml missing expected `package` or `project` fields

Hi, I'm new to rust, I've been very interested in the implementation of nakamoto's lightweight node. I have had some problems during installation and configuration.

In the Cargo.ml file I have the following parameters:

[dependencies]
cargo-edit = "0.7.0"
nakamoto-client = "0.2.0"

But when executing the command: cargo add nakamoto-client it gives me the following error:

[root@nakamoto ~]# cargo add nakamoto-client
    Updating 'https://github.com/rust-lang/crates.io-index' index
      Adding nakamoto-client v0.2.0 to dependencies
Command failed due to unhandled error: Cargo.toml missing expected `package` or `project` fields

I already have cargo_edit installed.

What could be happening?

Regards

Mobile integration

Hi there!

I'm starting to look at ways we could integrate a BIP157/158 client into Android applications (or just mobile in general), and wondered if you have any resources/docs on that somewhere. Has anyone tried it in a sample app, or do you know how you'd like to go about it? I see an open issue about an FFI layer (#14), but wondering if know of any other information you could point me to.

I'm one of the maintainers for bdk-ffi and bdk-android, and I maintain a sample Android app that showcases how to use the Bitcoin Development Kit (the Devkit Wallet). The wallet currently uses Electrum for its chain data, but I'd love to enable Neutrino-like client capabilities.

Related to this is the fact that the BDK library is looking at enabling using Neutrino clients for its blockchain data, and I'd like to help test/implement that using Nakamoto on Android.

Cheers!

Make client restartable

When client.run fails, users have to create a new client, reload blocks and peers before sync can be started. We should ensure client doesn't panic or is easily restartable.

Cannot start wallet

in terminal

./nakamoto-wallet --addresses bc1q0qjylfgu4t8yky6fxr599yw23ruqun0030t9af --genesis 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f

gives this

Error parsing option '--genesis' with value '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f': invalid digit found in string

What could I do wrong?

nakamoto p2p: panicked at 'assertion failed: peer.last_asked.as_ref() != Some(&locators)'

This is the log that I see on my node

I am writing a lightning node with the ldk using nakamoto, it is not completed al all but I found a strange crash
this morning that I am leaving it there

Looks like that nakamoto crash with the following assertion

thread '<unnamed>' panicked at 'assertion failed: peer.last_asked.as_ref() != Some(&locators)', /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/8744d43/p2p/src/fsm/syncmgr.rs:425:13

A full log is reported below.

2023-04-10T12:23:47.342Z WARN p2p Error receiving filter headers: ignoring message from [2001:19f0:6402:89:5400:4ff:fe4e:8adf]:18333: previous filter header does not match local tip
2023-04-10T12:23:48.113Z DEBUG p2p Received "headers" from [2001:19f0:6402:89:5400:4ff:fe4e:8adf]:18333
2023-04-10T12:23:48.113Z DEBUG nakamoto_p2p::fsm::syncmgr [sync] Received 1 block header(s) from [2001:19f0:6402:89:5400:4ff:fe4e:8adf]:18333
2023-04-10T12:23:48.113Z INFO p2p Block 000000000000e9ea85f16406a8f1f641ffc0c9623c4b241e26aa43d2053ba8f9 connected at height 2428316
2023-04-10T12:23:48.113Z INFO p2p Headers synced up to height 2428316 with hash 000000000000e9ea85f16406a8f1f641ffc0c9623c4b241e26aa43d2053ba8f9
2023-04-10T12:23:48.114Z INFO p2p Headers synced up to height 2428316 with hash 000000000000e9ea85f16406a8f1f641ffc0c9623c4b241e26aa43d2053ba8f9
2023-04-10T12:23:48.114Z INFO p2p Filter header chain is out of sync by 618 header(s) (2427698 to 2428316)
2023-04-10T12:23:48.114Z DEBUG p2p Sending "getcfheaders" to [2001:19f0:6402:89:5400:4ff:fe4e:8adf]:18333
2023-04-10T12:23:48.114Z INFO p2p Syncing filter headers with [2001:19f0:6402:89:5400:4ff:fe4e:8adf]:18333 from height 2427699 to 2428316 (block hash 000000000000e9ea85f16406a8f1f641ffc0c9623c4b241e26aa43d2053ba8f9)
2023-04-10T12:23:48.114Z DEBUG p2p Received "headers" from 45.76.236.69:18333
2023-04-10T12:23:48.114Z DEBUG nakamoto_p2p::fsm::syncmgr [sync] Received 1 block header(s) from 45.76.236.69:18333
2023-04-10T12:23:48.114Z DEBUG p2p Received "headers" from 35.212.255.229:18333
2023-04-10T12:23:48.114Z DEBUG nakamoto_p2p::fsm::syncmgr [sync] Received 1 block header(s) from 35.212.255.229:18333
2023-04-10T12:23:48.114Z DEBUG p2p Received "inv" from 35.214.213.127:18333
2023-04-10T12:23:48.114Z INFO p2p 35.214.213.127:18333: Discovered new block: 000000008a5eef11c068509444bc7d7e89fe366726b1ade9f6f821f0cd29d6b1
2023-04-10T12:23:48.114Z DEBUG p2p Sending "getheaders" to 35.214.213.127:18333
2023-04-10T12:23:48.115Z DEBUG nakamoto_client::service Write RawNetworkMessage { magic: 118034699, payload: GetCFHeaders(GetCFHeaders { filter_type: 0, start_height: 2427699, stop_hash: 000000000000e9ea85f16406a8f1f641ffc0c9623c4b241e26aa43d2053ba8f9 }) } to 2001:19f0:6402:89:5400:4ff:fe4e:8adf
2023-04-10T12:23:48.115Z DEBUG nakamoto_client::service Write RawNetworkMessage { magic: 118034699, payload: GetHeaders(GetHeadersMessage { version: 70016, locator_hashes: [000000000000e9ea85f16406a8f1f641ffc0c9623c4b241e26aa43d2053ba8f9, 00000000000016802f5f22dfd3109c6282f600845e950a54372ed4c3399188c9, 000000000000000e05885585fee6019dd05b2c5db17d61d2c7eca4ea78020155, 0000000000001b2c8529901836c39a450fc31bf61a8fb9e30811ff58f79d47bf, 00000000000000119a17f9acf99d53720afc97a28ddca3550329cfac335df8b1, 00000000000000113593b5b8992e4276c609ab7e3d12b942a555ca1079066bcd, 0000000000000019609321bcf6323650fe737c3bc9c4011650cda4fa0d2499c8, 00000000000069022b2de75a9457275cde3c508d54d961e084e0d237c35e71b5, 00000000eec0ec264c1a6e648bbcf318d82e076039692abf243043e7e2b9111d, 000000000000000aef5999ee05eb018888766dcd63f91d9121c3a717ab59dda7, 0000000000006f6db17813af4d0cd0201d421baa43db7bd613a0543e33dd6514, 00000000000000132f067bf278c24063822e5e122ecad7986f7c072645894890, 0000000000000009a775f2b20eb909752d3d57eae0fd5d9f0ed521c49ef144bf, 000000000000002613a8c8fab9051c0e6ac07c9eacb9cd5fa1ed436f617e4478, 000000000000000f3c35e62957d7495744ddf5985c781a279163bb1d80eefaaf, 00000000000000162f2a57878b6a7eb7e908df78c46831229a243866f1d9160f, 0000000000000005b11efef006719f1bf1fd5b49f67a928d9ef32d376b5d7357, 0000000000002205f81e66eaf6be01257d5e656e76a3ee428b22bcafd13f1915, 00000000cb1d7356d7658874263ca095429a98ef9a05c65c5641af7e3b828b24, 00000000000000185c13cb1113b24eafebdcfe21876db1805b32cfe9e538459e, 00000000000000007b5dfdb35e9400b69abe9b27f42b8b7516d9e49c70638021, 000000000000002ee3cd3b70485ce9f4df68f27faf407ae2a2fdf09fcfe94d38, 0000000000009e01086a2ff1dafb169ab8fcc12ee7998a8a371421b796007e8a, 000000000000a57c51ffa2de52b238154578b51e9ee067f59b96154c887d7d6f, 0000000000013ebf77921352a1350efa8027d9b6f68c7f0bb0b56ab97f94f826, 000000000000c04b88528605a8b18606913080e449c528924ef2c9deddc5598f, 00000000483d88dc015e55d833403af14c074e0bb8dd159afc29596b0683750f, 00000000000003158e02031c49590d41ed6672d5d6ae01d7b8000a5919efc563, 00000000065cb17eaac6c309ef037156aeb71aa50ff538a1775b38a04aa50863], stop_hash: 000000008a5eef11c068509444bc7d7e89fe366726b1ade9f6f821f0cd29d6b1 }) } to 35.214.213.127
2023-04-10T12:23:48.137Z DEBUG p2p Received "headers" from 66.183.0.205:18333
2023-04-10T12:23:48.137Z DEBUG nakamoto_p2p::fsm::syncmgr [sync] Received 1 block header(s) from 66.183.0.205:18333
2023-04-10T12:23:48.156Z DEBUG p2p Received "headers" from 35.214.213.127:18333
2023-04-10T12:23:48.156Z DEBUG nakamoto_p2p::fsm::syncmgr [sync] Received 1 block header(s) from 35.214.213.127:18333
2023-04-10T12:23:48.156Z INFO p2p Block 000000000000e9ea85f16406a8f1f641ffc0c9623c4b241e26aa43d2053ba8f9 disconnected at height 2428316
2023-04-10T12:23:48.156Z INFO p2p Block 000000008a5eef11c068509444bc7d7e89fe366726b1ade9f6f821f0cd29d6b1 connected at height 2428316
2023-04-10T12:23:48.156Z INFO p2p Headers synced up to height 2428316 with hash 000000008a5eef11c068509444bc7d7e89fe366726b1ade9f6f821f0cd29d6b1
2023-04-10T12:23:48.156Z INFO p2p Headers synced up to height 2428316 with hash 000000008a5eef11c068509444bc7d7e89fe366726b1ade9f6f821f0cd29d6b1
2023-04-10T12:23:48.157Z INFO p2p Filter header chain is out of sync by 618 header(s) (2427698 to 2428316)
2023-04-10T12:23:48.157Z DEBUG p2p Sending "getcfheaders" to 66.183.0.205:18333
2023-04-10T12:23:48.157Z INFO p2p Syncing filter headers with 66.183.0.205:18333 from height 2427699 to 2428316 (block hash 000000008a5eef11c068509444bc7d7e89fe366726b1ade9f6f821f0cd29d6b1)
2023-04-10T12:23:48.157Z DEBUG nakamoto_client::service Write RawNetworkMessage { magic: 118034699, payload: GetCFHeaders(GetCFHeaders { filter_type: 0, start_height: 2427699, stop_hash: 000000008a5eef11c068509444bc7d7e89fe366726b1ade9f6f821f0cd29d6b1 }) } to 66.183.0.205
2023-04-10T12:23:48.233Z DEBUG p2p Received "headers" from 34.210.154.40:18333
2023-04-10T12:23:48.233Z DEBUG nakamoto_p2p::fsm::syncmgr [sync] Received 1 block header(s) from 34.210.154.40:18333
2023-04-10T12:23:48.235Z DEBUG p2p Sending "getheaders" to 34.210.154.40:18333
2023-04-10T12:23:48.235Z DEBUG nakamoto_client::service Write RawNetworkMessage { magic: 118034699, payload: GetHeaders(GetHeadersMessage { version: 70016, locator_hashes: [000000008a5eef11c068509444bc7d7e89fe366726b1ade9f6f821f0cd29d6b1, 00000000000016802f5f22dfd3109c6282f600845e950a54372ed4c3399188c9, 000000000000000e05885585fee6019dd05b2c5db17d61d2c7eca4ea78020155, 0000000000001b2c8529901836c39a450fc31bf61a8fb9e30811ff58f79d47bf, 00000000000000119a17f9acf99d53720afc97a28ddca3550329cfac335df8b1, 00000000000000113593b5b8992e4276c609ab7e3d12b942a555ca1079066bcd, 0000000000000019609321bcf6323650fe737c3bc9c4011650cda4fa0d2499c8, 00000000000069022b2de75a9457275cde3c508d54d961e084e0d237c35e71b5, 00000000eec0ec264c1a6e648bbcf318d82e076039692abf243043e7e2b9111d, 000000000000000aef5999ee05eb018888766dcd63f91d9121c3a717ab59dda7, 0000000000006f6db17813af4d0cd0201d421baa43db7bd613a0543e33dd6514, 00000000000000132f067bf278c24063822e5e122ecad7986f7c072645894890, 0000000000000009a775f2b20eb909752d3d57eae0fd5d9f0ed521c49ef144bf, 000000000000002613a8c8fab9051c0e6ac07c9eacb9cd5fa1ed436f617e4478, 000000000000000f3c35e62957d7495744ddf5985c781a279163bb1d80eefaaf, 00000000000000162f2a57878b6a7eb7e908df78c46831229a243866f1d9160f, 0000000000000005b11efef006719f1bf1fd5b49f67a928d9ef32d376b5d7357, 0000000000002205f81e66eaf6be01257d5e656e76a3ee428b22bcafd13f1915, 00000000cb1d7356d7658874263ca095429a98ef9a05c65c5641af7e3b828b24, 00000000000000185c13cb1113b24eafebdcfe21876db1805b32cfe9e538459e, 00000000000000007b5dfdb35e9400b69abe9b27f42b8b7516d9e49c70638021, 000000000000002ee3cd3b70485ce9f4df68f27faf407ae2a2fdf09fcfe94d38, 0000000000009e01086a2ff1dafb169ab8fcc12ee7998a8a371421b796007e8a, 000000000000a57c51ffa2de52b238154578b51e9ee067f59b96154c887d7d6f, 0000000000013ebf77921352a1350efa8027d9b6f68c7f0bb0b56ab97f94f826, 000000000000c04b88528605a8b18606913080e449c528924ef2c9deddc5598f, 00000000483d88dc015e55d833403af14c074e0bb8dd159afc29596b0683750f, 00000000000003158e02031c49590d41ed6672d5d6ae01d7b8000a5919efc563, 00000000065cb17eaac6c309ef037156aeb71aa50ff538a1775b38a04aa50863], stop_hash: 000000000000e9ea85f16406a8f1f641ffc0c9623c4b241e26aa43d2053ba8f9 }) } to 34.210.154.40
2023-04-10T12:23:48.241Z DEBUG p2p Received "inv" from 203.132.94.196:18333
2023-04-10T12:23:48.300Z DEBUG p2p Received "inv" from 110.141.252.80:18333
2023-04-10T12:23:48.313Z DEBUG p2p Received "cfheaders" from [2001:19f0:6402:89:5400:4ff:fe4e:8adf]:18333
2023-04-10T12:23:48.313Z DEBUG spv Received 618 filter header(s) from [2001:19f0:6402:89:5400:4ff:fe4e:8adf]:18333
2023-04-10T12:23:48.313Z DEBUG p2p Disconnecting from [2001:19f0:6402:89:5400:4ff:fe4e:8adf]:18333: peer misbehaving: unknown `cfheaders` stop hash
2023-04-10T12:23:48.313Z INFO p2p Disconnected from [2001:19f0:6402:89:5400:4ff:fe4e:8adf]:18333 (peer misbehaving: unknown `cfheaders` stop hash)
2023-04-10T12:23:48.314Z INFO p2p Connecting to peer 54.215.91.44:18333 from source `84.27.211.215:18333` with ServiceFlags(NETWORK|WITNESS|COMPACT_FILTERS|NETWORK_LIMITED)
2023-04-10T12:23:48.350Z INFO p2p Disconnected from 66.183.0.205:18333 (connection reset)
2023-04-10T12:23:48.351Z INFO p2p Connecting to peer 16.162.119.13:18333 from source `3.71.96.36:18333` with ServiceFlags(NETWORK|WITNESS|COMPACT_FILTERS|NETWORK_LIMITED)
2023-04-10T12:23:48.433Z INFO p2p Filter header chain is out of sync by 618 header(s) (2427698 to 2428316)
2023-04-10T12:23:48.437Z DEBUG p2p Received "headers" from 34.210.154.40:18333
2023-04-10T12:23:48.438Z DEBUG nakamoto_p2p::fsm::syncmgr [sync] Received 1 block header(s) from 34.210.154.40:18333
thread '<unnamed>' panicked at 'assertion failed: peer.last_asked.as_ref() != Some(&locators)', /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/8744d43/p2p/src/fsm/syncmgr.rs:425:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2023-04-10T12:24:04.782Z DEBUG lampod::utils::logger -1 TRACE [lightning_background_processor:597] Calling PeerManager's timer_tick_occurred

2023-04-10T12:24:06.086Z DEBUG lampod::utils::logger -1 TRACE [lightning_background_processor:597] Persisting scorer

2023-04-10T12:24:06.086Z ERROR lampod::utils::logger -1 ERROR [lightning_background_processor:597] Error: Failed to persist scorer, check your disk and permissions File exists (os error 17)

2023-04-10T12:24:15.615Z DEBUG lampod::utils::logger -1 TRACE [lightning_background_processor:597] Calling ChannelManager's timer_tick_occurred

2023-04-10T12:24:15.615Z ERROR lampo_nakamoto Err(Disconnected)
thread '<unnamed>' panicked at 'Err(Disconnected)', lampo-nakamoto/src/lib.rs:107:13
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', /home/vincent/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lightning-background-processor-0.0.114/src/lib.rs:641:43

In addition, I am running a custom version of Nakamoto where I join different features proposed with by me with a PR, the branch that I am running is https://github.com/vincenzopalazzo/nakamoto/tree/macros/client_model-fixes

panicked at 'assertion failed: `(left == right)

I'm pretty sure this issue has already been reported, but I'm having trouble finding it.

My Nakamoto instance is crashing at startup with the following assertion:

2023-04-26T11:51:18.340Z INFO client Loading block headers from store..
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
  left: `2431071`,
 right: `2431070`', /home/vincent/.cargo/git/checkouts/nakamoto-90f2d5c288bae2ec/8744d43/chain/src/block/cache.rs:169:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Disconnected', lampo-nakamoto/src/lib.rs:85:42

I haven't had time to investigate further, but I believe this is an issue that Nakamoto should be able to recover from.

leaving it there for future issue triage.

Compiling error

In a Ubuntu 20.04 LTS on Windows Subsystem Linux v2 I got the following error with cargo build:
Compiling nakamoto-p2p v0.2.0 (/home/paco/nakamoto/p2p)
error[E0658]: use of unstable library feature 'range_is_empty': recently added
--> p2p/src/protocol/spvmgr.rs:541:30
|
541 | debug_assert!(!range.is_empty());
| ^^^^^^^^
|
= note: see issue #48111 rust-lang/rust#48111 for more information

error[E0658]: use of unstable library feature 'range_is_empty': recently added
--> p2p/src/protocol/spvmgr.rs:543:18
|
543 | if range.is_empty() {
| ^^^^^^^^
|
= note: see issue #48111 rust-lang/rust#48111 for more information

error: aborting due to 2 previous errors

For more information about this error, try rustc --explain E0658.
error: could not compile nakamoto-p2p.

To learn more, run the command again with --verbose.

C FFI

Starting thinking about how a C FFI would look, as the API stabilizes. For now, this FFI should only be around the nakamoto-client crate.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.