Skip to content

Conversation

lsilva01
Copy link
Contributor

@lsilva01 lsilva01 commented Nov 8, 2021

Remove CTxMemPool parameter from AcceptToMemoryPool function, as suggested in #23437 (comment) .

This requires that CChainState has access to MockedTxPool in tx_pool.cpp as mentioned #23173 (comment). So the MockedTxPool is attributed to CChainState::m_mempool before calling AcceptToMemoryPool.

Requires #23437.

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 8, 2021

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

Conflicts

No conflicts as of last run.

@mjdietzx
Copy link
Contributor

Code Review ACK 988cfd8

Copy link
Contributor

@stratospher stratospher left a comment

Choose a reason for hiding this comment

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

Concept ACK. This PR removes CTxMemPool pool argument from AcceptToMemoryPool() since it can be obtained from CChainState active_chainstate.m_mempool

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 988cfd8.

This change simplifies ATMP since chain params and the mempool are accessible from the chainstate.

It also removes the intermediate AcceptToMemoryPoolWithTime causing all ATMP callers to explicit set accept_time, usually GetTime().

@lsilva01 lsilva01 force-pushed the remove_pool_params_atmp branch from 988cfd8 to 1d96cbc Compare December 2, 2021 04:55
@lsilva01 lsilva01 force-pushed the remove_pool_params_atmp branch from 1d96cbc to 358f94a Compare December 2, 2021 05:12
@lsilva01
Copy link
Contributor Author

lsilva01 commented Dec 2, 2021

I changed the approach. Now, the m_mempool remains private and the getter and setter were added, as suggested by @stratospher in #23448 (review) and @promag in #23465 (comment) .

Not sure if this is idiomatic (c++ style). Otherwise, I can revert to original approach (with public m_mempool).

@lsilva01 lsilva01 force-pushed the remove_pool_params_atmp branch from 358f94a to 3f7d1c1 Compare December 2, 2021 19:20
@lsilva01 lsilva01 force-pushed the remove_pool_params_atmp branch from 3f7d1c1 to 83b3697 Compare December 3, 2021 22:21
@lsilva01 lsilva01 force-pushed the remove_pool_params_atmp branch 2 times, most recently from b6489b9 to d784d1e Compare December 7, 2021 14:53
@lsilva01 lsilva01 force-pushed the remove_pool_params_atmp branch from d784d1e to 2cc5a38 Compare December 7, 2021 18:32
Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

Approach ACK 2cc5a38, will review properly.

@lsilva01 lsilva01 force-pushed the remove_pool_params_atmp branch from 9e426c9 to 7503606 Compare December 7, 2021 21:52
Co-authored-by: John Newbery <1063656+jnewbery@users.noreply.github.com>
Co-authored-by: Jon Atack <jon@atack.com>
@lsilva01 lsilva01 force-pushed the remove_pool_params_atmp branch from 7503606 to f1f10c0 Compare December 7, 2021 21:57
@jnewbery
Copy link
Contributor

jnewbery commented Dec 8, 2021

utACK f1f10c0

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

left some nits in the test, but no blockers

review ACK f1f10c0 🔙

Show signature

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

review ACK f1f10c0514fe81318c8b064f9dad0e2f9a2cd037 🔙
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUgHpQv/Zm11wrNJ2iGL1U2uf4cOLbafgx6DxBsY5Jf4VOBRhAaTSdluLEBEkhdY
eTLy4lrXuzAhrs9SS8ogJYEUT2JWn5vmfPjXdsPIyJPRVT1IEUoeelarH03oOHEe
+xW5ILkL7S8GlNGB+nUqXkq47Qw5jY+zr39v3tGvHJkrVHVhaDZOlFmPoXKDVrdv
TnsQcV8GL+4ZL9gyg6+tM26uSeDOaTId8L/4xtmzkzgcPcZqPsT/LyXxKmKDjY5s
KHyASsIIZG+Tb2M7HGAaZiPZelhhg1kyJqv0tq+woEfeE3qQ41U+r/if+kM10kmh
cKy4Jfw8lR7em5e2fVE2NDf0va6i1TVJz/8ZPYSS0C5IK8aeC+0OK2CE0GKjlP8k
n/F7rAU9BUOkerA4ccwq1T+l0FwN4yOa2d3EZobHHRDn8jSmITqwaXxZHIDyB7/3
lIHrKEoNBvdlF1ohlQNqXGSJQeb+wQ1l9EWLM0Gj/U/8WjZTyswSxAn1UBJOEabH
CzoLf3ep
=M0GN
-----END PGP SIGNATURE-----

