-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Setting -blocksonly sets -maxmempool to zero. #9569
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
Conversation
Nodes running in -blocksonly mode do not send and receive transactions outside blocks. They do not have a mempool, so -maxmempool should be set to 0. Unused mempool memory can be used for the UTXO coincache (PR bitcoin#8610) so not setting -maxmempool to 0 can cause to coincache to grow larger than expected. If -blocksonly is set and -maxmempool is set to anything other than 0, error and exit. If -blocksonly is set and -maxmempool is not set, implicitly set -maxmempool to 0.
99daee0
to
2838d28
Compare
Whitelisted peers can still relay transactions for blocksonly, I suspect this would break that. (FWIW I don't like that whitelisting does stuff like that, but its what it does and people depend on it) |
The intended behavior is for nodes in blocks only mode to have a mempool
because of whitelisted peers.
NACK
…On Jan 17, 2017 4:48 PM, "Gregory Maxwell" ***@***.***> wrote:
Whitelisted peers can still relay transactions for blocksonly, I suspect
this would break that.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9569 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAl4QxnJy-KrmMlFU_e6Trkgj7BTg3alks5rTVNRgaJpZM4LmBxS>
.
|
Interesting, I was not aware.
How do we reconcile these things? Someone without whitelisted peers who
sets -blocksonly will not have a mempool, and can reasonably expect that
there won't ne an extra 300 MB added to their dbcache.
Even in cases where whitelisted peers exist, I doubt a full 300 MB (if
-maxmempool was not changed) will be used in commom cases.
Maybe -blocksonly should just disable the mempool/dbcache share, as
whatever mempool remains under these circumstances can't be a typical
always-full mempool?
|
@gmaxwell @pstratem Thank you. I wasn't aware of this behaviour. As far as I can tell, this can only happen to a -blocksonly node as follows:
so this can only happen if the node is connecting to a non-bitcoin-core peer which is disregarding the semantics of the relay field in the version message. @gmaxwell @pstratem can you give some use cases? Are people relying on this behaviour? |
Transaction relay to whitelisted peers ignores fRelay
…On Jan 18, 2017 12:03 PM, "John Newbery" ***@***.***> wrote:
@gmaxwell <https://github.com/gmaxwell> @pstratem
<https://github.com/pstratem> Thank you. I wasn't aware of this behaviour.
As far as I can tell, this can only happen to a -blocksonly node as
follows:
- the node connects to a peer and sends a version message. The 'relay'
field is set to FALSE (see PushNodeVersion() in net_processing.cpp -
bitcoin core *always* sets relay to FALSE if -blocksonly is set since
the global fRelayTxes = !blocksonly).
- the peer disregards the relay field. Note that bitcoin core respects
the relay field that it receives (see ProcessMessage() in
net_processing.cpp.
- the peer sends INVs/TXs, which the node accepts because
-whitelistrelay is set.
so this can *only* happen if the node is connecting to a non-bitcoin-core
peer which is disregarding the semantics of the relay field in the version
message.
@gmaxwell <https://github.com/gmaxwell> @pstratem
<https://github.com/pstratem> can you give some use cases? Are people
relying on this behaviour?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9569 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAl4Q4_0uz6blDzMpNtW2J0BGQrbL7XMks5rTmIEgaJpZM4LmBxS>
.
|
@pstratem Maybe I'm misunderstanding, but I would expect the only way for transactions to enter the node's mempool is for transactions to be relayed from peers. That can't happen if blocksonly is set, unless that peer is violating the relay field in our version message. Of course, we can send transactions to peers. That's true without a mempool, and is unaffected by this PR. You seem to understand this better than me - can you explain where I'm wrong. |
Somewhat unrelated to the discussion here, but I've been meaning to get rid of the fRelayTxes global for a while. I just hacked this up, and I think it makes reasoning about this much easier: theuni@f196610 . It was done quickly and probably isn't quite right, but I'll clean it up and PR separately if the approach is agreed upon. |
@theuni I agree that we should get rid of the global to make reasoning easier. I also think we need additional documentation here to make the intended behaviour more explicit (ie that blocksonly doesn't mean only blocks if you have some other setting!). Please tag me when you have a PR for the relay/accept transactions split so I can review it. I've had a look at theuni@f196610 and the approach looks generally good. |
Nodes in blocks only mode will accept transactions sent to them.
Nodes which have whitelisted a blocks only peer will send them transactions.
The only way to achieve what you want is to dynamically resize the cache
based on available memory.
…On Jan 18, 2017 5:20 PM, "John Newbery" ***@***.***> wrote:
@pstratem <https://github.com/pstratem> Maybe I'm misunderstanding, but I
would expect the only way for transactions to enter the node's mempool is
for transactions to be relayed *from* peers. That can't happen if
blocksonly is set, unless that peer is violating the relay field in our
version message.
Of course, we can send transactions *to* peers. That's true without a
mempool, and is unaffected by this PR.
You seem to understand this better than me - can you explain where I'm
wrong.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9569 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAl4Q1VKp8FTHJof-6PIhoCxB5JZlROxks5rTqxagaJpZM4LmBxS>
.
|
I don't think this is true. When a blocksonly node connects to a peer, it sends the version header with the relay field set to false:
( bitcoin/src/net_processing.cpp Lines 258 to 259 in 727a798
The peer receives that version message and sets fRelayTxes to false for that CNode. Any whitelist settings are not considered here:
( bitcoin/src/net_processing.cpp Lines 1242 to 1243 in 727a798
When the peer is sending messages to the blocksonly node, it checks the fRelayTxes field and explicitly clears all txs from its INV messages:
( bitcoin/src/net_processing.cpp Line 3017 in 727a798
I've run some tests locally, and they seem to confirm that bitcoin nodes will not send transactions to blocksonly peers, regardless of whitelist settings. Furthermore, setting -blocksonly soft sets -walletbroadcast to false, so the blocksonly node won't even broadcast transactions it originates (which is sensible behaviour - nodes that broadcasts just their own transactions are terrible for transaction privacy). It seems to me that the only ways to get transactions into a blocksonly node's mempool are to:
|
Maybe it's easier to just not add the unused mempool space to the available dbcache when blocksonly is set? |
@sipa - it's certainly true that what you're suggesting is possible. It's the approach that I started with, but changed tack later because it was a far smaller, cleaner code change to simply set mempool size to zero. I'm happy to revert to my original approach, but at the very least we should understand and document the behaviour that @pstratem is talking about. From my testing and code-reading, it doesn't seem possible that blocksonly nodes would ever have anything in their mempool. I also don't understand the use-case. |
Whitelisting was originally added so that armory user's mandatory Bitcoin nodes would still be able to reliably relay transactions when the armory software, which ignores frelaytxes, behind them wanted the transactions relayed. I have been told that other commercial custom wallet code depend on this whitelist always relays behavior (which is too bad, because I dislike it and think we never should have done it that way). The reason for this is because otherwise if your 'wallet' is implemented as [bitcoin core] - [custom stuff] there is no way for your custom stuff to implement a rebroadcast like functionality similar to that of the integrated wallet. Blocksonly isn't even a document option yet, because it has no servicebits significance so nodes could avoid having all their automatic outbound peers be blocks only and ending up unable to relay transactions. It will be at least one BIP and two releases from being a documented option for that reason (unless the thinking changes), so I really don't think it matters how we handle its memory usage vs dbcache for now. |
Looks like this is stuck/controversial. I think it's a good point that |
Yes - closing for now. This should be revisited when blocksonly is made a non-debug option. |
|
Fixes #9526
Nodes running in -blocksonly mode do not send and receive transactions
outside blocks. They do not have a mempool, so -maxmempool should be set
to 0.
Unused mempool memory can be used for the UTXO coincache (PR #8610) so
not setting -maxmempool to 0 can cause to coincache to grow larger than
expected.
If -blocksonly is set and -maxmempool is set to anything other than 0,
error and exit. If -blocksonly is set and -maxmempool is not set,
implicitly set -maxmempool to 0.
I've also added an additional comment around the nMempoolSizeMin check
in AppInitParameterInteraction() since it wasn't immediately obvious to me
what that check was doing.