diff --git a/config/protocol.mainnet.yml b/config/protocol.mainnet.yml index 8c146186a..3fd8681e2 100644 --- a/config/protocol.mainnet.yml +++ b/config/protocol.mainnet.yml @@ -2,7 +2,7 @@ ProtocolConfiguration: Magic: 5195086 SecondsPerBlock: 15 MemPoolSize: 50000 - StandbyValidators: + StandbyCommittee: - 03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c - 02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093 - 03b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a @@ -10,6 +10,7 @@ ProtocolConfiguration: - 024c7b7fb6c310fccf1ba33b082519d82964ea93868d676662d4a59ad548df0e7d - 02aaec38470f6aad0042c6e877cfd8087d2676b0f516fddd362801b9bd3936399e - 02486fd15702c4490a26703112a5cc1d0923fd697a33406bd5a1c00e0013b09a70 + ValidatorsCount: 7 SeedList: - seed1.neo.org:10333 - seed2.neo.org:10333 diff --git a/config/protocol.privnet.docker.four.yml b/config/protocol.privnet.docker.four.yml index cd75eb539..1dbe86087 100644 --- a/config/protocol.privnet.docker.four.yml +++ b/config/protocol.privnet.docker.four.yml @@ -2,11 +2,12 @@ ProtocolConfiguration: Magic: 56753 SecondsPerBlock: 15 MemPoolSize: 50000 - StandbyValidators: + StandbyCommittee: - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 - 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e - 03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699 - 02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62 + ValidatorsCount: 4 SeedList: - 172.200.0.1:20333 - 172.200.0.2:20334 diff --git a/config/protocol.privnet.docker.one.yml b/config/protocol.privnet.docker.one.yml index ab1bc4ba0..64ec31fd1 100644 --- a/config/protocol.privnet.docker.one.yml +++ b/config/protocol.privnet.docker.one.yml @@ -2,11 +2,12 @@ ProtocolConfiguration: Magic: 56753 SecondsPerBlock: 15 MemPoolSize: 50000 - StandbyValidators: + StandbyCommittee: - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 - 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e - 03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699 - 02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62 + ValidatorsCount: 4 SeedList: - 172.200.0.1:20333 - 172.200.0.2:20334 diff --git a/config/protocol.privnet.docker.single.yml b/config/protocol.privnet.docker.single.yml index e836404fb..44a787944 100644 --- a/config/protocol.privnet.docker.single.yml +++ b/config/protocol.privnet.docker.single.yml @@ -2,8 +2,9 @@ ProtocolConfiguration: Magic: 56753 SecondsPerBlock: 1 MemPoolSize: 50000 - StandbyValidators: + StandbyCommittee: - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 + ValidatorsCount: 1 SeedList: - 172.200.0.1:20333 VerifyBlocks: true diff --git a/config/protocol.privnet.docker.three.yml b/config/protocol.privnet.docker.three.yml index 74da6f1a1..1f02c5e76 100644 --- a/config/protocol.privnet.docker.three.yml +++ b/config/protocol.privnet.docker.three.yml @@ -2,11 +2,12 @@ ProtocolConfiguration: Magic: 56753 SecondsPerBlock: 15 MemPoolSize: 50000 - StandbyValidators: + StandbyCommittee: - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 - 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e - 03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699 - 02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62 + ValidatorsCount: 4 SeedList: - 172.200.0.1:20333 - 172.200.0.2:20334 diff --git a/config/protocol.privnet.docker.two.yml b/config/protocol.privnet.docker.two.yml index 7135bb3df..d16905874 100644 --- a/config/protocol.privnet.docker.two.yml +++ b/config/protocol.privnet.docker.two.yml @@ -2,11 +2,12 @@ ProtocolConfiguration: Magic: 56753 SecondsPerBlock: 15 MemPoolSize: 50000 - StandbyValidators: + StandbyCommittee: - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 - 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e - 03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699 - 02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62 + ValidatorsCount: 4 SeedList: - 172.200.0.1:20333 - 172.200.0.2:20334 diff --git a/config/protocol.privnet.yml b/config/protocol.privnet.yml index e17824f13..97390210b 100644 --- a/config/protocol.privnet.yml +++ b/config/protocol.privnet.yml @@ -2,7 +2,7 @@ ProtocolConfiguration: Magic: 56753 SecondsPerBlock: 15 MemPoolSize: 50000 - StandbyValidators: + StandbyCommittee: - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 - 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e - 03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699 diff --git a/config/protocol.testnet.yml b/config/protocol.testnet.yml index 7463f899b..a2caa370d 100644 --- a/config/protocol.testnet.yml +++ b/config/protocol.testnet.yml @@ -2,7 +2,7 @@ ProtocolConfiguration: Magic: 1951352142 SecondsPerBlock: 15 MemPoolSize: 50000 - StandbyValidators: + StandbyCommittee: - 023e9b32ea89b94d066e649b124fd50e396ee91369e8e2a6ae1b11c170d022256d - 03009b7540e10f2562e5fd8fac9eaec25166a58b26e412348ff5a86927bfac22a2 - 02ba2c70f5996f357a43198705859fae2cfea13e1172962800772b3d588a9d4abd @@ -10,6 +10,7 @@ ProtocolConfiguration: - 02a7834be9b32e2981d157cb5bbd3acb42cfd11ea5c3b10224d7a44e98c5910f1b - 0214baf0ceea3a66f17e7e1e839ea25fd8bed6cd82e6bb6e68250189065f44ff01 - 030205e9cefaea5a1dfc580af20c8d5aa2468bb0148f1a5e4605fc622c80e604ba + ValidatorsCount: 7 SeedList: - seed1t.neo.org:20333 - seed2t.neo.org:20333 diff --git a/config/protocol.unit_testnet.yml b/config/protocol.unit_testnet.yml index 48d370848..94f465989 100644 --- a/config/protocol.unit_testnet.yml +++ b/config/protocol.unit_testnet.yml @@ -2,7 +2,7 @@ ProtocolConfiguration: Magic: 42 SecondsPerBlock: 15 MemPoolSize: 50000 - StandbyValidators: + StandbyCommittee: - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 - 02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e - 03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699 diff --git a/pkg/config/protocol_config.go b/pkg/config/protocol_config.go index 45f880bf7..64969135d 100644 --- a/pkg/config/protocol_config.go +++ b/pkg/config/protocol_config.go @@ -10,11 +10,11 @@ type ( Magic netmode.Magic `yaml:"Magic"` MemPoolSize int `yaml:"MemPoolSize"` // SaveStorageBatch enables storage batch saving before every persist. - SaveStorageBatch bool `yaml:"SaveStorageBatch"` - SecondsPerBlock int `yaml:"SecondsPerBlock"` - SeedList []string `yaml:"SeedList"` - StandbyValidators []string `yaml:"StandbyValidators"` - ValidatorsCount int `yaml:"ValidatorsCount"` + SaveStorageBatch bool `yaml:"SaveStorageBatch"` + SecondsPerBlock int `yaml:"SecondsPerBlock"` + SeedList []string `yaml:"SeedList"` + StandbyCommittee []string `yaml:"StandbyCommittee"` + ValidatorsCount int `yaml:"ValidatorsCount"` // Whether to verify received blocks. VerifyBlocks bool `yaml:"VerifyBlocks"` // Whether to verify transactions in received blocks. diff --git a/pkg/core/helper_test.go b/pkg/core/helper_test.go index 51c2a8550..6aad4e04b 100644 --- a/pkg/core/helper_test.go +++ b/pkg/core/helper_test.go @@ -394,7 +394,7 @@ func addSigners(txs ...*transaction.Transaction) { func signTx(bc *Blockchain, txs ...*transaction.Transaction) error { validators := bc.GetStandByValidators() - rawScript, err := smartcontract.CreateMultiSigRedeemScript(len(bc.config.StandbyValidators)/2+1, validators) + rawScript, err := smartcontract.CreateMultiSigRedeemScript(bc.config.ValidatorsCount/2+1, validators) if err != nil { return errors.Wrap(err, "fail to sign tx") } diff --git a/pkg/core/util.go b/pkg/core/util.go index a906de28e..72f555523 100644 --- a/pkg/core/util.go +++ b/pkg/core/util.go @@ -1,6 +1,7 @@ package core import ( + "errors" "time" "github.com/nspcc-dev/neo-go/pkg/config" @@ -94,9 +95,12 @@ func deployNativeContracts(magic netmode.Magic) *transaction.Transaction { } func validatorsFromConfig(cfg config.ProtocolConfiguration) ([]*keys.PublicKey, error) { - validators := make([]*keys.PublicKey, len(cfg.StandbyValidators)) - for i, pubKeyStr := range cfg.StandbyValidators { - pubKey, err := keys.NewPublicKeyFromString(pubKeyStr) + if len(cfg.StandbyCommittee) < cfg.ValidatorsCount { + return nil, errors.New("validators count can be less than the size of StandbyCommittee") + } + validators := make([]*keys.PublicKey, cfg.ValidatorsCount) + for i := range validators { + pubKey, err := keys.NewPublicKeyFromString(cfg.StandbyCommittee[i]) if err != nil { return nil, err }