Skip to content

net: Log unknown CInv in PushInventory#15945

Closed
Bushstar wants to merge 1 commit intobitcoin:masterfrom
Bushstar:cinv-unknown
Closed

net: Log unknown CInv in PushInventory#15945
Bushstar wants to merge 1 commit intobitcoin:masterfrom
Bushstar:cinv-unknown

Conversation

@Bushstar
Copy link
Copy Markdown
Contributor

@Bushstar Bushstar commented May 3, 2019

Message for anyone adding an experimental or malformed CInv and using the PushInventory. Experimental Cinv should probably be added to its own vector for processing elsewhere like setInventoryTxToSend and vInventoryBlockToSend.

Update: Including the five locations below that call PushInventory with a CInv with its member variable 'type' set to either MSG_BLOCK or MSG_TX.

https://github.com/bitcoin/bitcoin/blob/7f0d7e7ed5b2a6a14a3fc9e5bf4d99073017b01e/src/interfaces/chain.cpp#L286-L287
https://github.com/bitcoin/bitcoin/blob/7f0d7e7ed5b2a6a14a3fc9e5bf4d99073017b01e/src/net_processing.cpp#L1206-L1210
https://github.com/bitcoin/bitcoin/blob/7f0d7e7ed5b2a6a14a3fc9e5bf4d99073017b01e/src/net_processing.cpp#L2264
https://github.com/bitcoin/bitcoin/blob/7f0d7e7ed5b2a6a14a3fc9e5bf4d99073017b01e/src/net_processing.cpp#L3680
https://github.com/bitcoin/bitcoin/blob/7f0d7e7ed5b2a6a14a3fc9e5bf4d99073017b01e/src/node/transaction.cpp#L72-L75

@fanquake fanquake added the P2P label May 3, 2019
@Bushstar
Copy link
Copy Markdown
Contributor Author

Bushstar commented May 3, 2019

Travis ran out of time on the last build, please press rebuild on Travis.

https://travis-ci.org/bitcoin/bitcoin/builds/527704947?utm_source=github_status&utm_medium=notification

@Bushstar
Copy link
Copy Markdown
Contributor Author

Bushstar commented May 3, 2019

From Travis

No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.

I'll recreate the commit and force push to get it to build again, I'd expect this to pass as every other build completed and the change is trivial.

@DrahtBot
Copy link
Copy Markdown
Contributor

DrahtBot commented May 3, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #15253 (Net: Consistently log outgoing INV messages by Empact)
  • #14046 (net: Refactor message parsing (CNetMessage), adds flexibility by jonasschnelli)
  • #14032 (Add p2p layer encryption with ECDH/ChaCha20Poly1305 by jonasschnelli)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@laanwj
Copy link
Copy Markdown
Member

laanwj commented May 6, 2019

Is this purely an implementation bug if this happens or can it be network-triggered?

Copy link
Copy Markdown
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

NACK, temporarily add the log if you are pushing other CInv. Unless you want to abort after the log:

} else {
    fprintf(stderr, "%s: Unknown CInv type:%s\n", __func__, inv.ToString());
    abort();

@Bushstar
Copy link
Copy Markdown
Contributor Author

Bushstar commented May 6, 2019

Is this purely an implementation bug if this happens or can it be network-triggered?

This will only be triggered via implementation most likely downstream of Bitcoin!

@laanwj
Copy link
Copy Markdown
Member

laanwj commented May 8, 2019

This will only be triggered via implementation most likely downstream of Bitcoin!

In that case, I think if this merits any change at all, an assertion (this is invalid input for this function) makes more sense.

@Bushstar
Copy link
Copy Markdown
Contributor Author

Bushstar commented May 8, 2019

vInventoryBlockToSend.push_back(inv.hash);
} else {
LogPrint(BCLog::NET, "%s: Unknown CInv type:%s\n", __func__, inv.ToString());
assert(false); // Should never happen in Bitcoin, only MSG_TX/MSG_BLOCK expected.
Copy link
Copy Markdown
Member

@maflcko maflcko May 8, 2019

Choose a reason for hiding this comment

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

Block relay and transaction relay have little in common. Over a run time assert, I'd rather make it impossible at compile time that no other types can be pushed. One way to achieve this is to remove PushInventory and add a method CNode::PushInventoryBlock(const&uint256 hash) (and PushInventoryTx respectively).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The PR below splits PushInventory into two.

#15253

@promag
Copy link
Copy Markdown
Contributor

promag commented May 9, 2019

Closed by #15992?

@laanwj
Copy link
Copy Markdown
Member

laanwj commented May 20, 2019

Closing, sorry, this is seemingly too controversial and hogging too much reviewer time for a change that doesn't accomplish anything in the current code.

@laanwj laanwj closed this May 20, 2019
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants