-
Notifications
You must be signed in to change notification settings - Fork 47
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
Lightnet sub-commands implementation (start/stop/status). #510
Changes from 9 commits
07b51d6
5af97cf
1b02d87
3e55a3c
4c423f3
8266310
967916a
ba114ef
ac92401
7fff5d6
1404cc4
a2f72ba
711ab32
ce5c6cc
6ffb65e
2b90442
8c921c8
9b9f589
16a1412
c440497
9dff90a
36d97de
1def217
9050aa1
6f87149
ae75be1
0963b73
3f1603d
3ea4eb1
b4142d0
4e8c27f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,11 @@ import Constants from '../lib/constants.js'; | |
import { deploy } from '../lib/deploy.js'; | ||
import { example } from '../lib/example.js'; | ||
import { file } from '../lib/file.js'; | ||
import { | ||
lightnetStatus, | ||
startLightnet, | ||
stopLightnet, | ||
} from '../lib/lightnet.js'; | ||
import { project } from '../lib/project.js'; | ||
import system from '../lib/system.js'; | ||
|
||
|
@@ -39,6 +44,9 @@ yargs(hideBin(process.argv)) | |
'Argument: %s, Given: %s, Choices: %s': chalk.red( | ||
`%s was %s. Must be one of: %s.` | ||
), | ||
'Not enough non-option arguments: %s': { | ||
one: chalk.red('Not enough non-option arguments: %s'), | ||
}, | ||
}) | ||
.demandCommand(1, chalk.red('Please provide a command.')) | ||
|
||
|
@@ -94,6 +102,120 @@ yargs(hideBin(process.argv)) | |
async (argv) => await example(argv.name) | ||
) | ||
.command(['system', 'sys', 's'], 'Show system info', {}, () => system()) | ||
.command( | ||
['lightnet <sub-command> [options]'], | ||
'Manage the lightweight Mina blockchain for zkApps development and testing purposes.\nYou can find more information about the Docker image in use at\nhttps://hub.docker.com/r/o1labs/mina-local-network', | ||
(yargs) => { | ||
yargs | ||
.command( | ||
[ | ||
'start [mode] [type] [proof-level] [mina-branch] [archive] [sync] [pull]', | ||
], | ||
'Start the lightweight Mina blockchain network Docker container.', | ||
{ | ||
mode: { | ||
alias: 'm', | ||
demand: false, | ||
string: true, | ||
hidden: false, | ||
choices: Constants.lightnetModes, | ||
default: 'single-node', | ||
description: | ||
'Whether to form the network with one node or with multiple network participants.\n"single-node" value will make the network faster.', | ||
}, | ||
type: { | ||
alias: 't', | ||
demand: false, | ||
string: true, | ||
hidden: false, | ||
choices: Constants.lightnetTypes, | ||
default: 'fast', | ||
description: | ||
'Whether to configure the network to be fast or slower with closer-to-real-world properties.', | ||
}, | ||
'proof-level': { | ||
alias: 'p', | ||
demand: false, | ||
string: true, | ||
hidden: false, | ||
choices: Constants.lightnetProofLevels, | ||
default: 'none', | ||
description: '"none" value will make the network faster.', | ||
}, | ||
'mina-branch': { | ||
alias: 'b', | ||
demand: false, | ||
string: true, | ||
hidden: false, | ||
choices: Constants.lightnetMinaBranches, | ||
default: 'rampup', | ||
description: | ||
'One of the major Mina repository branches the artifacts were compiled against.', | ||
}, | ||
archive: { | ||
alias: 'a', | ||
demand: false, | ||
boolean: true, | ||
hidden: false, | ||
default: true, | ||
description: | ||
'Whether to start the Mina Archive process and Archive Node API application within the Docker container.', | ||
}, | ||
sync: { | ||
alias: 's', | ||
demand: false, | ||
boolean: true, | ||
hidden: false, | ||
default: true, | ||
description: | ||
'Whether to wait for the network to reach the synchronized state.', | ||
}, | ||
pull: { | ||
alias: 'u', | ||
demand: false, | ||
boolean: true, | ||
hidden: false, | ||
default: true, | ||
description: | ||
'Whether to pull the latest version of the Docker image from the Docker Hub.', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shimkiv advantages and disadvantages? default is true, so when would we want to use false? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docker images are updated each night and pulling the new image will takes resources and time should you start the network next day from scratch. It is useful to set |
||
}, | ||
}, | ||
async (argv) => await startLightnet(argv) | ||
) | ||
.command( | ||
['stop [save-logs] [clean-up]'], | ||
'Stop the lightweight Mina blockchain network Docker container and perform the clean up.', | ||
shimkiv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
'save-logs': { | ||
alias: 'l', | ||
demand: false, | ||
boolean: true, | ||
hidden: false, | ||
default: true, | ||
description: | ||
'Whether to save the Docker container processes logs to the host file system.', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. default is true, what happens if false? where else would Docker container processes logs be saved? (or not saved at all?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}, | ||
'clean-up': { | ||
alias: 'c', | ||
demand: false, | ||
boolean: true, | ||
hidden: false, | ||
default: true, | ||
description: | ||
'Whether to remove the Docker container, dangling Docker images, consumed Docker volume and the blockchain network configuration.', | ||
barriebyron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
}, | ||
async (argv) => await stopLightnet(argv) | ||
) | ||
.command( | ||
['status'], | ||
'Get the lightweight Mina blockchain network status.', | ||
{}, | ||
async () => await lightnetStatus() | ||
) | ||
.demandCommand(); | ||
} | ||
) | ||
.version( | ||
fs.readJsonSync(path.join(__dirname, '..', '..', 'package.json')).version | ||
) | ||
|
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.
@shimkiv what is the disadvantage of
none
proof-level?none
is default, but does not test other proofs, right? maybe more description to help user choose the appropriate proof level?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.
It is the protocol configuration. One of the expensive parts of the protocol is creating blockchain snark proofs, so mocking that is important for faster everything. The
proof_level
Mina constant can be used to disable proving (set it to becheck
) or disable block calculation altogether (set it tonone
).None
is default because for zkApps development with o1js we don't really care about protocol proofs, assuming that it is well tested. Sometimes though one might want to run zkApps against network that has closer to "real world" properties (say, some of the Nightly CI tests). That is whenzk lightnet start --mode multi-node --type real --proof-level full
might be useful.