Skip to content
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

Keep track of recently rejected transactions. #484

Merged
merged 1 commit into from
Apr 10, 2016
Merged

Keep track of recently rejected transactions. #484

merged 1 commit into from
Apr 10, 2016

Conversation

dajohi
Copy link
Member

@dajohi dajohi commented Aug 13, 2015

This prevents the node from repeatedly requesting and rejecting the
same transaction as different peers inv the same transaction.

Idea from Bitcoin Core commit 0847d9cb5fcd2fdd5a21bde699944d966cf5add9.

Review on Reviewable

// limitNumRejectedTxns limits the number of rejected transactions by evicting
// a random rejected transaction if adding a new one would cause it to overflow
// the max allowed.
func (b *blockManager) limitNumRejectedTxns() error {
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer this be defined above the only function it's called from so it's consistent with the vast majority of the code base.

@davecgh
Copy link
Member

davecgh commented Aug 13, 2015

Other than my comment this looks good. I'll do some manual testing on it as well.

@davecgh davecgh added mempool and removed mempool labels Aug 23, 2015
@dajohi
Copy link
Member Author

dajohi commented Aug 24, 2015

I will wait on this as I'd like to add limits to requestedTxns and requestedBlocks as well.

@dajohi
Copy link
Member Author

dajohi commented Sep 29, 2015

I wonder if this should wait til after the #445?

delete(tmsg.peer.requestedTxns, *txHash)
delete(b.requestedTxns, *txHash)

if err != nil {
// Do not request this transactions again until a new block
Copy link
Member

Choose a reason for hiding this comment

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

We're working with one tx here. Update comment to reflect. transactions transaction.

@davecgh
Copy link
Member

davecgh commented Oct 7, 2015

@dajohi: I know this is waiting on #445 to go in, but would you please address the comments and rebase it on top of 445. I suspect that one should be going in within a week or so and I'd like to have this one ready. Thanks!

@davecgh
Copy link
Member

davecgh commented Oct 23, 2015

#445 has been merged. Please update this accordingly.

@dajohi
Copy link
Member Author

dajohi commented Nov 9, 2015

rebased.

This prevents the node from repeatedly requesting and rejecting the
same transaction as different peers inv the same transaction.

Idea from Bitcoin Core commit 0847d9cb5fcd2fdd5a21bde699944d966cf5add9

Also, limit the number of both requested blocks and transactions.
if len(m)+1 > limit {
// Generate a cryptographically random hash.
randHashBytes := make([]byte, wire.HashSize)
_, err := rand.Read(randHashBytes)
Copy link
Member

Choose a reason for hiding this comment

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

So, I'm not sure we really need strong cryptographic randomness here. I suspect reading from /dev/urandom may become an unnecessary bottleneck when processing transactions. In order to speed up the execution of this function, we may want to instead use a fast PRNG such as xorshift. There exists a pure-go implementation, which can be found here.

NOTE: I haven't benchmarked this yet, but this is a recommendation based on past experience when optimizing the SigCache in #598.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, you have a fair point and I think that's probably a reasonable place to look at for optimizing.

However, given this is really just a refactor of the existing code, I don't suspect it should hold up this PR.

@davecgh davecgh merged commit cab74fe into btcsuite:master Apr 10, 2016
@dajohi dajohi deleted the rejected branch February 28, 2019 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants