Skip to content

Commit 6d8ea7f

Browse files
authored
update docs and tests (#620)
* update README * add md files * update tests * fix scrips
1 parent 583e6b9 commit 6d8ea7f

File tree

9 files changed

+96
-38
lines changed

9 files changed

+96
-38
lines changed

CONTRIBUTING.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Contributing
2+
3+
We are always glad to receive contribution to the development of our project from the community!
4+
5+
## Issues
6+
7+
If you find a bug or want to suggest an improvement to support some new functionality,
8+
create an issue in the repository.
9+
10+
### Issue must include the following information:
11+
12+
- **Title**. Come up with a title that concisely describes the task.
13+
14+
- **Description**. Describe the issue in as much detail as possible. If you want to implement new functionality,
15+
describe why it is useful and how it will affect the project's codebase.
16+
17+
- **Code reference**. If this is a bug, be sure to attach the code where the error occurs and the text of the error.
18+
19+
- **Steps to reproduce**. If this is a bug, describe the steps to reproduce the bug and in what case it occurs
20+
(here it is also advisable to add the code that you run).
21+
22+
- **Labels**. Add the labels that describe the issue. Please refer to the
23+
[label list](https://docs.github.com/en/issues/using-labels-and-milestones-to-track-work/managing-labels#about-default-labels)
24+
to learn more about labels.
25+
26+
## Pull requests
27+
28+
> Before creating a pull request, make sure there is an issue corresponding to your changes. If there isn't one,
29+
> [create one first](#issues).
30+
31+
If you want to implement a feature or fix a bug, fork this repository from the `master` and after all the changes
32+
[create a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork)
33+
to the `master` branch. Don't forget to run automated tests locally before creating a PR.
34+
35+
### Pull request must include the following information:
36+
37+
- **Title**. The pull request should be named after the issue number as follows: "Issue <ISSUE_NUMBER>"
38+
39+
- **Description**. Briefly describe the feature or fix that was made.
40+
41+
- **Changes**. Describe the main changes made in the codebase. It is advisable to insert links to the code for
42+
greater clarity.
43+
44+
- **Interface changes**. Describe how the external interface has changed. It is advisable to insert links to
45+
the code for greater clarity.

README.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ can be set via environment variables or command line parameters see [table
7171
below](#table_conf). Use `--config` parameter with any command to set configuration file name. By default daemon
7272
use configuration file in JSON format `snetd.config.json` but other formats are
7373
also supported via [Viper](https://github.com/spf13/viper). Use `init-full` or `init`
74-
command to save configuration file with default values. The following configuration properties can be set using a configuration file.
74+
command to save configuration file with default values. The following configuration properties can be set using a
75+
configuration file.
7576

7677
### Main properties <a name="main_properties"></a>
7778

@@ -125,21 +126,25 @@ These parameters are needed if you specified free_calls in the service metadata.
125126

126127
* **private_key_for_free_calls** (required) —
127128
The private key is used to sign authorization tokens for free calls. This address is NOT required to have any tokens.
128-
129-
⚠️ This private key must correspond to the public address specified in your service_metadata.json under the free_calls.public_key field.
130129

131-
132-
* **trusted_free_call_signers** (optional, default SingularityNET addresses) — A list of trusted public addresses that are allowed to issue free call tokens on your behalf (e.g. trusted centralized backends or marketplaces).
130+
⚠️ This private key must correspond to the public address specified in your service_metadata.json under the
131+
free_calls.public_key field.
133132

134-
⚠️ If this field is left empty, free calls will not work via the SingularityNET Marketplace, but will still be available for clients using the Web3 approach (e.g., via SDKs).
133+
134+
* **trusted_free_call_signers** (optional, default SingularityNET addresses) — A list of trusted public addresses that
135+
are allowed to issue free call tokens on your behalf (e.g. trusted centralized backends or marketplaces).
136+
137+
⚠️ If this field is left empty, free calls will not work via the SingularityNET Marketplace, but will still be
138+
available for clients using the Web3 approach (e.g., via SDKs).
135139

136140
```json
137141
"trusted_free_call_signers": [
138142
"0x7DF35C98f41F3Af0df1dc4c7F7D4C19a71Dd059F",
139143
"0x3Bb9b2499c283cec176e7C707Ecb495B7a961ebf" ]
140144
```
141145

142-
* **min_balance_for_free_call** (optional, default 10) — The minimum token (FET) balance (in whole tokens) required on the user's wallet to be eligible for free calls (Web3-based flow).
146+
* **min_balance_for_free_call** (optional, default 10) — The minimum token (FET) balance (in whole tokens) required on
147+
the user's wallet to be eligible for free calls (Web3-based flow).
143148
```json
144149
"min_balance_for_free_call": "1"
145150
```
@@ -223,6 +228,14 @@ This options are less frequently needed.
223228
* **metering_endpoint** (optional; only applies if `metering_enabled` is set to true) —
224229
Needs to be a vaild url where the request and response stats are published as part of Metering
225230

231+
* **private_key_for_metering** (optional; only applies if `metering_enabled` is set to true)
232+
This is used for authentication between daemon and the metering service in the context publishing stats, Even the
233+
latest Channel Status is published, this way the offline channel state balance can also be tracked.
234+
Daemon will send a signature signed by this private key, metering service will already have the public key
235+
corresponding
236+
to this Daemon, metering service will ensure that the signer it receives matches the public key configured at its end.
237+
This is mandatory only when metering is enabled.
238+
226239
* **ssl_cert** (optional; default: `""`) —
227240
path to certificate to use for SSL.
228241

@@ -238,14 +251,6 @@ This options are less frequently needed.
238251
* **payment_channel_storage_server** (optional) —
239252
see [etcd server configuration](./etcddb#etcd-server-configuration)
240253

241-
* **pvt_key_for_metering** (optional;only applies if `metering_enabled` is set to true)
242-
This is used for authentication between daemon and the metering service in the context publishing stats, Even the
243-
latest Channel Status is published, this way the offline channel state balance can also be tracked.
244-
Daemon will send a signature signed by this private key, metering service will already have the public key
245-
corresponding
246-
to this Daemon, metering service will ensure that the signer it receives matches the public key configured at its end.
247-
This is mandatory only when metering is enabled.
248-
249254
* **rate_limit_per_minute** (optional; default: `Infinity`) —
250255
see [rate limiting configuration](./ratelimit/README.md)
251256

SECURITY.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Reporting Security Vulnerability
2+
3+
The SingularityNET team and community appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.
4+
5+
Only latest release version is supported. Ensure that you tested latest version before reporting vulnerability.
6+
7+
If you find a bug or have a question, you are free to open an issue. If you have a security related question or want to report a security vulnerability, please send it to [security@singualritynet.io](mailto:security@singualritynet.io).

config/version_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func Test_getBuildTime(t *testing.T) {
5454
}
5555

5656
func TestCheckVersionOfDaemon(t *testing.T) {
57-
versionTag = "v5.1.2"
57+
versionTag = "not-latest"
5858
message, err := CheckVersionOfDaemon()
5959
assert.NotNil(t, err)
6060
assert.Contains(t, err.Error(), "there is a newer version of the Daemon")

scripts/build

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ fi
3838
CGO_ENABLED=0 GOOS=$1 GOARCH=$2 go build -ldflags "
3939
-s -w
4040
-X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=ignore
41-
-X github.com/singnet/snet-daemon/v5/config.sha1Revision=$githash
42-
-X github.com/singnet/snet-daemon/v5/config.versionTag=$3
43-
-X github.com/singnet/snet-daemon/v5/config.buildTime=$now
44-
-X 'github.com/singnet/snet-daemon/v5/config.networkIdNameMapping=$networkJson'
41+
-X github.com/singnet/snet-daemon/v6/config.sha1Revision=$githash
42+
-X github.com/singnet/snet-daemon/v6/config.versionTag=$3
43+
-X github.com/singnet/snet-daemon/v6/config.buildTime=$now
44+
-X 'github.com/singnet/snet-daemon/v6/config.networkIdNameMapping=$networkJson'
4545
" -o build/"$buildname" snetd/main.go
4646
popd
4747

scripts/powershell/build.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if ($args.Count -lt 3)
1919

2020
$GOOS = $args[0] # linux
2121
$GOARCH = $args[1] # amd64
22-
$Version = $args[2] # v5.1.2
22+
$Version = $args[2] # v6.0.0
2323

2424
# change directory
2525
Push-Location $ParentPath
@@ -63,10 +63,10 @@ if ($GOOS -eq "windows")
6363
$Env:CGO_ENABLED = 0; $Env:GOOS = $GOOS; $Env:GOARCH = $GOARCH; go build -ldflags "
6464
-s -w
6565
-X google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=ignore
66-
-X github.com/singnet/snet-daemon/v5/config.sha1Revision=$GitHash
67-
-X github.com/singnet/snet-daemon/v5/config.versionTag=$Version
68-
-X github.com/singnet/snet-daemon/v5/config.buildTime=$Now
69-
-X 'github.com/singnet/snet-daemon/v5/config.networkIdNameMapping=$NetworkJson'" -o (Join-Path $BuildDirectory $BuildName) snetd/main.go
66+
-X github.com/singnet/snet-daemon/v6/config.sha1Revision=$GitHash
67+
-X github.com/singnet/snet-daemon/v6/config.versionTag=$Version
68+
-X github.com/singnet/snet-daemon/v6/config.buildTime=$Now
69+
-X 'github.com/singnet/snet-daemon/v6/config.networkIdNameMapping=$NetworkJson'" -o (Join-Path $BuildDirectory $BuildName) snetd/main.go
7070

7171
# return to previous directory
7272
Pop-Location

training/service_test.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,11 @@ func (suite *DaemonServiceSuite) createAdditionalTestModel(modelName string, aut
388388
}
389389

390390
func (suite *DaemonServiceSuite) TestDaemonService_GetModel() {
391-
testAuthCreads := createTestAuthDetails(suite.currentBlock, "get_model")
392-
badTestAuthCreads := creatBadTestAuthDetails(suite.currentBlock)
391+
suite.currentBlock, _ = suite.blockchain.CurrentBlock() // update block
392+
testAuthCreds := createTestAuthDetails(suite.currentBlock, "get_model")
393+
badTestAuthCreds := creatBadTestAuthDetails(suite.currentBlock)
393394

394-
// check without request
395+
// check without a request
395396
response1, err := suite.daemonService.GetModel(context.WithValue(context.Background(), "method", "get_model"), nil)
396397
assert.ErrorContains(suite.T(), err, ErrNoAuthorization.Error())
397398
assert.Equal(suite.T(), Status_ERRORED, response1.Status)
@@ -407,7 +408,7 @@ func (suite *DaemonServiceSuite) TestDaemonService_GetModel() {
407408

408409
// check with bad auth
409410
request3 := &CommonRequest{
410-
Authorization: badTestAuthCreads,
411+
Authorization: badTestAuthCreds,
411412
ModelId: "test_2_no_access",
412413
}
413414
response3, err := suite.daemonService.GetModel(context.WithValue(context.Background(), "method", "get_model"), request3)
@@ -416,7 +417,7 @@ func (suite *DaemonServiceSuite) TestDaemonService_GetModel() {
416417

417418
// check modelId is not empty string
418419
request4 := &CommonRequest{
419-
Authorization: testAuthCreads,
420+
Authorization: testAuthCreds,
420421
ModelId: "",
421422
}
422423
response4, err := suite.daemonService.GetModel(context.WithValue(context.Background(), "method", "get_model"), request4)
@@ -425,29 +426,29 @@ func (suite *DaemonServiceSuite) TestDaemonService_GetModel() {
425426
assert.Equal(suite.T(), Status_ERRORED, response4.Status)
426427

427428
b, _ := suite.blockchain.CurrentBlock()
428-
testAuthCreads = createTestAuthDetails(b, "get_model")
429+
testAuthCreds = createTestAuthDetails(b, "get_model")
429430
// check without access to model
430431
request5 := &CommonRequest{
431-
Authorization: testAuthCreads,
432+
Authorization: testAuthCreds,
432433
ModelId: "test_2_no_access",
433434
}
434435
response5, err := suite.daemonService.GetModel(context.WithValue(context.Background(), "method", "get_model"), request5)
435436
assert.ErrorContains(suite.T(), err, ErrAccessToModel.Error())
436437
assert.Equal(suite.T(), &ModelResponse{}, response5)
437438

438-
// check access to public model
439+
// check access to the public model
439440
request6 := &CommonRequest{
440-
Authorization: testAuthCreads,
441+
Authorization: testAuthCreds,
441442
ModelId: "test_1",
442443
}
443444
response6, err := suite.daemonService.GetModel(context.WithValue(context.Background(), "method", "get_model"), request6)
444445
assert.Nil(suite.T(), err)
445446
assert.NotEmpty(suite.T(), response6)
446447
assert.Equal(suite.T(), true, response6.IsPublic)
447448

448-
//check access to non public model
449+
//check access to the non-public model
449450
request7 := &CommonRequest{
450-
Authorization: testAuthCreads,
451+
Authorization: testAuthCreds,
451452
ModelId: "test_3",
452453
}
453454
response7, err := suite.daemonService.GetModel(context.WithValue(context.Background(), "method", "get_model"), request7)

training/training.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
syntax = "proto3";
22
import "google/protobuf/descriptor.proto"; // Required for indicators to work
33
package training;
4-
option go_package = "github.com/singnet/snet-daemon/v5/training";
4+
option go_package = "github.com/singnet/snet-daemon/v6/training";
55

66
// Methods that the service provider must implement
77
service Model {

training/training_daemon.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "google/protobuf/descriptor.proto"; // Required for indicators to work
55
import "google/protobuf/struct.proto"; // Required for google.protobuf.ListValue
66
import "training.proto";
77
import "google/protobuf/empty.proto";
8-
option go_package = "github.com/singnet/snet-daemon/v5/training";
8+
option go_package = "github.com/singnet/snet-daemon/v6/training";
99

1010
message AuthorizationDetails {
1111
// Check for relevance within a range of +/- N blocks

0 commit comments

Comments
 (0)