Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Dec 20, 2019

The miner needs read-only access to the mempool. Instead of using the mutable global ::mempool, keep a immutable reference to a mempool that is passed to the miner. Apart from the obvious benefits of removing a global and making things immutable, this might also simplify testing with multiple mempools.

This fixes a typo in the test documentation
@practicalswift
Copy link
Contributor

Strong concept ACK

Also welcome from a fuzz testing perspective :)

@DrahtBot
Copy link
Contributor

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #17693 (rpc: Add generateblock to mine a custom set of transactions by andrewtoth)
  • #17375 (Add asymptotes for benchmarking framework by JeremyRubin)
  • #17268 (Epoch Mempool by JeremyRubin)
  • #16975 (test: Show debug log on unit test failure by MarcoFalke)
  • #16411 (BIP-325: Signet support by kallewoof)
  • #16333 (test: Set BIP34Height = 2 for regtest by MarcoFalke)

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.

@jnewbery
Copy link
Contributor

Concept ACK

@JeremyRubin
Copy link
Contributor

Concept ACK, but this will make me sad from a rebasing perspective ;)

@promag
Copy link
Contributor

promag commented Dec 20, 2019

Concept ACK.

Copy link
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.

Code review ACK fa9c7398087b821ccebf522ee5184eca7fa81445.

@maflcko
Copy link
Member Author

maflcko commented Dec 22, 2019

Addressed feedback by @promag

@promag
Copy link
Contributor

promag commented Dec 22, 2019

ACK faa92a2.

@fjahr
Copy link
Contributor

fjahr commented Jan 2, 2020

ACK faa92a2

Reviewed code, tested locally.

Copy link
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

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

Code review ACK faa92a2

A couple of nits inline. Feel free to ignore.


BlockAssembler::BlockAssembler(const CChainParams& params, const Options& options) : chainparams(params)
BlockAssembler::BlockAssembler(const CTxMemPool& mempool, const CChainParams& params, const Options& options)
: chainparams(params),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: order member initialization list the same as the parameter list (and preferably on one line)

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer multiple lines

throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Cannot derive script without private keys"));
}

const CTxMemPool& mempool = EnsureMemPool();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: place this either at the start of the function (so it exits early if there is no mempool), or immediately before the call to generateBlocks(). Placing it between the code that creates coinbase_script and the coinbase_script CHECK seems random.

Same comment for generatetoaddress()

Copy link
Member Author

Choose a reason for hiding this comment

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

Might do in a follow-up to not invalidate the three reviews

maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Jan 2, 2020
faa92a2 rpc: Remove mempool global from miner (MarcoFalke)
6666ef1 test: Properly document blockinfo size in miner_tests (MarcoFalke)

Pull request description:

  The miner needs read-only access to the mempool. Instead of using the mutable global `::mempool`, keep a immutable reference to a mempool that is passed to the miner. Apart from the obvious benefits of removing a global and making things immutable, this might also simplify testing with multiple mempools.

ACKs for top commit:
  promag:
    ACK faa92a2.
  fjahr:
    ACK faa92a2
  jnewbery:
    Code review ACK faa92a2

Tree-SHA512: c44027b5d2217a724791166f3f3112c45110ac1dbb37bdae27148a0657e0d1a1d043b0d24e49fd45465ec014224d1b7eb15c92a33069ad883fa8ffeadc24735b
@maflcko maflcko merged commit faa92a2 into bitcoin:master Jan 2, 2020
@maflcko maflcko deleted the 1912-mempoolMiner branch January 2, 2020 22:52
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jan 4, 2020
faa92a2 rpc: Remove mempool global from miner (MarcoFalke)
6666ef1 test: Properly document blockinfo size in miner_tests (MarcoFalke)

Pull request description:

  The miner needs read-only access to the mempool. Instead of using the mutable global `::mempool`, keep a immutable reference to a mempool that is passed to the miner. Apart from the obvious benefits of removing a global and making things immutable, this might also simplify testing with multiple mempools.

ACKs for top commit:
  promag:
    ACK faa92a2.
  fjahr:
    ACK faa92a2
  jnewbery:
    Code review ACK faa92a2

Tree-SHA512: c44027b5d2217a724791166f3f3112c45110ac1dbb37bdae27148a0657e0d1a1d043b0d24e49fd45465ec014224d1b7eb15c92a33069ad883fa8ffeadc24735b
maflcko pushed a commit that referenced this pull request Jan 28, 2020
0dae5a5 Fix benchmarks filters (Elichai Turkel)

Pull request description:

  The bug was introduced in #17781
  before this fix `./src/bench/bench_bitcoin -filter=*` will fail with:

  ```
  # Benchmark, evals, iterations, total, min, max, median
  bench_bitcoin: bench/bench.cpp:119: static void benchmark::BenchRunner::RunAll(benchmark::Printer&, uint64_t, double, const string&, bool): Assertion `g_testing_setup == nullptr' failed.
  Aborted (core dumped)
  ```

ACKs for top commit:
  MarcoFalke:
    ACK 0dae5a5

Tree-SHA512: 43de4c7f4a5f29593972cf3bc822429466d0609c159c95d37c9e5370be392ace698b218a65542c7d53bfa52db7377ebdab808501ae109c2249f7f956bd318312
@ryanofsky ryanofsky mentioned this pull request Jun 4, 2020
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 20, 2020
Summary:
```
The miner needs read-only access to the mempool. Instead of using the
mutable global ::mempool, keep a immutable reference to a mempool that
is passed to the miner. Apart from the obvious benefits of removing a
global and making things immutable, this might also simplify testing
with multiple mempools.
```

Backport of core [[bitcoin/bitcoin#17781 | PR17781]].

Depends on D7984.

This differs quite a bit from the original PR because we already passed
a mempool. This is mostly rename and factorization to make it looks more
like core.

Test Plan:
  ninja all check-all
  ninja bench-bitcoin
With clang:
  ninja check

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Subscribers: jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D7988
sidhujag pushed a commit to syscoin-core/syscoin that referenced this pull request Nov 10, 2020
faa92a2 rpc: Remove mempool global from miner (MarcoFalke)
6666ef1 test: Properly document blockinfo size in miner_tests (MarcoFalke)

Pull request description:

  The miner needs read-only access to the mempool. Instead of using the mutable global `::mempool`, keep a immutable reference to a mempool that is passed to the miner. Apart from the obvious benefits of removing a global and making things immutable, this might also simplify testing with multiple mempools.

ACKs for top commit:
  promag:
    ACK faa92a2.
  fjahr:
    ACK faa92a2
  jnewbery:
    Code review ACK faa92a2

Tree-SHA512: c44027b5d2217a724791166f3f3112c45110ac1dbb37bdae27148a0657e0d1a1d043b0d24e49fd45465ec014224d1b7eb15c92a33069ad883fa8ffeadc24735b
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Dec 18, 2020
Summary:
> The bug was introduced in [[bitcoin/bitcoin#17781 | PR17781]]
> before this fix `./src/bench/bitcoin-bench -filter="RIPEMD160|SHA256|SHA1"` will fail with:
> ```
> # Benchmark, evals, iterations, total, min, max, median
> bench_bitcoin: bench/bench.cpp:119: static void benchmark::BenchRunner::RunAll(benchmark::Printer&, uint64_t, double, const string&, bool): Assertion `g_testing_setup == nullptr' failed.
> Aborted (core dumped)
> ```

This is a backport of Core [[bitcoin/bitcoin#18013 | PR18013]]

Test Plan: `ninja && ./src/bench/bitcoin-bench -filter="RIPEMD160|SHA256|SHA1"`

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D8690
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants