Skip to content

Conversation

AdityaNG
Copy link

@AdityaNG AdityaNG commented Apr 3, 2021

Removed the -feefilter option from src/net_processing.cpp. #21545
To make sure everything works, I ran make check and then ran test_runner.py with p2p_feefilter.py

$ test/functional/test_runner.py p2p_feefilter.py
Temporary test directory at /tmp/test_runner_₿_🏃_20210403_190347
Running Unit Tests for Test Framework Modules
..........
----------------------------------------------------------------------
Ran 10 tests in 0.633s

OK
Remaining jobs: [p2p_feefilter.py]
1/1 - p2p_feefilter.py passed, Duration: 15 s

TEST             | STATUS    | DURATION

p2p_feefilter.py | ✓ Passed  | 15 s

ALL              | ✓ Passed  | 15 s (accumulated) 
Runtime: 15 s

Regarding splitting up the feefilter logic and moving it to a seperate function for better readability, the g_filter_rounder.round() function is not thread safe and is currently inside a LOCK(cs_main); called at the begining of PeerManagerImpl::SendMessages(CNode* pto). Didn't make any changes for this, how would I proceed for this?

@fanquake fanquake added the P2P label Apr 3, 2021
@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 3, 2021

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

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.

@glozow
Copy link
Member

glozow commented Apr 6, 2021

To completely remove the -feefilter option you'll want to remove other uses (grep -feefilter), the surrounding unused variables, and the user option in init.cpp.

@ccdle12
Copy link
Contributor

ccdle12 commented Apr 6, 2021

In terms of extracting the logic into a separate function, one option you can use is an assert to make sure cs_main is held before entering the main function logic e.g. AssertLockHeld(cs_main) like used here.

@bitcoin bitcoin deleted a comment from OxideDevX Apr 6, 2021
@AdityaNG
Copy link
Author

@ccdle12 understood the usage of AssertLockHeld(cs_main).
In #21509 @jnewbery and @MarcoFalke talk about

  1. removing the -feefilter option ( as @glozow mentioned I have looked through all usages of 'feefilter')
  2. factoring out the feefilter logic out into its own function (will do so with AssertLockHeld(cs_main) ).

From what I understand about the goal of #21545 , was to remove the feefilter check from the message handler loop in net_processing.cpp. Wouldn't removing it from the init.cpp be problematic as it would entirely remove the option? Or is removing feefilter completely the goal? I would like some clarity on this.

Feefilter usage

Looked around and pulled up files with refrences to feefilter and understood the context of the refrence which was a good exercise that got me familiar with the codebase.

  1. init.cpp - argsman.AddArg("-feefilter", ...)
  2. net_processing.cpp
  3. net.cpp and net.h
if (m_tx_relay != nullptr) {
    stats.minFeeFilter = m_tx_relay->minFeeFilter;
} else {
    stats.minFeeFilter = 0;
}
  1. protocol.cpp and protocol.h
const char *FEEFILTER="feefilter";
...
const static std::string allNetMessageTypes[] = {
    ...
    NetMsgType::FEEFILTER,
};
  1. validation.h static const bool DEFAULT_FEEFILTER = true;
  2. version.h static const int FEEFILTER_VERSION = 70013;
  3. fees.cpp and fees.h explicit FeeFilterRounder(const CFeeRate& minIncrementalFee); (the non-thread safe round function)
  4. net.cpp
RPCResult::Type::NUM, "minfeefilter", "The minimum fee rate for transactions this peer accepts"
...
static RPCHelpMan getpeerinfo() {
    ...
    obj.pushKV("minfeefilter", ValueFromAmount(stats.minFeeFilter));
}
  1. policy_fee_tests.cpp FeeFilterRounder fee_rounder{CFeeRate{1000}};
  2. fees.cpp FeeFilterRounder fee_filter_rounder{minimal_incremental_fee};
  3. process_message.cpp FUZZ_TARGET_MSG(feefilter);
  4. Multiple python tests in test/functional
    a. p2p_feefilter.py
    b. p2p_ibd_txrelay.py
    c. p2p_leak.py
    d. rpc_net.py
    e. test_runner.py
    f. messages.py
    g. p2p.py

@jnewbery
Copy link
Contributor

jnewbery commented Apr 19, 2021

is removing feefilter completely the goal

Yes. The -feefilter config option is not used anywhere else, so it should be removed from the init code.

Looked around and pulled up files with refrences to feefilter and understood the context of the refrence which was a good exercise that got me familiar with the codebase...

All of these instances of minFeeFilter, FEEFILTER, FEEFILTER_VERSION, etc are separate from the -feefilter option, which is used to control whether we'll ever send feefilter messages to our peer.

@jnewbery jnewbery changed the title Removed -feefilter option Remove -feefilter option Apr 19, 2021
@jnewbery
Copy link
Contributor

Please also add rationale to the commit log. Why is it ok to remove -feefilter?

@maflcko
Copy link
Member

maflcko commented May 3, 2021

Closing for now due to inactivity. Let me know when you want to work on this again.

@maflcko maflcko closed this May 3, 2021
@bitcoin bitcoin deleted a comment from DrahtBot May 3, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 18, 2022
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.

7 participants