-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Derek Anderson <dmikey@users.noreply.github.com>
- Loading branch information
Showing
136 changed files
with
4,357 additions
and
752 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,6 @@ dist/ | |
runtime/ | ||
*.env | ||
__debug* | ||
|
||
*.exe | ||
.b7s_* | ||
*.exe | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,129 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Head Node", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}/cmd/node", | ||
"args": [ | ||
"--peer-db", | ||
"/tmp/b7s/head-peer-db", | ||
"--function-db", | ||
"/tmp/b7s/head-fdb", | ||
"--log-level", | ||
"debug", | ||
"--port", | ||
"9527", | ||
"--role", | ||
"head", | ||
"--workspace", | ||
"/tmp/debug/head", | ||
"--private-key", | ||
"${workspaceFolder}/configs/testkeys/ident1/priv.bin", | ||
"--rest-api", | ||
":8081" | ||
], | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
{ | ||
"name": "Launch Worker Node", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}/cmd/node", | ||
"args": [ | ||
"--peer-db", | ||
"/tmp/b7s/worker-peer-db", | ||
"--function-db", | ||
"/tmp/b7s/worker-fdb", | ||
"--log-level", | ||
"debug", | ||
"--port", | ||
"0", | ||
"--role", | ||
"worker", | ||
"--runtime-path", | ||
"/tmp/runtime", | ||
"--runtime-cli", | ||
"bls-runtime", | ||
"--workspace", | ||
"/tmp/debug/worker", | ||
"--private-key", | ||
"${workspaceFolder}/configs/testkeys/ident2/priv.bin", | ||
"--boot-nodes", | ||
"/ip4/0.0.0.0/tcp/9527/p2p/12D3KooWH9GerdSEroL2nqjpd2GuE5dwmqNi7uHX7FoywBdKcP4q" | ||
], | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
{ | ||
"name": "Launch Manager", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}/cmd/manager", | ||
"args": [ | ||
"-l", | ||
"3333", | ||
"--private-key", | ||
"${workspaceFolder}/configs/testkeys/ident2/priv.bin", | ||
"--allowed-peer", | ||
"QmSz8bJZjg9gWfvrJjYibo4UhSo8dXYtpNRb4kxn28SoHG" | ||
], | ||
"cwd": "${workspaceFolder}" | ||
} | ||
] | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Head Node", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}/cmd/node", | ||
"args": [ | ||
"--db", | ||
"/tmp/b7s/head-db", | ||
"--log-level", | ||
"debug", | ||
"--port", | ||
"9527", | ||
"--role", | ||
"head", | ||
"--workspace", | ||
"/tmp/debug/head", | ||
"--private-key", | ||
"${workspaceFolder}/configs/testkeys/ident1/priv.bin", | ||
"--rest-api", | ||
":8081" | ||
], | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
{ | ||
"name": "Launch Worker 1", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}/cmd/node", | ||
"args": [ | ||
"--db", | ||
"/tmp/b7s/worker1-db", | ||
"--log-level", | ||
"debug", | ||
"--port", | ||
"0", | ||
"--role", | ||
"worker", | ||
"--runtime-path", | ||
"/tmp/runtime", | ||
"--runtime-cli", | ||
"bls-runtime", | ||
"--workspace", | ||
"/tmp/debug/worker", | ||
"--private-key", | ||
"${workspaceFolder}/configs/testkeys/ident2/priv.bin", | ||
"--boot-nodes", | ||
"/ip4/0.0.0.0/tcp/9527/p2p/12D3KooWH9GerdSEroL2nqjpd2GuE5dwmqNi7uHX7FoywBdKcP4q" | ||
], | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
{ | ||
"name": "Launch Worker 2", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}/cmd/node", | ||
"args": [ | ||
"--db", | ||
"/tmp/b7s/worker2-db", | ||
"--log-level", | ||
"debug", | ||
"--port", | ||
"0", | ||
"--role", | ||
"worker", | ||
"--runtime-path", | ||
"/tmp/runtime", | ||
"--runtime-cli", | ||
"bls-runtime", | ||
"--workspace", | ||
"/tmp/debug/worker", | ||
"--private-key", | ||
"${workspaceFolder}/configs/testkeys/ident3/priv.bin", | ||
"--boot-nodes", | ||
"/ip4/0.0.0.0/tcp/9527/p2p/12D3KooWH9GerdSEroL2nqjpd2GuE5dwmqNi7uHX7FoywBdKcP4q" | ||
], | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
{ | ||
"name": "Launch Worker 3", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}/cmd/node", | ||
"args": [ | ||
"--db", | ||
"/tmp/b7s/worker3-db", | ||
"--log-level", | ||
"debug", | ||
"--port", | ||
"0", | ||
"--role", | ||
"worker", | ||
"--runtime-path", | ||
"/tmp/runtime", | ||
"--runtime-cli", | ||
"bls-runtime", | ||
"--workspace", | ||
"/tmp/debug/worker", | ||
"--private-key", | ||
"${workspaceFolder}/configs/testkeys/ident4/priv.bin", | ||
"--boot-nodes", | ||
"/ip4/0.0.0.0/tcp/9527/p2p/12D3KooWH9GerdSEroL2nqjpd2GuE5dwmqNi7uHX7FoywBdKcP4q" | ||
], | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
{ | ||
"name": "Launch Manager", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}/cmd/manager", | ||
"args": [ | ||
"-l", | ||
"3333", | ||
"--private-key", | ||
"${workspaceFolder}/configs/testkeys/ident2/priv.bin", | ||
"--allowed-peer", | ||
"QmSz8bJZjg9gWfvrJjYibo4UhSo8dXYtpNRb4kxn28SoHG" | ||
], | ||
"cwd": "${workspaceFolder}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/rs/zerolog" | ||
|
||
"github.com/blocklessnetwork/b7s/config" | ||
"github.com/blocklessnetwork/b7s/host" | ||
"github.com/blocklessnetwork/b7s/models/blockless" | ||
) | ||
|
||
func createHost(log zerolog.Logger, cfg config.Config, role blockless.NodeRole, dialbackPeers ...blockless.Peer) (*host.Host, error) { | ||
|
||
// Get the list of boot nodes addresses. | ||
bootNodes, err := getBootNodeAddresses(cfg.BootNodes) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not get boot node addresses: %w", err) | ||
} | ||
|
||
opts := []func(*host.Config){ | ||
host.WithPrivateKey(cfg.Connectivity.PrivateKey), | ||
host.WithBootNodes(bootNodes), | ||
host.WithDialBackAddress(cfg.Connectivity.DialbackAddress), | ||
host.WithDialBackPort(cfg.Connectivity.DialbackPort), | ||
host.WithDialBackWebsocketPort(cfg.Connectivity.WebsocketDialbackPort), | ||
host.WithWebsocket(cfg.Connectivity.Websocket), | ||
host.WithWebsocketPort(cfg.Connectivity.WebsocketPort), | ||
host.WithDialBackPeers(dialbackPeers), | ||
host.WithMustReachBootNodes(cfg.Connectivity.MustReachBootNodes), | ||
host.WithDisabledResourceLimits(cfg.Connectivity.DisableConnectionLimits), | ||
host.WithEnableP2PRelay(role == blockless.HeadNode), | ||
host.WithConnectionLimit(cfg.Connectivity.ConnectionCount), | ||
} | ||
|
||
// Create libp2p host. | ||
host, err := host.New(log, cfg.Connectivity.Address, cfg.Connectivity.Port, opts...) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not create host (key: '%s'): %w", cfg.Connectivity.PrivateKey, err) | ||
} | ||
|
||
return host, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.