Skip to content

p2p: isolate regtest from mainnet bootstrap state#10396

Open
jeetrex17 wants to merge 3 commits intomonero-project:masterfrom
jeetrex17:fix/regtest-mainnet-bootstrap
Open

p2p: isolate regtest from mainnet bootstrap state#10396
jeetrex17 wants to merge 3 commits intomonero-project:masterfrom
jeetrex17:fix/regtest-mainnet-bootstrap

Conversation

@jeetrex17
Copy link
Copy Markdown

Fixes #10392.

--regtest wasn't being handled in the p2p layer, so it defaulted to mainnet. That meant regtest could resolve seeds.moneroseeds.*, fall back to the hardcoded mainnet seed list, and share p2pstate.bin with mainnet.

This patch makes p2p treat --regtest as FAKECHAIN, skips automatic public seed bootstrap for that mode, and stores p2p state under <data-dir>/fake to keep it separate from mainnet.

Comment on lines +960 to +961
if (m_nettype == cryptonote::FAKECHAIN)
m_config_folder += "/fake";
Copy link
Copy Markdown
Contributor

@nahuhh nahuhh Apr 2, 2026

Choose a reason for hiding this comment

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

This doesnt work as expected.

example:

when using --testnet the default blockchain folder will be ~/.bitmonero/testnet/lmdb

when using --regrest the default blockchain folder will be ~/.bitmonero/fake/lmdb

when NOT using the default folder (ie, when using somethinf like --data-dir testing the latter will fail with an error of:

2026-04-02 21:48:38.803 E Exception in main! boost::filesystem::create_directory: Not a directory: "testing/fake"

This error does not happen with --testnet. Using data-dir with testnet will create a folder like ./testing/testnet

Can you make it create the subfolder in the same way that testnet and stagenet subfolders are created?

(Also, i would prefer if the subfolder be called regtest instead of fake)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for pointing that out. Addressed in 3348a4b.

Regtest data-dir handling is now normalized through arg_data_dir the same way as testnet/stagenet, so both core and p2p use <data-dir>/regtest instead of appending a subfolder later. I also switched the regtest subfolder from fake to regtest.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also, i would prefer if the subfolder be called regtest instead of fake

Considering the subfolder for the blockchain dir is already located in fake when using --regtest, I'd advocate for continuing to use fake to avoid breaking any flows that may rely on current behavior. There is even explicit logic for removing or reusing the already stored data in that dir

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the subfolder for the blockchain dir is already located in fake when using --regtest

you're right. I neglected to pay attention to what the current behavior was

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Makes sense, thanks. Switched it back to fake in 7a14dea while keeping the centralized data-dir handling.

@nahuhh
Copy link
Copy Markdown
Contributor

nahuhh commented Apr 5, 2026

Ran a few different tests (generating blocks, peering, syncing wallet, sending txs etc). this pr appears to resolve the linked issue, and is working as expected / havent found any other regressions (after data-dir was fixed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

regtest connects to mainnet seeds

4 participants