diff --git a/pkg/neorpc/result/version.go b/pkg/neorpc/result/version.go index 4dff198f66..7a06716324 100644 --- a/pkg/neorpc/result/version.go +++ b/pkg/neorpc/result/version.go @@ -1,6 +1,7 @@ package result import ( + "crypto" "encoding/json" "fmt" "strings" @@ -40,7 +41,9 @@ type ( ValidatorsCount byte InitialGasDistribution fixedn.Fixed8 // Hardforks is the map of network hardforks with the enabling height. - Hardforks map[config.Hardfork]uint32 + Hardforks map[config.Hardfork]uint32 + StandbyCommittee []crypto.PublicKey + SeedList []string // Below are NeoGo-specific extensions to the protocol that are // returned by the server in case they're enabled. @@ -57,16 +60,18 @@ type ( // protocolMarshallerAux is an auxiliary struct used for Protocol JSON marshalling. protocolMarshallerAux struct { - AddressVersion byte `json:"addressversion"` - Network netmode.Magic `json:"network"` - MillisecondsPerBlock int `json:"msperblock"` - MaxTraceableBlocks uint32 `json:"maxtraceableblocks"` - MaxValidUntilBlockIncrement uint32 `json:"maxvaliduntilblockincrement"` - MaxTransactionsPerBlock uint16 `json:"maxtransactionsperblock"` - MemoryPoolMaxTransactions int `json:"memorypoolmaxtransactions"` - ValidatorsCount byte `json:"validatorscount"` - InitialGasDistribution int64 `json:"initialgasdistribution"` - Hardforks []hardforkAux `json:"hardforks"` + AddressVersion byte `json:"addressversion"` + Network netmode.Magic `json:"network"` + MillisecondsPerBlock int `json:"msperblock"` + MaxTraceableBlocks uint32 `json:"maxtraceableblocks"` + MaxValidUntilBlockIncrement uint32 `json:"maxvaliduntilblockincrement"` + MaxTransactionsPerBlock uint16 `json:"maxtransactionsperblock"` + MemoryPoolMaxTransactions int `json:"memorypoolmaxtransactions"` + ValidatorsCount byte `json:"validatorscount"` + InitialGasDistribution int64 `json:"initialgasdistribution"` + Hardforks []hardforkAux `json:"hardforks"` + StandbyCommittee []crypto.PublicKey `json:"standbycommittee"` + SeedList []string `json:"seedlist"` CommitteeHistory map[uint32]uint32 `json:"committeehistory,omitempty"` P2PSigExtensions bool `json:"p2psigextensions,omitempty"` @@ -107,6 +112,8 @@ func (p Protocol) MarshalJSON() ([]byte, error) { ValidatorsCount: p.ValidatorsCount, InitialGasDistribution: int64(p.InitialGasDistribution), Hardforks: hfs, + StandbyCommittee: p.StandbyCommittee, + SeedList: p.SeedList, CommitteeHistory: p.CommitteeHistory, P2PSigExtensions: p.P2PSigExtensions, @@ -136,6 +143,8 @@ func (p *Protocol) UnmarshalJSON(data []byte) error { p.StateRootInHeader = aux.StateRootInHeader p.ValidatorsHistory = aux.ValidatorsHistory p.InitialGasDistribution = fixedn.Fixed8(aux.InitialGasDistribution) + p.StandbyCommittee = aux.StandbyCommittee + p.SeedList = aux.SeedList // Filter out unknown hardforks. for i := range aux.Hardforks { diff --git a/pkg/neorpc/result/version_test.go b/pkg/neorpc/result/version_test.go index d0480fbe21..38a861cb89 100644 --- a/pkg/neorpc/result/version_test.go +++ b/pkg/neorpc/result/version_test.go @@ -1,6 +1,7 @@ package result import ( + "crypto" "encoding/json" "testing" @@ -40,7 +41,9 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) { "msperblock": 15000, "network": 860833102, "validatorscount": 7, - "hardforks": [{"name": "Aspidochelone", "blockheight": 123}, {"name": "Basilisk", "blockheight": 1234}] + "hardforks": [{"name": "Aspidochelone", "blockheight": 123}, {"name": "Basilisk", "blockheight": 1234}], + "seedlist": ["seed1.neo.org:10333", "seed2.neo.org:10333"], + "standbycommittee": ["03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c", "02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093", "03b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a"] }, "rpc": { "maxiteratorresultitems": 100, @@ -62,7 +65,9 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) { "msperblock": 15000, "network": 860833102, "validatorscount": 7, - "hardforks": [{"name": "HF_Aspidochelone", "blockheight": 123}, {"name": "HF_Basilisk", "blockheight": 1234}] + "hardforks": [{"name": "HF_Aspidochelone", "blockheight": 123}, {"name": "HF_Basilisk", "blockheight": 1234}], + "seedlist": ["seed1.neo.org:10333", "seed2.neo.org:10333"], + "standbycommittee": ["03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c", "02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093", "03b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a"] }, "rpc": { "maxiteratorresultitems": 100, @@ -94,6 +99,15 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) { InitialGasDistribution: fixedn.Fixed8FromInt64(52000000), StateRootInHeader: false, Hardforks: map[config.Hardfork]uint32{config.HFAspidochelone: 123, config.HFBasilisk: 1234}, + StandbyCommittee: []crypto.PublicKey{ + "03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c", + "02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093", + "03b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a", + }, + SeedList: []string{ + "seed1.neo.org:10333", + "seed2.neo.org:10333", + }, }, } t.Run("MarshalJSON", func(t *testing.T) { diff --git a/pkg/services/rpcsrv/server.go b/pkg/services/rpcsrv/server.go index 7269fe219e..480252e5f4 100644 --- a/pkg/services/rpcsrv/server.go +++ b/pkg/services/rpcsrv/server.go @@ -3,6 +3,7 @@ package rpcsrv import ( "bytes" "context" + "crypto" "crypto/elliptic" "encoding/binary" "encoding/hex" @@ -886,6 +887,8 @@ func (s *Server) getVersion(_ params.Params) (any, *neorpc.Error) { ValidatorsCount: byte(cfg.GetNumOfCNs(s.chain.BlockHeight())), InitialGasDistribution: cfg.InitialGASSupply, Hardforks: hfs, + StandbyCommittee: []crypto.PublicKey{cfg.StandbyCommittee}, + SeedList: cfg.SeedList, CommitteeHistory: cfg.CommitteeHistory, P2PSigExtensions: cfg.P2PSigExtensions,