Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Apr 13, 2023

Currently it is possible to import a mempool by placing it in the datadir and starting the node. However this has many issues:

  • Users aren't expected to fiddle with the datadir, possibly corrupting it
  • An existing mempool file in the datadir may be overwritten
  • The node needs to be restarted
  • Importing an untrusted file this way is dangerous, because it can corrupt the mempool

Fix all issues by adding a new RPC.

@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 13, 2023

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK ajtowns, glozow, achow101
Concept ACK kevkevinpal, instagibbs, michaelfolkson, svanstaa, kristapsk

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #28207 (mempool: Persist with XOR 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.

@DrahtBot DrahtBot changed the title rpc: Add importmempool RPC rpc: Add importmempool RPC Apr 13, 2023
@ghost
Copy link

ghost commented Apr 13, 2023

Hi @MarcoFalke

More than 5 tests are failing

@maflcko maflcko force-pushed the 2304-import-mempool-rpc- branch from 846ff37 to d31a87f Compare April 13, 2023 17:54
@maflcko
Copy link
Member Author

maflcko commented Apr 13, 2023

I changed the approach to force named RPC options, compatible with #26485

@kevkevinpal
Copy link
Contributor

Concept ACK 846ff37fe7ac2a5b4f855faaadb3434158ed6364 (need to check latest commit)

tested by doing the following in regtest

bitcoin-cli createwallet "testwallet"
bitcoin-cli getnewaddress
bitcoin-cli generateto address 6 <previous commands output>
bitcoin-cli generate 20 (did this a couple times)
bitcoin-cli getbalance (validate you have a balance)
bitcoin-cli getnewaddress
bitcoin-cli send '{"<above output>": 0.1}' null "unset" null '{"fee_rate": 1}' (did this a few times)

shutdown bitcoind
copy mempool.dat from datadir to different location
delete mempool.dat from datadir
restart bitcoind
bitcoin-cli importmempool ./mempool.dat

Saw this in the logs
2023-04-13T19:12:01Z Imported mempool transactions from disk: 5 succeeded, 0 failed, 0 expired, 0 already there, 0 waiting for initial broadcast
got {} as response from cli

Might test again and check the exact values


Checking diff of mempool.dat files

did git diff ./datadir/regtest/mempool.dat mempool.dat and it gave me no changes in the vim editor to see
but
diff ./datadir/regtest/mempool.dat mempool.dat gave me
Binary files ./datadir/regtest/mempool.dat and ./mempool.dat differ
not sure if that matters

Copy link
Contributor

@ajtowns ajtowns 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

@instagibbs
Copy link
Member

concept ACK, will review

@maflcko maflcko force-pushed the 2304-import-mempool-rpc- branch from d31a87f to 1ef7f7a Compare April 14, 2023 14:59
Copy link
Member

@glozow glozow 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

@svanstaa
Copy link

Why is use_current_time defaulting to true? As far as i understand, this would set all the broadcast times of the transactions in mempool.dat to the current time, effectively extending their lifetimes, to the point that (time-) expired txns would be dumped into the network again.
So I would suggest defaulting the value to false, unless there is some rationale behind it that is not obvious.

@michaelfolkson
Copy link

Also while we're sneaking PR review club questions on here what do people here use this for? I'm assuming it is useful for mempool dev work (specific details would be interesting) but I can't imagine it is common for a user to want this.

Concept ACK (the RPC approach seems superior assuming people are currently importing mempools without a RPC being available)

@maflcko
Copy link
Member Author

maflcko commented Apr 27, 2023

The use case would be wanting to sync both the chain and the mempool to include everything/most known by the network or one of your other nodes. This is trivially possible for the chain, however for the mempool it is not.

One option would be to use the mempool P2P message type, or add a new message type. This would likely require lifting some restrictions or adding others to make it usable in a normal setting and still prevent privacy/DoS concerns. To what extent the existing mempool message type behavior can be modified will need to be considered in light of the discussion about its removal.

Another option would be to use a new RPC to import a mempool. In light of people potentially loading untrusted mempool data, I opted to use the same mempool acceptance defaults that would be picked as if the transactions were synced/submitted over P2P.

@svanstaa
Copy link

Concept ACK

@maflcko maflcko force-pushed the 2304-import-mempool-rpc- branch from 5d18c30 to fa60af6 Compare May 17, 2023 12:08
@kristapsk
Copy link
Contributor

Concept ACK

test_importmempool_union contributed by glozow

Co-authored-by: glozow <[email protected]>
@maflcko maflcko force-pushed the 2304-import-mempool-rpc- branch from fad4eaf to fa776e6 Compare August 7, 2023 09:51
@ajtowns
Copy link
Contributor

ajtowns commented Aug 7, 2023

utACK fa776e6

