Skip to content

Commit

Permalink
Training improvements, refactoring and updating libraries (#576)
Browse files Browse the repository at this point in the history
* Support for both http and https connections

* added back the auth checks

* Changed the delimiter of the Keys to accommodate underscore in names

* removed the typo

* Corrected the response being sent back

* Error handling

* Added Status in Model Detail

* removed unwanted debug

* Support for non block chain mode off and No model Server

* corrected the data stored for easier viewing of information

* support model server on blockchain disabled mode

* Removed default model param , added model name

* Parse the proto and keep the trainign and pricing details in data structures

* removed the debug typo

* removed bad logging and bug fix for description

* Support for Goerli Network

* Support for Goerli Network

* trying 17.0

* trying 17.0

* added dependency

* for running go.mod file to resolve dependencies:

* revert back to 15.0

* revert back to 15.0

* update tools and libs

* fix proto

* add service type: http

* fix: remove body

* fix

* add grpc calc sizing bytes

* refactor & update libraries

* merge

* update go.mod

* update go.mod and fix comments

* update training, fixes and refactor (#5)

* support for both HTTP and HTTPS connections
* added back the auth checks
* changed the delimiter of the Keys to accommodate underscore in names
* removed the typo
* added Status in Model Detail
* removed unwanted debug
* support for non blockchain mode off and No model Server
* corrected the data stored for easier viewing of information
* support model server on blockchain disabled mode
* removed default model param, added model name
* parse the proto and keep the training and pricing details in data structures
* removed the debug typo
* removed bad logging and bug fix for description
* support for new networks
* refactor & update libraries
* update go.mod and fix comments

---------

Co-authored-by: anandrgitnirman <anand.rajamani@nirman.io>

---------

Co-authored-by: anandrgitnirman <anand.rajamani@nirman.io>
  • Loading branch information
semyon-dev and anandrgitnirman committed Jan 15, 2024
1 parent 69de53a commit 406ed9c
Show file tree
Hide file tree
Showing 52 changed files with 2,683 additions and 1,165 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ jobs:
name: Install dependencies
command: |
# install protobuf
sudo apt-get update
sudo apt-get install protobuf-compiler
- run:
name: Run install script
command: ./scripts/install
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ blockchain/singularity_net_token.go

# etcd server temporary directories
storage-*
*.pem
*log
data.etcd/

14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ deploying SingularityNET services using SingularityNET Daemon should install the

### Prerequisites

* [Go 1.15+](https://golang.org/dl/)
* [Go 1.21+](https://golang.org/dl/)
* [Node 8+ w/npm](https://nodejs.org/en/download/)

### Dependencies
Expand Down Expand Up @@ -145,6 +145,18 @@ time.
Name of the network to be used for Daemon possible values are one of (kovan,ropsten,main,local or rinkeby).
Daemon will automatically read the Registry address associated with this network For local network ( you can also specify the registry address manually),see the blockchain_network_config.json

* **daemon_type** (required;) -
Defines the type of service. Available values :`grpc, jsonrpc, http, process`.

* **service_credentials** (optional, if daemon_type = http):
Array of credentials, example:
```
[{"key": "X-Banana-API-Key",
"value": "546bd7d4-d3e1-46ba-b752-bc45e4dc5b39",
"location": "header"}]
```
Location can be: query or header

* **daemon_end_point** (required;) -
Defines the ip and the port on which the daemon listens to.
format is :`<host>:<port>`.
Expand Down
16 changes: 7 additions & 9 deletions authutils/auth_service.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// authutils package provides functions for all authentication and singature validation related operations
// authutils package provides functions for all authentication and singature validation related operations
package authutils

import (
Expand Down Expand Up @@ -70,7 +70,7 @@ func VerifySigner(message []byte, signature []byte, signer common.Address) error
return fmt.Errorf("Incorrect signer.")
}

//Check if the block number passed is not more +- 5 from the latest block number on chain
// Check if the block number passed is not more +- 5 from the latest block number on chain
func CompareWithLatestBlockNumber(blockNumberPassed *big.Int) error {
latestBlockNumber, err := CurrentBlock()
if err != nil {
Expand All @@ -83,20 +83,20 @@ func CompareWithLatestBlockNumber(blockNumberPassed *big.Int) error {
return nil
}

//Check if the block number ( date on which the token was issued is not more than 1 month)
// Check if the block number ( date on which the token was issued is not more than 1 month)
func CheckIfTokenHasExpired(expiredBlock *big.Int) error {
currentBlockNumber, err := CurrentBlock()
if err != nil {
return err
}

if expiredBlock.Cmp(currentBlockNumber) < 0 {
if expiredBlock.Cmp(currentBlockNumber) < 0 {
return fmt.Errorf("authentication failed as the Free Call Token passed has expired")
}
return nil
}

//Get the current block number from on chain
// Get the current block number from on chain
func CurrentBlock() (*big.Int, error) {
if ethClient, err := blockchain.GetEthereumClient(); err != nil {
return nil, err
Expand All @@ -111,7 +111,7 @@ func CurrentBlock() (*big.Int, error) {
}
}

//Check if the payment address/signer passed matches to what is present in the metadata
// Check if the payment address/signer passed matches to what is present in the metadata
func VerifyAddress(address common.Address, otherAddress common.Address) error {
isSameAddress := otherAddress == address
if !isSameAddress {
Expand All @@ -120,8 +120,6 @@ func VerifyAddress(address common.Address, otherAddress common.Address) error {
return nil
}



func GetSignature(message []byte, privateKey *ecdsa.PrivateKey) (signature []byte) {
hash := crypto.Keccak256(
blockchain.HashPrefix32Bytes,
Expand All @@ -134,4 +132,4 @@ func GetSignature(message []byte, privateKey *ecdsa.PrivateKey) (signature []byt
}

return signature
}
}
6 changes: 2 additions & 4 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:generate nodejs ../resources/blockchain/scripts/generateAbi.js --contract-package singularitynet-platform-contracts --contract-name MultiPartyEscrow --go-package blockchain --output-file multi_party_escrow.go
//go:generate nodejs ../resources/blockchain/scripts/generateAbi.js --contract-package singularitynet-platform-contracts --contract-name Registry --go-package blockchain --output-file registry.go
//go:generate node ../resources/blockchain/scripts/generateAbi.js --contract-package singularitynet-platform-contracts --contract-name MultiPartyEscrow --go-package blockchain --output-file multi_party_escrow.go
//go:generate node ../resources/blockchain/scripts/generateAbi.js --contract-package singularitynet-platform-contracts --contract-name Registry --go-package blockchain --output-file registry.go
package blockchain

import (
Expand Down Expand Up @@ -79,8 +79,6 @@ func NewProcessor(metadata *ServiceMetadata) (Processor, error) {
return crypto.Keccak256(HashPrefix32Bytes, crypto.Keccak256(i))
}



return p, nil
}

Expand Down
2 changes: 1 addition & 1 deletion blockchain/ethereum_test_util.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:generate nodejs ../resources/blockchain/scripts/generateAbi.js --contract-package singularitynet-token-contracts --contract-name SingularityNetToken --go-package blockchain --output-file singularity_net_token.go
//go:generate node ../resources/blockchain/scripts/generateAbi.js --contract-package singularitynet-token-contracts --contract-name SingularityNetToken --go-package blockchain --output-file singularity_net_token.go

package blockchain

Expand Down
Loading

0 comments on commit 406ed9c

Please sign in to comment.