diff --git a/.docker/1600-privnet-blocks-single.acc.gz b/.docker/1600-privnet-blocks-single.acc.gz new file mode 100644 index 000000000..e8be800fb Binary files /dev/null and b/.docker/1600-privnet-blocks-single.acc.gz differ diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index c9dfb75bf..773e18606 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -69,3 +69,19 @@ services: - 20336:20336 - 30336:30336 - 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 + diff --git a/.docker/privnet-entrypoint.sh b/.docker/privnet-entrypoint.sh index db3c609ed..4a0c80f82 100755 --- a/.docker/privnet-entrypoint.sh +++ b/.docker/privnet-entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/sh -if test -f /6000-privnet-blocks.acc.gz; then - gunzip /6000-privnet-blocks.acc.gz - /usr/bin/neo-go db restore -i /6000-privnet-blocks.acc +if test -f /privnet-blocks.acc.gz; then + gunzip /privnet-blocks.acc.gz + /usr/bin/neo-go db restore -i /privnet-blocks.acc fi /usr/bin/neo-go "$@" diff --git a/Dockerfile b/Dockerfile index fea8deda5..c4a40aa47 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,7 @@ LABEL version=$VERSION WORKDIR / 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 /go/bin/neo-go /usr/bin/neo-go COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ diff --git a/Makefile b/Makefile index ecdae7062..352192676 100644 --- a/Makefile +++ b/Makefile @@ -107,6 +107,10 @@ env_up: @echo "=> Bootup environment" @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: @echo "=> Stop environment" @docker-compose -f $(DC_FILE) down diff --git a/config/protocol.privnet.docker.single.yml b/config/protocol.privnet.docker.single.yml new file mode 100644 index 000000000..2e0cdcd7e --- /dev/null +++ b/config/protocol.privnet.docker.single.yml @@ -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" diff --git a/go.mod b/go.mod index bcd5cb4c6..eac194fee 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/go-redis/redis v6.10.2+incompatible github.com/go-yaml/yaml v2.1.0+incompatible 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/pkg/errors v0.8.1 github.com/prometheus/client_golang v1.2.1 diff --git a/go.sum b/go.sum index 95c56f302..3223b56e9 100644 --- a/go.sum +++ b/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-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-20191213082456-c81c7a796775 h1:iqRxuEBrT2QbSdgmvGCwgn+lnOKmx1L5EiVTcOXUYt8= -github.com/nspcc-dev/dbft v0.0.0-20191213082456-c81c7a796775/go.mod h1:IyIyVYKfi41kAlGWqicz9G8Iyni71Resuhtd9Y5ujJM= +github.com/nspcc-dev/dbft v0.0.0-20200113100648-b3578fc15d82 h1:jwFLk2NKgyUbmJGlZsn3qIjoRqUkKajXb45ZuWbvkT4= +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/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA= github.com/nspcc-dev/rfc6979 v0.1.0 h1:Lwg7esRRoyK1Up/IN1vAef1EmvrBeMHeeEkek2fAJ6c= diff --git a/pkg/network/server.go b/pkg/network/server.go index a8812b474..b0b3eef89 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -108,6 +108,8 @@ func NewServer(config ServerConfig, chain core.Blockchainer, log *zap.Logger) *S Chain: chain, RequestTx: s.requestTx, Wallet: config.Wallet, + + TimePerBlock: config.TimePerBlock, }) if err != nil { return nil @@ -115,7 +117,7 @@ func NewServer(config ServerConfig, chain core.Blockchainer, log *zap.Logger) *S s.consensus = srv - if s.MinPeers <= 0 { + if s.MinPeers < 0 { s.log.Info("bad MinPeers configured, using the default value", zap.Int("configured", s.MinPeers), zap.Int("actual", defaultMinPeers)) @@ -156,6 +158,8 @@ func (s *Server) Start(errChan chan error) { zap.Uint32("blockHeight", s.chain.BlockHeight()), zap.Uint32("headerHeight", s.chain.HeaderHeight())) + s.tryStartConsensus() + s.discovery.BackFill(s.Seeds...) go s.bQueue.run() diff --git a/pkg/network/server_config.go b/pkg/network/server_config.go index 524557d3e..0cfad7f7e 100644 --- a/pkg/network/server_config.go +++ b/pkg/network/server_config.go @@ -57,6 +57,9 @@ type ( // Wallet is a wallet configuration. 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, MinPeers: appConfig.MinPeers, Wallet: wc, + TimePerBlock: time.Duration(protoConfig.SecondsPerBlock) * time.Second, } } diff --git a/pkg/smartcontract/contract.go b/pkg/smartcontract/contract.go index 4766659ea..d1c4f7521 100644 --- a/pkg/smartcontract/contract.go +++ b/pkg/smartcontract/contract.go @@ -12,7 +12,7 @@ import ( // CreateMultiSigRedeemScript creates a script runnable by the VM. 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) } if m > len(publicKeys) {