Skip to content

Commit

Permalink
Merge pull request #153 from TimeleapLabs/develop
Browse files Browse the repository at this point in the history
v0.13
  • Loading branch information
pouya-eghbali authored Aug 27, 2024
2 parents bd242eb + 05dde8b commit 06c4999
Show file tree
Hide file tree
Showing 153 changed files with 7,628 additions and 5,073 deletions.
12 changes: 7 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ linters:
- ineffassign
- staticcheck
- typecheck
- dupl
- unused
- asasalint
- asciicheck
Expand Down Expand Up @@ -203,16 +204,17 @@ issues:
- funlen
- forbidigo
- gochecknoinits
- path: "ent"
- dupl
- path: ".generated.go"
linters:
- gomnd
- forbidigo
- path: "config"
- typecheck
- path: "_mock.go"
linters:
- gomnd
- staticcheck
- path: "_test\\.go"
linters:
- bodyclose
- exhaustive
- funlen
- goconst
- gocognit
Expand Down
78 changes: 76 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,81 @@
## v0.12.0
## v0.13.0 (2024-08-27)

### ✨ Features

- add optional tls support
- **func-config**: add config struct for registering functions >>> ⏰ 3h
- **rpc**: refactor rpc service to accept unix socket >>> ⏰ 6h
- **rpc**: add comments and re arrange codes >>> ⏰ 6h
- **rpc-runtime**: add some runtime and refactor rpc service >>> ⏰ 6h
- **handlers**: refactoring rpc handlers >>> ⏰ 4h
- **bls-test**: add unittest for bls and move bls sign to identity …
- **bls-test**: add unittest for bls and move bls sign to identity method >>> ⏰ 1.5h
- add the new schnorr based pos contract
- **identity**: add flag to get permission to write to secret file,…
- **identity**: add flag to get permission to write to secret file, to prevent losing keys. and some refactor >>> ⏰ 3h
- **identity**: merge and add unit test for identity >>> ⏰ 1h

### 🐛🚑️ Fixes

- **concept**: remove unneccery file >>> ⏰ 5m
- fix rpc issues
- small bug fixes
- small bug fixes with rpc
- filter out unavailable workers
- **lint**: fix linters >>> ⏰ 5m
- **eth-rpc**: fix problem of race condition for client list >>> ⏰ 1h
- **eth-rpc**: rename isExist to isFound >>> ⏰ 2m
- **eth-rpc**: fix problem of race condition for client list >>> ⏰ 1h
- **linters**: do linter fixes >>> ⏰ 2m
- **identity**: rename export signer function name >>> ⏰ 2m
- **identity**: rename export signer function name >>> ⏰ 2m
- **evmlog**: fix mutex problem >>> ⏰ 30m

### fix

- display help correctly when no arguments are entered

### ✅🤡🧪 Tests

- fix mock modules
- fix mock contracts

### 🎨🏗️ Style & Architecture

- **linter**: fix linters problems >>> ⏰ 3h
- fix lint

### 🔐🚧📈✏️ 💩👽️🍻💬🥚🌱🚩🥅🩺 Others

- add unchained AI plugins

### 🚨 Linting

- fix go mod tidy

## v0.12.0 (2024-04-25)

### ✨ Features

- **services**: add some tests to project >>> ⏰ 3h
- **pubsub**: ability to send messages based on channels and sub-channel subscribe >>> ⏰ 6h
- **pubsub**: add internal pubsub and lots of refactor >>> ⏰ 2d
- record consensus info on boolean records
- refactor consensus to save all signatures in db
- add slashing mechanism
- add the proof-of-stake eip712 struct type definitions and signing functions

### 🐛🚑️ Fixes

- fix identity key generation
- **flags**: make config flag unrequired >>> ⏰ 2m
- **flags**: make config flag unrequired >>> ⏰ 2m
- **correctness**: delete unused tests temprorary >>> ⏰ 2m
- **connection**: fix the problem of reconnecting to the broker >>> ⏰ 2h
- **linters**: fix linters >>> ⏰ 2m
- **models**: fix problem of deserializing sia >>> ⏰ 2h
- **badge**: move badger to services and add unit tests >>> ⏰ 30m
- **linters**: solve linters problems >>> ⏰ 1h
- **linters-services**: add a new linter and fix dup in services >>> ⏰ 30m
- **crypto**: fix linters about comments >>> ⏰ 2m
- **crypto**: fix unused assining in evm init >>> ⏰ 10m
Expand All @@ -20,8 +85,10 @@

### ♻️ Refactorings

- **ctx**: implement ctx passing through project >>> ⏰ 2h
- **services**: capsulate services using interfaces >>> ⏰ 1h
- fix debounce and pre-hook issues
- **crypto**: move etherum to crypto and refactor crypto to make a identity manager >>> ⏰ 2h
- **crypto**: move etherum to crypto and refactor crypto to make a identity manage >>> ⏰ 2h
- refactor the eip712 module to repository pattern

### feat
Expand Down Expand Up @@ -58,6 +125,8 @@

### 💚👷 CI & Build

- remove commitizen-branch
- **docker**: fix docker build
- migrate to the new org name

### 📌➕⬇️ ➖⬆️ Dependencies
Expand All @@ -66,9 +135,14 @@

### 📝💡 Documentation

- **changelog**: add changelog
- **crypto**: add some comments in crypto package >>> ⏰ 10m
- add documentation for installing pre-commit hooks

### 🚨 Linting

- fix unnecessary trailing new line

