Skip to content

Add seed file for importing mempool before taking snapshot#131

Open
brunoerg wants to merge 2 commits intodergoegge:masterfrom
brunoerg:2026-02-seed-file
Open

Add seed file for importing mempool before taking snapshot#131
brunoerg wants to merge 2 commits intodergoegge:masterfrom
brunoerg:2026-02-seed-file

Conversation

@brunoerg
Copy link
Contributor

@brunoerg brunoerg commented Mar 4, 2026

This PR adds a new flag called --seedfile which is used to pass a seed file that its raw bytes will be used to create a mempool.dat file that will be imported before taking the snapshot. The main motivation of this feature is to test the BIP153 (Send template) which requires a populated mempool to be able to create the templates.

As previously discussed with @Crypt-iQ, this PR implements a simple way of doing it, it only imports the mempool but doesn't update any context which is enough for testing BIP153. However, I intend to implement in a follow-up another flag that would be used to import a serialized version of Program which would require update the context.

@brunoerg brunoerg force-pushed the 2026-02-seed-file branch from da9e1de to f18b5b1 Compare March 4, 2026 18:04
@brunoerg brunoerg force-pushed the 2026-02-seed-file branch from f18b5b1 to e8d93dd Compare March 4, 2026 18:19
scenario initialization the seed file's bytes are written as `mempool.dat` and
imported into the node, then the snapshot is taken with that mempool state so
every test case executes against a node that starts with pre-populated
transactions.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it's helpful to explain here how the mempool.dat is created? I guess you need to mine the same number of blocks on a regtest node, create transactions, and then dump the file? Thinking about it more, the blocks need to be identical to what fuzzamoto creates?

Copy link
Owner

Choose a reason for hiding this comment

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

I wonder if it'd be better to allow an IR testcase as seedfile that is then executed before the snapshot. That seems a little more generic, and would enable other states as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

We were trying to figure out what RPCs to call to build the context and if in-mempool txns should be included in the context. I think we'd need dumptxoutset for the build_txos call and getrawmempool + getmempoolentry if mempool txns are included? Then we'd also need the block headers, though that seems straightforward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if it'd be better to allow an IR testcase as seedfile that is then executed before the snapshot. That seems a little more generic, and would enable other states as well.

This would be good, but the current approach is much simpler for now. But yes, the idea is having something like that as well, we just need to figure out what is necessary as @Crypt-iQ mentioned.

@Crypt-iQ
Copy link
Contributor

Crypt-iQ commented Mar 9, 2026

Leaving a note that the updated BIP153 code is linked here and it uses new message types now.

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.

3 participants