-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Lotus Daemon CLI: Auto remove existing chain if importing chain file or snapshot #11277
Conversation
please do follow the pr template and fill the relevant part in! |
cmd/lotus/daemon.go
Outdated
willImportChain = true | ||
} | ||
|
||
if cctx.Bool("remove-existing-chain") || willImportChain { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we specify the behaviour expected if remove-existing-chain
is set to be false yet willImportChain
is true? warning & remove, or error out? or follow remove-existing-chain
to not remove and continue with import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, maybe we should just error out. Otherwise we are somehow creating undefined behaviors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mb1896 What I would suggest is:
- if
remove-existing-chain
, just remove the chain - if it's not specified, prompt the user with a y/n question asking whether they want the chain to be deleted -- if yes, do so, if not proceed without doing so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comments! Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arajasek Please take another look.
1167961
to
bdffac3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, feel free to merge after addressing minor comments.
CHANGELOG.md
Outdated
@@ -34,6 +34,7 @@ This feature release requires a **minimum Go version of v1.19.12 or higher to su | |||
- feat: Lotus Gateway: add MpoolPending, ChainGetBlock and MinerGetBaseInfo ([filecoin-project/lotus#10929](https://github.com/filecoin-project/lotus/pull/10929)) | |||
|
|||
## Improvements | |||
- chore: Auto remove local chain data when importing chain file or snapshot ([filecoin-project/lotus#11277](https://github.com/filecoin-project/lotus/pull/11277)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for including this! It needs to be moved up to the UNRELEASED
section, though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Fixed
if willImportChain && !willRemoveChain { | ||
// Confirm with the user about the intention to remove chain data. | ||
reader := bufio.NewReader(os.Stdin) | ||
fmt.Print("Importing chain or snapshot will by default delete existing local chain data. Do you want to proceed and delete? (yes/no): ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Print("Importing chain or snapshot will by default delete existing local chain data. Do you want to proceed and delete? (yes/no): ") | |
fmt.Print("Do you want to delete existing local chain data as part of the import process? (yes/no): ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(just a bit more clear, there isn't really a default since we're forcing users to specify)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, however we couldn't differentiate between
- user not specifying a flag's value
- user specifically specifying a flag to false
That's why we have to ask for the user's input...
} | ||
userInput = strings.ToLower(strings.TrimSpace(userInput)) | ||
|
||
if userInput == "yes" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to handle case-sensitivity here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ToLower()
function handled it.
4dce700
to
49044b4
Compare
Related Issues
Based on the discussion https://filecoinproject.slack.com/archives/CP50PPW2X/p1695108301930859
Proposed Changes
When user wants to import chain file or snapshot, we will by default remove the local chain data, unless the user says otherwise.
Additional Info
None.
Checklist
Before you mark the PR ready for review, please make sure that:
<PR type>: <area>: <change being made>
fix: mempool: Introduce a cache for valid signatures
PR type
: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, testarea
, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps