Compare commits

...

3 commits

Author SHA1 Message Date
Ekaterina Pavlova
950f35de34 cli vm: add default config if nothing passed
Supply VM console with default config.

Close #3450

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-06-07 11:00:16 +03:00
Ekaterina Pavlova
c3705664c2 cli: add config generate command
Add cli command to generate YAML configuration files.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-06-07 11:00:16 +03:00
Ekaterina Pavlova
e95d87779b cli: refactor usage field
Unified style is with lowercase letter.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-06-07 11:00:14 +03:00
24 changed files with 1555 additions and 95 deletions

View file

@ -150,6 +150,38 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
verbose: true 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: tests:
name: Run tests name: Run tests
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}

View file

@ -75,15 +75,28 @@ The resulting binary is `bin/neo-go.exe`.
## Running a node ## Running a node
A node needs to connect to some network, either local one (usually referred to Before running a Neo node, you need to generate the necessary configuration files
as `privnet`) or public (like `mainnet` or `testnet`). Network configuration for the network you wish to connect to, such as a local network (`privnet`), or
is stored in a file and NeoGo allows you to store multiple files in one a public network like `mainnet` or `testnet`. NeoGo stores network configuration
directory (`./config` by default) and easily switch between them using network files in a directory (`./config` by default) and allows you to easily switch
flags. 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 ./bin/neo-go node
``` ```

View file

@ -5,6 +5,7 @@ import (
"os" "os"
"runtime" "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/query"
"github.com/nspcc-dev/neo-go/cli/server" "github.com/nspcc-dev/neo-go/cli/server"
"github.com/nspcc-dev/neo-go/cli/smartcontract" "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, vm.NewCommands()...)
ctl.Commands = append(ctl.Commands, util.NewCommands()...) ctl.Commands = append(ctl.Commands, util.NewCommands()...)
ctl.Commands = append(ctl.Commands, query.NewCommands()...) ctl.Commands = append(ctl.Commands, query.NewCommands()...)
ctl.Commands = append(ctl.Commands, nodeconfig.NewCommands()...)
return ctl return ctl
} }

121
cli/config/config.go Normal file
View file

@ -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
}

127
cli/config/mainnet.go Normal file
View file

@ -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"},
},
},
}

View file

@ -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"},
},
},
}

101
cli/config/privnet.go Normal file
View file

@ -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"},
},
},
}

View file

@ -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",
},
},
},
}

121
cli/config/testnet.go Normal file
View file

@ -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"},
},
},
}

105
cli/config/testnet_neofs.go Normal file
View file

@ -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"},
},
},
}

145
cli/config/unit_testnet.go Normal file
View file

@ -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"},
},
},
}

101
cli/config/vm.go Normal file
View file

@ -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"},
},
},
}

View file