@DrahtBot DrahtBot requested a review from glozow August 7, 2023 11:54
Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

reACK fa776e6

@glozow glozow requested review from instagibbs and mzumsande August 9, 2023 12:58
@achow101
Copy link
Member

ACK fa776e6

@achow101 achow101 merged commit cd43a84 into bitcoin:master Aug 15, 2023
@maflcko maflcko deleted the 2304-import-mempool-rpc- branch August 15, 2023 14:26
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 17, 2023
fa776e6 Add importmempool RPC (MarcoFalke)
fa20d73 refactor: Add and use kernel::ImportMempoolOptions (MarcoFalke)
fa88669 doc: Clarify the getmempoolinfo.loaded RPC field documentation (MarcoFalke)
6888886 Remove Chainstate::LoadMempool (MarcoFalke)

Pull request description:

  Currently it is possible to import a mempool by placing it in the datadir and starting the node. However this has many issues:

  * Users aren't expected to fiddle with the datadir, possibly corrupting it
  * An existing mempool file in the datadir may be overwritten
  * The node needs to be restarted
  * Importing an untrusted file this way is dangerous, because it can corrupt the mempool

  Fix all issues by adding a new RPC.

ACKs for top commit:
  ajtowns:
    utACK fa776e6
  achow101:
    ACK fa776e6
  glozow:
    reACK fa776e6

Tree-SHA512: fcb1a92d6460839283c546c47a2d930c363ac1013c4c50dc5215ddf9fe5e51921d23fe0abfae0a5a7631983cfc7e2fff3788b70f95937d0a989a203be4d67546
mzumsande added a commit to mzumsande/bitcoin that referenced this pull request Aug 17, 2023
fanquake added a commit to bitcoin-core/gui that referenced this pull request Aug 18, 2023
…ng oneline description

2394314 rpc: remove one more quote from non-string oneline description (Martin Zumsande)

Pull request description:

  This fixes a silent conflict between bitcoin/bitcoin#28123 (which removed all `\"options\"`) and bitcoin/bitcoin#27460 (which added a new one).

  It should fix the current CI failures.

ACKs for top commit:
  ajtowns:
    utACK 2394314
  MarcoFalke:
    lgtm ACK 2394314
  jonatack:
    ACK 2394314
  hebasto:
    ACK 2394314

Tree-SHA512: feb0c2b936a77be45d9c65aa7d738277b2266b5153665fee3b1413045de521195dc7d5efa2fc8b37b22f16e9b8d0ee8de25bfd151a428666122b31f64056557a
Frank-GER pushed a commit to syscoin/syscoin that referenced this pull request Sep 8, 2023
…ne description

2394314 rpc: remove one more quote from non-string oneline description (Martin Zumsande)

Pull request description:

  This fixes a silent conflict between bitcoin#28123 (which removed all `\"options\"`) and bitcoin#27460 (which added a new one).

  It should fix the current CI failures.

ACKs for top commit:
  ajtowns:
    utACK 2394314
  MarcoFalke:
    lgtm ACK 2394314
  jonatack:
    ACK 2394314
  hebasto:
    ACK 2394314

Tree-SHA512: feb0c2b936a77be45d9c65aa7d738277b2266b5153665fee3b1413045de521195dc7d5efa2fc8b37b22f16e9b8d0ee8de25bfd151a428666122b31f64056557a
@fanquake
Copy link
Member

Release notes added in #28637.

theStack added a commit to theStack/bitcoin that referenced this pull request Oct 15, 2023
glozow added a commit that referenced this pull request Oct 18, 2023
1b672eb doc: add release note for #27460 (new `importmempool` RPC) (Sebastian Falbesoner)

Pull request description:

  This PR adds a missing release note for #27460.

ACKs for top commit:
  glozow:
    ACK 1b672eb

Tree-SHA512: 89deadbfd6779e6eb19801c9fe7459a9876b920d44e09df102774c1eb8b3c0716462613dc99d1711eda4bd959ea61595b33f4528424ac02cf1af6cb4e5f1f0e9
Frank-GER pushed a commit to syscoin/syscoin that referenced this pull request Oct 21, 2023
…portmempool` RPC)

1b672eb doc: add release note for bitcoin#27460 (new `importmempool` RPC) (Sebastian Falbesoner)

Pull request description:

  This PR adds a missing release note for bitcoin#27460.

ACKs for top commit:
  glozow:
    ACK 1b672eb

Tree-SHA512: 89deadbfd6779e6eb19801c9fe7459a9876b920d44e09df102774c1eb8b3c0716462613dc99d1711eda4bd959ea61595b33f4528424ac02cf1af6cb4e5f1f0e9
@bitcoin bitcoin locked and limited conversation to collaborators Oct 10, 2024
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.