mirror of
https://github.com/luxfi/netrunner.git
synced 2026-07-27 00:04:23 +00:00
rename: github.com/luxfi/protocol → github.com/luxfi/proto (imports + go.mod replace)
This commit is contained in:
Executable
Executable
Executable
Executable
@@ -0,0 +1,94 @@
|
||||
name: Chaos tests
|
||||
|
||||
# Runs the netrunner chaos suite against a freshly-built luxd. Gated on
|
||||
# changes to paths that affect partition / replication / bridge semantics
|
||||
# so we don't waste runners on docs-only PRs. Build tag `chaos` + env
|
||||
# `RUN_CHAOS=1` gate the tests at the Go level — without both the tests
|
||||
# are no-ops, so a passing run with neither set still proves the build
|
||||
# compiles.
|
||||
#
|
||||
# Followup (#54): once the PartitionNetwork RPC + iptables/pfctl
|
||||
# plumbing lands, this workflow will exercise real network partition
|
||||
# scenarios. Today it covers the in-memory bft messageFilter primitive
|
||||
# + the existing PauseNode (node-failure) scenarios.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'tests/**'
|
||||
- 'local/**'
|
||||
- 'server/**'
|
||||
- 'rpcpb/**'
|
||||
- 'go.mod'
|
||||
- 'go.sum'
|
||||
- '.github/workflows/chaos-test.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'tests/**'
|
||||
- 'local/**'
|
||||
- 'server/**'
|
||||
- 'rpcpb/**'
|
||||
- 'go.mod'
|
||||
- 'go.sum'
|
||||
- '.github/workflows/chaos-test.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
GOWORK: off
|
||||
CGO_ENABLED: "0"
|
||||
RUN_CHAOS: "1"
|
||||
LUXD_VERSION: "1.22.79"
|
||||
|
||||
jobs:
|
||||
chaos:
|
||||
name: Chaos suite
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout netrunner
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.26.3'
|
||||
check-latest: true
|
||||
|
||||
- name: Cache Go modules
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
~/go/pkg/mod
|
||||
key: ${{ runner.os }}-chaos-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-chaos-
|
||||
|
||||
# luxd is fetched from the luxfi/node release artifacts. The chaos
|
||||
# tests pass LUXD_PATH so netrunner-managed networks point at this
|
||||
# binary instead of trying to compile one on the fly.
|
||||
- name: Fetch luxd
|
||||
run: |
|
||||
set -e
|
||||
curl -fsSL -o /tmp/luxd.tgz \
|
||||
"https://github.com/luxfi/node/releases/download/v${LUXD_VERSION}/luxd-linux-amd64-v${LUXD_VERSION}.tar.gz"
|
||||
mkdir -p /tmp/luxd-bin
|
||||
tar -xzf /tmp/luxd.tgz -C /tmp/luxd-bin --strip-components=1
|
||||
/tmp/luxd-bin/luxd --version
|
||||
echo "LUXD_PATH=/tmp/luxd-bin/luxd" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Run chaos tests
|
||||
env:
|
||||
# Tests gated by build tag `chaos` skip themselves unless this
|
||||
# tag is set; gated by env `RUN_CHAOS=1` to also catch the
|
||||
# check inside the test bodies.
|
||||
RUN_CHAOS: "1"
|
||||
LUXD_PATH: ${{ env.LUXD_PATH }}
|
||||
run: |
|
||||
go test -tags chaos -timeout 25m -count=1 ./tests/... \
|
||||
-run "TestConsensus_|TestBridge_|TestDEX_" \
|
||||
-v
|
||||
@@ -26,7 +26,7 @@ require (
|
||||
github.com/luxfi/metric v1.5.1
|
||||
github.com/luxfi/node v1.26.2
|
||||
github.com/luxfi/p2p v1.19.2
|
||||
github.com/luxfi/protocol v0.0.3
|
||||
github.com/luxfi/proto v0.0.0-proto-rename
|
||||
github.com/luxfi/sdk v1.16.57
|
||||
github.com/luxfi/utxo v0.3.0
|
||||
github.com/luxfi/validators v1.0.0
|
||||
@@ -221,3 +221,7 @@ require (
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
)
|
||||
|
||||
// Local-dev overlay for the protocol → proto rename.
|
||||
// Strip once GitHub admin renames luxfi/protocol → luxfi/proto and a real tag exists.
|
||||
replace github.com/luxfi/proto => ../protocol
|
||||
|
||||
+3
-3
@@ -21,7 +21,7 @@ import (
|
||||
"github.com/luxfi/keys"
|
||||
|
||||
"github.com/luxfi/genesis/pkg/genesis"
|
||||
"github.com/luxfi/protocol/p/reward"
|
||||
"github.com/luxfi/proto/p/reward"
|
||||
|
||||
"github.com/luxfi/sdk/wallet/chain/x"
|
||||
"github.com/luxfi/utxo"
|
||||
@@ -40,8 +40,8 @@ import (
|
||||
"github.com/luxfi/netrunner/network"
|
||||
"github.com/luxfi/netrunner/network/node"
|
||||
"github.com/luxfi/netrunner/utils"
|
||||
"github.com/luxfi/protocol/p/signer"
|
||||
"github.com/luxfi/protocol/p/txs"
|
||||
"github.com/luxfi/proto/p/signer"
|
||||
"github.com/luxfi/proto/p/txs"
|
||||
"github.com/luxfi/sdk/admin"
|
||||
"github.com/luxfi/sdk/platformvm"
|
||||
pwallet "github.com/luxfi/sdk/wallet/chain/p"
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
"github.com/luxfi/netrunner/network"
|
||||
"github.com/luxfi/netrunner/network/node"
|
||||
"github.com/luxfi/netrunner/utils"
|
||||
"github.com/luxfi/protocol/p/signer"
|
||||
"github.com/luxfi/proto/p/signer"
|
||||
|
||||
"github.com/luxfi/address"
|
||||
luxtls "github.com/luxfi/tls"
|
||||
|
||||
+11
-8
@@ -1304,15 +1304,18 @@ func (ln *localNetwork) buildArgs(
|
||||
}
|
||||
|
||||
// Flags for Lux
|
||||
// luxd accepts --bootstrap-ips and --bootstrap-ids as separate flags
|
||||
// (no combined --bootstrap-nodes). Emit both, paired index-by-index.
|
||||
flags := map[string]string{
|
||||
config.NetworkIDKey: fmt.Sprintf("%d", ln.networkID),
|
||||
config.DataDirKey: dataDir,
|
||||
config.DBPathKey: dbDir,
|
||||
config.LogsDirKey: logsDir,
|
||||
config.PluginDirKey: pluginDir, // Always pass plugin dir for consistency
|
||||
config.HTTPPortKey: fmt.Sprintf("%d", apiPort),
|
||||
config.StakingPortKey: fmt.Sprintf("%d", p2pPort),
|
||||
config.BootstrapNodesKey: ln.bootstraps.IPsArg(),
|
||||
config.NetworkIDKey: fmt.Sprintf("%d", ln.networkID),
|
||||
config.DataDirKey: dataDir,
|
||||
config.DBPathKey: dbDir,
|
||||
config.LogsDirKey: logsDir,
|
||||
config.PluginDirKey: pluginDir, // Always pass plugin dir for consistency
|
||||
config.HTTPPortKey: fmt.Sprintf("%d", apiPort),
|
||||
config.StakingPortKey: fmt.Sprintf("%d", p2pPort),
|
||||
config.BootstrapIPsKey: ln.bootstraps.IPsArg(),
|
||||
config.BootstrapIDsKey: ln.bootstraps.IDsArg(),
|
||||
}
|
||||
|
||||
// Write staking key/cert etc. to disk so the new node can use them,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,295 +0,0 @@
|
||||
package local
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/netip"
|
||||
"time"
|
||||
|
||||
"github.com/luxfi/netrunner/api"
|
||||
"github.com/luxfi/netrunner/network/node"
|
||||
"github.com/luxfi/netrunner/network/node/status"
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/p2p/message"
|
||||
"github.com/luxfi/p2p/peer"
|
||||
"github.com/luxfi/p2p/throttling"
|
||||
"github.com/luxfi/sdk/node/consensus/networking/router"
|
||||
"github.com/luxfi/sdk/node/consensus/networking/tracker"
|
||||
"github.com/luxfi/sdk/node/consensus/validators"
|
||||
"github.com/luxfi/staking"
|
||||
"github.com/luxfi/utils"
|
||||
"github.com/luxfi/utils/constants"
|
||||
"github.com/luxfi/crypto/bls"
|
||||
luxlog "github.com/luxfi/log"
|
||||
luxmetrics "github.com/luxfi/metrics"
|
||||
"github.com/luxfi/math/meter"
|
||||
"github.com/luxfi/utils/resource"
|
||||
"github.com/luxfi/utils/set"
|
||||
"github.com/luxfi/version"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
var (
|
||||
_ getConnFunc = defaultGetConnFunc
|
||||
_ node.Node = (*localNode)(nil)
|
||||
)
|
||||
|
||||
type getConnFunc func(context.Context, node.Node) (net.Conn, error)
|
||||
|
||||
const (
|
||||
peerMsgQueueBufferSize = 1024
|
||||
peerResourceTrackerDuration = 10 * time.Second
|
||||
peerStartWaitTimeout = 30 * time.Second
|
||||
)
|
||||
|
||||
// Gives access to basic node info, and to most node apis
|
||||
type localNode struct {
|
||||
// Must be unique across all nodes in this network.
|
||||
name string
|
||||
// [nodeID] is this node's Lux Node ID.
|
||||
// Set in network.AddNode
|
||||
nodeID ids.NodeID
|
||||
// The ID of the network this node exists in
|
||||
networkID uint32
|
||||
// Allows user to make API calls to this node.
|
||||
client api.Client
|
||||
// The process running this node.
|
||||
process NodeProcess
|
||||
// The API port
|
||||
apiPort uint16
|
||||
// The P2P (staking) port
|
||||
p2pPort uint16
|
||||
// Returns a connection to this node
|
||||
getConnFunc getConnFunc
|
||||
// The data dir of the node
|
||||
dataDir string
|
||||
// The db dir of the node
|
||||
dbDir string
|
||||
// The logs dir of the node
|
||||
logsDir string
|
||||
// The plugin dir of the node
|
||||
pluginDir string
|
||||
// The node config
|
||||
config node.Config
|
||||
// The node httpHost
|
||||
httpHost string
|
||||
// maps from peer ID to peer object
|
||||
attachedPeers map[string]peer.Peer
|
||||
// signals that the process is stopped but the information is valid
|
||||
// and can be resumed
|
||||
paused bool
|
||||
}
|
||||
|
||||
func defaultGetConnFunc(ctx context.Context, node node.Node) (net.Conn, error) {
|
||||
dialer := net.Dialer{}
|
||||
return dialer.DialContext(ctx, constants.NetworkType, net.JoinHostPort(node.GetURL(), fmt.Sprintf("%d", node.GetP2PPort())))
|
||||
}
|
||||
|
||||
// AttachPeer: see Network
|
||||
func (node *localNode) AttachPeer(ctx context.Context, router router.InboundHandler) (peer.Peer, error) {
|
||||
tlsCert, err := staking.NewTLSCert()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tlsConfg := peer.TLSConfig(*tlsCert, nil)
|
||||
clientUpgrader := peer.NewTLSClientUpgrader(tlsConfg, prometheus.NewCounter(prometheus.CounterOpts{}))
|
||||
conn, err := node.getConnFunc(ctx, node)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mc, err := message.NewCreator(
|
||||
luxlog.NewNoOpLogger(),
|
||||
luxmetrics.NewPrometheusMetrics("netrunner", prometheus.NewRegistry()),
|
||||
constants.DefaultNetworkCompressionType,
|
||||
10*time.Second,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
metrics, err := peer.NewMetrics(
|
||||
prometheus.NewRegistry(),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resourceTracker, err := tracker.NewResourceTracker(
|
||||
prometheus.NewRegistry(),
|
||||
resource.NoUsage,
|
||||
meter.ContinuousFactory{},
|
||||
peerResourceTrackerDuration,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
signerIP := utils.NewAtomic(netip.AddrPortFrom(netip.IPv6Unspecified(), 0))
|
||||
tls := tlsCert.PrivateKey.(crypto.Signer)
|
||||
// Create a dummy BLS signer for now
|
||||
blsKey, err := bls.NewSecretKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
config := &peer.Config{
|
||||
Metrics: metrics,
|
||||
MessageCreator: mc,
|
||||
Log: luxlog.NewNoOpLogger(),
|
||||
InboundMsgThrottler: throttling.NewNoInboundThrottler(),
|
||||
Network: peer.TestNetwork,
|
||||
Router: router,
|
||||
VersionCompatibility: version.GetCompatibility(node.networkID),
|
||||
MySubnets: set.Set[ids.ID]{},
|
||||
Beacons: validators.NewManager(),
|
||||
Validators: validators.NewManager(),
|
||||
NetworkID: node.networkID,
|
||||
PingFrequency: constants.DefaultPingFrequency,
|
||||
PongTimeout: constants.DefaultPingPongTimeout,
|
||||
MaxClockDifference: time.Minute,
|
||||
ResourceTracker: resourceTracker,
|
||||
IPSigner: peer.NewIPSigner(signerIP, tls, blsKey),
|
||||
}
|
||||
_, conn, cert, err := clientUpgrader.Upgrade(conn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p := peer.Start(
|
||||
config,
|
||||
conn,
|
||||
cert,
|
||||
ids.NodeIDFromCert(&ids.Certificate{
|
||||
Raw: cert.Raw,
|
||||
PublicKey: cert.PublicKey,
|
||||
}),
|
||||
peer.NewBlockingMessageQueue(
|
||||
config.Metrics,
|
||||
luxlog.NewNoOpLogger(),
|
||||
peerMsgQueueBufferSize,
|
||||
),
|
||||
)
|
||||
cctx, cancel := context.WithTimeout(ctx, peerStartWaitTimeout)
|
||||
err = p.AwaitReady(cctx)
|
||||
cancel()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
node.attachedPeers[p.ID().String()] = p
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func (node *localNode) SendOutboundMessage(ctx context.Context, peerID string, content []byte, op uint32) (bool, error) {
|
||||
attachedPeer, ok := node.attachedPeers[peerID]
|
||||
if !ok {
|
||||
return false, fmt.Errorf("peer with ID %s is not attached here", peerID)
|
||||
}
|
||||
msg := NewTestMsg(message.Op(op), content, false)
|
||||
return attachedPeer.Send(ctx, msg), nil
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
func (node *localNode) GetName() string {
|
||||
return node.name
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
func (node *localNode) GetNodeID() ids.NodeID {
|
||||
return node.nodeID
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
func (node *localNode) GetAPIClient() api.Client {
|
||||
return node.client
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
func (node *localNode) GetURL() string {
|
||||
if node.httpHost == "0.0.0.0" || node.httpHost == "." {
|
||||
return "0.0.0.0"
|
||||
}
|
||||
return "127.0.0.1"
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
func (node *localNode) GetP2PPort() uint16 {
|
||||
return node.p2pPort
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
func (node *localNode) GetAPIPort() uint16 {
|
||||
return node.apiPort
|
||||
}
|
||||
|
||||
func (node *localNode) Status() status.Status {
|
||||
return node.process.Status()
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
func (node *localNode) GetBinaryPath() string {
|
||||
return node.config.BinaryPath
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
func (node *localNode) GetPluginDir() string {
|
||||
return node.pluginDir
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
func (node *localNode) GetDataDir() string {
|
||||
return node.dataDir
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
// TODO rename method so linter doesn't complain.
|
||||
func (node *localNode) GetDbDir() string { //nolint
|
||||
return node.dbDir
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
func (node *localNode) GetLogsDir() string {
|
||||
return node.logsDir
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
func (node *localNode) GetConfigFile() string {
|
||||
return node.config.ConfigFile
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
func (node *localNode) GetConfig() node.Config {
|
||||
return node.config
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
func (node *localNode) GetFlag(k string) (string, error) {
|
||||
var v string
|
||||
if node.config.ConfigFile != "" {
|
||||
var configFileMap map[string]interface{}
|
||||
if err := json.Unmarshal([]byte(node.config.ConfigFile), &configFileMap); err != nil {
|
||||
return "", err
|
||||
}
|
||||
vIntf, ok := configFileMap[k]
|
||||
if ok {
|
||||
v, ok = vIntf.(string)
|
||||
if !ok {
|
||||
return "", fmt.Errorf("unexpected type for %q expected string got %T", k, vIntf)
|
||||
}
|
||||
}
|
||||
} else if node.config.Flags != nil {
|
||||
vIntf, ok := node.config.Flags[k]
|
||||
if ok {
|
||||
v, ok = vIntf.(string)
|
||||
if !ok {
|
||||
return "", fmt.Errorf("unexpected type for %q expected string got %T", k, vIntf)
|
||||
}
|
||||
}
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// See node.Node
|
||||
func (node *localNode) GetPaused() bool {
|
||||
return node.paused
|
||||
}
|
||||
@@ -1,243 +0,0 @@
|
||||
package local
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto"
|
||||
"crypto/tls"
|
||||
"encoding/binary"
|
||||
"io"
|
||||
"net"
|
||||
"net/netip"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/luxfi/netrunner/network/node"
|
||||
"github.com/luxfi/ids"
|
||||
"github.com/luxfi/p2p/message"
|
||||
"github.com/luxfi/p2p/peer"
|
||||
"github.com/luxfi/staking"
|
||||
"github.com/luxfi/utils/constants"
|
||||
"github.com/luxfi/utils/ips"
|
||||
"github.com/luxfi/utils/logging"
|
||||
"github.com/luxfi/utils/wrappers"
|
||||
"github.com/luxfi/version"
|
||||
"github.com/luxfi/metrics"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const bitmaskCodec = uint32(1 << 31)
|
||||
|
||||
func upgradeConn(myTLSCert *tls.Certificate, conn net.Conn) (ids.NodeID, net.Conn, error) {
|
||||
tlsConfig := peer.TLSConfig(*myTLSCert, nil)
|
||||
upgrader := peer.NewTLSServerUpgrader(tlsConfig)
|
||||
// this will block until the ssh handshake is done
|
||||
peerID, tlsConn, _, err := upgrader.Upgrade(conn)
|
||||
return peerID, tlsConn, err
|
||||
}
|
||||
|
||||
// verifyProtocol reads from the connection and asserts that we read the expected message sequence.
|
||||
// It also sends the required messages to complete the p2p handshake.
|
||||
// Sequence:
|
||||
// 1. Write the version message length to peer
|
||||
// 2. Write version message to peer
|
||||
// 3. Write peerlist message length to peer
|
||||
// 4. Write peerlist message to peer
|
||||
// If an unexpected error occurs, or we get an unexpected message, sends an error on [errCh].
|
||||
// Sends nil on [errCh] if we get the expected message sequence.
|
||||
func verifyProtocol(
|
||||
require *require.Assertions,
|
||||
opSequence []message.Op,
|
||||
mc message.Creator,
|
||||
nodeConn net.Conn,
|
||||
errCh chan error,
|
||||
) {
|
||||
// do the TLS handshake
|
||||
myTLSCert, err := staking.NewTLSCert()
|
||||
if err != nil {
|
||||
errCh <- err
|
||||
return
|
||||
}
|
||||
peerID, tlsConn, err := upgradeConn(myTLSCert, nodeConn)
|
||||
if err != nil {
|
||||
errCh <- err
|
||||
return
|
||||
}
|
||||
nodeConn = tlsConn
|
||||
|
||||
// send the peer our version and peerlist
|
||||
|
||||
// create the version message
|
||||
myIP := netip.AddrPortFrom(netip.IPv6Unspecified(), 0)
|
||||
now := uint64(time.Now().Unix())
|
||||
unsignedIP := peer.UnsignedIP{
|
||||
AddrPort: myIP,
|
||||
Timestamp: now,
|
||||
}
|
||||
signer := myTLSCert.PrivateKey.(crypto.Signer)
|
||||
signedIP, err := unsignedIP.Sign(signer)
|
||||
if err != nil {
|
||||
errCh <- err
|
||||
return
|
||||
}
|
||||
verMsg, err := mc.Version(
|
||||
constants.MainnetID,
|
||||
now,
|
||||
myIP,
|
||||
version.CurrentApp.String(),
|
||||
now,
|
||||
signedIP.Signature,
|
||||
[]ids.ID{},
|
||||
)
|
||||
if err != nil {
|
||||
errCh <- err
|
||||
return
|
||||
}
|
||||
|
||||
// create the PeerList message
|
||||
plMsg, err := mc.PeerList([]ips.ClaimedIPPort{}, true)
|
||||
if err != nil {
|
||||
errCh <- err
|
||||
return
|
||||
}
|
||||
|
||||
// send the Version message
|
||||
if err := sendMessage(nodeConn, verMsg.Bytes(), errCh); err != nil {
|
||||
// if there was an error no need to continue
|
||||
return
|
||||
}
|
||||
// send the PeerList message
|
||||
if err := sendMessage(nodeConn, plMsg.Bytes(), errCh); err != nil {
|
||||
// if there was an error no need to continue
|
||||
return
|
||||
}
|
||||
|
||||
// at this point we sent all messages expected for handshake,
|
||||
// now *read* the messages on the other end and check they are in
|
||||
// the expected sequence
|
||||
for _, expectedOpMsg := range opSequence {
|
||||
msgBytes, err := readMessage(nodeConn, errCh)
|
||||
if err != nil {
|
||||
// If there was an error no need continue
|
||||
return
|
||||
}
|
||||
msg, err := mc.Parse(msgBytes.Bytes(), peerID, func() {})
|
||||
require.NoError(err)
|
||||
op := msg.Op()
|
||||
require.Equal(expectedOpMsg, op)
|
||||
}
|
||||
// signal we are actually done
|
||||
errCh <- nil
|
||||
}
|
||||
|
||||
// readMessage reads from the connection and returns a protocol message in bytes
|
||||
func readMessage(nodeConn net.Conn, errCh chan error) (*bytes.Buffer, error) {
|
||||
msgLenBytes := &bytes.Buffer{}
|
||||
// read the message length
|
||||
if _, err := io.CopyN(msgLenBytes, nodeConn, wrappers.IntLen); err != nil {
|
||||
errCh <- err
|
||||
return nil, err
|
||||
}
|
||||
msgLen := binary.BigEndian.Uint32(msgLenBytes.Bytes())
|
||||
msgLen &^= bitmaskCodec
|
||||
msgBytes := &bytes.Buffer{}
|
||||
// read the message
|
||||
if _, err := io.CopyN(msgBytes, nodeConn, int64(msgLen)); err != nil {
|
||||
errCh <- err
|
||||
return nil, err
|
||||
}
|
||||
return msgBytes, nil
|
||||
}
|
||||
|
||||
// sendMessage sends a protocol message to the node peer
|
||||
func sendMessage(nodeConn net.Conn, msgBytes []byte, errCh chan error) error {
|
||||
// buffer for message length
|
||||
msgLenBytes := make([]byte, wrappers.IntLen)
|
||||
lenBuf := bytes.NewBuffer(msgLenBytes)
|
||||
|
||||
// write the message length
|
||||
binary.BigEndian.PutUint32(msgLenBytes, uint32(len(msgBytes)))
|
||||
// send the message length
|
||||
if _, err := io.CopyN(nodeConn, lenBuf, wrappers.IntLen); err != nil {
|
||||
errCh <- err
|
||||
return err
|
||||
}
|
||||
// write the message
|
||||
msgBuf := bytes.NewBuffer(msgBytes)
|
||||
// send the message
|
||||
if _, err := io.CopyN(nodeConn, msgBuf, int64(len(msgBytes))); err != nil {
|
||||
errCh <- err
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// TestAttachPeer tests that we can attach a test peer to a node
|
||||
// and that the node receives messages sent through the test peer
|
||||
func TestAttachPeer(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
// [nodeConn] is the connection that [node] uses to read from/write to [peer] (defined below)
|
||||
// Similar for [peerConn].
|
||||
nodeConn, peerConn := net.Pipe()
|
||||
defer func() {
|
||||
_ = nodeConn.Close()
|
||||
_ = peerConn.Close()
|
||||
}()
|
||||
|
||||
node := localNode{
|
||||
nodeID: ids.GenerateTestNodeID(),
|
||||
networkID: constants.MainnetID,
|
||||
getConnFunc: func(ctx context.Context, n node.Node) (net.Conn, error) {
|
||||
return peerConn, nil
|
||||
},
|
||||
attachedPeers: map[string]peer.Peer{},
|
||||
}
|
||||
|
||||
// For message creation and parsing
|
||||
mc, err := message.NewCreator(
|
||||
logging.NoLog{},
|
||||
metrics.NewRegistry(),
|
||||
"",
|
||||
constants.DefaultNetworkCompressionType,
|
||||
10*time.Second,
|
||||
)
|
||||
require.NoError(err)
|
||||
|
||||
// Expect the peer to send these messages in this order.
|
||||
expectedMessages := []message.Op{
|
||||
message.VersionOp,
|
||||
message.PeerListOp,
|
||||
message.ChitsOp,
|
||||
}
|
||||
|
||||
// [p] define below will write to/read from [peerConn]
|
||||
// Start a goroutine that reads messages from the other end of that
|
||||
// connection and asserts that we get the expected messages
|
||||
errCh := make(chan error, 1)
|
||||
go verifyProtocol(require, expectedMessages, mc, nodeConn, errCh)
|
||||
|
||||
// attach a test peer to [node]
|
||||
handler := &noOpInboundHandler{}
|
||||
p, err := node.AttachPeer(context.Background(), handler)
|
||||
require.NoError(err)
|
||||
|
||||
// we'll use a Chits message for testing. (We could use any message type.)
|
||||
containerIDs := []ids.ID{
|
||||
ids.GenerateTestID(),
|
||||
ids.GenerateTestID(),
|
||||
ids.GenerateTestID(),
|
||||
}
|
||||
requestID := uint32(42)
|
||||
chainID := constants.PlatformChainID
|
||||
// create the Chits message
|
||||
msg, err := mc.Chits(chainID, requestID, []ids.ID{}, containerIDs)
|
||||
require.NoError(err)
|
||||
// send chits to [node]
|
||||
ok := p.Send(context.Background(), msg)
|
||||
require.True(ok)
|
||||
// wait until the go routines are done
|
||||
// also ensures that [require] calls will be reflected in test results if failed
|
||||
require.NoError(<-errCh)
|
||||
}
|
||||
@@ -6,7 +6,7 @@ package local
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/luxfi/protocol/p/txs"
|
||||
"github.com/luxfi/proto/p/txs"
|
||||
"github.com/luxfi/sdk/platformvm"
|
||||
pwalletwallet "github.com/luxfi/sdk/wallet/chain/p/wallet"
|
||||
"github.com/luxfi/sdk/wallet/primary/common"
|
||||
|
||||
+649
-1175
File diff suppressed because it is too large
Load Diff
+121
-97
@@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc-gen-go-grpc v1.6.2
|
||||
// - protoc (unknown)
|
||||
// source: rpcpb/rpc.proto
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
PingService_Ping_FullMethodName = "/rpcpb.PingService/Ping"
|
||||
@@ -38,8 +38,9 @@ func NewPingServiceClient(cc grpc.ClientConnInterface) PingServiceClient {
|
||||
}
|
||||
|
||||
func (c *pingServiceClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(PingResponse)
|
||||
err := c.cc.Invoke(ctx, PingService_Ping_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, PingService_Ping_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -48,20 +49,24 @@ func (c *pingServiceClient) Ping(ctx context.Context, in *PingRequest, opts ...g
|
||||
|
||||
// PingServiceServer is the server API for PingService service.
|
||||
// All implementations must embed UnimplementedPingServiceServer
|
||||
// for forward compatibility
|
||||
// for forward compatibility.
|
||||
type PingServiceServer interface {
|
||||
Ping(context.Context, *PingRequest) (*PingResponse, error)
|
||||
mustEmbedUnimplementedPingServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedPingServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedPingServiceServer struct {
|
||||
}
|
||||
// UnimplementedPingServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedPingServiceServer struct{}
|
||||
|
||||
func (UnimplementedPingServiceServer) Ping(context.Context, *PingRequest) (*PingResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method Ping not implemented")
|
||||
}
|
||||
func (UnimplementedPingServiceServer) mustEmbedUnimplementedPingServiceServer() {}
|
||||
func (UnimplementedPingServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafePingServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to PingServiceServer will
|
||||
@@ -71,6 +76,13 @@ type UnsafePingServiceServer interface {
|
||||
}
|
||||
|
||||
func RegisterPingServiceServer(s grpc.ServiceRegistrar, srv PingServiceServer) {
|
||||
// If the following call panics, it indicates UnimplementedPingServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&PingService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
@@ -151,7 +163,7 @@ type ControlServiceClient interface {
|
||||
URIs(ctx context.Context, in *URIsRequest, opts ...grpc.CallOption) (*URIsResponse, error)
|
||||
WaitForHealthy(ctx context.Context, in *WaitForHealthyRequest, opts ...grpc.CallOption) (*WaitForHealthyResponse, error)
|
||||
Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error)
|
||||
StreamStatus(ctx context.Context, in *StreamStatusRequest, opts ...grpc.CallOption) (ControlService_StreamStatusClient, error)
|
||||
StreamStatus(ctx context.Context, in *StreamStatusRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[StreamStatusResponse], error)
|
||||
RemoveNode(ctx context.Context, in *RemoveNodeRequest, opts ...grpc.CallOption) (*RemoveNodeResponse, error)
|
||||
AddNode(ctx context.Context, in *AddNodeRequest, opts ...grpc.CallOption) (*AddNodeResponse, error)
|
||||
RestartNode(ctx context.Context, in *RestartNodeRequest, opts ...grpc.CallOption) (*RestartNodeResponse, error)
|
||||
@@ -178,8 +190,9 @@ func NewControlServiceClient(cc grpc.ClientConnInterface) ControlServiceClient {
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) RPCVersion(ctx context.Context, in *RPCVersionRequest, opts ...grpc.CallOption) (*RPCVersionResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RPCVersionResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_RPCVersion_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_RPCVersion_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -187,8 +200,9 @@ func (c *controlServiceClient) RPCVersion(ctx context.Context, in *RPCVersionReq
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) Start(ctx context.Context, in *StartRequest, opts ...grpc.CallOption) (*StartResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(StartResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_Start_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_Start_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -196,8 +210,9 @@ func (c *controlServiceClient) Start(ctx context.Context, in *StartRequest, opts
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) CreateBlockchains(ctx context.Context, in *CreateBlockchainsRequest, opts ...grpc.CallOption) (*CreateBlockchainsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(CreateBlockchainsResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_CreateBlockchains_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_CreateBlockchains_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -205,8 +220,9 @@ func (c *controlServiceClient) CreateBlockchains(ctx context.Context, in *Create
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) TransformElasticChains(ctx context.Context, in *TransformElasticChainsRequest, opts ...grpc.CallOption) (*TransformElasticChainsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(TransformElasticChainsResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_TransformElasticChains_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_TransformElasticChains_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -214,8 +230,9 @@ func (c *controlServiceClient) TransformElasticChains(ctx context.Context, in *T
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) AddPermissionlessValidator(ctx context.Context, in *AddPermissionlessValidatorRequest, opts ...grpc.CallOption) (*AddPermissionlessValidatorResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(AddPermissionlessValidatorResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_AddPermissionlessValidator_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_AddPermissionlessValidator_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -223,8 +240,9 @@ func (c *controlServiceClient) AddPermissionlessValidator(ctx context.Context, i
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) RemoveChainValidator(ctx context.Context, in *RemoveChainValidatorRequest, opts ...grpc.CallOption) (*RemoveChainValidatorResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RemoveChainValidatorResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_RemoveChainValidator_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_RemoveChainValidator_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -232,8 +250,9 @@ func (c *controlServiceClient) RemoveChainValidator(ctx context.Context, in *Rem
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) CreateChains(ctx context.Context, in *CreateChainsRequest, opts ...grpc.CallOption) (*CreateChainsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(CreateChainsResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_CreateChains_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_CreateChains_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -241,8 +260,9 @@ func (c *controlServiceClient) CreateChains(ctx context.Context, in *CreateChain
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) Health(ctx context.Context, in *HealthRequest, opts ...grpc.CallOption) (*HealthResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(HealthResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_Health_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_Health_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -250,8 +270,9 @@ func (c *controlServiceClient) Health(ctx context.Context, in *HealthRequest, op
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) URIs(ctx context.Context, in *URIsRequest, opts ...grpc.CallOption) (*URIsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(URIsResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_URIs_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_URIs_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -259,8 +280,9 @@ func (c *controlServiceClient) URIs(ctx context.Context, in *URIsRequest, opts .
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) WaitForHealthy(ctx context.Context, in *WaitForHealthyRequest, opts ...grpc.CallOption) (*WaitForHealthyResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(WaitForHealthyResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_WaitForHealthy_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_WaitForHealthy_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -268,20 +290,22 @@ func (c *controlServiceClient) WaitForHealthy(ctx context.Context, in *WaitForHe
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(StatusResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_Status_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_Status_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) StreamStatus(ctx context.Context, in *StreamStatusRequest, opts ...grpc.CallOption) (ControlService_StreamStatusClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &ControlService_ServiceDesc.Streams[0], ControlService_StreamStatus_FullMethodName, opts...)
|
||||
func (c *controlServiceClient) StreamStatus(ctx context.Context, in *StreamStatusRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[StreamStatusResponse], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &ControlService_ServiceDesc.Streams[0], ControlService_StreamStatus_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &controlServiceStreamStatusClient{stream}
|
||||
x := &grpc.GenericClientStream[StreamStatusRequest, StreamStatusResponse]{ClientStream: stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -291,26 +315,13 @@ func (c *controlServiceClient) StreamStatus(ctx context.Context, in *StreamStatu
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type ControlService_StreamStatusClient interface {
|
||||
Recv() (*StreamStatusResponse, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type controlServiceStreamStatusClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *controlServiceStreamStatusClient) Recv() (*StreamStatusResponse, error) {
|
||||
m := new(StreamStatusResponse)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type ControlService_StreamStatusClient = grpc.ServerStreamingClient[StreamStatusResponse]
|
||||
|
||||
func (c *controlServiceClient) RemoveNode(ctx context.Context, in *RemoveNodeRequest, opts ...grpc.CallOption) (*RemoveNodeResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RemoveNodeResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_RemoveNode_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_RemoveNode_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -318,8 +329,9 @@ func (c *controlServiceClient) RemoveNode(ctx context.Context, in *RemoveNodeReq
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) AddNode(ctx context.Context, in *AddNodeRequest, opts ...grpc.CallOption) (*AddNodeResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(AddNodeResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_AddNode_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_AddNode_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -327,8 +339,9 @@ func (c *controlServiceClient) AddNode(ctx context.Context, in *AddNodeRequest,
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) RestartNode(ctx context.Context, in *RestartNodeRequest, opts ...grpc.CallOption) (*RestartNodeResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RestartNodeResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_RestartNode_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_RestartNode_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -336,8 +349,9 @@ func (c *controlServiceClient) RestartNode(ctx context.Context, in *RestartNodeR
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) PauseNode(ctx context.Context, in *PauseNodeRequest, opts ...grpc.CallOption) (*PauseNodeResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(PauseNodeResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_PauseNode_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_PauseNode_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -345,8 +359,9 @@ func (c *controlServiceClient) PauseNode(ctx context.Context, in *PauseNodeReque
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) ResumeNode(ctx context.Context, in *ResumeNodeRequest, opts ...grpc.CallOption) (*ResumeNodeResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ResumeNodeResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_ResumeNode_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_ResumeNode_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -354,8 +369,9 @@ func (c *controlServiceClient) ResumeNode(ctx context.Context, in *ResumeNodeReq
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) Stop(ctx context.Context, in *StopRequest, opts ...grpc.CallOption) (*StopResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(StopResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_Stop_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_Stop_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -363,8 +379,9 @@ func (c *controlServiceClient) Stop(ctx context.Context, in *StopRequest, opts .
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) AttachPeer(ctx context.Context, in *AttachPeerRequest, opts ...grpc.CallOption) (*AttachPeerResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(AttachPeerResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_AttachPeer_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_AttachPeer_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -372,8 +389,9 @@ func (c *controlServiceClient) AttachPeer(ctx context.Context, in *AttachPeerReq
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) SendOutboundMessage(ctx context.Context, in *SendOutboundMessageRequest, opts ...grpc.CallOption) (*SendOutboundMessageResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SendOutboundMessageResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_SendOutboundMessage_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_SendOutboundMessage_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -381,8 +399,9 @@ func (c *controlServiceClient) SendOutboundMessage(ctx context.Context, in *Send
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) SaveSnapshot(ctx context.Context, in *SaveSnapshotRequest, opts ...grpc.CallOption) (*SaveSnapshotResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SaveSnapshotResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_SaveSnapshot_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_SaveSnapshot_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -390,8 +409,9 @@ func (c *controlServiceClient) SaveSnapshot(ctx context.Context, in *SaveSnapsho
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) SaveHotSnapshot(ctx context.Context, in *SaveSnapshotRequest, opts ...grpc.CallOption) (*SaveSnapshotResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(SaveSnapshotResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_SaveHotSnapshot_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_SaveHotSnapshot_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -399,8 +419,9 @@ func (c *controlServiceClient) SaveHotSnapshot(ctx context.Context, in *SaveSnap
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) LoadSnapshot(ctx context.Context, in *LoadSnapshotRequest, opts ...grpc.CallOption) (*LoadSnapshotResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(LoadSnapshotResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_LoadSnapshot_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_LoadSnapshot_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -408,8 +429,9 @@ func (c *controlServiceClient) LoadSnapshot(ctx context.Context, in *LoadSnapsho
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) RemoveSnapshot(ctx context.Context, in *RemoveSnapshotRequest, opts ...grpc.CallOption) (*RemoveSnapshotResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RemoveSnapshotResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_RemoveSnapshot_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_RemoveSnapshot_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -417,8 +439,9 @@ func (c *controlServiceClient) RemoveSnapshot(ctx context.Context, in *RemoveSna
|
||||
}
|
||||
|
||||
func (c *controlServiceClient) GetSnapshotNames(ctx context.Context, in *GetSnapshotNamesRequest, opts ...grpc.CallOption) (*GetSnapshotNamesResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetSnapshotNamesResponse)
|
||||
err := c.cc.Invoke(ctx, ControlService_GetSnapshotNames_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, ControlService_GetSnapshotNames_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -427,7 +450,7 @@ func (c *controlServiceClient) GetSnapshotNames(ctx context.Context, in *GetSnap
|
||||
|
||||
// ControlServiceServer is the server API for ControlService service.
|
||||
// All implementations must embed UnimplementedControlServiceServer
|
||||
// for forward compatibility
|
||||
// for forward compatibility.
|
||||
type ControlServiceServer interface {
|
||||
RPCVersion(context.Context, *RPCVersionRequest) (*RPCVersionResponse, error)
|
||||
Start(context.Context, *StartRequest) (*StartResponse, error)
|
||||
@@ -440,7 +463,7 @@ type ControlServiceServer interface {
|
||||
URIs(context.Context, *URIsRequest) (*URIsResponse, error)
|
||||
WaitForHealthy(context.Context, *WaitForHealthyRequest) (*WaitForHealthyResponse, error)
|
||||
Status(context.Context, *StatusRequest) (*StatusResponse, error)
|
||||
StreamStatus(*StreamStatusRequest, ControlService_StreamStatusServer) error
|
||||
StreamStatus(*StreamStatusRequest, grpc.ServerStreamingServer[StreamStatusResponse]) error
|
||||
RemoveNode(context.Context, *RemoveNodeRequest) (*RemoveNodeResponse, error)
|
||||
AddNode(context.Context, *AddNodeRequest) (*AddNodeResponse, error)
|
||||
RestartNode(context.Context, *RestartNodeRequest) (*RestartNodeResponse, error)
|
||||
@@ -459,86 +482,90 @@ type ControlServiceServer interface {
|
||||
mustEmbedUnimplementedControlServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedControlServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedControlServiceServer struct {
|
||||
}
|
||||
// UnimplementedControlServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedControlServiceServer struct{}
|
||||
|
||||
func (UnimplementedControlServiceServer) RPCVersion(context.Context, *RPCVersionRequest) (*RPCVersionResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RPCVersion not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method RPCVersion not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) Start(context.Context, *StartRequest) (*StartResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Start not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method Start not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) CreateBlockchains(context.Context, *CreateBlockchainsRequest) (*CreateBlockchainsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateBlockchains not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateBlockchains not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) TransformElasticChains(context.Context, *TransformElasticChainsRequest) (*TransformElasticChainsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method TransformElasticChains not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method TransformElasticChains not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) AddPermissionlessValidator(context.Context, *AddPermissionlessValidatorRequest) (*AddPermissionlessValidatorResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AddPermissionlessValidator not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method AddPermissionlessValidator not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) RemoveChainValidator(context.Context, *RemoveChainValidatorRequest) (*RemoveChainValidatorResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RemoveChainValidator not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method RemoveChainValidator not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) CreateChains(context.Context, *CreateChainsRequest) (*CreateChainsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateChains not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateChains not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) Health(context.Context, *HealthRequest) (*HealthResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Health not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method Health not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) URIs(context.Context, *URIsRequest) (*URIsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method URIs not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method URIs not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) WaitForHealthy(context.Context, *WaitForHealthyRequest) (*WaitForHealthyResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method WaitForHealthy not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method WaitForHealthy not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) Status(context.Context, *StatusRequest) (*StatusResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Status not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method Status not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) StreamStatus(*StreamStatusRequest, ControlService_StreamStatusServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method StreamStatus not implemented")
|
||||
func (UnimplementedControlServiceServer) StreamStatus(*StreamStatusRequest, grpc.ServerStreamingServer[StreamStatusResponse]) error {
|
||||
return status.Error(codes.Unimplemented, "method StreamStatus not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) RemoveNode(context.Context, *RemoveNodeRequest) (*RemoveNodeResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RemoveNode not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method RemoveNode not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) AddNode(context.Context, *AddNodeRequest) (*AddNodeResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AddNode not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method AddNode not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) RestartNode(context.Context, *RestartNodeRequest) (*RestartNodeResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RestartNode not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method RestartNode not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) PauseNode(context.Context, *PauseNodeRequest) (*PauseNodeResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method PauseNode not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method PauseNode not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) ResumeNode(context.Context, *ResumeNodeRequest) (*ResumeNodeResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ResumeNode not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method ResumeNode not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) Stop(context.Context, *StopRequest) (*StopResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Stop not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method Stop not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) AttachPeer(context.Context, *AttachPeerRequest) (*AttachPeerResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AttachPeer not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method AttachPeer not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) SendOutboundMessage(context.Context, *SendOutboundMessageRequest) (*SendOutboundMessageResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SendOutboundMessage not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method SendOutboundMessage not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) SaveSnapshot(context.Context, *SaveSnapshotRequest) (*SaveSnapshotResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SaveSnapshot not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method SaveSnapshot not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) SaveHotSnapshot(context.Context, *SaveSnapshotRequest) (*SaveSnapshotResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SaveHotSnapshot not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method SaveHotSnapshot not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) LoadSnapshot(context.Context, *LoadSnapshotRequest) (*LoadSnapshotResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method LoadSnapshot not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method LoadSnapshot not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) RemoveSnapshot(context.Context, *RemoveSnapshotRequest) (*RemoveSnapshotResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RemoveSnapshot not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method RemoveSnapshot not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) GetSnapshotNames(context.Context, *GetSnapshotNamesRequest) (*GetSnapshotNamesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetSnapshotNames not implemented")
|
||||
return nil, status.Error(codes.Unimplemented, "method GetSnapshotNames not implemented")
|
||||
}
|
||||
func (UnimplementedControlServiceServer) mustEmbedUnimplementedControlServiceServer() {}
|
||||
func (UnimplementedControlServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeControlServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to ControlServiceServer will
|
||||
@@ -548,6 +575,13 @@ type UnsafeControlServiceServer interface {
|
||||
}
|
||||
|
||||
func RegisterControlServiceServer(s grpc.ServiceRegistrar, srv ControlServiceServer) {
|
||||
// If the following call panics, it indicates UnimplementedControlServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&ControlService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
@@ -754,21 +788,11 @@ func _ControlService_StreamStatus_Handler(srv interface{}, stream grpc.ServerStr
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(ControlServiceServer).StreamStatus(m, &controlServiceStreamStatusServer{stream})
|
||||
return srv.(ControlServiceServer).StreamStatus(m, &grpc.GenericServerStream[StreamStatusRequest, StreamStatusResponse]{ServerStream: stream})
|
||||
}
|
||||
|
||||
type ControlService_StreamStatusServer interface {
|
||||
Send(*StreamStatusResponse) error
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type controlServiceStreamStatusServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *controlServiceStreamStatusServer) Send(m *StreamStatusResponse) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type ControlService_StreamStatusServer = grpc.ServerStreamingServer[StreamStatusResponse]
|
||||
|
||||
func _ControlService_RemoveNode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(RemoveNodeRequest)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -594,7 +594,7 @@ func (a *AttachPeerResponse) Decode(rd *zap.Reader) error {
|
||||
}
|
||||
|
||||
// SendOutboundMessageRequest matches rpcpb.SendOutboundMessageRequest.
|
||||
// The proto field is named `bytes` (the AVM/p2p message body); we use
|
||||
// The proto field is named `bytes` (the XVM/p2p message body); we use
|
||||
// MsgBody to avoid collision with the Go builtin.
|
||||
type SendOutboundMessageRequest struct {
|
||||
NodeName string
|
||||
|
||||
Reference in New Issue
Block a user