From 0b303651d66e7709a02a51bd7776dbb8fa2f5636 Mon Sep 17 00:00:00 2001 From: samvel-vardanyan Date: Wed, 16 Aug 2023 10:12:10 +0400 Subject: [PATCH] reloved merge conflicts --- Makefile | 2 +- contract/pkg/bucket/messages.go | 33 +-- contract/pkg/bucket/messages_test.go | 30 ++- .../pkg/cache/ddc_bucket_contract_cache.go | 6 +- contract/pkg/mock/ddc_bucket_contract_mock.go | 31 ++- core/pkg/topology/sync/topology.go | 19 +- core/pkg/topology/topology.go | 44 +-- core/pkg/topology/topology_test.go | 253 ++++++++++++------ core/pkg/topology/vNode.go | 10 +- ddc-schemas | 2 +- model/pb/state.pb.go | 147 +++++----- 11 files changed, 349 insertions(+), 228 deletions(-) diff --git a/Makefile b/Makefile index 7fe2c69..1ef3bd4 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ packages = ./model/... ./core/... ./contract/... ./contentadrstorage/... -test: +tests: go test ${packages} lint: diff --git a/contract/pkg/bucket/messages.go b/contract/pkg/bucket/messages.go index fba0e8a..304c636 100644 --- a/contract/pkg/bucket/messages.go +++ b/contract/pkg/bucket/messages.go @@ -12,7 +12,6 @@ type ( Balance = types.U128 Cash = Balance Resource = uint32 - NodeId = uint32 Token = uint64 ClusterId = uint32 AccountId = types.AccountID @@ -22,20 +21,18 @@ type ( BucketParams = Params CdnNodeParams = Params NodeState = byte - NodeKey = uint64 + NodeKey = string VNodes = [][]Token ) const ( - UNKNOWN NodeState = iota - ADDING + ADDING = iota ACTIVE DELETING OFFLINE ) var NodeTags = map[string]byte{ - "UNKNOWN": UNKNOWN, "ADDING": ADDING, "ACTIVE": ACTIVE, "DELETING": DELETING, @@ -44,27 +41,33 @@ var NodeTags = map[string]byte{ type Cluster struct { ManagerId AccountId - NodesKeys []string + Params Params + NodesKeys []NodeKey ResourcePerVNode Resource ResourceUsed Resource Revenues Cash Nodes []NodeKey VNodes [][]Token TotalRent Balance - CdnNodesKeys []string - CdnUsdPerGb Balance + CdnNodesKeys []NodeKey CdnRevenues Cash + CdnUsdPerGb Balance } -type NewCluster struct { - Params Params - ResourcePerVNode Resource +type NodeVNodesInfo struct { + NodeKey NodeKey + VNodes []Token } type ClusterStatus struct { - ClusterId ClusterId - Cluster Cluster - Params Params + ClusterId ClusterId + Cluster Cluster + NodesVNodes []NodeVNodesInfo +} + +type NewCluster struct { + Params Params + ResourcePerVNode Resource } type CDNCluster struct { @@ -322,7 +325,7 @@ type ClusterParams struct { func (c *ClusterStatus) ReplicationFactor() uint { params := &ClusterParams{} - err := json.Unmarshal([]byte(c.Params), params) + err := json.Unmarshal([]byte(c.Cluster.Params), params) if err != nil || params.ReplicationFactor <= 0 { return 0 } diff --git a/contract/pkg/bucket/messages_test.go b/contract/pkg/bucket/messages_test.go index df9dcc1..9630991 100644 --- a/contract/pkg/bucket/messages_test.go +++ b/contract/pkg/bucket/messages_test.go @@ -2,10 +2,11 @@ package bucket import ( "encoding/hex" - "github.com/cerebellum-network/cere-ddc-sdk-go/contract/pkg" "strings" "testing" + "github.com/cerebellum-network/cere-ddc-sdk-go/contract/pkg" + "github.com/centrifuge/go-substrate-rpc-client/v4/types" "github.com/stretchr/testify/assert" ) @@ -28,9 +29,9 @@ func TestBucketWriteAccess(t *testing.T) { func TestClusterStatus_ReplicationFactor(t *testing.T) { type fields struct { - ClusterId ClusterId - Cluster Cluster - Params Params + ClusterId ClusterId + Cluster Cluster + NodesVNodes []NodeVNodesInfo } tests := []struct { name string @@ -41,8 +42,9 @@ func TestClusterStatus_ReplicationFactor(t *testing.T) { name: "ReplicationFactor as integer", fields: fields{ ClusterId: 1, - Params: `{"ReplicationFactor": 3}`, - Cluster: Cluster{}, + Cluster: Cluster{ + Params: `{"ReplicationFactor": 3}`, + }, }, want: 3, }, @@ -50,8 +52,9 @@ func TestClusterStatus_ReplicationFactor(t *testing.T) { name: "ReplicationFactor as string", fields: fields{ ClusterId: 1, - Params: `{"ReplicationFactor": "3"}`, - Cluster: Cluster{}, + Cluster: Cluster{ + Params: `{"ReplicationFactor": "3"}`, + }, }, want: 3, }, @@ -59,8 +62,9 @@ func TestClusterStatus_ReplicationFactor(t *testing.T) { name: "ReplicationFactor not set", fields: fields{ ClusterId: 1, - Params: `{}`, - Cluster: Cluster{}, + Cluster: Cluster{ + Params: `{}`, + }, }, want: 0, }, @@ -68,9 +72,9 @@ func TestClusterStatus_ReplicationFactor(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { c := &ClusterStatus{ - ClusterId: tt.fields.ClusterId, - Cluster: tt.fields.Cluster, - Params: tt.fields.Params, + ClusterId: tt.fields.ClusterId, + Cluster: tt.fields.Cluster, + NodesVNodes: tt.fields.NodesVNodes, } assert.Equalf(t, tt.want, c.ReplicationFactor(), "ReplicationFactor()") }) diff --git a/contract/pkg/cache/ddc_bucket_contract_cache.go b/contract/pkg/cache/ddc_bucket_contract_cache.go index 8e7107a..da2f5aa 100644 --- a/contract/pkg/cache/ddc_bucket_contract_cache.go +++ b/contract/pkg/cache/ddc_bucket_contract_cache.go @@ -25,7 +25,7 @@ type ( ClearNodes() ClearBuckets() ClearAccounts() - ClearNodeById(id bucket.NodeId) + ClearNodeById(id bucket.NodeKey) ClearBucketById(id bucket.BucketId) ClearAccountById(id bucket.AccountId) bucket.DdcBucketContract @@ -200,8 +200,8 @@ func (d *ddcBucketContractCached) ClearAccounts() { d.accountCache.Flush() } -func (d *ddcBucketContractCached) ClearNodeById(id bucket.NodeId) { //nolint:golint,unused - d.nodeCache.Delete(toString(id)) +func (d *ddcBucketContractCached) ClearNodeById(key bucket.NodeKey) { //nolint:golint,unused + d.nodeCache.Delete(key) } func (d *ddcBucketContractCached) ClearNodeByKey(nodeKey string) { diff --git a/contract/pkg/mock/ddc_bucket_contract_mock.go b/contract/pkg/mock/ddc_bucket_contract_mock.go index 5012b0e..0edb115 100644 --- a/contract/pkg/mock/ddc_bucket_contract_mock.go +++ b/contract/pkg/mock/ddc_bucket_contract_mock.go @@ -35,10 +35,14 @@ type ( } Cluster struct { - Id uint32 - VNodes [][]uint64 - Nodes []uint32 - Params string + Id uint32 + NodesVNodes []NodeVNodes + Params string + } + + NodeVNodes struct { + NodeKey string + VNodes []uint64 } CDNNode struct { @@ -55,7 +59,7 @@ type ( CDNCluster struct { Id uint32 - Nodes []uint32 + Nodes []string } ddcBucketContractMock struct { @@ -69,6 +73,18 @@ type ( } ) +func mapNodesVNodes(nodes []NodeVNodes) []bucket.NodeVNodesInfo { + var nodesVNodes []bucket.NodeVNodesInfo + for _, node := range nodes { + nodeVNodes := bucket.NodeVNodesInfo{ + NodeKey: node.NodeKey, + VNodes: node.VNodes, + } + nodesVNodes = append(nodesVNodes, nodeVNodes) + } + return nodesVNodes +} + func CreateDdcBucketContractMock(apiUrl string, accountId string, nodes []Node, clusters []Cluster, cdnNodes []CDNNode, cdnClusters []CDNCluster) bucket.DdcBucketContract { log.Info("DDC Bucket contract configured [MOCK]") return &ddcBucketContractMock{ @@ -102,14 +118,13 @@ func (d *ddcBucketContractMock) ClusterGet(clusterId uint32) (*bucket.ClusterSta ClusterId: clusterId, Cluster: bucket.Cluster{ ManagerId: types.AccountID{}, - Nodes: cluster.Nodes, - VNodes: cluster.VNodes, + Params: cluster.Params, ResourcePerVNode: 32, ResourceUsed: 0, Revenues: types.NewU128(*big.NewInt(1)), TotalRent: types.NewU128(*big.NewInt(1)), }, - Params: cluster.Params, + NodesVNodes: mapNodesVNodes(cluster.NodesVNodes), }, nil } } diff --git a/core/pkg/topology/sync/topology.go b/core/pkg/topology/sync/topology.go index 1f19fe5..8ca7406 100644 --- a/core/pkg/topology/sync/topology.go +++ b/core/pkg/topology/sync/topology.go @@ -1,8 +1,9 @@ package sync import ( - "github.com/cerebellum-network/cere-ddc-sdk-go/core/pkg/topology" "sync" + + "github.com/cerebellum-network/cere-ddc-sdk-go/core/pkg/topology" ) type ring struct { @@ -10,15 +11,15 @@ type ring struct { mutex sync.RWMutex } -func NewTopology(nodeIds []uint32, vNodes [][]uint64, replicaFactor uint) topology.Ring { +func NewTopology(nodes topology.NodesVNodes, replicaFactor uint) topology.Ring { return &ring{ - ring: topology.NewTopology(nodeIds, vNodes, replicaFactor), + ring: topology.NewTopology(nodes, replicaFactor), } } -func (r *ring) Tokens(nodeId uint32) []uint64 { +func (r *ring) Tokens(nodeKey string) []uint64 { r.mutex.RLock() - result := r.ring.Tokens(nodeId) + result := r.ring.Tokens(nodeKey) r.mutex.RUnlock() return result @@ -40,17 +41,17 @@ func (r *ring) Replicas(token uint64) []topology.VNode { return result } -func (r *ring) Partitions(nodeId uint32) []topology.Partition { +func (r *ring) Partitions(nodeKey string) []topology.Partition { r.mutex.RLock() - result := r.ring.Partitions(nodeId) + result := r.ring.Partitions(nodeKey) r.mutex.RUnlock() return result } -func (r *ring) ExcessPartitions(nodeId uint32) []topology.Partition { +func (r *ring) ExcessPartitions(nodeKey string) []topology.Partition { r.mutex.RLock() - result := r.ring.ExcessPartitions(nodeId) + result := r.ring.ExcessPartitions(nodeKey) r.mutex.RUnlock() return result diff --git a/core/pkg/topology/topology.go b/core/pkg/topology/topology.go index 9c97bb3..c05e49a 100644 --- a/core/pkg/topology/topology.go +++ b/core/pkg/topology/topology.go @@ -1,18 +1,19 @@ package topology import ( - "github.com/cerebellum-network/cere-ddc-sdk-go/core/pkg/utils" "sort" + + "github.com/cerebellum-network/cere-ddc-sdk-go/core/pkg/utils" ) type ( Ring interface { - Tokens(nodeId uint32) []uint64 + Tokens(nodeKey string) []uint64 Neighbours(token uint64) (VNode, VNode) Replicas(token uint64) []VNode - Partitions(nodeId uint32) []Partition - ExcessPartitions(nodeId uint32) []Partition + Partitions(nodeKey string) []Partition + ExcessPartitions(nodeKey string) []Partition RemoveVNode(token uint64) bool @@ -26,17 +27,26 @@ type ( } ) -func NewTopology(nodeIds []uint32, vNodes [][]uint64, replicaFactor uint) Ring { +type ( + NodeVNodes struct { + NodeKey string + VNodes []uint64 + } + + NodesVNodes = []NodeVNodes +) + +func NewTopology(nodes NodesVNodes, replicaFactor uint) Ring { if replicaFactor == 0 { replicaFactor = 1 } topologyVNodes := make([]VNode, 0) - for i, nodeId := range nodeIds { - for _, token := range vNodes[i] { + for _, node := range nodes { + for _, token := range node.VNodes { topologyVNode := VNode{ - nodeId: nodeId, - token: token, + nodeKey: node.NodeKey, + token: token, } topologyVNodes = append(topologyVNodes, topologyVNode) @@ -53,10 +63,10 @@ func NewTopology(nodeIds []uint32, vNodes [][]uint64, replicaFactor uint) Ring { } } -func (r *ring) Tokens(nodeId uint32) []uint64 { +func (r *ring) Tokens(nodeKey string) []uint64 { result := make([]uint64, 0) - r.vNodeDo(nodeId, func(i int, vNode VNode) { + r.vNodeDo(nodeKey, func(i int, vNode VNode) { result = append(result, vNode.token) }) @@ -90,9 +100,9 @@ func (r *ring) Neighbours(token uint64) (prev VNode, next VNode) { return } -func (r *ring) Partitions(nodeId uint32) []Partition { +func (r *ring) Partitions(nodeKey string) []Partition { result := make([]Partition, 0) - r.vNodeDo(nodeId, func(i int, vNode VNode) { + r.vNodeDo(nodeKey, func(i int, vNode VNode) { for j := uint(1); j < r.replicationFactor; j++ { i = r.prevIndex(i) } @@ -108,8 +118,8 @@ func (r *ring) Partitions(nodeId uint32) []Partition { return result } -func (r *ring) ExcessPartitions(nodeId uint32) []Partition { - partitions := r.Partitions(nodeId) +func (r *ring) ExcessPartitions(nodeKey string) []Partition { + partitions := r.Partitions(nodeKey) result := make([]Partition, 0) for i := 0; i < len(partitions); i++ { @@ -155,9 +165,9 @@ func (r *ring) nextIndex(i int) int { return nextIndex(i, len(r.vNodes)) } -func (r *ring) vNodeDo(nodeId uint32, do func(int, VNode)) { +func (r *ring) vNodeDo(nodeKey string, do func(int, VNode)) { for i, vNode := range r.vNodes { - if nodeId == vNode.nodeId { + if nodeKey == vNode.nodeKey { do(i, vNode) } } diff --git a/core/pkg/topology/topology_test.go b/core/pkg/topology/topology_test.go index 35850b2..a75fef4 100644 --- a/core/pkg/topology/topology_test.go +++ b/core/pkg/topology/topology_test.go @@ -1,38 +1,127 @@ package topology import ( - "github.com/stretchr/testify/assert" "sort" "testing" + + "github.com/stretchr/testify/assert" ) +var NodeKey1 = "e5be9a5092b81bca64be81d212e7f2f9eba183bb7a90954f7b76361f6edb5c0a" +var NodeKey2 = "8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48" +var NodeKey3 = "90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22" +var NodeKey4 = "306721211d5404bd9da88e0204360a1a9ab8b87c66c1bc2fcdd37f3c2222cc20" +var NodeKey5 = "e659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4e" +var NodeKey6 = "1cbd2d43530a44705ad088af313e18f80b53ef16b36177cd4b77b846f2a5f07c" +var NodeKey7 = "be5ddb1579b72e84524fc29e78609e3caf42e85aa118ebfe0b0ad404b5bdd25f" + var clusters = []struct { name string - nodeIds []uint32 - vNodes [][]uint64 + nodesVNodes NodesVNodes replicaFactor uint }{ - {"size 2 replication 3", []uint32{1, 2}, [][]uint64{{9223372036854775806, 3074457345618258602, 15372286728091293010}, {12297829382473034408, 6148914691236517204, 18446744073709551612}}, 2}, - {"size 3 replication 3", []uint32{1, 2, 3}, [][]uint64{{12297829382473034408, 3074457345618258602}, {6148914691236517204, 15372286728091293010}, {18446744073709551612, 9223372036854775806}}, 3}, - {"size 4 replication 3", []uint32{1, 2, 3, 4}, [][]uint64{{12297829382473034408, 3074457345618258602}, {6148914691236517204, 15372286728091293010}, {18446744073709551612, 9223372036854775806}, {4611686018427387903}}, 3}, - {"size 2 replication 1", []uint32{1, 2}, [][]uint64{{9223372036854775806, 3074457345618258602, 15372286728091293010}, {12297829382473034408, 6148914691236517204, 18446744073709551612}}, 1}, - {"size 3 replication 1", []uint32{1, 2, 3}, [][]uint64{{12297829382473034408, 3074457345618258602}, {6148914691236517204, 15372286728091293010}, {18446744073709551612, 9223372036854775806}}, 1}, + { + "size 2 replication 3", + NodesVNodes{ + NodeVNodes{ + NodeKey: NodeKey1, + VNodes: []uint64{9223372036854775806, 3074457345618258602, 15372286728091293010}, + }, + NodeVNodes{ + NodeKey: NodeKey2, + VNodes: []uint64{12297829382473034408, 6148914691236517204, 18446744073709551612}, + }, + }, + 2, + }, + { + "size 3 replication 3", + NodesVNodes{ + NodeVNodes{ + NodeKey: NodeKey1, + VNodes: []uint64{12297829382473034408, 3074457345618258602}, + }, + NodeVNodes{ + NodeKey: NodeKey2, + VNodes: []uint64{6148914691236517204, 15372286728091293010}, + }, + NodeVNodes{ + NodeKey: NodeKey3, + VNodes: []uint64{18446744073709551612, 9223372036854775806}, + }, + }, + 3, + }, + { + "size 4 replication 3", + NodesVNodes{ + NodeVNodes{ + NodeKey: NodeKey1, + VNodes: []uint64{12297829382473034408, 3074457345618258602}, + }, + NodeVNodes{ + NodeKey: NodeKey2, + VNodes: []uint64{6148914691236517204, 15372286728091293010}, + }, + NodeVNodes{ + NodeKey: NodeKey3, + VNodes: []uint64{18446744073709551612, 9223372036854775806}, + }, + NodeVNodes{ + NodeKey: NodeKey4, + VNodes: []uint64{4611686018427387903}, + }, + }, + 3, + }, + { + "size 2 replication 1", + NodesVNodes{ + NodeVNodes{ + NodeKey: NodeKey1, + VNodes: []uint64{9223372036854775806, 3074457345618258602, 15372286728091293010}, + }, + NodeVNodes{ + NodeKey: NodeKey2, + VNodes: []uint64{12297829382473034408, 6148914691236517204, 18446744073709551612}, + }, + }, + 1, + }, + { + "size 3 replication 1", + NodesVNodes{ + NodeVNodes{ + NodeKey: NodeKey1, + VNodes: []uint64{12297829382473034408, 3074457345618258602}, + }, + NodeVNodes{ + NodeKey: NodeKey2, + VNodes: []uint64{6148914691236517204, 15372286728091293010}, + }, + NodeVNodes{ + NodeKey: NodeKey3, + VNodes: []uint64{18446744073709551612, 9223372036854775806}, + }, + }, + 1, + }, } func TestTokens(t *testing.T) { for _, test := range clusters { t.Run(test.name, func(t *testing.T) { //given - testSubject := NewTopology(test.nodeIds, test.vNodes, test.replicaFactor) + testSubject := NewTopology(test.nodesVNodes, test.replicaFactor) - for i, nodeId := range test.nodeIds { + for _, node := range test.nodesVNodes { //when - tokens := testSubject.Tokens(nodeId) + tokens := testSubject.Tokens(node.NodeKey) //then assert.True(t, sort.SliceIsSorted(tokens, func(i, j int) bool { return tokens[i] < tokens[j] })) - expected := test.vNodes[i] + expected := node.VNodes assert.Len(t, tokens, len(expected)) for _, value := range expected { assert.Contains(t, tokens, value) @@ -49,19 +138,19 @@ func TestNeighbours(t *testing.T) { prev VNode next VNode }{ - {0, 3074457345618258602, VNode{2, 18446744073709551612}, VNode{2, 6148914691236517204}}, - {0, 3074457345618258602 + 100, VNode{1, 3074457345618258602}, VNode{2, 6148914691236517204}}, - {0, 18446744073709551612, VNode{1, 15372286728091293010}, VNode{1, 3074457345618258602}}, - {0, 18446744073709551612 + 1, VNode{2, 18446744073709551612}, VNode{1, 3074457345618258602}}, - {1, 6148914691236517204, VNode{1, 3074457345618258602}, VNode{3, 9223372036854775806}}, - {1, 6148914691236517204 + 100, VNode{2, 6148914691236517204}, VNode{3, 9223372036854775806}}, + {0, 3074457345618258602, VNode{NodeKey2, 18446744073709551612}, VNode{NodeKey2, 6148914691236517204}}, + {0, 3074457345618258602 + 100, VNode{NodeKey1, 3074457345618258602}, VNode{NodeKey2, 6148914691236517204}}, + {0, 18446744073709551612, VNode{NodeKey1, 15372286728091293010}, VNode{NodeKey1, 3074457345618258602}}, + {0, 18446744073709551612 + 1, VNode{NodeKey2, 18446744073709551612}, VNode{NodeKey1, 3074457345618258602}}, + {1, 6148914691236517204, VNode{NodeKey1, 3074457345618258602}, VNode{NodeKey3, 9223372036854775806}}, + {1, 6148914691236517204 + 100, VNode{NodeKey2, 6148914691236517204}, VNode{NodeKey3, 9223372036854775806}}, } for _, test := range tests { cluster := clusters[test.clusterId] t.Run(cluster.name, func(t *testing.T) { //given - testSubject := NewTopology(cluster.nodeIds, cluster.vNodes, cluster.replicaFactor) + testSubject := NewTopology(cluster.nodesVNodes, cluster.replicaFactor) //when prev, next := testSubject.Neighbours(test.token) @@ -80,21 +169,21 @@ func TestReplicas(t *testing.T) { token uint64 replicas []VNode }{ - {0, 3074457345618258602, []VNode{{1, 3074457345618258602}, {2, 6148914691236517204}}}, - {0, 3074457345618258602 + 100, []VNode{{1, 3074457345618258602}, {2, 6148914691236517204}}}, - {0, 18446744073709551612, []VNode{{2, 18446744073709551612}, {1, 3074457345618258602}}}, - {0, 18446744073709551612 + 1, []VNode{{2, 18446744073709551612}, {1, 3074457345618258602}}}, - {1, 6148914691236517204, []VNode{{2, 6148914691236517204}, {3, 9223372036854775806}, {1, 12297829382473034408}}}, - {1, 6148914691236517204 + 10, []VNode{{2, 6148914691236517204}, {3, 9223372036854775806}, {1, 12297829382473034408}}}, - {2, 6980919141067302587, []VNode{{2, 6148914691236517204}, {3, 9223372036854775806}, {1, 12297829382473034408}}}, - {2, 7577601381952616217, []VNode{{2, 6148914691236517204}, {3, 9223372036854775806}, {1, 12297829382473034408}}}, + {0, 3074457345618258602, []VNode{{NodeKey1, 3074457345618258602}, {NodeKey2, 6148914691236517204}}}, + {0, 3074457345618258602 + 100, []VNode{{NodeKey1, 3074457345618258602}, {NodeKey2, 6148914691236517204}}}, + {0, 18446744073709551612, []VNode{{NodeKey2, 18446744073709551612}, {NodeKey1, 3074457345618258602}}}, + {0, 18446744073709551612 + 1, []VNode{{NodeKey2, 18446744073709551612}, {NodeKey1, 3074457345618258602}}}, + {1, 6148914691236517204, []VNode{{NodeKey2, 6148914691236517204}, {NodeKey3, 9223372036854775806}, {NodeKey1, 12297829382473034408}}}, + {1, 6148914691236517204 + 10, []VNode{{NodeKey2, 6148914691236517204}, {NodeKey3, 9223372036854775806}, {NodeKey1, 12297829382473034408}}}, + {2, 6980919141067302587, []VNode{{NodeKey2, 6148914691236517204}, {NodeKey3, 9223372036854775806}, {NodeKey1, 12297829382473034408}}}, + {2, 7577601381952616217, []VNode{{NodeKey2, 6148914691236517204}, {NodeKey3, 9223372036854775806}, {NodeKey1, 12297829382473034408}}}, } for _, test := range tests { cluster := clusters[test.clusterId] t.Run(cluster.name, func(t *testing.T) { //given - testSubject := NewTopology(cluster.nodeIds, cluster.vNodes, cluster.replicaFactor) + testSubject := NewTopology(cluster.nodesVNodes, cluster.replicaFactor) //when replicas := testSubject.Replicas(test.token) @@ -111,66 +200,66 @@ func TestReplicas(t *testing.T) { func TestPartitions(t *testing.T) { tests := []struct { clusterId int - nodeId uint32 + nodeKey string partitions []Partition }{ - {3, 1, + {3, NodeKey1, []Partition{ - {From: 3074457345618258602, To: 6148914691236517204 - 1, VNodes: []VNode{{nodeId: 1, token: 3074457345618258602}}}, - {From: 9223372036854775806, To: 12297829382473034408 - 1, VNodes: []VNode{{nodeId: 1, token: 9223372036854775806}}}, - {From: 15372286728091293010, To: 18446744073709551612 - 1, VNodes: []VNode{{nodeId: 1, token: 15372286728091293010}}}, + {From: 3074457345618258602, To: 6148914691236517204 - 1, VNodes: []VNode{{nodeKey: NodeKey1, token: 3074457345618258602}}}, + {From: 9223372036854775806, To: 12297829382473034408 - 1, VNodes: []VNode{{nodeKey: NodeKey1, token: 9223372036854775806}}}, + {From: 15372286728091293010, To: 18446744073709551612 - 1, VNodes: []VNode{{nodeKey: NodeKey1, token: 15372286728091293010}}}, }, }, - {3, 2, + {3, NodeKey2, []Partition{ - {From: 6148914691236517204, To: 9223372036854775806 - 1, VNodes: []VNode{{nodeId: 2, token: 6148914691236517204}}}, - {From: 12297829382473034408, To: 15372286728091293010 - 1, VNodes: []VNode{{nodeId: 2, token: 12297829382473034408}}}, - {From: 18446744073709551612, To: 3074457345618258602 - 1, VNodes: []VNode{{nodeId: 2, token: 18446744073709551612}}}, + {From: 6148914691236517204, To: 9223372036854775806 - 1, VNodes: []VNode{{nodeKey: NodeKey2, token: 6148914691236517204}}}, + {From: 12297829382473034408, To: 15372286728091293010 - 1, VNodes: []VNode{{nodeKey: NodeKey2, token: 12297829382473034408}}}, + {From: 18446744073709551612, To: 3074457345618258602 - 1, VNodes: []VNode{{nodeKey: NodeKey2, token: 18446744073709551612}}}, }, }, - {4, 1, + {4, NodeKey1, []Partition{ - {From: 3074457345618258602, To: 6148914691236517204 - 1, VNodes: []VNode{{nodeId: 1, token: 3074457345618258602}}}, - {From: 12297829382473034408, To: 15372286728091293010 - 1, VNodes: []VNode{{nodeId: 1, token: 12297829382473034408}}}, + {From: 3074457345618258602, To: 6148914691236517204 - 1, VNodes: []VNode{{nodeKey: NodeKey1, token: 3074457345618258602}}}, + {From: 12297829382473034408, To: 15372286728091293010 - 1, VNodes: []VNode{{nodeKey: NodeKey1, token: 12297829382473034408}}}, }, }, - {4, 2, + {4, NodeKey2, []Partition{ - {From: 6148914691236517204, To: 9223372036854775806 - 1, VNodes: []VNode{{nodeId: 2, token: 6148914691236517204}}}, - {From: 15372286728091293010, To: 18446744073709551612 - 1, VNodes: []VNode{{nodeId: 2, token: 15372286728091293010}}}, + {From: 6148914691236517204, To: 9223372036854775806 - 1, VNodes: []VNode{{nodeKey: NodeKey2, token: 6148914691236517204}}}, + {From: 15372286728091293010, To: 18446744073709551612 - 1, VNodes: []VNode{{nodeKey: NodeKey2, token: 15372286728091293010}}}, }, }, - {4, 3, + {4, NodeKey3, []Partition{ - {From: 9223372036854775806, To: 12297829382473034408 - 1, VNodes: []VNode{{nodeId: 3, token: 9223372036854775806}}}, - {From: 18446744073709551612, To: 3074457345618258602 - 1, VNodes: []VNode{{nodeId: 3, token: 18446744073709551612}}}, + {From: 9223372036854775806, To: 12297829382473034408 - 1, VNodes: []VNode{{nodeKey: NodeKey3, token: 9223372036854775806}}}, + {From: 18446744073709551612, To: 3074457345618258602 - 1, VNodes: []VNode{{nodeKey: NodeKey3, token: 18446744073709551612}}}, }, }, - {0, 1, + {0, NodeKey1, []Partition{ - {From: 18446744073709551612, To: 3074457345618258602 - 1, VNodes: []VNode{{nodeId: 2, token: 18446744073709551612}, {nodeId: 1, token: 3074457345618258602}}}, - {From: 3074457345618258602, To: 6148914691236517204 - 1, VNodes: []VNode{{nodeId: 1, token: 3074457345618258602}, {nodeId: 2, token: 6148914691236517204}}}, - {From: 6148914691236517204, To: 9223372036854775806 - 1, VNodes: []VNode{{nodeId: 2, token: 6148914691236517204}, {nodeId: 1, token: 9223372036854775806}}}, - {From: 9223372036854775806, To: 12297829382473034408 - 1, VNodes: []VNode{{nodeId: 1, token: 9223372036854775806}, {nodeId: 2, token: 12297829382473034408}}}, - {From: 12297829382473034408, To: 15372286728091293010 - 1, VNodes: []VNode{{nodeId: 2, token: 12297829382473034408}, {nodeId: 1, token: 15372286728091293010}}}, - {From: 15372286728091293010, To: 18446744073709551612 - 1, VNodes: []VNode{{nodeId: 1, token: 15372286728091293010}, {nodeId: 2, token: 18446744073709551612}}}, + {From: 18446744073709551612, To: 3074457345618258602 - 1, VNodes: []VNode{{nodeKey: NodeKey2, token: 18446744073709551612}, {nodeKey: NodeKey1, token: 3074457345618258602}}}, + {From: 3074457345618258602, To: 6148914691236517204 - 1, VNodes: []VNode{{nodeKey: NodeKey1, token: 3074457345618258602}, {nodeKey: NodeKey2, token: 6148914691236517204}}}, + {From: 6148914691236517204, To: 9223372036854775806 - 1, VNodes: []VNode{{nodeKey: NodeKey2, token: 6148914691236517204}, {nodeKey: NodeKey1, token: 9223372036854775806}}}, + {From: 9223372036854775806, To: 12297829382473034408 - 1, VNodes: []VNode{{nodeKey: NodeKey1, token: 9223372036854775806}, {nodeKey: NodeKey2, token: 12297829382473034408}}}, + {From: 12297829382473034408, To: 15372286728091293010 - 1, VNodes: []VNode{{nodeKey: NodeKey2, token: 12297829382473034408}, {nodeKey: NodeKey1, token: 15372286728091293010}}}, + {From: 15372286728091293010, To: 18446744073709551612 - 1, VNodes: []VNode{{nodeKey: NodeKey1, token: 15372286728091293010}, {nodeKey: NodeKey2, token: 18446744073709551612}}}, }, }, - {0, 2, + {0, NodeKey2, []Partition{ - {From: 3074457345618258602, To: 6148914691236517204 - 1, VNodes: []VNode{{nodeId: 1, token: 3074457345618258602}, {nodeId: 2, token: 6148914691236517204}}}, - {From: 6148914691236517204, To: 9223372036854775806 - 1, VNodes: []VNode{{nodeId: 2, token: 6148914691236517204}, {nodeId: 1, token: 9223372036854775806}}}, - {From: 9223372036854775806, To: 12297829382473034408 - 1, VNodes: []VNode{{nodeId: 1, token: 9223372036854775806}, {nodeId: 2, token: 12297829382473034408}}}, - {From: 12297829382473034408, To: 15372286728091293010 - 1, VNodes: []VNode{{nodeId: 2, token: 12297829382473034408}, {nodeId: 1, token: 15372286728091293010}}}, - {From: 15372286728091293010, To: 18446744073709551612 - 1, VNodes: []VNode{{nodeId: 1, token: 15372286728091293010}, {nodeId: 2, token: 18446744073709551612}}}, - {From: 18446744073709551612, To: 3074457345618258602 - 1, VNodes: []VNode{{nodeId: 2, token: 18446744073709551612}, {nodeId: 1, token: 3074457345618258602}}}, + {From: 3074457345618258602, To: 6148914691236517204 - 1, VNodes: []VNode{{nodeKey: NodeKey1, token: 3074457345618258602}, {nodeKey: NodeKey2, token: 6148914691236517204}}}, + {From: 6148914691236517204, To: 9223372036854775806 - 1, VNodes: []VNode{{nodeKey: NodeKey2, token: 6148914691236517204}, {nodeKey: NodeKey1, token: 9223372036854775806}}}, + {From: 9223372036854775806, To: 12297829382473034408 - 1, VNodes: []VNode{{nodeKey: NodeKey1, token: 9223372036854775806}, {nodeKey: NodeKey2, token: 12297829382473034408}}}, + {From: 12297829382473034408, To: 15372286728091293010 - 1, VNodes: []VNode{{nodeKey: NodeKey2, token: 12297829382473034408}, {nodeKey: NodeKey1, token: 15372286728091293010}}}, + {From: 15372286728091293010, To: 18446744073709551612 - 1, VNodes: []VNode{{nodeKey: NodeKey1, token: 15372286728091293010}, {nodeKey: NodeKey2, token: 18446744073709551612}}}, + {From: 18446744073709551612, To: 3074457345618258602 - 1, VNodes: []VNode{{nodeKey: NodeKey2, token: 18446744073709551612}, {nodeKey: NodeKey1, token: 3074457345618258602}}}, }, }, - {2, 4, + {2, NodeKey4, []Partition{ - {From: 18446744073709551612, To: 3074457345618258602 - 1, VNodes: []VNode{{nodeId: 3, token: 18446744073709551612}, {nodeId: 1, token: 3074457345618258602}, {nodeId: 4, token: 4611686018427387903}}}, - {From: 3074457345618258602, To: 4611686018427387903 - 1, VNodes: []VNode{{nodeId: 1, token: 3074457345618258602}, {nodeId: 4, token: 4611686018427387903}, {nodeId: 2, token: 6148914691236517204}}}, - {From: 4611686018427387903, To: 6148914691236517204 - 1, VNodes: []VNode{{nodeId: 4, token: 4611686018427387903}, {nodeId: 2, token: 6148914691236517204}, {nodeId: 3, token: 9223372036854775806}}}, + {From: 18446744073709551612, To: 3074457345618258602 - 1, VNodes: []VNode{{nodeKey: NodeKey3, token: 18446744073709551612}, {nodeKey: NodeKey1, token: 3074457345618258602}, {nodeKey: NodeKey4, token: 4611686018427387903}}}, + {From: 3074457345618258602, To: 4611686018427387903 - 1, VNodes: []VNode{{nodeKey: NodeKey1, token: 3074457345618258602}, {nodeKey: NodeKey4, token: 4611686018427387903}, {nodeKey: NodeKey2, token: 6148914691236517204}}}, + {From: 4611686018427387903, To: 6148914691236517204 - 1, VNodes: []VNode{{nodeKey: NodeKey4, token: 4611686018427387903}, {nodeKey: NodeKey2, token: 6148914691236517204}, {nodeKey: NodeKey3, token: 9223372036854775806}}}, }, }, } @@ -179,10 +268,10 @@ func TestPartitions(t *testing.T) { cluster := clusters[test.clusterId] t.Run(cluster.name, func(t *testing.T) { //given - testSubject := NewTopology(cluster.nodeIds, cluster.vNodes, cluster.replicaFactor) + testSubject := NewTopology(cluster.nodesVNodes, cluster.replicaFactor) //when - partitions := testSubject.Partitions(test.nodeId) + partitions := testSubject.Partitions(test.nodeKey) //then assert.Len(t, partitions, len(test.partitions)) @@ -196,28 +285,28 @@ func TestPartitions(t *testing.T) { func TestExcessPartitions(t *testing.T) { tests := []struct { clusterId int - nodeId uint32 + nodeKey string excessPartitions []Partition }{ - {3, 1, []Partition{{From: 6148914691236517204, To: 9223372036854775806 - 1}, {From: 12297829382473034408, To: 15372286728091293010 - 1}, {From: 18446744073709551612, To: 3074457345618258602 - 1}}}, - {3, 2, []Partition{{From: 9223372036854775806, To: 12297829382473034408 - 1}, {From: 15372286728091293010, To: 18446744073709551612 - 1}, {From: 3074457345618258602, To: 6148914691236517204 - 1}}}, - {4, 1, []Partition{{From: 6148914691236517204, To: 12297829382473034408 - 1}, {From: 15372286728091293010, To: 3074457345618258602 - 1}}}, - {4, 2, []Partition{{From: 9223372036854775806, To: 15372286728091293010 - 1}, {From: 18446744073709551612, To: 6148914691236517204 - 1}}}, - {4, 3, []Partition{{From: 12297829382473034408, To: 18446744073709551612 - 1}, {From: 3074457345618258602, To: 9223372036854775806 - 1}}}, - {0, 1, []Partition{}}, - {0, 2, []Partition{}}, - {0, 3, []Partition{}}, - {2, 4, []Partition{{From: 6148914691236517204, To: 18446744073709551612 - 1}}}, + {3, NodeKey1, []Partition{{From: 6148914691236517204, To: 9223372036854775806 - 1}, {From: 12297829382473034408, To: 15372286728091293010 - 1}, {From: 18446744073709551612, To: 3074457345618258602 - 1}}}, + {3, NodeKey2, []Partition{{From: 9223372036854775806, To: 12297829382473034408 - 1}, {From: 15372286728091293010, To: 18446744073709551612 - 1}, {From: 3074457345618258602, To: 6148914691236517204 - 1}}}, + {4, NodeKey1, []Partition{{From: 6148914691236517204, To: 12297829382473034408 - 1}, {From: 15372286728091293010, To: 3074457345618258602 - 1}}}, + {4, NodeKey2, []Partition{{From: 9223372036854775806, To: 15372286728091293010 - 1}, {From: 18446744073709551612, To: 6148914691236517204 - 1}}}, + {4, NodeKey3, []Partition{{From: 12297829382473034408, To: 18446744073709551612 - 1}, {From: 3074457345618258602, To: 9223372036854775806 - 1}}}, + {0, NodeKey1, []Partition{}}, + {0, NodeKey2, []Partition{}}, + {0, NodeKey3, []Partition{}}, + {2, NodeKey4, []Partition{{From: 6148914691236517204, To: 18446744073709551612 - 1}}}, } for _, test := range tests { cluster := clusters[test.clusterId] t.Run(cluster.name, func(t *testing.T) { //given - testSubject := NewTopology(cluster.nodeIds, cluster.vNodes, cluster.replicaFactor) + testSubject := NewTopology(cluster.nodesVNodes, cluster.replicaFactor) //when - partitions := testSubject.ExcessPartitions(test.nodeId) + partitions := testSubject.ExcessPartitions(test.nodeKey) //then assert.Len(t, partitions, len(test.excessPartitions)) @@ -236,15 +325,15 @@ func TestRemoveVNode(t *testing.T) { expectIsRemoved bool expected []VNode }{ - {0, 100, false, []VNode{{token: 3074457345618258602, nodeId: 1}, {token: 6148914691236517204, nodeId: 2}, {token: 9223372036854775806, nodeId: 1}, {token: 12297829382473034408, nodeId: 2}, {token: 15372286728091293010, nodeId: 1}, {token: 18446744073709551612, nodeId: 2}}}, - {0, 9223372036854775806, true, []VNode{{token: 3074457345618258602, nodeId: 1}, {token: 6148914691236517204, nodeId: 2}, {token: 12297829382473034408, nodeId: 2}, {token: 15372286728091293010, nodeId: 1}, {token: 18446744073709551612, nodeId: 2}}}, - {0, 12297829382473034408, true, []VNode{{token: 3074457345618258602, nodeId: 1}, {token: 6148914691236517204, nodeId: 2}, {token: 9223372036854775806, nodeId: 1}, {token: 15372286728091293010, nodeId: 1}, {token: 18446744073709551612, nodeId: 2}}}, + {0, 100, false, []VNode{{token: 3074457345618258602, nodeKey: NodeKey1}, {token: 6148914691236517204, nodeKey: NodeKey2}, {token: 9223372036854775806, nodeKey: NodeKey1}, {token: 12297829382473034408, nodeKey: NodeKey2}, {token: 15372286728091293010, nodeKey: NodeKey1}, {token: 18446744073709551612, nodeKey: NodeKey2}}}, + {0, 9223372036854775806, true, []VNode{{token: 3074457345618258602, nodeKey: NodeKey1}, {token: 6148914691236517204, nodeKey: NodeKey2}, {token: 12297829382473034408, nodeKey: NodeKey2}, {token: 15372286728091293010, nodeKey: NodeKey1}, {token: 18446744073709551612, nodeKey: NodeKey2}}}, + {0, 12297829382473034408, true, []VNode{{token: 3074457345618258602, nodeKey: NodeKey1}, {token: 6148914691236517204, nodeKey: NodeKey2}, {token: 9223372036854775806, nodeKey: NodeKey1}, {token: 15372286728091293010, nodeKey: NodeKey1}, {token: 18446744073709551612, nodeKey: NodeKey2}}}, } for _, test := range tests { cluster := clusters[test.clusterId] t.Run(cluster.name, func(t *testing.T) { //given - testSubject := NewTopology(cluster.nodeIds, cluster.vNodes, cluster.replicaFactor) + testSubject := NewTopology(cluster.nodesVNodes, cluster.replicaFactor) //when ok := testSubject.RemoveVNode(test.token) diff --git a/core/pkg/topology/vNode.go b/core/pkg/topology/vNode.go index 15af732..db8c2b7 100644 --- a/core/pkg/topology/vNode.go +++ b/core/pkg/topology/vNode.go @@ -3,12 +3,12 @@ package topology import "fmt" type VNode struct { - nodeId uint32 - token uint64 + nodeKey string + token uint64 } -func (v VNode) NodeId() uint32 { - return v.nodeId +func (v VNode) NodeKey() string { + return v.nodeKey } func (v VNode) Token() uint64 { @@ -16,5 +16,5 @@ func (v VNode) Token() uint64 { } func (v VNode) String() string { - return fmt.Sprintf("{\"nodeId\":%d,\"token\":%d}", v.nodeId, v.token) + return fmt.Sprintf("{\"nodeKey\":%v,\"token\":%d}", v.nodeKey, v.token) } diff --git a/ddc-schemas b/ddc-schemas index a1bd223..23cd2e6 160000 --- a/ddc-schemas +++ b/ddc-schemas @@ -1 +1 @@ -Subproject commit a1bd22370f112d88c9d5f730a0d6124bc700abb2 +Subproject commit 23cd2e62d7ab55d21856b03df4644d35e2119ceb diff --git a/model/pb/state.pb.go b/model/pb/state.pb.go index 29ce6cb..7ac98b5 100644 --- a/model/pb/state.pb.go +++ b/model/pb/state.pb.go @@ -160,8 +160,8 @@ type ShortState struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // ID of the node from smart contract - NodeID uint32 `protobuf:"varint,1,opt,name=nodeID,proto3" json:"nodeID,omitempty"` + // PubKey of the node from smart contract + NodeKey string `protobuf:"bytes,1,opt,name=nodeKey,proto3" json:"nodeKey,omitempty"` // ID of the cluster from smart contract ClusterID uint32 `protobuf:"varint,2,opt,name=clusterID,proto3" json:"clusterID,omitempty"` // URL of the node @@ -208,11 +208,11 @@ func (*ShortState) Descriptor() ([]byte, []int) { return file_state_proto_rawDescGZIP(), []int{1} } -func (x *ShortState) GetNodeID() uint32 { +func (x *ShortState) GetNodeKey() string { if x != nil { - return x.NodeID + return x.NodeKey } - return 0 + return "" } func (x *ShortState) GetClusterID() uint32 { @@ -261,7 +261,7 @@ func (x *ShortState) GetUpdated() uint64 { // State bring short state (last updated state) and list of checks (who checks the state and what is the result) // each check is signed by CDN node, that make them // statistic is a last statistic state of CDN node, that needed for diagnostic only -// sign(CID(NodeID+ClusterID+URL+State+Location+Size+Updated_at)) +// sign(CID(nodeKey+ClusterID+URL+State+Location+Size+Updated_at)) type GossipState struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -415,8 +415,7 @@ func (x *Check) GetSignature() *StateSignature { // // - It is normal, if time of signing is bigger from state timestamp. // - The State hash is: -// - Short state: `Hash = CID(NodeID+ClusterID+URL+State+Location+Size+Updated_at)` -// +// - Short state: `Hash = CID(nodeKey+ClusterID+URL+State+Location+Size+Updated_at)` // - The signing scheme should be sr25519, and `scheme` should be empty. // - If this not supported by a signer, then `scheme` should be "ed25519". // @@ -695,72 +694,72 @@ var file_state_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x6f, 0x73, 0x73, 0x69, 0x70, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x22, 0xbf, 0x01, 0x0a, 0x0a, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x44, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x44, 0x12, 0x1c, 0x0a, 0x09, 0x63, - 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, - 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x44, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1f, 0x0a, 0x05, 0x73, - 0x74, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x70, 0x62, 0x2e, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1a, 0x0a, 0x08, - 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x18, 0x0a, 0x07, - 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x75, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x22, 0x96, 0x02, 0x0a, 0x0b, 0x47, 0x6f, 0x73, 0x73, 0x69, - 0x70, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x2d, 0x0a, 0x0a, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, - 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x62, 0x2e, - 0x53, 0x68, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x09, 0x6c, 0x61, 0x73, 0x74, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x30, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, - 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x09, 0x73, 0x69, - 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x2b, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x74, 0x69, - 0x73, 0x74, 0x69, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x62, 0x2e, - 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x69, - 0x73, 0x74, 0x69, 0x63, 0x12, 0x33, 0x0a, 0x06, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x18, 0x04, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x6f, 0x73, 0x73, 0x69, 0x70, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x45, 0x6e, 0x74, 0x72, - 0x79, 0x52, 0x06, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x1a, 0x44, 0x0a, 0x0b, 0x43, 0x68, 0x65, - 0x63, 0x6b, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x70, 0x62, 0x2e, 0x43, - 0x68, 0x65, 0x63, 0x6b, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, - 0x5f, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x24, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x68, 0x6f, - 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x30, - 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x69, 0x67, 0x6e, - 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x22, 0x9a, 0x01, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x69, 0x67, - 0x6e, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, - 0x72, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x75, 0x6c, - 0x74, 0x69, 0x48, 0x61, 0x73, 0x68, 0x54, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x0d, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x48, 0x61, 0x73, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0xbf, 0x01, - 0x0a, 0x09, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x12, 0x1a, 0x0a, 0x08, 0x73, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x73, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2b, 0x0a, 0x09, 0x72, 0x65, 0x64, 0x69, 0x72, - 0x65, 0x63, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x62, 0x2e, - 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x73, 0x52, 0x09, 0x72, 0x65, 0x64, 0x69, 0x72, - 0x65, 0x63, 0x74, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x73, 0x69, - 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x63, 0x61, 0x63, 0x68, 0x65, 0x53, - 0x69, 0x7a, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x70, 0x75, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x03, 0x63, 0x70, 0x75, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x61, 0x6d, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x03, 0x72, 0x61, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x68, 0x64, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x02, 0x68, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x70, 0x74, 0x69, 0x6d, - 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x22, - 0x33, 0x0a, 0x09, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x73, 0x12, 0x12, 0x0a, 0x04, - 0x73, 0x6f, 0x66, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x6f, 0x66, 0x74, - 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, - 0x68, 0x61, 0x72, 0x64, 0x2a, 0x37, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x06, 0x0a, - 0x02, 0x4e, 0x41, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x47, 0x52, 0x41, 0x59, 0x10, 0x01, 0x12, - 0x09, 0x0a, 0x05, 0x47, 0x52, 0x45, 0x45, 0x4e, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x42, 0x4c, - 0x55, 0x45, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x52, 0x45, 0x44, 0x10, 0x04, 0x42, 0x05, 0x5a, - 0x03, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x3a, 0x02, 0x38, 0x01, 0x22, 0xc1, 0x01, 0x0a, 0x0a, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x4b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x1c, 0x0a, + 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x44, 0x12, 0x10, 0x0a, 0x03, 0x75, + 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1f, 0x0a, + 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x70, + 0x62, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1a, + 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, + 0x7a, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x18, + 0x0a, 0x07, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x07, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x22, 0x96, 0x02, 0x0a, 0x0b, 0x47, 0x6f, 0x73, + 0x73, 0x69, 0x70, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x2d, 0x0a, 0x0a, 0x6c, 0x61, 0x73, 0x74, + 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, + 0x62, 0x2e, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x09, 0x6c, 0x61, + 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x30, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x62, 0x2e, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x09, + 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x2b, 0x0a, 0x09, 0x73, 0x74, 0x61, + 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, + 0x62, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x52, 0x09, 0x73, 0x74, 0x61, + 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x12, 0x33, 0x0a, 0x06, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, + 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x6f, 0x73, 0x73, + 0x69, 0x70, 0x53, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x52, 0x06, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x1a, 0x44, 0x0a, 0x0b, 0x43, + 0x68, 0x65, 0x63, 0x6b, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1f, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x70, 0x62, + 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x22, 0x5f, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x24, 0x0a, 0x05, 0x73, 0x74, + 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x53, + 0x68, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x12, 0x30, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x70, 0x62, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x69, + 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x22, 0x9a, 0x01, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x53, 0x69, 0x67, 0x6e, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, + 0x69, 0x67, 0x6e, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x69, 0x67, + 0x6e, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, + 0x75, 0x6c, 0x74, 0x69, 0x48, 0x61, 0x73, 0x68, 0x54, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0d, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x48, 0x61, 0x73, 0x68, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, + 0xbf, 0x01, 0x0a, 0x09, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x12, 0x1a, 0x0a, + 0x08, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x08, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2b, 0x0a, 0x09, 0x72, 0x65, 0x64, + 0x69, 0x72, 0x65, 0x63, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, + 0x62, 0x2e, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x73, 0x52, 0x09, 0x72, 0x65, 0x64, + 0x69, 0x72, 0x65, 0x63, 0x74, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x61, 0x63, 0x68, 0x65, 0x5f, + 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x63, 0x61, 0x63, 0x68, + 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x70, 0x75, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x03, 0x63, 0x70, 0x75, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x61, 0x6d, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x72, 0x61, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x68, 0x64, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x68, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x70, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x70, 0x74, 0x69, 0x6d, + 0x65, 0x22, 0x33, 0x0a, 0x09, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x73, 0x12, 0x12, + 0x0a, 0x04, 0x73, 0x6f, 0x66, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x6f, + 0x66, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x04, 0x68, 0x61, 0x72, 0x64, 0x2a, 0x37, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, + 0x06, 0x0a, 0x02, 0x4e, 0x41, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x47, 0x52, 0x41, 0x59, 0x10, + 0x01, 0x12, 0x09, 0x0a, 0x05, 0x47, 0x52, 0x45, 0x45, 0x4e, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, + 0x42, 0x4c, 0x55, 0x45, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x52, 0x45, 0x44, 0x10, 0x04, 0x42, + 0x05, 0x5a, 0x03, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var (