## v0.11.21 (2024-03-31)

### feat
Expand Down
7 changes: 5 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ Unchained is a distributed computation engine:

Cryptographic signatures and a proof-of-stake consensus secure all computations on Unchained.

## Running a Node
## Read More

See [QuickStart](./quickstart.md).
- [QuickStart](./quickstart.md) for running a node
- [Schema](./schema.md) of the Unchained network
- [Changelog](./CHANGELOG.md) of Unchained
- [Contributing](./CONTRIBUTING.md) to Unchained

## License

Expand Down
25 changes: 19 additions & 6 deletions cmd/handler/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package handler
import (
"github.com/TimeleapLabs/unchained/internal/app"
"github.com/TimeleapLabs/unchained/internal/config"
"github.com/TimeleapLabs/unchained/internal/log"
"github.com/TimeleapLabs/unchained/internal/utils"
"github.com/spf13/cobra"
)

Expand All @@ -12,13 +12,19 @@ var broker = &cobra.Command{
Use: "broker",
Short: "Run the Unchained client in broker mode",
Long: `Run the Unchained client in broker mode`,

PreRun: func(cmd *cobra.Command, _ []string) {
config.App.Network.CertFile = cmd.Flags().Lookup("cert-file").Value.String()
config.App.Network.KeyFile = cmd.Flags().Lookup("key-file").Value.String()
},

Run: func(_ *cobra.Command, _ []string) {
err := config.Load(config.App.System.ConfigPath, config.App.System.SecretsPath)
if err != nil {
panic(err)
}

log.Start(config.App.System.Log)
utils.SetupLogger(config.App.System.Log)
app.Broker()
},
}
Expand All @@ -30,9 +36,16 @@ func WithBrokerCmd(cmd *cobra.Command) {

func init() {
broker.Flags().StringP(
"broker",
"b",
"wss://shinobi.brokers.kenshi.io",
"Unchained broker to connect to",
"cert-file",
"C",
"",
"TLS certificate file",
)

broker.Flags().StringP(
"key-file",
"k",
"",
"TLS key file",
)
}
4 changes: 2 additions & 2 deletions cmd/handler/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package handler
import (
"github.com/TimeleapLabs/unchained/internal/app"
"github.com/TimeleapLabs/unchained/internal/config"
"github.com/TimeleapLabs/unchained/internal/log"
"github.com/TimeleapLabs/unchained/internal/utils"
"github.com/spf13/cobra"
)

Expand All @@ -24,7 +24,7 @@ var consumer = &cobra.Command{
panic(err)
}

log.Start(config.App.System.Log)
utils.SetupLogger(config.App.System.Log)
app.Consumer()
},
}
Expand Down
50 changes: 50 additions & 0 deletions cmd/handler/plugin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package handler

import (
"os"

"github.com/TimeleapLabs/unchained/cmd/handler/plugins"
"github.com/gorilla/websocket"
"github.com/spf13/cobra"
)

var conn *websocket.Conn

func Read() <-chan []byte {
out := make(chan []byte)

go func() {
for {
_, payload, err := conn.ReadMessage()
if err != nil {
panic(err)
}

out <- payload
}
}()

return out
}

// plugin represents the plugin command.
var plugin = &cobra.Command{
Use: "plugin",
Short: "Run an Unchained plugin locally",
Long: `Run an Unchained plugin locally`,

Run: func(cmd *cobra.Command, _ []string) {
os.Exit(1)
},
}

// WithPluginCmd appends the plugin command to the root command.
func WithPluginCmd(cmd *cobra.Command) {
cmd.AddCommand(plugin)
}

func init() {
plugins.WithAIPluginCmd(plugin)
plugins.WithTextToImagePluginCmd(plugin)
plugins.WithTranslatePluginCmd(plugin)
}
41 changes: 41 additions & 0 deletions cmd/handler/plugins/ai.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package plugins

import (
"log"
"os"
"os/signal"
"syscall"

"github.com/TimeleapLabs/unchained/internal/service/ai"
"github.com/spf13/cobra"
)

// worker represents the worker command.
var aiPlugin = &cobra.Command{
Use: "ai",
Short: "Start the Unchained ai server for local invocation",
Long: `Start the Unchained ai server for local invocation`,

Run: func(cmd *cobra.Command, _ []string) {
wg, cancel := ai.StartServer(cmd.Context())

// Set up signal handling
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)

go func() {
sig := <-sigChan
log.Printf("Received signal: %v. Shutting down gracefully...", sig)
cancel() // Cancel the context to stop all managed processes
}()

// Wait for all processes to finish
wg.Wait()
log.Println("All processes have been stopped.")
},
}

// WithRunCmd appends the run command to the root command.
func WithAIPluginCmd(cmd *cobra.Command) {
cmd.AddCommand(aiPlugin)
}
41 changes: 41 additions & 0 deletions cmd/handler/plugins/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package plugins

import "github.com/gorilla/websocket"

var conn *websocket.Conn
var closed = false

func Read() <-chan []byte {
out := make(chan []byte)

go func() {
for {
_, payload, err := conn.ReadMessage()
if err != nil {
if !closed {
panic(err)
}
}

out <- payload
}
}()

return out
}

func CloseSocket() {
if conn != nil {
closed = true
err := conn.WriteMessage(
websocket.CloseMessage,
websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""))
if err != nil {
return
}
err = conn.Close()
if err != nil {
return
}
}
}
Loading

0 comments on commit 06c4999

Please sign in to comment.