mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 19:42:23 +00:00
Merge pull request #596 from nspcc-dev/feature/single_node
network: allow single-node privnet setup. Closes #595.
This commit is contained in:
commit
7ba5267494
11 changed files with 90 additions and 9 deletions
BIN
.docker/1600-privnet-blocks-single.acc.gz
Normal file
BIN
.docker/1600-privnet-blocks-single.acc.gz
Normal file
Binary file not shown.
|
@ -69,3 +69,19 @@ services:
|
||||||
- 20336:20336
|
- 20336:20336
|
||||||
- 30336:30336
|
- 30336:30336
|
||||||
- 20004:20004
|
- 20004:20004
|
||||||
|
node_single:
|
||||||
|
container_name: neo_go_node_single
|
||||||
|
image: env_neo_go_image
|
||||||
|
command: "node --config-path /config --privnet"
|
||||||
|
volumes:
|
||||||
|
- ../config/protocol.privnet.docker.single.yml:/config/protocol.privnet.yml
|
||||||
|
- volume_chain:/chains
|
||||||
|
- ./1600-privnet-blocks-single.acc.gz:/privnet-blocks.acc.gz
|
||||||
|
networks:
|
||||||
|
neo_go_network:
|
||||||
|
ipv4_address: 172.200.0.1
|
||||||
|
ports:
|
||||||
|
- 20333:20333
|
||||||
|
- 30333:30333
|
||||||
|
- 20001:20001
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
if test -f /6000-privnet-blocks.acc.gz; then
|
if test -f /privnet-blocks.acc.gz; then
|
||||||
gunzip /6000-privnet-blocks.acc.gz
|
gunzip /privnet-blocks.acc.gz
|
||||||
/usr/bin/neo-go db restore -i /6000-privnet-blocks.acc
|
/usr/bin/neo-go db restore -i /privnet-blocks.acc
|
||||||
fi
|
fi
|
||||||
/usr/bin/neo-go "$@"
|
/usr/bin/neo-go "$@"
|
||||||
|
|
|
@ -30,7 +30,7 @@ LABEL version=$VERSION
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
|
|
||||||
COPY --from=builder /neo-go/config /config
|
COPY --from=builder /neo-go/config /config
|
||||||
COPY --from=builder /neo-go/.docker/6000-privnet-blocks.acc.gz /
|
COPY --from=builder /neo-go/.docker/6000-privnet-blocks.acc.gz /privnet-blocks.acc.gz
|
||||||
COPY --from=builder /neo-go/.docker/privnet-entrypoint.sh /usr/bin/privnet-entrypoint.sh
|
COPY --from=builder /neo-go/.docker/privnet-entrypoint.sh /usr/bin/privnet-entrypoint.sh
|
||||||
COPY --from=builder /go/bin/neo-go /usr/bin/neo-go
|
COPY --from=builder /go/bin/neo-go /usr/bin/neo-go
|
||||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -107,6 +107,10 @@ env_up:
|
||||||
@echo "=> Bootup environment"
|
@echo "=> Bootup environment"
|
||||||
@docker-compose -f $(DC_FILE) up -d node_one node_two node_three node_four
|
@docker-compose -f $(DC_FILE) up -d node_one node_two node_three node_four
|
||||||
|
|
||||||
|
env_single:
|
||||||
|
@echo "=> Bootup environment"
|
||||||
|
@docker-compose -f $(DC_FILE) up -d node_single
|
||||||
|
|
||||||
env_down:
|
env_down:
|
||||||
@echo "=> Stop environment"
|
@echo "=> Stop environment"
|
||||||
@docker-compose -f $(DC_FILE) down
|
@docker-compose -f $(DC_FILE) down
|
||||||
|
|
53
config/protocol.privnet.docker.single.yml
Normal file
53
config/protocol.privnet.docker.single.yml
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
ProtocolConfiguration:
|
||||||
|
Magic: 56753
|
||||||
|
AddressVersion: 23
|
||||||
|
SecondsPerBlock: 1
|
||||||
|
LowPriorityThreshold: 0.001
|
||||||
|
StandbyValidators:
|
||||||
|
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
|
||||||
|
SeedList:
|
||||||
|
- 172.200.0.1:20333
|
||||||
|
SystemFee:
|
||||||
|
EnrollmentTransaction: 1000
|
||||||
|
IssueTransaction: 500
|
||||||
|
PublishTransaction: 500
|
||||||
|
RegisterTransaction: 10000
|
||||||
|
VerifyBlocks: true
|
||||||
|
VerifyTransactions: true
|
||||||
|
|
||||||
|
ApplicationConfiguration:
|
||||||
|
# LogPath could be set up in case you need stdout logs to some proper file.
|
||||||
|
# LogPath: "./log/neogo.log"
|
||||||
|
DBConfiguration:
|
||||||
|
Type: "leveldb" #other options: 'inmemory','redis','boltdb'.
|
||||||
|
# DB type options. Uncomment those you need in case you want to switch DB type.
|
||||||
|
LevelDBOptions:
|
||||||
|
DataDirectoryPath: "/chains/single"
|
||||||
|
# RedisDBOptions:
|
||||||
|
# Addr: "localhost:6379"
|
||||||
|
# Password: ""
|
||||||
|
# DB: 0
|
||||||
|
# BoltDBOptions:
|
||||||
|
# FilePath: "./chains/privnet.bolt"
|
||||||
|
# Uncomment in order to set up custom address for node.
|
||||||
|
# Address: 127.0.0.1
|
||||||
|
NodePort: 20333
|
||||||
|
Relay: true
|
||||||
|
DialTimeout: 3
|
||||||
|
ProtoTickInterval: 2
|
||||||
|
MaxPeers: 10
|
||||||
|
AttemptConnPeers: 5
|
||||||
|
MinPeers: 0
|
||||||
|
RPC:
|
||||||
|
Enabled: true
|
||||||
|
EnableCORSWorkaround: false
|
||||||
|
Port: 30333
|
||||||
|
Prometheus:
|
||||||
|
Enabled: true
|
||||||
|
Port: 20001
|
||||||
|
Pprof:
|
||||||
|
Enabled: false
|
||||||
|
Port: 20011
|
||||||
|
UnlockWallet:
|
||||||
|
Path: "6PYLmjBYJ4wQTCEfqvnznGJwZeW9pfUcV5m5oreHxqryUgqKpTRAFt9L8Y"
|
||||||
|
Password: "one"
|
2
go.mod
2
go.mod
|
@ -7,7 +7,7 @@ require (
|
||||||
github.com/go-redis/redis v6.10.2+incompatible
|
github.com/go-redis/redis v6.10.2+incompatible
|
||||||
github.com/go-yaml/yaml v2.1.0+incompatible
|
github.com/go-yaml/yaml v2.1.0+incompatible
|
||||||
github.com/mr-tron/base58 v1.1.2
|
github.com/mr-tron/base58 v1.1.2
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20191213082456-c81c7a796775
|
github.com/nspcc-dev/dbft v0.0.0-20200113100648-b3578fc15d82
|
||||||
github.com/nspcc-dev/rfc6979 v0.1.0
|
github.com/nspcc-dev/rfc6979 v0.1.0
|
||||||
github.com/pkg/errors v0.8.1
|
github.com/pkg/errors v0.8.1
|
||||||
github.com/prometheus/client_golang v1.2.1
|
github.com/prometheus/client_golang v1.2.1
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -94,8 +94,8 @@ github.com/nspcc-dev/dbft v0.0.0-20191205084618-dacb1a30c254 h1:A4OkQDQOSPsJF8qU
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20191205084618-dacb1a30c254/go.mod h1:w1Ln2aT+dBlPhLnuZhBV+DfPEdS2CHWWLp5JTScY3bw=
|
github.com/nspcc-dev/dbft v0.0.0-20191205084618-dacb1a30c254/go.mod h1:w1Ln2aT+dBlPhLnuZhBV+DfPEdS2CHWWLp5JTScY3bw=
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20191209120240-0d6b7568d9ae h1:T5V1QANlNMKun0EPB3eqg2PTXG4rmLhzDyEiV63kdB0=
|
github.com/nspcc-dev/dbft v0.0.0-20191209120240-0d6b7568d9ae h1:T5V1QANlNMKun0EPB3eqg2PTXG4rmLhzDyEiV63kdB0=
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20191209120240-0d6b7568d9ae/go.mod h1:3FjXOoHmA51EGfb5GS/HOv7VdmngNRTssSeQ729dvGY=
|
github.com/nspcc-dev/dbft v0.0.0-20191209120240-0d6b7568d9ae/go.mod h1:3FjXOoHmA51EGfb5GS/HOv7VdmngNRTssSeQ729dvGY=
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20191213082456-c81c7a796775 h1:iqRxuEBrT2QbSdgmvGCwgn+lnOKmx1L5EiVTcOXUYt8=
|
github.com/nspcc-dev/dbft v0.0.0-20200113100648-b3578fc15d82 h1:jwFLk2NKgyUbmJGlZsn3qIjoRqUkKajXb45ZuWbvkT4=
|
||||||
github.com/nspcc-dev/dbft v0.0.0-20191213082456-c81c7a796775/go.mod h1:IyIyVYKfi41kAlGWqicz9G8Iyni71Resuhtd9Y5ujJM=
|
github.com/nspcc-dev/dbft v0.0.0-20200113100648-b3578fc15d82/go.mod h1:IyIyVYKfi41kAlGWqicz9G8Iyni71Resuhtd9Y5ujJM=
|
||||||
github.com/nspcc-dev/neofs-crypto v0.2.0 h1:ftN+59WqxSWz/RCgXYOfhmltOOqU+udsNQSvN6wkFck=
|
github.com/nspcc-dev/neofs-crypto v0.2.0 h1:ftN+59WqxSWz/RCgXYOfhmltOOqU+udsNQSvN6wkFck=
|
||||||
github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA=
|
github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA=
|
||||||
github.com/nspcc-dev/rfc6979 v0.1.0 h1:Lwg7esRRoyK1Up/IN1vAef1EmvrBeMHeeEkek2fAJ6c=
|
github.com/nspcc-dev/rfc6979 v0.1.0 h1:Lwg7esRRoyK1Up/IN1vAef1EmvrBeMHeeEkek2fAJ6c=
|
||||||
|
|
|
@ -108,6 +108,8 @@ func NewServer(config ServerConfig, chain core.Blockchainer, log *zap.Logger) *S
|
||||||
Chain: chain,
|
Chain: chain,
|
||||||
RequestTx: s.requestTx,
|
RequestTx: s.requestTx,
|
||||||
Wallet: config.Wallet,
|
Wallet: config.Wallet,
|
||||||
|
|
||||||
|
TimePerBlock: config.TimePerBlock,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -115,7 +117,7 @@ func NewServer(config ServerConfig, chain core.Blockchainer, log *zap.Logger) *S
|
||||||
|
|
||||||
s.consensus = srv
|
s.consensus = srv
|
||||||
|
|
||||||
if s.MinPeers <= 0 {
|
if s.MinPeers < 0 {
|
||||||
s.log.Info("bad MinPeers configured, using the default value",
|
s.log.Info("bad MinPeers configured, using the default value",
|
||||||
zap.Int("configured", s.MinPeers),
|
zap.Int("configured", s.MinPeers),
|
||||||
zap.Int("actual", defaultMinPeers))
|
zap.Int("actual", defaultMinPeers))
|
||||||
|
@ -156,6 +158,8 @@ func (s *Server) Start(errChan chan error) {
|
||||||
zap.Uint32("blockHeight", s.chain.BlockHeight()),
|
zap.Uint32("blockHeight", s.chain.BlockHeight()),
|
||||||
zap.Uint32("headerHeight", s.chain.HeaderHeight()))
|
zap.Uint32("headerHeight", s.chain.HeaderHeight()))
|
||||||
|
|
||||||
|
s.tryStartConsensus()
|
||||||
|
|
||||||
s.discovery.BackFill(s.Seeds...)
|
s.discovery.BackFill(s.Seeds...)
|
||||||
|
|
||||||
go s.bQueue.run()
|
go s.bQueue.run()
|
||||||
|
|
|
@ -57,6 +57,9 @@ type (
|
||||||
|
|
||||||
// Wallet is a wallet configuration.
|
// Wallet is a wallet configuration.
|
||||||
Wallet *config.WalletConfig
|
Wallet *config.WalletConfig
|
||||||
|
|
||||||
|
// TimePerBlock is an interval which should pass between two successive blocks.
|
||||||
|
TimePerBlock time.Duration
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -84,5 +87,6 @@ func NewServerConfig(cfg config.Config) ServerConfig {
|
||||||
AttemptConnPeers: appConfig.AttemptConnPeers,
|
AttemptConnPeers: appConfig.AttemptConnPeers,
|
||||||
MinPeers: appConfig.MinPeers,
|
MinPeers: appConfig.MinPeers,
|
||||||
Wallet: wc,
|
Wallet: wc,
|
||||||
|
TimePerBlock: time.Duration(protoConfig.SecondsPerBlock) * time.Second,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
// CreateMultiSigRedeemScript creates a script runnable by the VM.
|
// CreateMultiSigRedeemScript creates a script runnable by the VM.
|
||||||
func CreateMultiSigRedeemScript(m int, publicKeys keys.PublicKeys) ([]byte, error) {
|
func CreateMultiSigRedeemScript(m int, publicKeys keys.PublicKeys) ([]byte, error) {
|
||||||
if m <= 1 {
|
if m < 1 {
|
||||||
return nil, fmt.Errorf("param m cannot be smaller or equal to 1 got %d", m)
|
return nil, fmt.Errorf("param m cannot be smaller or equal to 1 got %d", m)
|
||||||
}
|
}
|
||||||
if m > len(publicKeys) {
|
if m > len(publicKeys) {
|
||||||
|
|
Loading…
Reference in a new issue