Skip to content

Commit 68d0de4

Browse files
Merge 08a877c into 4580ae4
2 parents 4580ae4 + 08a877c commit 68d0de4

File tree

565 files changed

+28604
-8000
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

565 files changed

+28604
-8000
lines changed

.github/workflows/build_and_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
runs-on: ${{ matrix.runs-on }}
1616
name: Build
1717
steps:
18-
- name: Set up Go 1.17.6
18+
- name: Set up Go 1.20.5
1919
uses: actions/setup-go@v3
2020
with:
21-
go-version: 1.17.6
21+
go-version: 1.20.5
2222
id: go
2323

2424
- name: Check out code into the Go module directory

.github/workflows/check-cli-md.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Check CLI.md files
2+
3+
on:
4+
pull_request:
5+
branches: [ master, rc/*, feat/* ]
6+
types: [opened, ready_for_review]
7+
push:
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
strategy:
13+
matrix:
14+
runs-on: [ubuntu-latest]
15+
runs-on: ${{ matrix.runs-on }}
16+
name: Check CLI.md
17+
steps:
18+
- name: Set up Go 1.20.5
19+
uses: actions/setup-go@v3
20+
with:
21+
go-version: 1.20.5
22+
id: go
23+
24+
- name: Check out code into the Go module directory
25+
uses: actions/checkout@v3
26+
27+
- name: Get dependencies
28+
run: |
29+
go get -v -t -d ./...
30+
if [ -f Gopkg.toml ]; then
31+
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
32+
dep ensure
33+
fi
34+
- name: Check
35+
run: |
36+
make check-cli-md

.github/workflows/code-coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
runs-on: ${{ matrix.runs-on }}
1818
name: Build
1919
steps:
20-
- name: Set up Go 1.17.6
20+
- name: Set up Go 1.20.5
2121
uses: actions/setup-go@v3
2222
with:
23-
go-version: 1.17.6
23+
go-version: 1.20.5
2424
id: go
2525

2626
- name: Check out code into the Go module directory

.github/workflows/create_release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
runs-on: ${{ matrix.runs-on }}
2020
name: Build
2121
steps:
22-
- name: Set up Go 1.17.6
22+
- name: Set up Go 1.20.5
2323
uses: actions/setup-go@v3
2424
with:
25-
go-version: 1.17.6
25+
go-version: 1.20.5
2626
id: go
2727

2828
- name: Check out code into the Go module directory

.github/workflows/deploy-docker.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ jobs:
1616
steps:
1717
- uses: actions/setup-go@v3
1818
with:
19-
go-version: 1.17.6
19+
go-version: 1.20.5
2020
- uses: actions/checkout@v3
2121
- name: golangci-lint
2222
uses: golangci/golangci-lint-action@v3
2323
with:
2424
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
25-
version: v1.45.2
25+
version: v1.53.2
2626

2727
# Optional: working directory, useful for monorepos
2828
# working-directory: somedir

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ cmd/node/stats/**
3232

3333
# Local overrides for testnet scripts
3434
scripts/testnet/local.sh
35+
36+
# Autogenerated test files
37+
integrationTests/multiShard/endOfEpoch/startInEpoch/Static

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,18 @@ lint: lint-install run-lint
9191

9292
install-proto:
9393
bash ./install-proto.sh
94+
95+
check-cli-md:
96+
cd ./cmd/assessment && go build
97+
cd ./cmd/keygenerator && go build
98+
cd ./cmd/logviewer && go build
99+
cd ./cmd/node && go build
100+
cd ./cmd/seednode && go build
101+
cd ./cmd/termui && go build
102+
cd ./cmd && bash ./CLI.md.sh
103+
@status=$$(git status --porcelain | grep CLI); \
104+
if [ ! -z "$${status}" ]; \
105+
then \
106+
echo "Error - please update all CLI.md files by running the 'cli-docs' or 'check-cli-md' from Makefile!"; \
107+
exit 1; \
108+
fi

api/errors/errors.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,9 @@ var ErrInvalidRole = errors.New("invalid role")
165165

166166
// ErrIsDataTrieMigrated signals that an error occurred while trying to verify the migration status of the data trie
167167
var ErrIsDataTrieMigrated = errors.New("could not verify the migration status of the data trie")
168+
169+
// ErrGetEligibleManagedKeys signals that an error occurred while getting the eligible managed keys
170+
var ErrGetEligibleManagedKeys = errors.New("error getting the eligible managed keys")
171+
172+
// ErrGetWaitingManagedKeys signals that an error occurred while getting the waiting managed keys
173+
var ErrGetWaitingManagedKeys = errors.New("error getting the waiting managed keys")

api/groups/nodeGroup.go

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ const (
2727
epochStartDataForEpoch = "/epoch-start/:epoch"
2828
bootstrapStatusPath = "/bootstrapstatus"
2929
connectedPeersRatingsPath = "/connected-peers-ratings"
30+
managedKeys = "/managed-keys"
31+
managedKeysCount = "/managed-keys/count"
32+
eligibleManagedKeys = "/managed-keys/eligible"
33+
waitingManagedKeys = "/managed-keys/waiting"
3034
)
3135

3236
// nodeFacadeHandler defines the methods to be implemented by a facade for node requests
@@ -36,7 +40,11 @@ type nodeFacadeHandler interface {
3640
GetQueryHandler(name string) (debug.QueryHandler, error)
3741
GetEpochStartDataAPI(epoch uint32) (*common.EpochStartDataAPI, error)
3842
GetPeerInfo(pid string) ([]core.QueryP2PPeerInfo, error)
39-
GetConnectedPeersRatings() string
43+
GetConnectedPeersRatingsOnMainNetwork() (string, error)
44+
GetManagedKeysCount() int
45+
GetManagedKeys() []string
46+
GetEligibleManagedKeys() ([]string, error)
47+
GetWaitingManagedKeys() ([]string, error)
4048
IsInterfaceNil() bool
4149
}
4250

@@ -109,6 +117,26 @@ func NewNodeGroup(facade nodeFacadeHandler) (*nodeGroup, error) {
109117
Method: http.MethodGet,
110118
Handler: ng.connectedPeersRatings,
111119
},
120+
{
121+
Path: managedKeysCount,
122+
Method: http.MethodGet,
123+
Handler: ng.managedKeysCount,
124+
},
125+
{
126+
Path: managedKeys,
127+
Method: http.MethodGet,
128+
Handler: ng.managedKeys,
129+
},
130+
{
131+
Path: eligibleManagedKeys,
132+
Method: http.MethodGet,
133+
Handler: ng.managedKeysEligible,
134+
},
135+
{
136+
Path: waitingManagedKeys,
137+
Method: http.MethodGet,
138+
Handler: ng.managedKeysWaiting,
139+
},
112140
}
113141
ng.endpoints = endpoints
114142

@@ -327,7 +355,19 @@ func (ng *nodeGroup) bootstrapMetrics(c *gin.Context) {
327355

328356
// connectedPeersRatings returns the node's connected peers ratings
329357
func (ng *nodeGroup) connectedPeersRatings(c *gin.Context) {
330-
ratings := ng.getFacade().GetConnectedPeersRatings()
358+
ratings, err := ng.getFacade().GetConnectedPeersRatingsOnMainNetwork()
359+
if err != nil {
360+
c.JSON(
361+
http.StatusInternalServerError,
362+
shared.GenericAPIResponse{
363+
Data: nil,
364+
Error: err.Error(),
365+
Code: shared.ReturnCodeInternalError,
366+
},
367+
)
368+
return
369+
}
370+
331371
c.JSON(
332372
http.StatusOK,
333373
shared.GenericAPIResponse{
@@ -338,6 +378,68 @@ func (ng *nodeGroup) connectedPeersRatings(c *gin.Context) {
338378
)
339379
}
340380

381+
// managedKeysCount returns the node's number of managed keys
382+
func (ng *nodeGroup) managedKeysCount(c *gin.Context) {
383+
count := ng.getFacade().GetManagedKeysCount()
384+
c.JSON(
385+
http.StatusOK,
386+
shared.GenericAPIResponse{
387+
Data: gin.H{"count": count},
388+
Error: "",
389+
Code: shared.ReturnCodeSuccess,
390+
},
391+
)
392+
}
393+
394+
// managedKeys returns all keys managed by the current node
395+
func (ng *nodeGroup) managedKeys(c *gin.Context) {
396+
keys := ng.getFacade().GetManagedKeys()
397+
c.JSON(
398+
http.StatusOK,
399+
shared.GenericAPIResponse{
400+
Data: gin.H{"managedKeys": keys},
401+
Error: "",
402+
Code: shared.ReturnCodeSuccess,
403+
},
404+
)
405+
}
406+
407+
// managedKeysEligible returns the node's eligible managed keys
408+
func (ng *nodeGroup) managedKeysEligible(c *gin.Context) {
409+
keys, err := ng.getFacade().GetEligibleManagedKeys()
410+
if err != nil {
411+
shared.RespondWithInternalError(c, errors.ErrGetEligibleManagedKeys, err)
412+
return
413+
}
414+
415+
c.JSON(
416+
http.StatusOK,
417+
shared.GenericAPIResponse{
418+
Data: gin.H{"eligibleKeys": keys},
419+
Error: "",
420+
Code: shared.ReturnCodeSuccess,
421+
},
422+
)
423+
}
424+
425+
// managedKeysWaiting returns the node's waiting managed keys
426+
func (ng *nodeGroup) managedKeysWaiting(c *gin.Context) {
427+
keys, err := ng.getFacade().GetWaitingManagedKeys()
428+
if err != nil {
429+
shared.RespondWithInternalError(c, errors.ErrGetWaitingManagedKeys, err)
430+
return
431+
}
432+
433+
c.JSON(
434+
http.StatusOK,
435+
shared.GenericAPIResponse{
436+
Data: gin.H{"waitingKeys": keys},
437+
Error: "",
438+
Code: shared.ReturnCodeSuccess,
439+
},
440+
)
441+
}
442+
341443
func (ng *nodeGroup) getFacade() nodeFacadeHandler {
342444
ng.mutFacade.RLock()
343445
defer ng.mutFacade.RUnlock()

0 commit comments

Comments
 (0)