From e95d87779b88df13306d19a8a33193ddc033a151 Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Fri, 7 Jun 2024 11:00:14 +0300 Subject: [PATCH 1/3] cli: refactor usage field Unified style is with lowercase letter. Signed-off-by: Ekaterina Pavlova --- cli/query/query.go | 14 +++--- cli/server/server.go | 6 +-- cli/smartcontract/generate.go | 8 ++-- cli/smartcontract/smart_contract.go | 20 ++++----- cli/txctx/tx.go | 2 +- cli/util/convert.go | 12 +++--- cli/vm/cli.go | 66 ++++++++++++++--------------- cli/wallet/nep11.go | 2 +- cli/wallet/nep17.go | 8 ++-- cli/wallet/validator.go | 2 +- cli/wallet/wallet.go | 30 ++++++------- 11 files changed, 85 insertions(+), 85 deletions(-) diff --git a/cli/query/query.go b/cli/query/query.go index 5a63ebf32..f919d1d75 100644 --- a/cli/query/query.go +++ b/cli/query/query.go @@ -30,44 +30,44 @@ func NewCommands() []cli.Command { queryTxFlags := append([]cli.Flag{ cli.BoolFlag{ Name: "verbose, v", - Usage: "Output full tx info and execution logs", + Usage: "output full tx info and execution logs", }, }, options.RPC...) return []cli.Command{{ Name: "query", - Usage: "Query data from RPC node", + Usage: "query data from RPC node", Subcommands: []cli.Command{ { Name: "candidates", - Usage: "Get candidates and votes", + Usage: "get candidates and votes", UsageText: "neo-go query candidates -r endpoint [-s timeout]", Action: queryCandidates, Flags: options.RPC, }, { Name: "committee", - Usage: "Get committee list", + Usage: "get committee list", UsageText: "neo-go query committee -r endpoint [-s timeout]", Action: queryCommittee, Flags: options.RPC, }, { Name: "height", - Usage: "Get node height", + Usage: "get node height", UsageText: "neo-go query height -r endpoint [-s timeout]", Action: queryHeight, Flags: options.RPC, }, { Name: "tx", - Usage: "Query transaction status", + Usage: "query transaction status", UsageText: "neo-go query tx -r endpoint [-s timeout] [-v]", Action: queryTx, Flags: queryTxFlags, }, { Name: "voter", - Usage: "Print NEO holder account state", + Usage: "print NEO holder account state", UsageText: "neo-go query voter
-r endpoint [-s timeout]", Action: queryVoter, Flags: options.RPC, diff --git a/cli/server/server.go b/cli/server/server.go index d51b70159..1a1a5f348 100644 --- a/cli/server/server.go +++ b/cli/server/server.go @@ -55,7 +55,7 @@ func NewCommands() []cli.Command { }, cli.StringFlag{ Name: "out, o", - Usage: "Output file (stdout if not given)", + Usage: "output file (stdout if not given)", }, ) var cfgCountInFlags = make([]cli.Flag, len(cfgWithCountFlags)) @@ -63,7 +63,7 @@ func NewCommands() []cli.Command { cfgCountInFlags = append(cfgCountInFlags, cli.StringFlag{ Name: "in, i", - Usage: "Input file (stdin if not given)", + Usage: "input file (stdin if not given)", }, cli.StringFlag{ Name: "dump", @@ -78,7 +78,7 @@ func NewCommands() []cli.Command { copy(cfgHeightFlags, cfgFlags) cfgHeightFlags[len(cfgHeightFlags)-1] = cli.UintFlag{ Name: "height", - Usage: "Height of the state to reset DB to", + Usage: "height of the state to reset DB to", Required: true, } return []cli.Command{ diff --git a/cli/smartcontract/generate.go b/cli/smartcontract/generate.go index 28f9f18ce..2235155cd 100644 --- a/cli/smartcontract/generate.go +++ b/cli/smartcontract/generate.go @@ -16,21 +16,21 @@ import ( var generatorFlags = []cli.Flag{ cli.StringFlag{ Name: "config, c", - Usage: "Configuration file to use", + Usage: "configuration file to use", }, cli.StringFlag{ Name: "manifest, m", Required: true, - Usage: "Read contract manifest (*.manifest.json) file", + Usage: "read contract manifest (*.manifest.json) file", }, cli.StringFlag{ Name: "out, o", Required: true, - Usage: "Output of the compiled wrapper", + Usage: "output of the compiled wrapper", }, cli.StringFlag{ Name: "hash", - Usage: "Smart-contract hash. If not passed, the wrapper will be designed for dynamic hash usage", + Usage: "smart-contract hash. If not passed, the wrapper will be designed for dynamic hash usage", }, } diff --git a/cli/smartcontract/smart_contract.go b/cli/smartcontract/smart_contract.go index 87b04ed95..648ab0f7e 100644 --- a/cli/smartcontract/smart_contract.go +++ b/cli/smartcontract/smart_contract.go @@ -78,7 +78,7 @@ func NewCommands() []cli.Command { testInvokeScriptFlags := []cli.Flag{ cli.StringFlag{ Name: "in, i", - Usage: "Input location of the .nef file that needs to be invoked", + Usage: "input location of the .nef file that needs to be invoked", }, options.Historic, } @@ -98,11 +98,11 @@ func NewCommands() []cli.Command { deployFlags := append(invokeFunctionFlags, []cli.Flag{ cli.StringFlag{ Name: "in, i", - Usage: "Input file for the smart contract (*.nef)", + Usage: "input file for the smart contract (*.nef)", }, cli.StringFlag{ Name: "manifest, m", - Usage: "Manifest input file (*.manifest.json)", + Usage: "manifest input file (*.manifest.json)", }, }...) manifestAddGroupFlags := append([]cli.Flag{ @@ -143,27 +143,27 @@ func NewCommands() []cli.Command { Flags: []cli.Flag{ cli.StringFlag{ Name: "in, i", - Usage: "Input file for the smart contract to be compiled (*.go file or directory)", + Usage: "input file for the smart contract to be compiled (*.go file or directory)", }, cli.StringFlag{ Name: "out, o", - Usage: "Output of the compiled contract", + Usage: "output of the compiled contract", }, cli.BoolFlag{ Name: "verbose, v", - Usage: "Print out additional information after a compiling", + Usage: "print out additional information after a compiling", }, cli.StringFlag{ Name: "debug, d", - Usage: "Emit debug info in a separate file", + Usage: "emit debug info in a separate file", }, cli.StringFlag{ Name: "manifest, m", - Usage: "Emit contract manifest (*.manifest.json) file into separate file using configuration input file (*.yml)", + Usage: "emit contract manifest (*.manifest.json) file into separate file using configuration input file (*.yml)", }, cli.StringFlag{ Name: "config, c", - Usage: "Configuration input file (*.yml)", + Usage: "configuration input file (*.yml)", }, cli.BoolFlag{ Name: "no-standards", @@ -239,7 +239,7 @@ func NewCommands() []cli.Command { }, { Name: "testinvokescript", - Usage: "Invoke compiled AVM code in NEF format on the blockchain (test mode, not creating a transaction for it)", + Usage: "invoke compiled AVM code in NEF format on the blockchain (test mode, not creating a transaction for it)", UsageText: "neo-go contract testinvokescript -r endpoint -i input.nef [--historic index/hash] [signers...]", Description: `Executes given compiled AVM instructions in NEF format with the given set of signers not included sender by default. See testinvokefunction documentation diff --git a/cli/txctx/tx.go b/cli/txctx/tx.go index a012d10f8..6829f5e2a 100644 --- a/cli/txctx/tx.go +++ b/cli/txctx/tx.go @@ -38,7 +38,7 @@ var ( // ForceFlag is a flag used to force transaction send. ForceFlag = cli.BoolFlag{ Name: "force", - Usage: "Do not ask for a confirmation (and ignore errors)", + Usage: "do not ask for a confirmation (and ignore errors)", } // AwaitFlag is a flag used to wait for the transaction to be included in a block. AwaitFlag = cli.BoolFlag{ diff --git a/cli/util/convert.go b/cli/util/convert.go index 4205edd9a..bef7b9097 100644 --- a/cli/util/convert.go +++ b/cli/util/convert.go @@ -30,11 +30,11 @@ func NewCommands() []cli.Command { return []cli.Command{ { Name: "util", - Usage: "Various helper commands", + Usage: "various helper commands", Subcommands: []cli.Command{ { Name: "convert", - Usage: "Convert provided argument into other possible formats", + Usage: "convert provided argument into other possible formats", UsageText: `convert is an argument which is tried to be interpreted as an item of different types @@ -43,7 +43,7 @@ func NewCommands() []cli.Command { }, { Name: "sendtx", - Usage: "Send complete transaction stored in a context file", + Usage: "send complete transaction stored in a context file", UsageText: "sendtx [-r ] [--await]", Description: `Sends the transaction from the given context file to the given RPC node if it's completely signed and ready. This command expects a ContractParametersContext @@ -56,7 +56,7 @@ func NewCommands() []cli.Command { }, { Name: "canceltx", - Usage: "Cancel transaction by sending conflicting transaction", + Usage: "cancel transaction by sending conflicting transaction", UsageText: "canceltx -r --wallet [--account ] [--wallet-config ] [--gas ] [--await]", Description: `Aims to prevent a transaction from being added to the blockchain by dispatching a more prioritized conflicting transaction to the specified RPC node. The input for this command should @@ -76,7 +76,7 @@ func NewCommands() []cli.Command { }, { Name: "txdump", - Usage: "Dump transaction stored in file", + Usage: "dump transaction stored in file", UsageText: "txdump [-r ] ", Action: txDump, Flags: txDumpFlags, @@ -89,7 +89,7 @@ func NewCommands() []cli.Command { }, { Name: "ops", - Usage: "Pretty-print VM opcodes of the given base64- or hex- encoded script (base64 is checked first). If the input file is specified, then the script is taken from the file.", + Usage: "pretty-print VM opcodes of the given base64- or hex- encoded script (base64 is checked first). If the input file is specified, then the script is taken from the file.", UsageText: "ops [-i path-to-file] [--hex]", Action: handleOps, Flags: []cli.Flag{ diff --git a/cli/vm/cli.go b/cli/vm/cli.go index 8389d0c84..07bfa4fcb 100644 --- a/cli/vm/cli.go +++ b/cli/vm/cli.go @@ -72,7 +72,7 @@ const ( var ( historicFlag = cli.IntFlag{ Name: historicFlagFullName, - Usage: "Height for historic script invocation (for MPT-enabled blockchain configuration with KeepOnlyLatestState setting disabled). " + + Usage: "height for historic script invocation (for MPT-enabled blockchain configuration with KeepOnlyLatestState setting disabled). " + "Assuming that block N-th is specified as an argument, the historic invocation is based on the storage state of height N and fake currently-accepting block with index N+1.", } gasFlag = cli.Int64Flag{ @@ -81,28 +81,28 @@ var ( } hashFlag = cli.StringFlag{ Name: hashFlagFullName, - Usage: "Smart-contract hash in LE form or address", + Usage: "smart-contract hash in LE form or address", } ) var commands = []cli.Command{ { Name: "exit", - Usage: "Exit the VM prompt", + Usage: "exit the VM prompt", UsageText: "exit", Description: "Exit the VM prompt.", Action: handleExit, }, { Name: "ip", - Usage: "Show current instruction", + Usage: "show current instruction", UsageText: "ip", Description: "Show current instruction.", Action: handleIP, }, { Name: "break", - Usage: "Place a breakpoint", + Usage: "place a breakpoint", UsageText: `break `, Description: ` is mandatory parameter. @@ -112,7 +112,7 @@ Example: }, { Name: "jump", - Usage: "Jump to the specified instruction (absolute IP value)", + Usage: "jump to the specified instruction (absolute IP value)", UsageText: `jump `, Description: ` is mandatory parameter (absolute IP value). @@ -122,42 +122,42 @@ Example: }, { Name: "estack", - Usage: "Show evaluation stack contents", + Usage: "show evaluation stack contents", UsageText: "estack", Description: "Show evaluation stack contents.", Action: handleXStack, }, { Name: "istack", - Usage: "Show invocation stack contents", + Usage: "show invocation stack contents", UsageText: "istack", Description: "Show invocation stack contents.", Action: handleXStack, }, { Name: "sslot", - Usage: "Show static slot contents", + Usage: "show static slot contents", UsageText: "sslot", Description: "Show static slot contents.", Action: handleSlots, }, { Name: "lslot", - Usage: "Show local slot contents", + Usage: "show local slot contents", UsageText: "lslot", Description: "Show local slot contents", Action: handleSlots, }, { Name: "aslot", - Usage: "Show arguments slot contents", + Usage: "show arguments slot contents", UsageText: "aslot", Description: "Show arguments slot contents.", Action: handleSlots, }, { Name: "loadnef", - Usage: "Load a NEF (possibly with a contract hash) into the VM optionally using provided scoped signers in the context", + Usage: "load a NEF (possibly with a contract hash) into the VM optionally using provided scoped signers in the context", UsageText: `loadnef [--historic ] [--gas ] [--hash ] [] [-- , ...]`, Flags: []cli.Flag{historicFlag, gasFlag, hashFlag}, Description: ` parameter is mandatory, parameter (if omitted) will @@ -172,7 +172,7 @@ Example: }, { Name: "loadbase64", - Usage: "Load a base64-encoded script string into the VM optionally attaching to it provided signers with scopes", + Usage: "load a base64-encoded script string into the VM optionally attaching to it provided signers with scopes", UsageText: `loadbase64 [--historic ] [--gas ] [-- , ...]`, Flags: []cli.Flag{historicFlag, gasFlag}, Description: ` is mandatory parameter. @@ -185,7 +185,7 @@ Example: }, { Name: "loadhex", - Usage: "Load a hex-encoded script string into the VM optionally attaching to it provided signers with scopes", + Usage: "load a hex-encoded script string into the VM optionally attaching to it provided signers with scopes", UsageText: `loadhex [--historic ] [--gas ] [-- , ...]`, Flags: []cli.Flag{historicFlag, gasFlag}, Description: ` is mandatory parameter. @@ -198,7 +198,7 @@ Example: }, { Name: "loadgo", - Usage: "Compile and load a Go file with the manifest into the VM optionally attaching to it provided signers with scopes and setting provided hash", + Usage: "compile and load a Go file with the manifest into the VM optionally attaching to it provided signers with scopes and setting provided hash", UsageText: `loadgo [--historic ] [--gas ] [--hash ] [-- , ...]`, Flags: []cli.Flag{historicFlag, gasFlag, hashFlag}, Description: ` is mandatory parameter. @@ -211,7 +211,7 @@ Example: }, { Name: "loadtx", - Usage: "Load transaction into the VM from chain or from parameter context file", + Usage: "load transaction into the VM from chain or from parameter context file", UsageText: `loadtx [--historic ] [--gas ] `, Flags: []cli.Flag{historicFlag, gasFlag}, Description: `Load transaction into the VM from chain or from parameter context file. @@ -228,7 +228,7 @@ Example: }, { Name: "loaddeployed", - Usage: "Load deployed contract into the VM from chain optionally attaching to it provided signers with scopes", + Usage: "load deployed contract into the VM from chain optionally attaching to it provided signers with scopes", UsageText: `loaddeployed [--historic ] [--gas ] [-- , ...]`, Flags: []cli.Flag{historicFlag, gasFlag}, Description: `Load deployed contract into the VM from chain optionally attaching to it provided signers with scopes. @@ -244,7 +244,7 @@ Example: }, { Name: "reset", - Usage: "Unload compiled script from the VM and reset context to proper (possibly, historic) state", + Usage: "unload compiled script from the VM and reset context to proper (possibly, historic) state", UsageText: "reset", Flags: []cli.Flag{historicFlag}, Description: "Unload compiled script from the VM and reset context to proper (possibly, historic) state.", @@ -252,7 +252,7 @@ Example: }, { Name: "parse", - Usage: "Parse provided argument and convert it into other possible formats", + Usage: "parse provided argument and convert it into other possible formats", UsageText: `parse `, Description: ` is an argument which is tried to be interpreted as an item of different types and converted to other formats. Strings are escaped and output in quotes.`, @@ -260,7 +260,7 @@ and converted to other formats. Strings are escaped and output in quotes.`, }, { Name: "run", - Usage: "Usage Execute the current loaded script", + Usage: "usage Execute the current loaded script", UsageText: `run [ [...]]`, Description: ` is a contract method, specified in manifest. It can be '_' which will push parameters onto the stack and execute from the current offset. @@ -275,14 +275,14 @@ Example: }, { Name: "cont", - Usage: "Continue execution of the current loaded script", + Usage: "continue execution of the current loaded script", UsageText: "cont", Description: "Continue execution of the current loaded script.", Action: handleCont, }, { Name: "step", - Usage: "Step (n) instruction in the program", + Usage: "step (n) instruction in the program", UsageText: `step []`, Description: ` is optional parameter to specify number of instructions to run. @@ -292,7 +292,7 @@ Example: }, { Name: "stepinto", - Usage: "Stepinto instruction to take in the debugger", + Usage: "stepinto instruction to take in the debugger", UsageText: "stepinto", Description: `Stepinto instruction to take in the debugger. @@ -302,7 +302,7 @@ Example: }, { Name: "stepout", - Usage: "Stepout instruction to take in the debugger", + Usage: "stepout instruction to take in the debugger", UsageText: "stepout", Description: `Stepout instruction to take in the debugger. @@ -312,7 +312,7 @@ Example: }, { Name: "stepover", - Usage: "Stepover instruction to take in the debugger", + Usage: "stepover instruction to take in the debugger", UsageText: "stepover", Description: `Stepover instruction to take in the debugger. @@ -322,26 +322,26 @@ Example: }, { Name: "ops", - Usage: "Dump opcodes of the current loaded program", + Usage: "dump opcodes of the current loaded program", UsageText: "ops", Description: "Dump opcodes of the current loaded program", Action: handleOps, }, { Name: "events", - Usage: "Dump events emitted by the current loaded program", + Usage: "dump events emitted by the current loaded program", UsageText: "events", Description: "Dump events emitted by the current loaded program", Action: handleEvents, }, { Name: "env", - Usage: "Dump state of the chain that is used for VM CLI invocations (use -v for verbose node configuration)", + Usage: "dump state of the chain that is used for VM CLI invocations (use -v for verbose node configuration)", UsageText: `env [-v]`, Flags: []cli.Flag{ cli.BoolFlag{ Name: verboseFlagFullName + ",v", - Usage: "Print the whole blockchain node configuration.", + Usage: "print the whole blockchain node configuration.", }, }, Description: `Dump state of the chain that is used for VM CLI invocations (use -v for verbose node configuration). @@ -352,16 +352,16 @@ Example: }, { Name: "storage", - Usage: "Dump storage of the contract with the specified hash, address or ID as is at the current stage of script invocation", + Usage: "dump storage of the contract with the specified hash, address or ID as is at the current stage of script invocation", UsageText: `storage [] [--backwards] [--diff]`, Flags: []cli.Flag{ cli.BoolFlag{ Name: backwardsFlagFullName + ",b", - Usage: "Backwards traversal direction", + Usage: "backwards traversal direction", }, cli.BoolFlag{ Name: diffFlagFullName + ",d", - Usage: "Dump only those storage items that were added or changed during the current script invocation. Note that this call won't show removed storage items, use 'changes' command for that.", + Usage: "dump only those storage items that were added or changed during the current script invocation. Note that this call won't show removed storage items, use 'changes' command for that.", }, }, Description: `Dump storage of the contract with the specified hash, address or ID as is at the current stage of script invocation. @@ -378,7 +378,7 @@ Example: }, { Name: "changes", - Usage: "Dump storage changes as is at the current stage of loaded script invocation", + Usage: "dump storage changes as is at the current stage of loaded script invocation", UsageText: `changes [ []]`, Description: `Dump storage changes as is at the current stage of loaded script invocation. If no script is loaded or executed, then no changes are present. diff --git a/cli/wallet/nep11.go b/cli/wallet/nep11.go index 9fcce1a86..870dd35ab 100644 --- a/cli/wallet/nep11.go +++ b/cli/wallet/nep11.go @@ -26,7 +26,7 @@ func newNEP11Commands() []cli.Command { maxIters := strconv.Itoa(config.DefaultMaxIteratorResultItems) tokenAddressFlag := flags.AddressFlag{ Name: "token", - Usage: "Token contract address or hash in LE", + Usage: "token contract address or hash in LE", } ownerAddressFlag := flags.AddressFlag{ Name: "address", diff --git a/cli/wallet/nep17.go b/cli/wallet/nep17.go index de4d6a09a..646ec0107 100644 --- a/cli/wallet/nep17.go +++ b/cli/wallet/nep17.go @@ -41,7 +41,7 @@ type transferTarget struct { var ( tokenFlag = cli.StringFlag{ Name: "token", - Usage: "Token to use (hash or name (for NEO/GAS or imported tokens))", + Usage: "token to use (hash or name (for NEO/GAS or imported tokens))", } baseBalanceFlags = []cli.Flag{ walletPathFlag, @@ -49,7 +49,7 @@ var ( tokenFlag, flags.AddressFlag{ Name: "address, a", - Usage: "Address to use", + Usage: "address to use", }, } importFlags = append([]cli.Flag{ @@ -57,7 +57,7 @@ var ( walletConfigFlag, flags.AddressFlag{ Name: "token", - Usage: "Token contract address or hash in LE", + Usage: "token contract address or hash in LE", }, }, options.RPC...) baseTransferFlags = []cli.Flag{ @@ -73,7 +73,7 @@ var ( txctx.AwaitFlag, cli.StringFlag{ Name: "amount", - Usage: "Amount of asset to send", + Usage: "amount of asset to send", }, } multiTransferFlags = append([]cli.Flag{ diff --git a/cli/wallet/validator.go b/cli/wallet/validator.go index db6a0308b..c0dca22d9 100644 --- a/cli/wallet/validator.go +++ b/cli/wallet/validator.go @@ -32,7 +32,7 @@ func newValidatorCommands() []cli.Command { txctx.AwaitFlag, flags.AddressFlag{ Name: "address, a", - Usage: "Address to register", + Usage: "address to register", }, }, options.RPC...), }, diff --git a/cli/wallet/wallet.go b/cli/wallet/wallet.go index 825fa1702..53f20f651 100644 --- a/cli/wallet/wallet.go +++ b/cli/wallet/wallet.go @@ -49,11 +49,11 @@ var ( var ( walletPathFlag = cli.StringFlag{ Name: "wallet, w", - Usage: "Path to the wallet file ('-' to read from stdin); conflicts with --wallet-config flag.", + Usage: "path to the wallet file ('-' to read from stdin); conflicts with --wallet-config flag.", } walletConfigFlag = cli.StringFlag{ Name: "wallet-config", - Usage: "Path to the wallet config file; conflicts with --wallet flag.", + Usage: "path to the wallet config file; conflicts with --wallet flag.", } wifFlag = cli.StringFlag{ Name: "wif", @@ -61,7 +61,7 @@ var ( } decryptFlag = cli.BoolFlag{ Name: "decrypt, d", - Usage: "Decrypt encrypted keys.", + Usage: "decrypt encrypted keys.", } inFlag = cli.StringFlag{ Name: "in", @@ -69,11 +69,11 @@ var ( } fromAddrFlag = flags.AddressFlag{ Name: "from", - Usage: "Address to send an asset from", + Usage: "address to send an asset from", } toAddrFlag = flags.AddressFlag{ Name: "to", - Usage: "Address to send an asset to", + Usage: "address to send an asset to", } ) @@ -89,7 +89,7 @@ func NewCommands() []cli.Command { txctx.AwaitFlag, flags.AddressFlag{ Name: "address, a", - Usage: "Address to claim GAS for", + Usage: "address to claim GAS for", }, } claimFlags = append(claimFlags, options.RPC...) @@ -101,7 +101,7 @@ func NewCommands() []cli.Command { inFlag, flags.AddressFlag{ Name: "address, a", - Usage: "Address to use", + Usage: "address to use", }, } signFlags = append(signFlags, options.RPC...) @@ -126,7 +126,7 @@ func NewCommands() []cli.Command { walletConfigFlag, cli.BoolFlag{ Name: "account, a", - Usage: "Create a new account", + Usage: "create a new account", }, }, }, @@ -225,11 +225,11 @@ func NewCommands() []cli.Command { wifFlag, cli.StringFlag{ Name: "name, n", - Usage: "Optional account name", + Usage: "optional account name", }, cli.StringFlag{ Name: "contract", - Usage: "Verification script for custom contracts", + Usage: "verification script for custom contracts", }, }, }, @@ -252,11 +252,11 @@ func NewCommands() []cli.Command { wifFlag, cli.StringFlag{ Name: "name, n", - Usage: "Optional account name", + Usage: "optional account name", }, cli.IntFlag{ Name: "min, m", - Usage: "Minimal number of signatures", + Usage: "minimal number of signatures", }, }, }, @@ -271,11 +271,11 @@ func NewCommands() []cli.Command { wifFlag, cli.StringFlag{ Name: "name, n", - Usage: "Optional account name", + Usage: "optional account name", }, flags.AddressFlag{ Name: "contract, c", - Usage: "Contract hash or address", + Usage: "contract hash or address", }, }, options.RPC...), }, @@ -290,7 +290,7 @@ func NewCommands() []cli.Command { txctx.ForceFlag, flags.AddressFlag{ Name: "address, a", - Usage: "Account address or hash in LE form to be removed", + Usage: "account address or hash in LE form to be removed", }, }, }, From c3705664c25a910593917ecf50d90aec4257f231 Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Thu, 6 Jun 2024 15:06:10 +0300 Subject: [PATCH 2/3] cli: add config generate command Add cli command to generate YAML configuration files. Signed-off-by: Ekaterina Pavlova --- .github/workflows/tests.yml | 32 +++ README.md | 25 +- cli/app/app.go | 2 + cli/config/config.go | 121 +++++++++ cli/config/mainnet.go | 127 +++++++++ cli/config/mainnet_neofs.go | 96 +++++++ cli/config/privnet.go | 101 +++++++ cli/config/privnet_docker.go | 492 +++++++++++++++++++++++++++++++++++ cli/config/testnet.go | 121 +++++++++ cli/config/testnet_neofs.go | 105 ++++++++ cli/config/unit_testnet.go | 145 +++++++++++ cli/config/vm.go | 101 +++++++ 12 files changed, 1462 insertions(+), 6 deletions(-) create mode 100644 cli/config/config.go create mode 100644 cli/config/mainnet.go create mode 100644 cli/config/mainnet_neofs.go create mode 100644 cli/config/privnet.go create mode 100644 cli/config/privnet_docker.go create mode 100644 cli/config/testnet.go create mode 100644 cli/config/testnet_neofs.go create mode 100644 cli/config/unit_testnet.go create mode 100644 cli/config/vm.go diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 524214bd1..e2a0edbb8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -150,6 +150,38 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} verbose: true + check_config: + name: Check Configuration Files + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Build NeoGo + run: | + echo "=> Building binary" + export GOGC=off + export CGO_ENABLED=0 + VERSION=$(git describe --tags --always || echo "untagged") + COMMIT=$(git rev-parse HEAD) + BUILD_FLAGS="-X main.Version=$VERSION -X main.Commit=$COMMIT" + BINARY_PATH="./neo-go" + go build -trimpath -v -ldflags "$BUILD_FLAGS" -o ${BINARY_PATH} ./cli/main.go + + - name: Generate Configurations + run: | + ./neo-go config generate --all + + - name: Check for configuration changes + run: | + git diff --exit-code ./config || (echo "::error ::Configuration mismatch detected. Please update the configuration files:" && git diff ./config) + tests: name: Run tests runs-on: ${{ matrix.os }} diff --git a/README.md b/README.md index a435c83c3..f70d1dc35 100644 --- a/README.md +++ b/README.md @@ -75,15 +75,28 @@ The resulting binary is `bin/neo-go.exe`. ## Running a node -A node needs to connect to some network, either local one (usually referred to -as `privnet`) or public (like `mainnet` or `testnet`). Network configuration -is stored in a file and NeoGo allows you to store multiple files in one -directory (`./config` by default) and easily switch between them using network -flags. +Before running a Neo node, you need to generate the necessary configuration files +for the network you wish to connect to, such as a local network (`privnet`), or +a public network like `mainnet` or `testnet`. NeoGo stores network configuration +files in a directory (`./config` by default) and allows you to easily switch +between them using network flags. -To start Neo node on a private network, use: +### Initial Setup +First, generate the configuration files for all available networks: + +```bash +./bin/neo-go config generate --all ``` + +This command will create configuration files for each network in +the `./config` directory. You need to run this step only once before the first run. + +### Starting the Node + +To start a Neo node on a private network, use: + +```bash ./bin/neo-go node ``` diff --git a/cli/app/app.go b/cli/app/app.go index c62b5e42d..93cde6e45 100644 --- a/cli/app/app.go +++ b/cli/app/app.go @@ -5,6 +5,7 @@ import ( "os" "runtime" + nodeconfig "github.com/nspcc-dev/neo-go/cli/config" "github.com/nspcc-dev/neo-go/cli/query" "github.com/nspcc-dev/neo-go/cli/server" "github.com/nspcc-dev/neo-go/cli/smartcontract" @@ -37,5 +38,6 @@ func New() *cli.App { ctl.Commands = append(ctl.Commands, vm.NewCommands()...) ctl.Commands = append(ctl.Commands, util.NewCommands()...) ctl.Commands = append(ctl.Commands, query.NewCommands()...) + ctl.Commands = append(ctl.Commands, nodeconfig.NewCommands()...) return ctl } diff --git a/cli/config/config.go b/cli/config/config.go new file mode 100644 index 000000000..4e4564c5c --- /dev/null +++ b/cli/config/config.go @@ -0,0 +1,121 @@ +package config + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/nspcc-dev/neo-go/cli/cmdargs" + "github.com/nspcc-dev/neo-go/pkg/config" + "github.com/urfave/cli" + "gopkg.in/yaml.v3" +) + +// NewCommands returns 'config' command. +func NewCommands() []cli.Command { + return []cli.Command{ + { + Name: "config", + Usage: "NeoGo node configuration management", + Subcommands: []cli.Command{ + { + Name: "generate", + Usage: "generate configuration files", + UsageText: "neo-go config generate [--privnet | --mainnet | --testnet | --unit_testnet | --mainnet_neofs | --testnet_neofs | --docker | --all] [--config-path path]", + Action: configGenerate, + Flags: []cli.Flag{ + cli.BoolFlag{Name: "privnet, p", Usage: "generate private network configuration"}, + cli.BoolFlag{Name: "mainnet, m", Usage: "generate mainnet network configuration"}, + cli.BoolFlag{Name: "testnet, t", Usage: "generate testnet network configuration"}, + cli.BoolFlag{Name: "unit_testnet", Usage: "generate unit test network configuration"}, + cli.BoolFlag{Name: "mainnet_neofs", Usage: "generate mainnet NeoFS network configuration"}, + cli.BoolFlag{Name: "testnet_neofs", Usage: "generate testnet NeoFS network configuration"}, + cli.BoolFlag{Name: "docker", Usage: "generate Docker configuration"}, + cli.BoolFlag{Name: "all", Usage: "generate all networks configurations"}, + cli.StringFlag{Name: "config-path", Usage: "path to the directory where configuration files will be generated"}, + }, + }, + }, + }, + } +} + +func configGenerate(ctx *cli.Context) error { + if err := cmdargs.EnsureNone(ctx); err != nil { + return err + } + + filesToGenerate := make(map[string]config.Config) + + if ctx.Bool("all") { + filesToGenerate = map[string]config.Config{ + "protocol.mainnet.yml": Mainnet, + "protocol.mainnet.neofs.yml": MainnetNeoFS, + "protocol.testnet.yml": Testnet, + "protocol.testnet.neofs.yml": TestnetNeoFS, + "protocol.unit_testnet.yml": UnitTestnet, + "protocol.unit_testnet.single.yml": UnitTestnetSingle, + "protocol.privnet.docker.one.yml": PrivnetDockerOne, + "protocol.privnet.docker.two.yml": PrivnetDockerTwo, + "protocol.privnet.docker.three.yml": PrivnetDockerThree, + "protocol.privnet.docker.four.yml": PrivnetDockerFour, + "protocol.privnet.docker.single.yml": PrivnetDockerSingle, + "protocol.privnet.yml": Privnet, + } + } else { + if ctx.Bool("privnet") { + filesToGenerate["protocol.privnet.yml"] = Privnet + } + if ctx.Bool("mainnet") { + filesToGenerate["protocol.mainnet.yml"] = Mainnet + } + if ctx.Bool("testnet") { + filesToGenerate["protocol.testnet.yml"] = Testnet + } + if ctx.Bool("unit_testnet") { + filesToGenerate["protocol.unit_testnet.yml"] = UnitTestnet + filesToGenerate["protocol.unit_testnet.single.yml"] = UnitTestnetSingle + } + if ctx.Bool("mainnet_neofs") { + filesToGenerate["protocol.mainnet.neofs.yml"] = MainnetNeoFS + } + if ctx.Bool("testnet_neofs") { + filesToGenerate["protocol.testnet.neofs.yml"] = TestnetNeoFS + } + if ctx.Bool("docker") { + filesToGenerate["protocol.privnet.docker.one.yml"] = PrivnetDockerOne + filesToGenerate["protocol.privnet.docker.two.yml"] = PrivnetDockerTwo + filesToGenerate["protocol.privnet.docker.three.yml"] = PrivnetDockerThree + filesToGenerate["protocol.privnet.docker.four.yml"] = PrivnetDockerFour + filesToGenerate["protocol.privnet.docker.single.yml"] = PrivnetDockerSingle + } + } + configDir := ctx.String("config-path") + if configDir == "" { + configDir = "config" + } + if err := os.MkdirAll(configDir, 0755); err != nil { + return cli.NewExitError(fmt.Errorf("unable to create configuration directory: %w", err), 1) + } + + for fileName, cfg := range filesToGenerate { + if err := writeConfigToFile(cfg, filepath.Join(configDir, fileName)); err != nil { + return err + } + } + return nil +} + +func writeConfigToFile(cfg config.Config, filename string) error { + file, err := os.Create(filename) + if err != nil { + return cli.NewExitError(fmt.Errorf("failed to create file %s: %w", filename, err), 1) + } + defer file.Close() + + encoder := yaml.NewEncoder(file) + if err := encoder.Encode(cfg); err != nil { + return cli.NewExitError(fmt.Errorf("failed to encode configuration to file %s: %w", filename, err), 1) + } + return nil +} diff --git a/cli/config/mainnet.go b/cli/config/mainnet.go new file mode 100644 index 000000000..cfd3dc9f9 --- /dev/null +++ b/cli/config/mainnet.go @@ -0,0 +1,127 @@ +package config + +import ( + "time" + + "github.com/nspcc-dev/neo-go/pkg/config" + "github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig" +) + +// Mainnet is the configuration for the Neo N3 mainnet. +var Mainnet = config.Config{ + ProtocolConfiguration: config.ProtocolConfiguration{ + Magic: 860833102, + MaxTraceableBlocks: 2102400, + InitialGASSupply: 52000000, + TimePerBlock: 15 * time.Second, + MemPoolSize: 50000, + StandbyCommittee: []string{ + "03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c", + "02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093", + "03b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a", + "02ca0e27697b9c248f6f16e085fd0061e26f44da85b58ee835c110caa5ec3ba554", + "024c7b7fb6c310fccf1ba33b082519d82964ea93868d676662d4a59ad548df0e7d", + "02aaec38470f6aad0042c6e877cfd8087d2676b0f516fddd362801b9bd3936399e", + "02486fd15702c4490a26703112a5cc1d0923fd697a33406bd5a1c00e0013b09a70", + "023a36c72844610b4d34d1968662424011bf783ca9d984efa19a20babf5582f3fe", + "03708b860c1de5d87f5b151a12c2a99feebd2e8b315ee8e7cf8aa19692a9e18379", + "03c6aa6e12638b36e88adc1ccdceac4db9929575c3e03576c617c49cce7114a050", + "03204223f8c86b8cd5c89ef12e4f0dbb314172e9241e30c9ef2293790793537cf0", + "02a62c915cf19c7f19a50ec217e79fac2439bbaad658493de0c7d8ffa92ab0aa62", + "03409f31f0d66bdc2f70a9730b66fe186658f84a8018204db01c106edc36553cd0", + "0288342b141c30dc8ffcde0204929bb46aed5756b41ef4a56778d15ada8f0c6654", + "020f2887f41474cfeb11fd262e982051c1541418137c02a0f4961af911045de639", + "0222038884bbd1d8ff109ed3bdef3542e768eef76c1247aea8bc8171f532928c30", + "03d281b42002647f0113f36c7b8efb30db66078dfaaa9ab3ff76d043a98d512fde", + "02504acbc1f4b3bdad1d86d6e1a08603771db135a73e61c9d565ae06a1938cd2ad", + "0226933336f1b75baa42d42b71d9091508b638046d19abd67f4e119bf64a7cfb4d", + "03cdcea66032b82f5c30450e381e5295cae85c5e6943af716cc6b646352a6067dc", + "02cd5a5547119e24feaa7c2a0f37b8c9366216bab7054de0065c9be42084003c8a", + }, + ValidatorsCount: 7, + VerifyTransactions: false, + P2PSigExtensions: false, + Hardforks: map[string]uint32{ + "Aspidochelone": 1730000, + "Basilisk": 4120000, + "Cockatrice": 5450000, + }, + SeedList: []string{ + "seed1.neo.org:10333", + "seed2.neo.org:10333", + "seed3.neo.org:10333", + "seed4.neo.org:10333", + "seed5.neo.org:10333", + }, + }, + + ApplicationConfiguration: config.ApplicationConfiguration{ + Ledger: config.Ledger{ + SkipBlockVerification: false, + }, + // LogPath could be set up in case you need stdout logs to some proper file. + // LogPath: "./log/neogo.log" + DBConfiguration: dbconfig.DBConfiguration{ + Type: dbconfig.LevelDB, // Other options: 'inmemory','boltdb' + // DB type options. Uncomment those you need in case you want to switch DB type. + LevelDBOptions: dbconfig.LevelDBOptions{ + DataDirectoryPath: "./chains/mainnet", + // BoltDBOptions: + // FilePath: "./chains/mainnet.bolt" + }, + }, + P2P: config.P2P{ + Addresses: []string{":10333"}, // in form of "[host]:[port][:announcedPort]" + DialTimeout: 3000 * time.Millisecond, + ProtoTickInterval: 2000 * time.Millisecond, + PingInterval: 30000 * time.Millisecond, + PingTimeout: 90000 * time.Millisecond, + MaxPeers: 100, + MinPeers: 10, + AttemptConnPeers: 20, + }, + Relay: true, + Consensus: config.Consensus{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/cn_wallet.json", + Password: "pass", + }, + }, + Oracle: config.OracleConfiguration{ + Enabled: false, + AllowedContentTypes: []string{ + "application/json", + }, + }, + P2PNotary: config.P2PNotary{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/notary_wallet.json", + Password: "pass", + }, + }, + RPC: config.RPC{ + BasicService: config.BasicService{ + Enabled: true, + Addresses: []string{":10332"}}, + MaxGasInvoke: 15, + EnableCORSWorkaround: false, + TLSConfig: config.TLS{ + BasicService: config.BasicService{ + Enabled: false, + Addresses: []string{":10331"}}, + CertFile: "serv.crt", + KeyFile: "serv.key", + }, + }, + Prometheus: config.BasicService{ + Enabled: true, + Addresses: []string{":2112"}, + }, + Pprof: config.BasicService{ + Enabled: false, + Addresses: []string{":2113"}, + }, + }, +} diff --git a/cli/config/mainnet_neofs.go b/cli/config/mainnet_neofs.go new file mode 100644 index 000000000..7b0534de2 --- /dev/null +++ b/cli/config/mainnet_neofs.go @@ -0,0 +1,96 @@ +package config + +import ( + "time" + + "github.com/nspcc-dev/neo-go/pkg/config" + "github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig" +) + +// MainnetNeoFS is the configuration for the NeoFS mainnet. +var MainnetNeoFS = config.Config{ + ProtocolConfiguration: config.ProtocolConfiguration{ + Magic: 91414437, + MaxTraceableBlocks: 2102400, + InitialGASSupply: 52000000, + TimePerBlock: 15 * time.Second, + MemPoolSize: 50000, + StandbyCommittee: []string{ + "026fa34ec057d74c2fdf1a18e336d0bd597ea401a0b2ad57340d5c220d09f44086", + "039a9db2a30942b1843db673aeb0d4fd6433f74cec1d879de6343cb9fcf7628fa4", + "0366d255e7ce23ea6f7f1e4bedf5cbafe598705b47e6ec213ef13b2f0819e8ab33", + "023f9cb7bbe154d529d5c719fdc39feaa831a43ae03d2a4280575b60f52fa7bc52", + "039ba959e0ab6dc616df8b803692f1c30ba9071b76b05535eb994bf5bbc402ad5f", + "035a2a18cddafa25ad353dea5e6730a1b9fcb4b918c4a0303c4387bb9c3b816adf", + "031f4d9c66f2ec348832c48fd3a16dfaeb59e85f557ae1e07f6696d0375c64f97b", + }, + ValidatorsCount: 7, + VerifyTransactions: true, + P2PSigExtensions: true, + Hardforks: map[string]uint32{ + "Aspidochelone": 3000000, + "Basilisk": 4500000, + "Cockatrice": 5800000, + }, + SeedList: []string{ + "morph1.fs.neo.org:40333", + "morph2.fs.neo.org:40333", + "morph3.fs.neo.org:40333", + "morph4.fs.neo.org:40333", + "morph5.fs.neo.org:40333", + "morph6.fs.neo.org:40333", + "morph7.fs.neo.org:40333", + }, + }, + + ApplicationConfiguration: config.ApplicationConfiguration{ + DBConfiguration: dbconfig.DBConfiguration{ + Type: dbconfig.LevelDB, + LevelDBOptions: dbconfig.LevelDBOptions{ + DataDirectoryPath: "./chains/mainnet.neofs", + }, + }, + P2P: config.P2P{ + Addresses: []string{":40333"}, + DialTimeout: 3 * time.Second, + ProtoTickInterval: 2 * time.Second, + PingInterval: 30 * time.Second, + PingTimeout: 90 * time.Second, + MaxPeers: 100, + MinPeers: 5, + AttemptConnPeers: 20, + }, + Relay: true, + Consensus: config.Consensus{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/cn_wallet.json", + Password: "pass", + }, + }, + RPC: config.RPC{ + BasicService: config.BasicService{ + Enabled: true, + Addresses: []string{":40332"}, + }, + MaxGasInvoke: 15, + EnableCORSWorkaround: false, + TLSConfig: config.TLS{ + BasicService: config.BasicService{ + Enabled: false, + Addresses: []string{":40331"}, + }, + CertFile: "serv.crt", + KeyFile: "serv.key", + }, + }, + Prometheus: config.BasicService{ + Enabled: false, + Addresses: []string{":2112"}, + }, + Pprof: config.BasicService{ + Enabled: false, + Addresses: []string{":2113"}, + }, + }, +} diff --git a/cli/config/privnet.go b/cli/config/privnet.go new file mode 100644 index 000000000..402163977 --- /dev/null +++ b/cli/config/privnet.go @@ -0,0 +1,101 @@ +package config + +import ( + "time" + + "github.com/nspcc-dev/neo-go/pkg/config" + "github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig" +) + +// Privnet is the configuration for the Neo N3 privnet. +var Privnet = config.Config{ + ProtocolConfiguration: config.ProtocolConfiguration{ + Magic: 56753, + MaxTraceableBlocks: 200000, + TimePerBlock: 15 * time.Second, + MemPoolSize: 50000, + StandbyCommittee: []string{ + "02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2", + "02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e", + "03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699", + "02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62", + }, + ValidatorsCount: 4, + VerifyTransactions: true, + P2PSigExtensions: false, + SeedList: []string{ + "localhost:20333", + "localhost:20334", + "localhost:20335", + "localhost:20336", + }, + }, + + ApplicationConfiguration: config.ApplicationConfiguration{ + Ledger: config.Ledger{ + SkipBlockVerification: false}, + // LogPath could be set up in case you need stdout logs to some proper file. + // LogPath: "./log/neogo.log" + DBConfiguration: dbconfig.DBConfiguration{ + Type: dbconfig.LevelDB, + // Other options: 'inmemory','boltdb' + // DB type options. Uncomment those you need in case you want to switch DB type. + LevelDBOptions: dbconfig.LevelDBOptions{ + DataDirectoryPath: "./chains/privnet", + // BoltDBOptions: + // FilePath: "./chains/privnet.bolt" + }, + }, + P2P: config.P2P{ + Addresses: []string{":20332"}, // In form of "[host]:[port][:announcedPort]" + DialTimeout: 3 * time.Second, + ProtoTickInterval: 2 * time.Second, + PingInterval: 30 * time.Second, + PingTimeout: 90 * time.Second, + MaxPeers: 10, + AttemptConnPeers: 5, + MinPeers: 3, + }, + Relay: true, + Consensus: config.Consensus{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/cn_wallet.json", + Password: "pass", + }, + }, + P2PNotary: config.P2PNotary{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/notary_wallet.json", + Password: "pass", + }, + }, + RPC: config.RPC{ + BasicService: config.BasicService{ + Enabled: true, + Addresses: []string{":20331"}, + }, + MaxGasInvoke: 15, + EnableCORSWorkaround: false, + SessionEnabled: true, + SessionExpirationTime: 180, // Higher expiration time for manual requests and tests. + TLSConfig: config.TLS{ + BasicService: config.BasicService{ + Enabled: false, + Addresses: []string{":20330"}, + }, + CertFile: "serv.crt", + KeyFile: "serv.key", + }, + }, + Prometheus: config.BasicService{ + Enabled: true, + Addresses: []string{":2112"}, + }, + Pprof: config.BasicService{ + Enabled: false, + Addresses: []string{":2113"}, + }, + }, +} diff --git a/cli/config/privnet_docker.go b/cli/config/privnet_docker.go new file mode 100644 index 000000000..02e2700e1 --- /dev/null +++ b/cli/config/privnet_docker.go @@ -0,0 +1,492 @@ +package config + +import ( + "time" + + "github.com/nspcc-dev/neo-go/pkg/config" + "github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig" +) + +// PrivnetDockerOne is the configuration for the first node in the Dockerized private network. +var PrivnetDockerOne = config.Config{ + ProtocolConfiguration: config.ProtocolConfiguration{ + Magic: 56753, + MaxTraceableBlocks: 200000, + TimePerBlock: 15 * time.Second, + MemPoolSize: 50000, + StandbyCommittee: []string{ + "02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2", + "02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e", + "03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699", + "02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62", + }, + ValidatorsCount: 4, + VerifyTransactions: true, + P2PSigExtensions: false, + SeedList: []string{ + "node_one:20333", + "node_two:20334", + "node_three:20335", + "node_four:20336", + }, + }, + + ApplicationConfiguration: config.ApplicationConfiguration{ + Ledger: config.Ledger{SkipBlockVerification: false}, + // LogPath: "./log/neogo.log" + DBConfiguration: dbconfig.DBConfiguration{ + Type: dbconfig.LevelDB, // Change DB type if required. Other options: 'inmemory','boltdb' + LevelDBOptions: dbconfig.LevelDBOptions{ + DataDirectoryPath: "/chains/one", + }, + // BoltDBOptions: dbconfig.BoltDBOptions{ + // FilePath: "./chains/privnet.bolt" + // } + }, + P2P: config.P2P{ + Addresses: []string{":20333"}, // Standard port configuration for this environment + DialTimeout: 3 * time.Second, + ProtoTickInterval: 2 * time.Second, + PingInterval: 30 * time.Second, + PingTimeout: 90 * time.Second, + MaxPeers: 10, + AttemptConnPeers: 5, + MinPeers: 2, + }, + Relay: true, + Oracle: config.OracleConfiguration{ + Enabled: false, + AllowedContentTypes: []string{ + "application/json", + }, + Nodes: []string{ + "http://node_one:30333", + "http://node_two:30334", + "http://node_three:30335", + "http://node_four:30336", + }, + RequestTimeout: 5 * time.Second, + UnlockWallet: config.Wallet{ + Path: "/wallet1.json", + Password: "one", + }, + }, + RPC: config.RPC{ + BasicService: config.BasicService{ + Enabled: true, + Addresses: []string{":30333"}, + }, + MaxGasInvoke: 15, + EnableCORSWorkaround: false, + SessionEnabled: true, + }, + P2PNotary: config.P2PNotary{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/notary_wallet.json", + Password: "pass", + }, + }, + Prometheus: config.BasicService{ + Enabled: true, + Addresses: []string{":20001"}, + }, + Pprof: config.BasicService{ + Enabled: false, + Addresses: []string{":20011"}, + }, + Consensus: config.Consensus{ + Enabled: true, + UnlockWallet: config.Wallet{ + Path: "/wallet1.json", + Password: "one", + }, + }, + }, +} + +// PrivnetDockerTwo is the configuration for the second node in the Dockerized private network. +var PrivnetDockerTwo = config.Config{ + ProtocolConfiguration: config.ProtocolConfiguration{ + Magic: 56753, + MaxTraceableBlocks: 200000, + TimePerBlock: 15 * time.Second, + MemPoolSize: 50000, + StandbyCommittee: []string{ + "02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2", + "02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e", + "03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699", + "02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62", + }, + ValidatorsCount: 4, + SeedList: []string{ + "node_one:20333", + "node_two:20334", + "node_three:20335", + "node_four:20336", + }, + VerifyTransactions: true, + P2PSigExtensions: false, + }, + + ApplicationConfiguration: config.ApplicationConfiguration{ + Ledger: config.Ledger{SkipBlockVerification: false}, + // LogPath could be set up in case you need stdout logs to some proper file. + // LogPath: "./log/neogo.log" + DBConfiguration: dbconfig.DBConfiguration{ + Type: dbconfig.LevelDB, // other options: 'inmemory','boltdb' + // DB type options. Uncomment those you need in case you want to switch DB type. + LevelDBOptions: dbconfig.LevelDBOptions{ + DataDirectoryPath: "/chains/two", + }, + // BoltDBOptions: + // FilePath: "./chains/privnet.bolt" + }, + P2P: config.P2P{ + Addresses: []string{":20334"}, // in form of "[host]:[port][:announcedPort]" + DialTimeout: 3 * time.Second, + ProtoTickInterval: 2 * time.Second, + PingInterval: 30 * time.Second, + PingTimeout: 90 * time.Second, + MaxPeers: 10, + AttemptConnPeers: 5, + MinPeers: 2, + }, + Relay: true, + Oracle: config.OracleConfiguration{ + Enabled: false, + AllowedContentTypes: []string{ + "application/json", + }, + Nodes: []string{ + "http://node_one:30333", + "http://node_two:30334", + "http://node_three:30335", + "http://node_four:30336", + }, + RequestTimeout: 5 * time.Second, + UnlockWallet: config.Wallet{ + Path: "/wallet2.json", + Password: "two", + }, + }, + RPC: config.RPC{ + BasicService: config.BasicService{ + Enabled: true, + Addresses: []string{":30334"}}, + MaxGasInvoke: 15, + EnableCORSWorkaround: false, + SessionEnabled: true, + }, + P2PNotary: config.P2PNotary{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/notary_wallet.json", + Password: "pass", + }, + }, + Prometheus: config.BasicService{ + Enabled: true, + Addresses: []string{":20002"}, + }, + Pprof: config.BasicService{ + Enabled: false, + Addresses: []string{":20012"}, + }, + Consensus: config.Consensus{ + Enabled: true, + UnlockWallet: config.Wallet{ + Path: "/wallet2.json", + Password: "two", + }, + }, + }, +} + +// PrivnetDockerThree is the configuration for the third node in the Dockerized private network. +var PrivnetDockerThree = config.Config{ + ProtocolConfiguration: config.ProtocolConfiguration{ + Magic: 56753, + MaxTraceableBlocks: 200000, + TimePerBlock: 15 * time.Second, + MemPoolSize: 50000, + StandbyCommittee: []string{ + "02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2", + "02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e", + "03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699", + "02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62", + }, + ValidatorsCount: 4, + VerifyTransactions: true, + P2PSigExtensions: false, + SeedList: []string{ + "node_one:20333", + "node_two:20334", + "node_three:20335", + "node_four:20336", + }, + }, + + ApplicationConfiguration: config.ApplicationConfiguration{ + Ledger: config.Ledger{ + SkipBlockVerification: false}, + // LogPath could be set up in case you need stdout logs to some proper file. + // LogPath: "./log/neogo.log" + DBConfiguration: dbconfig.DBConfiguration{ + Type: dbconfig.LevelDB, // other options: 'inmemory','boltdb' + // DB type options. Uncomment those you need in case you want to switch DB type. + LevelDBOptions: dbconfig.LevelDBOptions{ + DataDirectoryPath: "/chains/three", + }, + // BoltDBOptions: + // FilePath: "./chains/privnet.bolt" + }, + P2P: config.P2P{ + Addresses: []string{":20335"}, // in form of "[host]:[port][:announcedPort]" + DialTimeout: 3 * time.Second, + ProtoTickInterval: 2 * time.Second, + PingInterval: 30 * time.Second, + PingTimeout: 90 * time.Second, + MaxPeers: 10, + AttemptConnPeers: 5, + MinPeers: 2, + }, + Relay: true, + Oracle: config.OracleConfiguration{ + Enabled: false, + AllowedContentTypes: []string{ + "application/json", + }, + Nodes: []string{ + "http://node_one:30333", + "http://node_two:30334", + "http://node_three:30335", + "http://node_four:30336", + }, + RequestTimeout: 5 * time.Second, + UnlockWallet: config.Wallet{ + Path: "/wallet3.json", + Password: "three", + }, + }, + RPC: config.RPC{ + BasicService: config.BasicService{ + Enabled: true, + Addresses: []string{":30335"}}, + MaxGasInvoke: 15, + EnableCORSWorkaround: false, + SessionEnabled: true, + }, + P2PNotary: config.P2PNotary{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/notary_wallet.json", + Password: "pass", + }, + }, + Prometheus: config.BasicService{ + Enabled: true, + Addresses: []string{":20003"}, + }, + Pprof: config.BasicService{ + Enabled: false, + Addresses: []string{":20013"}, + }, + Consensus: config.Consensus{ + Enabled: true, + UnlockWallet: config.Wallet{ + Path: "/wallet3.json", + Password: "three", + }, + }, + }, +} + +// PrivnetDockerFour is the configuration for the fourth node in the Dockerized private network. +var PrivnetDockerFour = config.Config{ + ProtocolConfiguration: config.ProtocolConfiguration{ + Magic: 56753, + MaxTraceableBlocks: 200000, + TimePerBlock: 15 * time.Second, + MemPoolSize: 50000, + StandbyCommittee: []string{ + "02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2", + "02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e", + "03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699", + "02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62", + }, + ValidatorsCount: 4, + SeedList: []string{ + "node_one:20333", + "node_two:20334", + "node_three:20335", + "node_four:20336", + }, + VerifyTransactions: true, + P2PSigExtensions: false, + }, + + ApplicationConfiguration: config.ApplicationConfiguration{ + Ledger: config.Ledger{ + SkipBlockVerification: false}, + // LogPath could be set up in case you need stdout logs to some proper file. + // LogPath: "./log/neogo.log" + DBConfiguration: dbconfig.DBConfiguration{ + Type: dbconfig.LevelDB, // other options: 'inmemory','boltdb' + // DB type options. Uncomment those you need in case you want to switch DB type. + LevelDBOptions: dbconfig.LevelDBOptions{ + DataDirectoryPath: "/chains/four", + }, + // BoltDBOptions: + // FilePath: "./chains/privnet.bolt" + }, + P2P: config.P2P{ + Addresses: []string{":20336"}, // in form of "[host]:[port][:announcedPort]" + DialTimeout: 3 * time.Second, + ProtoTickInterval: 2 * time.Second, + PingInterval: 30 * time.Second, + PingTimeout: 90 * time.Second, + MaxPeers: 10, + AttemptConnPeers: 5, + MinPeers: 2, + }, + Relay: true, + Oracle: config.OracleConfiguration{ + Enabled: false, + AllowedContentTypes: []string{ + "application/json", + }, + Nodes: []string{ + "http://node_one:30333", + "http://node_two:30334", + "http://node_three:30335", + "http://node_four:30336", + }, + RequestTimeout: 5 * time.Second, + UnlockWallet: config.Wallet{ + Path: "/wallet4.json", + Password: "four", + }, + }, + RPC: config.RPC{ + BasicService: config.BasicService{ + Enabled: true, + Addresses: []string{":30336"}}, + MaxGasInvoke: 15, + EnableCORSWorkaround: false, + SessionEnabled: true, + }, + P2PNotary: config.P2PNotary{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/notary_wallet.json", + Password: "pass", + }, + }, + Prometheus: config.BasicService{ + Enabled: true, + Addresses: []string{":20004"}, + }, + Pprof: config.BasicService{ + Enabled: false, + Addresses: []string{":20014"}, + }, + Consensus: config.Consensus{ + Enabled: true, + UnlockWallet: config.Wallet{ + Path: "/wallet4.json", + Password: "four", + }, + }, + }, +} + +// PrivnetDockerSingle is the configuration for the single node in the Dockerized private network. +var PrivnetDockerSingle = config.Config{ + ProtocolConfiguration: config.ProtocolConfiguration{ + Magic: 56753, + MaxTraceableBlocks: 200000, + TimePerBlock: 1 * time.Second, // TimePerBlock adjusted to 1 second + MemPoolSize: 50000, + StandbyCommittee: []string{ + "02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2", + }, + ValidatorsCount: 1, + SeedList: []string{ + "node_single:20333", + }, + VerifyTransactions: true, + P2PSigExtensions: false, + }, + + ApplicationConfiguration: config.ApplicationConfiguration{ + Ledger: config.Ledger{ + SkipBlockVerification: false}, + // LogPath could be set up in case you need stdout logs to some proper file. + // LogPath: "./log/neogo.log" + DBConfiguration: dbconfig.DBConfiguration{ + Type: dbconfig.LevelDB, // other options: 'inmemory','boltdb' + // DB type options. Uncomment those you need in case you want to switch DB type. + LevelDBOptions: dbconfig.LevelDBOptions{ + DataDirectoryPath: "/chains/single", + }, + // BoltDBOptions: + // FilePath: "./chains/privnet.bolt" + }, + P2P: config.P2P{ + Addresses: []string{":20333"}, // Standard port configuration for single-node + DialTimeout: 3 * time.Second, + ProtoTickInterval: 2 * time.Second, + PingInterval: 30 * time.Second, + PingTimeout: 90 * time.Second, + MaxPeers: 10, + AttemptConnPeers: 5, + MinPeers: 0, + }, + Relay: true, + Oracle: config.OracleConfiguration{ + Enabled: false, + AllowedContentTypes: []string{ + "application/json", + }, + Nodes: []string{ + "http://node_single:30333", + }, + RequestTimeout: 5 * time.Second, + UnlockWallet: config.Wallet{ + Path: "/wallet1_solo.json", + Password: "one", + }, + }, + RPC: config.RPC{ + BasicService: config.BasicService{ + Enabled: true, + Addresses: []string{":30333"}}, + MaxGasInvoke: 15, + EnableCORSWorkaround: false, + SessionEnabled: true, + }, + P2PNotary: config.P2PNotary{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/notary_wallet.json", + Password: "pass", + }, + }, + Prometheus: config.BasicService{ + Enabled: true, + Addresses: []string{":20001"}, + }, + Pprof: config.BasicService{ + Enabled: false, + Addresses: []string{":20011"}, + }, + Consensus: config.Consensus{ + Enabled: true, + UnlockWallet: config.Wallet{ + Path: "/wallet1.json", + Password: "one", + }, + }, + }, +} diff --git a/cli/config/testnet.go b/cli/config/testnet.go new file mode 100644 index 000000000..0fad6dd5f --- /dev/null +++ b/cli/config/testnet.go @@ -0,0 +1,121 @@ +package config + +import ( + "time" + + "github.com/nspcc-dev/neo-go/pkg/config" + "github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig" +) + +// Testnet is the configuration for the Neo N3 testnet. +var Testnet = config.Config{ + ProtocolConfiguration: config.ProtocolConfiguration{ + Magic: 894710606, + MaxBlockSize: 2097152, + MaxBlockSystemFee: 150000000000, + MaxTraceableBlocks: 2102400, + MaxTransactionsPerBlock: 5000, + InitialGASSupply: 52000000, + TimePerBlock: 15 * time.Second, + MemPoolSize: 50000, + StandbyCommittee: []string{ + "03408dcd416396f64783ac587ea1e1593c57d9fea880c8a6a1920e92a259477806", + "02a7834be9b32e2981d157cb5bbd3acb42cfd11ea5c3b10224d7a44e98c5910f1b", + "0214baf0ceea3a66f17e7e1e839ea25fd8bed6cd82e6bb6e68250189065f44ff01", + "030205e9cefaea5a1dfc580af20c8d5aa2468bb0148f1a5e4605fc622c80e604ba", + "025831cee3708e87d78211bec0d1bfee9f4c85ae784762f042e7f31c0d40c329b8", + "02cf9dc6e85d581480d91e88e8cbeaa0c153a046e89ded08b4cefd851e1d7325b5", + "03840415b0a0fcf066bcc3dc92d8349ebd33a6ab1402ef649bae00e5d9f5840828", + "026328aae34f149853430f526ecaa9cf9c8d78a4ea82d08bdf63dd03c4d0693be6", + "02c69a8d084ee7319cfecf5161ff257aa2d1f53e79bf6c6f164cff5d94675c38b3", + "0207da870cedb777fceff948641021714ec815110ca111ccc7a54c168e065bda70", + "035056669864feea401d8c31e447fb82dd29f342a9476cfd449584ce2a6165e4d7", + "0370c75c54445565df62cfe2e76fbec4ba00d1298867972213530cae6d418da636", + "03957af9e77282ae3263544b7b2458903624adc3f5dee303957cb6570524a5f254", + "03d84d22b8753cf225d263a3a782a4e16ca72ef323cfde04977c74f14873ab1e4c", + "02147c1b1d5728e1954958daff2f88ee2fa50a06890a8a9db3fa9e972b66ae559f", + "03c609bea5a4825908027e4ab217e7efc06e311f19ecad9d417089f14927a173d5", + "0231edee3978d46c335e851c76059166eb8878516f459e085c0dd092f0f1d51c21", + "03184b018d6b2bc093e535519732b3fd3f7551c8cffaf4621dd5a0b89482ca66c9", + }, + ValidatorsCount: 7, + VerifyTransactions: false, + P2PSigExtensions: false, + Hardforks: map[string]uint32{ + "Aspidochelone": 210000, + "Basilisk": 2680000, + "Cockatrice": 3967000, + }, + SeedList: []string{ + "seed1t5.neo.org:20333", + "seed2t5.neo.org:20333", + "seed3t5.neo.org:20333", + "seed4t5.neo.org:20333", + "seed5t5.neo.org:20333", + }, + }, + + ApplicationConfiguration: config.ApplicationConfiguration{ + DBConfiguration: dbconfig.DBConfiguration{ + Type: dbconfig.LevelDB, + LevelDBOptions: dbconfig.LevelDBOptions{ + DataDirectoryPath: "./chains/testnet", + }, + }, + P2P: config.P2P{ + Addresses: []string{":20333"}, + DialTimeout: 3 * time.Second, + ProtoTickInterval: 2 * time.Second, + PingInterval: 30 * time.Second, + PingTimeout: 90 * time.Second, + MaxPeers: 100, + MinPeers: 10, + AttemptConnPeers: 20, + }, + Relay: true, + Consensus: config.Consensus{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/cn_wallet.json", + Password: "pass", + }, + }, + Oracle: config.OracleConfiguration{ + Enabled: false, + AllowedContentTypes: []string{ + "application/json", + }, + }, + P2PNotary: config.P2PNotary{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/notary_wallet.json", + Password: "pass", + }, + }, + RPC: config.RPC{ + BasicService: config.BasicService{ + Enabled: true, + Addresses: []string{":20332"}, + }, + MaxGasInvoke: 15, + EnableCORSWorkaround: false, + TLSConfig: config.TLS{ + BasicService: config.BasicService{ + Enabled: false, + Addresses: []string{":20331"}, + }, + CertFile: "serv.crt", + KeyFile: "serv.key", + }, + }, + Prometheus: config.BasicService{ + Enabled: true, + Addresses: []string{":2112"}, + }, + Pprof: config.BasicService{ + Enabled: false, + Addresses: []string{":2113"}, + }, + }, +} diff --git a/cli/config/testnet_neofs.go b/cli/config/testnet_neofs.go new file mode 100644 index 000000000..02a3f5f16 --- /dev/null +++ b/cli/config/testnet_neofs.go @@ -0,0 +1,105 @@ +package config + +import ( + "time" + + "github.com/nspcc-dev/neo-go/pkg/config" + "github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig" +) + +// TestnetNeoFS is the configuration for the NeoFS testnet. +var TestnetNeoFS = config.Config{ + ProtocolConfiguration: config.ProtocolConfiguration{ + Magic: 735783775, + MaxTraceableBlocks: 2102400, + InitialGASSupply: 52000000, + TimePerBlock: 15 * time.Second, + MemPoolSize: 50000, + StandbyCommittee: []string{ + "0337f5f45e5be5aeae4a919d0787fcb743656560949061d5b8b05509b85ffbfd53", + "020b86534a9a264d28b79155b0ec36d555ed0068eb1b0c4d40c35cc7d2f04759b8", + "02c2efdc01181b0bc14fc19e0acb12281396c8c9ffe64458d621d781a1ded436b7", + "026f9b40a73f29787ef5b289ac845bc43c64680fdd42fc170b1171d3c57213a89f", + "0272350def90715494b857315c9b9c70181739eeec52d777424fef2891c3396cad", + "03a8cee2d3877bcce5b4595578714d77ca2d47673150b8b9cd4e391b7c73b6bda3", + "0215e735a657f6e23478728d1d0718d516bf50c06c2abd92ec7c00eba2bd7a2552", + }, + ValidatorsCount: 7, + VerifyTransactions: true, + P2PSigExtensions: true, + SeedList: []string{ + "morph1.t5.fs.neo.org:50333", + "morph2.t5.fs.neo.org:50333", + "morph3.t5.fs.neo.org:50333", + "morph4.t5.fs.neo.org:50333", + "morph5.t5.fs.neo.org:50333", + "morph6.t5.fs.neo.org:50333", + "morph7.t5.fs.neo.org:50333", + }, + }, + + ApplicationConfiguration: config.ApplicationConfiguration{ + DBConfiguration: dbconfig.DBConfiguration{ + Type: dbconfig.LevelDB, + LevelDBOptions: dbconfig.LevelDBOptions{ + DataDirectoryPath: "./chains/testnet.neofs", + }, + }, + P2P: config.P2P{ + Addresses: []string{":50333"}, + DialTimeout: 3 * time.Second, + ProtoTickInterval: 2 * time.Second, + PingInterval: 30 * time.Second, + PingTimeout: 90 * time.Second, + MaxPeers: 100, + MinPeers: 5, + AttemptConnPeers: 20, + }, + Relay: true, + Consensus: config.Consensus{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/cn_wallet.json", + Password: "pass", + }, + }, + Oracle: config.OracleConfiguration{ + Enabled: false, + AllowedContentTypes: []string{ + "application/json", + }, + }, + RPC: config.RPC{ + BasicService: config.BasicService{ + Enabled: true, + Addresses: []string{":50332"}, + }, + MaxGasInvoke: 100, + EnableCORSWorkaround: false, + StartWhenSynchronized: false, + TLSConfig: config.TLS{ + BasicService: config.BasicService{ + Enabled: false, + Addresses: []string{":50331"}, + }, + CertFile: "server.crt", + KeyFile: "server.key", + }, + }, + P2PNotary: config.P2PNotary{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/notary_wallet.json", + Password: "pass", + }, + }, + Prometheus: config.BasicService{ + Enabled: false, + Addresses: []string{":2112"}, + }, + Pprof: config.BasicService{ + Enabled: false, + Addresses: []string{":2113"}, + }, + }, +} diff --git a/cli/config/unit_testnet.go b/cli/config/unit_testnet.go new file mode 100644 index 000000000..ef3fdc492 --- /dev/null +++ b/cli/config/unit_testnet.go @@ -0,0 +1,145 @@ +package config + +import ( + "time" + + "github.com/nspcc-dev/neo-go/pkg/config" + "github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig" +) + +// UnitTestnet is the configuration for the unit test network with four validators. +var UnitTestnet = config.Config{ + ProtocolConfiguration: config.ProtocolConfiguration{ + Magic: 42, + MaxTraceableBlocks: 200000, + TimePerBlock: 15 * time.Second, + MemPoolSize: 50000, + StandbyCommittee: []string{ + "02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2", + "02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e", + "03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699", + "02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62", + "02c429b3ea1aa486cb2edfd6e99d8055c1f81f1a9206664e2c40a586d187257557", + "02c4de32252c50fa171dbe25379e4e2d55cdc12f69e382c39f59a44573ecff2f9d", + }, + ValidatorsCount: 4, + VerifyTransactions: true, + P2PSigExtensions: true, + Hardforks: map[string]uint32{ + "Aspidochelone": 25, + }, + SeedList: []string{ + "127.0.0.1:20334", + "127.0.0.1:20335", + "127.0.0.1:20336", + }, + }, + + ApplicationConfiguration: config.ApplicationConfiguration{ + Ledger: config.Ledger{ + SkipBlockVerification: false}, + // LogPath could be set up in case you need stdout logs to some proper file. + // LogPath: "./log/neogo.log" + DBConfiguration: dbconfig.DBConfiguration{ + Type: dbconfig.InMemoryDB, // Utilizing in-memory database for unit testing + }, + P2P: config.P2P{ + Addresses: []string{":20333"}, // Standard port configuration for this unit test environment + DialTimeout: 3 * time.Second, + ProtoTickInterval: 2 * time.Second, + PingInterval: 30 * time.Second, + PingTimeout: 90 * time.Second, + MaxPeers: 50, + AttemptConnPeers: 5, + MinPeers: 0, + }, + Relay: true, + RPC: config.RPC{ + BasicService: config.BasicService{ + Enabled: true, + Addresses: []string{"127.0.0.1:0"}}, + MaxGasInvoke: 15, + EnableCORSWorkaround: false, + SessionEnabled: true, + SessionExpirationTime: 2, + MaxFindStorageResultItems: 2, + }, + Prometheus: config.BasicService{ + Enabled: false, // Disabled for unit tests + Addresses: []string{":2112"}, + }, + Pprof: config.BasicService{ + Enabled: false, // Disabled for unit tests + Addresses: []string{":2113"}, + }, + Consensus: config.Consensus{ + Enabled: true, + UnlockWallet: config.Wallet{ + Path: "/wallet1.json", + Password: "one", + }, + }, + }, +} + +// UnitTestnetSingle is the configuration for the unit test network with one validator. +var UnitTestnetSingle = config.Config{ + ProtocolConfiguration: config.ProtocolConfiguration{ + Magic: 42, + MaxTraceableBlocks: 200000, + TimePerBlock: 100 * time.Millisecond, + MemPoolSize: 100, + StandbyCommittee: []string{ + "02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2", + }, + ValidatorsCount: 1, + VerifyTransactions: true, + P2PSigExtensions: true, + Hardforks: map[string]uint32{ + "Aspidochelone": 25, + }, + }, + + ApplicationConfiguration: config.ApplicationConfiguration{ + Ledger: config.Ledger{ + SkipBlockVerification: false}, + // LogPath could be set up in case you need stdout logs to some proper file. + // LogPath: "./log/neogo.log" + DBConfiguration: dbconfig.DBConfiguration{ + Type: dbconfig.InMemoryDB, + }, + P2P: config.P2P{ + Addresses: []string{":0"}, + DialTimeout: 3 * time.Second, + ProtoTickInterval: 2 * time.Second, + PingInterval: 30 * time.Second, + PingTimeout: 90 * time.Second, + MinPeers: 0, + MaxPeers: 10, + AttemptConnPeers: 5, + }, + Relay: true, + Consensus: config.Consensus{ + Enabled: true, + UnlockWallet: config.Wallet{ + Path: "../testdata/wallet1_solo.json", + Password: "one", + }, + }, + RPC: config.RPC{ + BasicService: config.BasicService{ + Enabled: true, + Addresses: []string{"127.0.0.1:0"}}, + MaxGasInvoke: 15, + EnableCORSWorkaround: false, + }, + Prometheus: config.BasicService{ + Enabled: false, // Disabled for unit tests + Addresses: []string{":2112"}, + }, + Pprof: config.BasicService{ + Enabled: false, // Disabled for unit tests + Addresses: []string{":2113"}, + }, + }, +} diff --git a/cli/config/vm.go b/cli/config/vm.go new file mode 100644 index 000000000..b31052344 --- /dev/null +++ b/cli/config/vm.go @@ -0,0 +1,101 @@ +package config + +import ( + "time" + + "github.com/nspcc-dev/neo-go/pkg/config" + "github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig" +) + +// VM is a default configuration for the chain-backed VM CLI. +var VM = config.Config{ + ProtocolConfiguration: config.ProtocolConfiguration{ + Magic: 56753, + MaxTraceableBlocks: 200000, + TimePerBlock: 15 * time.Second, + MemPoolSize: 50000, + StandbyCommittee: []string{ + "02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2", + "02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e", + "03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699", + "02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62", + }, + ValidatorsCount: 4, + VerifyTransactions: true, + P2PSigExtensions: false, + SeedList: []string{ + "localhost:20333", + "localhost:20334", + "localhost:20335", + "localhost:20336", + }, + }, + + ApplicationConfiguration: config.ApplicationConfiguration{ + Ledger: config.Ledger{ + SkipBlockVerification: false}, + // LogPath could be set up in case you need stdout logs to some proper file. + // LogPath: "./log/neogo.log" + DBConfiguration: dbconfig.DBConfiguration{ + Type: dbconfig.InMemoryDB, + // Other options: 'leveldb','boltdb' + // DB type options. Uncomment those you need in case you want to switch DB type. + LevelDBOptions: dbconfig.LevelDBOptions{ + DataDirectoryPath: "./chains/privnet", + // BoltDBOptions: + // FilePath: "./chains/privnet.bolt" + }, + }, + P2P: config.P2P{ + Addresses: []string{":20332"}, // In form of "[host]:[port][:announcedPort]" + DialTimeout: 3 * time.Second, + ProtoTickInterval: 2 * time.Second, + PingInterval: 30 * time.Second, + PingTimeout: 90 * time.Second, + MaxPeers: 10, + AttemptConnPeers: 5, + MinPeers: 3, + }, + Relay: true, + Consensus: config.Consensus{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/cn_wallet.json", + Password: "pass", + }, + }, + P2PNotary: config.P2PNotary{ + Enabled: false, + UnlockWallet: config.Wallet{ + Path: "/notary_wallet.json", + Password: "pass", + }, + }, + RPC: config.RPC{ + BasicService: config.BasicService{ + Enabled: true, + Addresses: []string{":20331"}, + }, + MaxGasInvoke: 15, + EnableCORSWorkaround: false, + SessionEnabled: true, + SessionExpirationTime: 180, // Higher expiration time for manual requests and tests. + TLSConfig: config.TLS{ + BasicService: config.BasicService{ + Enabled: false, + Addresses: []string{":20330"}, + }, + CertFile: "serv.crt", + KeyFile: "serv.key", + }, + }, + Prometheus: config.BasicService{ + Enabled: true, + Addresses: []string{":2112"}, + }, + Pprof: config.BasicService{ + Enabled: false, + Addresses: []string{":2113"}, + }, + }, +} From 950f35de34afc3ddca7d3837e288a27506d26026 Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Thu, 6 Jun 2024 13:49:00 +0300 Subject: [PATCH 3/3] cli vm: add default config if nothing passed Supply VM console with default config. Close #3450 Signed-off-by: Ekaterina Pavlova --- cli/vm/vm.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cli/vm/vm.go b/cli/vm/vm.go index e9e1e2a58..2ab01c2b3 100644 --- a/cli/vm/vm.go +++ b/cli/vm/vm.go @@ -6,6 +6,7 @@ import ( "github.com/chzyer/readline" "github.com/nspcc-dev/neo-go/cli/cmdargs" + "github.com/nspcc-dev/neo-go/cli/config" "github.com/nspcc-dev/neo-go/cli/options" "github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig" "github.com/urfave/cli" @@ -27,10 +28,13 @@ func startVMPrompt(ctx *cli.Context) error { if err := cmdargs.EnsureNone(ctx); err != nil { return err } - - cfg, err := options.GetConfigFromContext(ctx) - if err != nil { - return cli.NewExitError(err, 1) + var err error + cfg := config.VM + if ctx.String("config-file") != "" || ctx.String("config-path") != "" { + cfg, err = options.GetConfigFromContext(ctx) + if err != nil { + return cli.NewExitError(err, 1) + } } if ctx.NumFlags() == 0 { cfg.ApplicationConfiguration.DBConfiguration.Type = dbconfig.InMemoryDB