Comment on lines +1099 to +1100
assert(active_chainstate.GetMempool() != nullptr);
CTxMemPool& pool{*active_chainstate.GetMempool()};
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert(active_chainstate.GetMempool() != nullptr);
CTxMemPool& pool{*active_chainstate.GetMempool()};
CTxMemPool& pool{*Assert(active_chainstate.GetMempool())};

nit: Can be written shorter

Comment on lines +32 to +34
class DummyChainState final : public CChainState
{
public:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
class DummyChainState final : public CChainState
{
public:
struct DummyChainState final : public CChainState {

nit: Can be written shorter, but might be controversial to use struct here. I think in tests it is fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to declare this as a class, even if it requires an additional line for the access specifier (since it's a class and not just a data structure).

Comment on lines +35 to +37
void SetMempool(CTxMemPool* mempool)
{
m_mempool = mempool;
Copy link
Member

Choose a reason for hiding this comment

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

nit: mempool is never null, so can use a reference

Suggested change
void SetMempool(CTxMemPool* mempool)
{
m_mempool = mempool;
void SetMempool(CTxMemPool& mempool)
{
m_mempool = &mempool;

@jonatack
Copy link
Member

jonatack commented Dec 8, 2021

Post-merge ACK, modulo that I'm not sure if the CChainState::GetMempool() getter adds value. I've proposed a follow-up to remove it that picks up some of Marco's review feedback.

@lsilva01 lsilva01 deleted the remove_pool_params_atmp branch December 8, 2021 12:06
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 8, 2021
f1f10c0 Remove CTxMemPool params from ATMP (lsilva01)

Pull request description:

  Remove `CTxMemPool` parameter from `AcceptToMemoryPool` function, as suggested in bitcoin#23437 (comment) .

  This requires that `CChainState` has access to `MockedTxPool` in  `tx_pool.cpp` as mentioned bitcoin#23173 (comment). So the `MockedTxPool` is attributed to `CChainState::m_mempool` before calling `AcceptToMemoryPool`.

  Requires bitcoin#23437.

ACKs for top commit:
  jnewbery:
    utACK f1f10c0
  MarcoFalke:
    review ACK f1f10c0 🔙

Tree-SHA512: 2a4885f4645014fc1fa98bb1090f13721c1a0796bc0021b9cb43bc8cc13920b6eaf057d1f5ed796e0a110e7813e41fe0196334ce7c80d1231fc057a9a3bdf349
RandyMcMillan pushed a commit to RandyMcMillan/mempool-tab that referenced this pull request Dec 23, 2021
efbb49e Remove CTxMemPool params from ATMP (lsilva01)

Pull request description:

  Remove `CTxMemPool` parameter from `AcceptToMemoryPool` function, as suggested in bitcoin/bitcoin#23437 (comment) .

  This requires that `CChainState` has access to `MockedTxPool` in  `tx_pool.cpp` as mentioned bitcoin/bitcoin#23173 (comment). So the `MockedTxPool` is attributed to `CChainState::m_mempool` before calling `AcceptToMemoryPool`.

  Requires #23437.

ACKs for top commit:
  jnewbery:
    utACK efbb49e
  MarcoFalke:
    review ACK efbb49e 🔙

Tree-SHA512: 2a4885f4645014fc1fa98bb1090f13721c1a0796bc0021b9cb43bc8cc13920b6eaf057d1f5ed796e0a110e7813e41fe0196334ce7c80d1231fc057a9a3bdf349
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 11, 2022
Summary:
Co-authored-by: John Newbery <1063656+jnewbery@users.noreply.github.com>
Co-authored-by: Jon Atack <jon@atack.com>

This is a backport of [[bitcoin/bitcoin#23465 | core#23465]]

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D12457
@bitcoin bitcoin locked and limited conversation to collaborators Dec 8, 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.

8 participants