@ -30,44 +30,44 @@ func NewCommands() []cli.Command {
queryTxFlags := append([]cli.Flag{ queryTxFlags := append([]cli.Flag{
cli.BoolFlag{ cli.BoolFlag{
Name: "verbose, v", Name: "verbose, v",
Usage: "Output full tx info and execution logs", Usage: "output full tx info and execution logs",
}, },
}, options.RPC...) }, options.RPC...)
return []cli.Command{{ return []cli.Command{{
Name: "query", Name: "query",
Usage: "Query data from RPC node", Usage: "query data from RPC node",
Subcommands: []cli.Command{ Subcommands: []cli.Command{
{ {
Name: "candidates", Name: "candidates",
Usage: "Get candidates and votes", Usage: "get candidates and votes",
UsageText: "neo-go query candidates -r endpoint [-s timeout]", UsageText: "neo-go query candidates -r endpoint [-s timeout]",
Action: queryCandidates, Action: queryCandidates,
Flags: options.RPC, Flags: options.RPC,
}, },
{ {
Name: "committee", Name: "committee",
Usage: "Get committee list", Usage: "get committee list",
UsageText: "neo-go query committee -r endpoint [-s timeout]", UsageText: "neo-go query committee -r endpoint [-s timeout]",
Action: queryCommittee, Action: queryCommittee,
Flags: options.RPC, Flags: options.RPC,
}, },
{ {
Name: "height", Name: "height",
Usage: "Get node height", Usage: "get node height",
UsageText: "neo-go query height -r endpoint [-s timeout]", UsageText: "neo-go query height -r endpoint [-s timeout]",
Action: queryHeight, Action: queryHeight,
Flags: options.RPC, Flags: options.RPC,
}, },
{ {
Name: "tx", Name: "tx",
Usage: "Query transaction status", Usage: "query transaction status",
UsageText: "neo-go query tx <hash> -r endpoint [-s timeout] [-v]", UsageText: "neo-go query tx <hash> -r endpoint [-s timeout] [-v]",
Action: queryTx, Action: queryTx,
Flags: queryTxFlags, Flags: queryTxFlags,
}, },
{ {
Name: "voter", Name: "voter",
Usage: "Print NEO holder account state", Usage: "print NEO holder account state",
UsageText: "neo-go query voter <address> -r endpoint [-s timeout]", UsageText: "neo-go query voter <address> -r endpoint [-s timeout]",
Action: queryVoter, Action: queryVoter,
Flags: options.RPC, Flags: options.RPC,

View file

@ -55,7 +55,7 @@ func NewCommands() []cli.Command {
}, },
cli.StringFlag{ cli.StringFlag{
Name: "out, o", Name: "out, o",
Usage: "Output file (stdout if not given)", Usage: "output file (stdout if not given)",
}, },
) )
var cfgCountInFlags = make([]cli.Flag, len(cfgWithCountFlags)) var cfgCountInFlags = make([]cli.Flag, len(cfgWithCountFlags))
@ -63,7 +63,7 @@ func NewCommands() []cli.Command {
cfgCountInFlags = append(cfgCountInFlags, cfgCountInFlags = append(cfgCountInFlags,
cli.StringFlag{ cli.StringFlag{
Name: "in, i", Name: "in, i",
Usage: "Input file (stdin if not given)", Usage: "input file (stdin if not given)",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "dump", Name: "dump",
@ -78,7 +78,7 @@ func NewCommands() []cli.Command {
copy(cfgHeightFlags, cfgFlags) copy(cfgHeightFlags, cfgFlags)
cfgHeightFlags[len(cfgHeightFlags)-1] = cli.UintFlag{ cfgHeightFlags[len(cfgHeightFlags)-1] = cli.UintFlag{
Name: "height", Name: "height",
Usage: "Height of the state to reset DB to", Usage: "height of the state to reset DB to",
Required: true, Required: true,
} }
return []cli.Command{ return []cli.Command{

View file

@ -16,21 +16,21 @@ import (
var generatorFlags = []cli.Flag{ var generatorFlags = []cli.Flag{
cli.StringFlag{ cli.StringFlag{
Name: "config, c", Name: "config, c",
Usage: "Configuration file to use", Usage: "configuration file to use",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "manifest, m", Name: "manifest, m",
Required: true, Required: true,
Usage: "Read contract manifest (*.manifest.json) file", Usage: "read contract manifest (*.manifest.json) file",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "out, o", Name: "out, o",
Required: true, Required: true,
Usage: "Output of the compiled wrapper", Usage: "output of the compiled wrapper",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "hash", 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",
}, },
} }

View file

@ -78,7 +78,7 @@ func NewCommands() []cli.Command {
testInvokeScriptFlags := []cli.Flag{ testInvokeScriptFlags := []cli.Flag{
cli.StringFlag{ cli.StringFlag{
Name: "in, i", 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, options.Historic,
} }
@ -98,11 +98,11 @@ func NewCommands() []cli.Command {
deployFlags := append(invokeFunctionFlags, []cli.Flag{ deployFlags := append(invokeFunctionFlags, []cli.Flag{
cli.StringFlag{ cli.StringFlag{
Name: "in, i", Name: "in, i",
Usage: "Input file for the smart contract (*.nef)", Usage: "input file for the smart contract (*.nef)",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "manifest, m", Name: "manifest, m",
Usage: "Manifest input file (*.manifest.json)", Usage: "manifest input file (*.manifest.json)",
}, },
}...) }...)
manifestAddGroupFlags := append([]cli.Flag{ manifestAddGroupFlags := append([]cli.Flag{
@ -143,27 +143,27 @@ func NewCommands() []cli.Command {
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.StringFlag{ cli.StringFlag{
Name: "in, i", 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{ cli.StringFlag{
Name: "out, o", Name: "out, o",
Usage: "Output of the compiled contract", Usage: "output of the compiled contract",
}, },
cli.BoolFlag{ cli.BoolFlag{
Name: "verbose, v", Name: "verbose, v",
Usage: "Print out additional information after a compiling", Usage: "print out additional information after a compiling",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "debug, d", Name: "debug, d",
Usage: "Emit debug info in a separate file", Usage: "emit debug info in a separate file",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "manifest, m", 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{ cli.StringFlag{
Name: "config, c", Name: "config, c",
Usage: "Configuration input file (*.yml)", Usage: "configuration input file (*.yml)",
}, },
cli.BoolFlag{ cli.BoolFlag{
Name: "no-standards", Name: "no-standards",
@ -239,7 +239,7 @@ func NewCommands() []cli.Command {
}, },
{ {
Name: "testinvokescript", 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...]", 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 Description: `Executes given compiled AVM instructions in NEF format with the given set of
signers not included sender by default. See testinvokefunction documentation signers not included sender by default. See testinvokefunction documentation

View file

@ -38,7 +38,7 @@ var (
// ForceFlag is a flag used to force transaction send. // ForceFlag is a flag used to force transaction send.
ForceFlag = cli.BoolFlag{ ForceFlag = cli.BoolFlag{
Name: "force", 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 is a flag used to wait for the transaction to be included in a block.
AwaitFlag = cli.BoolFlag{ AwaitFlag = cli.BoolFlag{

View file

@ -30,11 +30,11 @@ func NewCommands() []cli.Command {
return []cli.Command{ return []cli.Command{
{ {
Name: "util", Name: "util",
Usage: "Various helper commands", Usage: "various helper commands",
Subcommands: []cli.Command{ Subcommands: []cli.Command{
{ {
Name: "convert", Name: "convert",
Usage: "Convert provided argument into other possible formats", Usage: "convert provided argument into other possible formats",
UsageText: `convert <arg> UsageText: `convert <arg>
<arg> is an argument which is tried to be interpreted as an item of different types <arg> 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", Name: "sendtx",
Usage: "Send complete transaction stored in a context file", Usage: "send complete transaction stored in a context file",
UsageText: "sendtx [-r <endpoint>] <file.in> [--await]", UsageText: "sendtx [-r <endpoint>] <file.in> [--await]",
Description: `Sends the transaction from the given context file to the given RPC node if it's 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 completely signed and ready. This command expects a ContractParametersContext
@ -56,7 +56,7 @@ func NewCommands() []cli.Command {
}, },
{ {
Name: "canceltx", Name: "canceltx",
Usage: "Cancel transaction by sending conflicting transaction", Usage: "cancel transaction by sending conflicting transaction",
UsageText: "canceltx <txid> -r <endpoint> --wallet <wallet> [--account <account>] [--wallet-config <path>] [--gas <gas>] [--await]", UsageText: "canceltx <txid> -r <endpoint> --wallet <wallet> [--account <account>] [--wallet-config <path>] [--gas <gas>] [--await]",
Description: `Aims to prevent a transaction from being added to the blockchain by dispatching a more 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 prioritized conflicting transaction to the specified RPC node. The input for this command should
@ -76,7 +76,7 @@ func NewCommands() []cli.Command {
}, },
{ {
Name: "txdump", Name: "txdump",
Usage: "Dump transaction stored in file", Usage: "dump transaction stored in file",
UsageText: "txdump [-r <endpoint>] <file.in>", UsageText: "txdump [-r <endpoint>] <file.in>",
Action: txDump, Action: txDump,
Flags: txDumpFlags, Flags: txDumpFlags,
@ -89,7 +89,7 @@ func NewCommands() []cli.Command {
}, },
{ {
Name: "ops", 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 <base64/hex-encoded script> [-i path-to-file] [--hex]", UsageText: "ops <base64/hex-encoded script> [-i path-to-file] [--hex]",
Action: handleOps, Action: handleOps,
Flags: []cli.Flag{ Flags: []cli.Flag{

View file

@ -72,7 +72,7 @@ const (
var ( var (
historicFlag = cli.IntFlag{ historicFlag = cli.IntFlag{
Name: historicFlagFullName, 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.", "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{ gasFlag = cli.Int64Flag{
@ -81,28 +81,28 @@ var (
} }
hashFlag = cli.StringFlag{ hashFlag = cli.StringFlag{
Name: hashFlagFullName, Name: hashFlagFullName,
Usage: "Smart-contract hash in LE form or address", Usage: "smart-contract hash in LE form or address",
} }
) )
var commands = []cli.Command{ var commands = []cli.Command{
{ {
Name: "exit", Name: "exit",
Usage: "Exit the VM prompt", Usage: "exit the VM prompt",
UsageText: "exit", UsageText: "exit",
Description: "Exit the VM prompt.", Description: "Exit the VM prompt.",
Action: handleExit, Action: handleExit,
}, },
{ {
Name: "ip", Name: "ip",
Usage: "Show current instruction", Usage: "show current instruction",
UsageText: "ip", UsageText: "ip",
Description: "Show current instruction.", Description: "Show current instruction.",
Action: handleIP, Action: handleIP,
}, },
{ {
Name: "break", Name: "break",
Usage: "Place a breakpoint", Usage: "place a breakpoint",
UsageText: `break <ip>`, UsageText: `break <ip>`,
Description: `<ip> is mandatory parameter. Description: `<ip> is mandatory parameter.
@ -112,7 +112,7 @@ Example:
}, },
{ {
Name: "jump", Name: "jump",
Usage: "Jump to the specified instruction (absolute IP value)", Usage: "jump to the specified instruction (absolute IP value)",
UsageText: `jump <ip>`, UsageText: `jump <ip>`,
Description: `<ip> is mandatory parameter (absolute IP value). Description: `<ip> is mandatory parameter (absolute IP value).
@ -122,42 +122,42 @@ Example:
}, },
{ {
Name: "estack", Name: "estack",
Usage: "Show evaluation stack contents", Usage: "show evaluation stack contents",
UsageText: "estack", UsageText: "estack",
Description: "Show evaluation stack contents.", Description: "Show evaluation stack contents.",
Action: handleXStack, Action: handleXStack,
}, },
{ {
Name: "istack", Name: "istack",
Usage: "Show invocation stack contents", Usage: "show invocation stack contents",
UsageText: "istack", UsageText: "istack",
Description: "Show invocation stack contents.", Description: "Show invocation stack contents.",
Action: handleXStack, Action: handleXStack,
}, },
{ {
Name: "sslot", Name: "sslot",
Usage: "Show static slot contents", Usage: "show static slot contents",
UsageText: "sslot", UsageText: "sslot",
Description: "Show static slot contents.", Description: "Show static slot contents.",
Action: handleSlots, Action: handleSlots,
}, },
{ {
Name: "lslot", Name: "lslot",
Usage: "Show local slot contents", Usage: "show local slot contents",
UsageText: "lslot", UsageText: "lslot",
Description: "Show local slot contents", Description: "Show local slot contents",
Action: handleSlots, Action: handleSlots,
}, },
{ {
Name: "aslot", Name: "aslot",
Usage: "Show arguments slot contents", Usage: "show arguments slot contents",
UsageText: "aslot", UsageText: "aslot",
Description: "Show arguments slot contents.", Description: "Show arguments slot contents.",
Action: handleSlots, Action: handleSlots,
}, },
{ {
Name: "loadnef", 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 <height>] [--gas <int>] [--hash <hash-or-address>] <file> [<manifest>] [-- <signer-with-scope>, ...]`, UsageText: `loadnef [--historic <height>] [--gas <int>] [--hash <hash-or-address>] <file> [<manifest>] [-- <signer-with-scope>, ...]`,
Flags: []cli.Flag{historicFlag, gasFlag, hashFlag}, Flags: []cli.Flag{historicFlag, gasFlag, hashFlag},
Description: `<file> parameter is mandatory, <manifest> parameter (if omitted) will Description: `<file> parameter is mandatory, <manifest> parameter (if omitted) will
@ -172,7 +172,7 @@ Example:
}, },
{ {
Name: "loadbase64", 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 <height>] [--gas <int>] <string> [-- <signer-with-scope>, ...]`, UsageText: `loadbase64 [--historic <height>] [--gas <int>] <string> [-- <signer-with-scope>, ...]`,
Flags: []cli.Flag{historicFlag, gasFlag}, Flags: []cli.Flag{historicFlag, gasFlag},
Description: `<string> is mandatory parameter. Description: `<string> is mandatory parameter.
@ -185,7 +185,7 @@ Example:
}, },
{ {
Name: "loadhex", 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 <height>] [--gas <int>] <string> [-- <signer-with-scope>, ...]`, UsageText: `loadhex [--historic <height>] [--gas <int>] <string> [-- <signer-with-scope>, ...]`,
Flags: []cli.Flag{historicFlag, gasFlag}, Flags: []cli.Flag{historicFlag, gasFlag},
Description: `<string> is mandatory parameter. Description: `<string> is mandatory parameter.
@ -198,7 +198,7 @@ Example:
}, },
{ {
Name: "loadgo", 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 <height>] [--gas <int>] [--hash <hash-or-address>] <file> [-- <signer-with-scope>, ...]`, UsageText: `loadgo [--historic <height>] [--gas <int>] [--hash <hash-or-address>] <file> [-- <signer-with-scope>, ...]`,
Flags: []cli.Flag{historicFlag, gasFlag, hashFlag}, Flags: []cli.Flag{historicFlag, gasFlag, hashFlag},
Description: `<file> is mandatory parameter. Description: `<file> is mandatory parameter.
@ -211,7 +211,7 @@ Example:
}, },
{ {
Name: "loadtx", 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 <height>] [--gas <int>] <file-or-hash>`, UsageText: `loadtx [--historic <height>] [--gas <int>] <file-or-hash>`,
Flags: []cli.Flag{historicFlag, gasFlag}, Flags: []cli.Flag{historicFlag, gasFlag},
Description: `Load transaction into the VM from chain or from parameter context file. Description: `Load transaction into the VM from chain or from parameter context file.
@ -228,7 +228,7 @@ Example:
}, },
{ {
Name: "loaddeployed", 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 <height>] [--gas <int>] <hash-or-address-or-id> [-- <signer-with-scope>, ...]`, UsageText: `loaddeployed [--historic <height>] [--gas <int>] <hash-or-address-or-id> [-- <signer-with-scope>, ...]`,
Flags: []cli.Flag{historicFlag, gasFlag}, Flags: []cli.Flag{historicFlag, gasFlag},
Description: `Load deployed contract into the VM from chain optionally attaching to it provided signers with scopes. Description: `Load deployed contract into the VM from chain optionally attaching to it provided signers with scopes.
@ -244,7 +244,7 @@ Example:
}, },
{ {
Name: "reset", 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", UsageText: "reset",
Flags: []cli.Flag{historicFlag}, Flags: []cli.Flag{historicFlag},
Description: "Unload compiled script from the VM and reset context to proper (possibly, historic) state.", Description: "Unload compiled script from the VM and reset context to proper (possibly, historic) state.",
@ -252,7 +252,7 @@ Example:
}, },
{ {
Name: "parse", 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 <arg>`, UsageText: `parse <arg>`,
Description: `<arg> is an argument which is tried to be interpreted as an item of different types Description: `<arg> 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.`, 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", Name: "run",
Usage: "Usage Execute the current loaded script", Usage: "usage Execute the current loaded script",
UsageText: `run [<method> [<parameter>...]]`, UsageText: `run [<method> [<parameter>...]]`,
Description: `<method> is a contract method, specified in manifest. It can be '_' which will push Description: `<method> is a contract method, specified in manifest. It can be '_' which will push
parameters onto the stack and execute from the current offset. parameters onto the stack and execute from the current offset.
@ -275,14 +275,14 @@ Example:
}, },
{ {
Name: "cont", Name: "cont",
Usage: "Continue execution of the current loaded script", Usage: "continue execution of the current loaded script",
UsageText: "cont", UsageText: "cont",
Description: "Continue execution of the current loaded script.", Description: "Continue execution of the current loaded script.",
Action: handleCont, Action: handleCont,
}, },
{ {
Name: "step", Name: "step",
Usage: "Step (n) instruction in the program", Usage: "step (n) instruction in the program",
UsageText: `step [<n>]`, UsageText: `step [<n>]`,
Description: `<n> is optional parameter to specify number of instructions to run. Description: `<n> is optional parameter to specify number of instructions to run.
@ -292,7 +292,7 @@ Example:
}, },
{ {
Name: "stepinto", Name: "stepinto",
Usage: "Stepinto instruction to take in the debugger", Usage: "stepinto instruction to take in the debugger",
UsageText: "stepinto", UsageText: "stepinto",
Description: `Stepinto instruction to take in the debugger. Description: `Stepinto instruction to take in the debugger.
@ -302,7 +302,7 @@ Example:
}, },
{ {
Name: "stepout", Name: "stepout",
Usage: "Stepout instruction to take in the debugger", Usage: "stepout instruction to take in the debugger",
UsageText: "stepout", UsageText: "stepout",
Description: `Stepout instruction to take in the debugger. Description: `Stepout instruction to take in the debugger.
@ -312,7 +312,7 @@ Example:
}, },
{ {
Name: "stepover", Name: "stepover",
Usage: "Stepover instruction to take in the debugger", Usage: "stepover instruction to take in the debugger",
UsageText: "stepover", UsageText: "stepover",
Description: `Stepover instruction to take in the debugger. Description: `Stepover instruction to take in the debugger.
@ -322,26 +322,26 @@ Example:
}, },
{ {
Name: "ops", Name: "ops",
Usage: "Dump opcodes of the current loaded program", Usage: "dump opcodes of the current loaded program",
UsageText: "ops", UsageText: "ops",
Description: "Dump opcodes of the current loaded program", Description: "Dump opcodes of the current loaded program",
Action: handleOps, Action: handleOps,
}, },
{ {
Name: "events", Name: "events",
Usage: "Dump events emitted by the current loaded program", Usage: "dump events emitted by the current loaded program",
UsageText: "events", UsageText: "events",
Description: "Dump events emitted by the current loaded program", Description: "Dump events emitted by the current loaded program",
Action: handleEvents, Action: handleEvents,
}, },
{ {
Name: "env", 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]`, UsageText: `env [-v]`,
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{ cli.BoolFlag{
Name: verboseFlagFullName + ",v", 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). 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", 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 <hash-or-address-or-id> [<prefix>] [--backwards] [--diff]`, UsageText: `storage <hash-or-address-or-id> [<prefix>] [--backwards] [--diff]`,
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{ cli.BoolFlag{
Name: backwardsFlagFullName + ",b", Name: backwardsFlagFullName + ",b",
Usage: "Backwards traversal direction", Usage: "backwards traversal direction",
}, },
cli.BoolFlag{ cli.BoolFlag{
Name: diffFlagFullName + ",d", 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. 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", 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 [<hash-or-address-or-id> [<prefix>]]`, UsageText: `changes [<hash-or-address-or-id> [<prefix>]]`,
Description: `Dump storage changes as is at the current stage of loaded script invocation. 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. If no script is loaded or executed, then no changes are present.

View file

@ -6,6 +6,7 @@ import (
"github.com/chzyer/readline" "github.com/chzyer/readline"
"github.com/nspcc-dev/neo-go/cli/cmdargs" "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/cli/options"
"github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig" "github.com/nspcc-dev/neo-go/pkg/core/storage/dbconfig"
"github.com/urfave/cli" "github.com/urfave/cli"
@ -27,11 +28,14 @@ func startVMPrompt(ctx *cli.Context) error {
if err := cmdargs.EnsureNone(ctx); err != nil { if err := cmdargs.EnsureNone(ctx); err != nil {
return err return err
} }
var err error
cfg, err := options.GetConfigFromContext(ctx) cfg := config.VM
if ctx.String("config-file") != "" || ctx.String("config-path") != "" {
cfg, err = options.GetConfigFromContext(ctx)
if err != nil { if err != nil {
return cli.NewExitError(err, 1) return cli.NewExitError(err, 1)
} }
}
if ctx.NumFlags() == 0 { if ctx.NumFlags() == 0 {
cfg.ApplicationConfiguration.DBConfiguration.Type = dbconfig.InMemoryDB cfg.ApplicationConfiguration.DBConfiguration.Type = dbconfig.InMemoryDB
} }

View file

@ -26,7 +26,7 @@ func newNEP11Commands() []cli.Command {
maxIters := strconv.Itoa(config.DefaultMaxIteratorResultItems) maxIters := strconv.Itoa(config.DefaultMaxIteratorResultItems)
tokenAddressFlag := flags.AddressFlag{ tokenAddressFlag := flags.AddressFlag{
Name: "token", Name: "token",
Usage: "Token contract address or hash in LE", Usage: "token contract address or hash in LE",
} }
ownerAddressFlag := flags.AddressFlag{ ownerAddressFlag := flags.AddressFlag{
Name: "address", Name: "address",

View file

@ -41,7 +41,7 @@ type transferTarget struct {
var ( var (
tokenFlag = cli.StringFlag{ tokenFlag = cli.StringFlag{
Name: "token", 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{ baseBalanceFlags = []cli.Flag{
walletPathFlag, walletPathFlag,
@ -49,7 +49,7 @@ var (
tokenFlag, tokenFlag,
flags.AddressFlag{ flags.AddressFlag{
Name: "address, a", Name: "address, a",
Usage: "Address to use", Usage: "address to use",
}, },
} }
importFlags = append([]cli.Flag{ importFlags = append([]cli.Flag{
@ -57,7 +57,7 @@ var (
walletConfigFlag, walletConfigFlag,
flags.AddressFlag{ flags.AddressFlag{
Name: "token", Name: "token",
Usage: "Token contract address or hash in LE", Usage: "token contract address or hash in LE",
}, },
}, options.RPC...) }, options.RPC...)
baseTransferFlags = []cli.Flag{ baseTransferFlags = []cli.Flag{
@ -73,7 +73,7 @@ var (
txctx.AwaitFlag, txctx.AwaitFlag,
cli.StringFlag{ cli.StringFlag{
Name: "amount", Name: "amount",
Usage: "Amount of asset to send", Usage: "amount of asset to send",
}, },
} }
multiTransferFlags = append([]cli.Flag{ multiTransferFlags = append([]cli.Flag{

View file

@ -32,7 +32,7 @@ func newValidatorCommands() []cli.Command {
txctx.AwaitFlag, txctx.AwaitFlag,
flags.AddressFlag{ flags.AddressFlag{
Name: "address, a", Name: "address, a",
Usage: "Address to register", Usage: "address to register",
}, },
}, options.RPC...), }, options.RPC...),
}, },

View file

@ -49,11 +49,11 @@ var (
var ( var (
walletPathFlag = cli.StringFlag{ walletPathFlag = cli.StringFlag{
Name: "wallet, w", 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{ walletConfigFlag = cli.StringFlag{
Name: "wallet-config", 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{ wifFlag = cli.StringFlag{
Name: "wif", Name: "wif",
@ -61,7 +61,7 @@ var (
} }
decryptFlag = cli.BoolFlag{ decryptFlag = cli.BoolFlag{
Name: "decrypt, d", Name: "decrypt, d",
Usage: "Decrypt encrypted keys.", Usage: "decrypt encrypted keys.",
} }
inFlag = cli.StringFlag{ inFlag = cli.StringFlag{
Name: "in", Name: "in",
@ -69,11 +69,11 @@ var (
} }
fromAddrFlag = flags.AddressFlag{ fromAddrFlag = flags.AddressFlag{
Name: "from", Name: "from",
Usage: "Address to send an asset from", Usage: "address to send an asset from",
} }
toAddrFlag = flags.AddressFlag{ toAddrFlag = flags.AddressFlag{
Name: "to", 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, txctx.AwaitFlag,
flags.AddressFlag{ flags.AddressFlag{
Name: "address, a", Name: "address, a",
Usage: "Address to claim GAS for", Usage: "address to claim GAS for",
}, },
} }
claimFlags = append(claimFlags, options.RPC...) claimFlags = append(claimFlags, options.RPC...)
@ -101,7 +101,7 @@ func NewCommands() []cli.Command {
inFlag, inFlag,
flags.AddressFlag{ flags.AddressFlag{
Name: "address, a", Name: "address, a",
Usage: "Address to use", Usage: "address to use",
}, },
} }
signFlags = append(signFlags, options.RPC...) signFlags = append(signFlags, options.RPC...)
@ -126,7 +126,7 @@ func NewCommands() []cli.Command {
walletConfigFlag, walletConfigFlag,
cli.BoolFlag{ cli.BoolFlag{
Name: "account, a", Name: "account, a",
Usage: "Create a new account", Usage: "create a new account",
}, },
}, },
}, },
@ -225,11 +225,11 @@ func NewCommands() []cli.Command {
wifFlag, wifFlag,
cli.StringFlag{ cli.StringFlag{
Name: "name, n", Name: "name, n",
Usage: "Optional account name", Usage: "optional account name",
}, },
cli.StringFlag{ cli.StringFlag{
Name: "contract", Name: "contract",
Usage: "Verification script for custom contracts", Usage: "verification script for custom contracts",
}, },
}, },
}, },
@ -252,11 +252,11 @@ func NewCommands() []cli.Command {
wifFlag, wifFlag,
cli.StringFlag{ cli.StringFlag{
Name: "name, n", Name: "name, n",
Usage: "Optional account name", Usage: "optional account name",
}, },
cli.IntFlag{ cli.IntFlag{
Name: "min, m", Name: "min, m",
Usage: "Minimal number of signatures", Usage: "minimal number of signatures",
}, },
}, },
}, },
@ -271,11 +271,11 @@ func NewCommands() []cli.Command {
wifFlag, wifFlag,
cli.StringFlag{ cli.StringFlag{
Name: "name, n", Name: "name, n",
Usage: "Optional account name", Usage: "optional account name",
}, },
flags.AddressFlag{ flags.AddressFlag{
Name: "contract, c", Name: "contract, c",
Usage: "Contract hash or address", Usage: "contract hash or address",
}, },
}, options.RPC...), }, options.RPC...),
}, },
@ -290,7 +290,7 @@ func NewCommands() []cli.Command {
txctx.ForceFlag, txctx.ForceFlag,
flags.AddressFlag{ flags.AddressFlag{
Name: "address, a", 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",
}, },
}, },
}, },