mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 11:45:01 +00:00
refactor: rename g* grpc packages to rpc* (galiasreader, gkeystore, gwarp, ghttp)
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package galiasreader
|
||||
package rpcaliasreader
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package galiasreader
|
||||
package rpcaliasreader
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package galiasreader
|
||||
package rpcaliasreader
|
||||
|
||||
import (
|
||||
"testing"
|
||||
+7
-1
@@ -3,7 +3,13 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package gkeystore
|
||||
// Package rpckeystore is the keystore-over-RPC client and server. The
|
||||
// transport is selected by build tag: `grpc` selects the legacy gRPC
|
||||
// codepath in this file; the default build (no tag) will eventually
|
||||
// select a ZAP-based codepath (task #57). Mirrors the rpcdb naming
|
||||
// pattern — `rpc` is the value (remote procedure call), the substrate
|
||||
// is per-tag.
|
||||
package rpckeystore
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package gkeystore
|
||||
package rpckeystore
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package gwarp
|
||||
package rpcwarp
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package gwarp
|
||||
package rpcwarp
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
|
||||
//go:build test && grpc
|
||||
|
||||
package gwarp
|
||||
package rpcwarp
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@@ -95,7 +95,7 @@ func (f *factory) newZAP(logger log.Logger) (interface{}, error) {
|
||||
// IMPORTANT: Start with os.Environ() so the subprocess inherits PATH, HOME, etc.
|
||||
// Setting cmd.Env to a non-nil value prevents exec.Cmd from inheriting the parent env.
|
||||
cmd := subprocess.NewCmd(f.path)
|
||||
cmd.Env = append(os.Environ(), "LUX_VM_TRANSPORT=zap")
|
||||
cmd.Env = append(os.Environ(), "VM_TRANSPORT=zap")
|
||||
|
||||
status, stopper, err := subprocess.Bootstrap(
|
||||
context.TODO(),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package ghttp
|
||||
package rpchttp
|
||||
|
||||
import (
|
||||
"io"
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
|
||||
"github.com/luxfi/log"
|
||||
|
||||
"github.com/luxfi/node/vms/rpcchainvm/ghttp/greader"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/ghttp/gresponsewriter"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/rpchttp/rpcreader"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/rpchttp/rpcresponsewriter"
|
||||
"github.com/luxfi/node/proto/pb/io/reader"
|
||||
"github.com/luxfi/vm/rpc/grpcutils"
|
||||
|
||||
@@ -54,7 +54,7 @@ func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
defer closer.GracefulStop()
|
||||
|
||||
// Wrap [w] with a lock to ensure that it is accessed in a thread-safe manner.
|
||||
w = gresponsewriter.NewLockedWriter(w)
|
||||
w = rpcresponsewriter.NewLockedWriter(w)
|
||||
|
||||
serverListener, err := grpcutils.NewListener()
|
||||
if err != nil {
|
||||
@@ -64,8 +64,8 @@ func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
server := grpcutils.NewServer()
|
||||
closer.Add(server)
|
||||
responsewriterpb.RegisterWriterServer(server, gresponsewriter.NewServer(w))
|
||||
reader.RegisterReaderServer(server, greader.NewServer(r.Body))
|
||||
responsewriterpb.RegisterWriterServer(server, rpcresponsewriter.NewServer(w))
|
||||
reader.RegisterReaderServer(server, rpcreader.NewServer(r.Body))
|
||||
|
||||
// Start responsewriter gRPC service.
|
||||
go grpcutils.Serve(serverListener, server)
|
||||
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package ghttp
|
||||
package rpchttp
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -14,8 +14,8 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/luxfi/node/vms/rpcchainvm/ghttp/greader"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/ghttp/gresponsewriter"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/rpchttp/rpcreader"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/rpchttp/rpcresponsewriter"
|
||||
"github.com/luxfi/node/proto/pb/io/reader"
|
||||
"github.com/luxfi/vm/rpc/grpcutils"
|
||||
|
||||
@@ -52,8 +52,8 @@ func (s *Server) Handle(ctx context.Context, req *httppb.HTTPRequest) (*httppb.H
|
||||
writerHeaders[elem.Key] = elem.Values
|
||||
}
|
||||
|
||||
writer := gresponsewriter.NewClient(writerHeaders, responsewriterpb.NewWriterClient(clientConn))
|
||||
body := greader.NewClient(reader.NewReaderClient(clientConn))
|
||||
writer := rpcresponsewriter.NewClient(writerHeaders, responsewriterpb.NewWriterClient(clientConn))
|
||||
body := rpcreader.NewClient(reader.NewReaderClient(clientConn))
|
||||
|
||||
// create the request with the current context
|
||||
request, err := http.NewRequestWithContext(
|
||||
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package ghttp
|
||||
package rpchttp
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package gconn
|
||||
package rpcconn
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package gconn
|
||||
package rpcconn
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package gconn
|
||||
package rpcconn
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package greader
|
||||
package rpcreader
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package greader
|
||||
package rpcreader
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package greader
|
||||
package rpcreader
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package gresponsewriter
|
||||
package rpcresponsewriter
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
+7
-7
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package gresponsewriter
|
||||
package rpcresponsewriter
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@@ -13,9 +13,9 @@ import (
|
||||
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
|
||||
"github.com/luxfi/node/vms/rpcchainvm/ghttp/gconn"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/ghttp/greader"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/ghttp/gwriter"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/rpchttp/rpcconn"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/rpchttp/rpcreader"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/rpchttp/rpcwriter"
|
||||
"github.com/luxfi/vm/rpc/grpcutils"
|
||||
|
||||
responsewriterpb "github.com/luxfi/node/proto/pb/http/responsewriter"
|
||||
@@ -108,7 +108,7 @@ func (c *Client) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
conn := gconn.NewClient(
|
||||
conn := rpcconn.NewClient(
|
||||
connpb.NewConnClient(clientConn),
|
||||
&addr{
|
||||
network: resp.LocalNetwork,
|
||||
@@ -121,8 +121,8 @@ func (c *Client) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
clientConn,
|
||||
)
|
||||
|
||||
reader := greader.NewClient(readerpb.NewReaderClient(clientConn))
|
||||
writer := gwriter.NewClient(writerpb.NewWriterClient(clientConn))
|
||||
reader := rpcreader.NewClient(readerpb.NewReaderClient(clientConn))
|
||||
writer := rpcwriter.NewClient(writerpb.NewWriterClient(clientConn))
|
||||
|
||||
readWriter := bufio.NewReadWriter(
|
||||
bufio.NewReader(reader),
|
||||
+7
-7
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package gresponsewriter
|
||||
package rpcresponsewriter
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
|
||||
"github.com/luxfi/node/vms/rpcchainvm/ghttp/gconn"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/ghttp/greader"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/ghttp/gwriter"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/rpchttp/rpcconn"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/rpchttp/rpcreader"
|
||||
"github.com/luxfi/node/vms/rpcchainvm/rpchttp/rpcwriter"
|
||||
"github.com/luxfi/vm/rpc/grpcutils"
|
||||
|
||||
responsewriterpb "github.com/luxfi/node/proto/pb/http/responsewriter"
|
||||
@@ -103,9 +103,9 @@ func (s *Server) Hijack(context.Context, *emptypb.Empty) (*responsewriterpb.Hija
|
||||
closer := grpcutils.ServerCloser{}
|
||||
closer.Add(server)
|
||||
|
||||
connpb.RegisterConnServer(server, gconn.NewServer(conn, &closer))
|
||||
readerpb.RegisterReaderServer(server, greader.NewServer(readWriter))
|
||||
writerpb.RegisterWriterServer(server, gwriter.NewServer(readWriter))
|
||||
connpb.RegisterConnServer(server, rpcconn.NewServer(conn, &closer))
|
||||
readerpb.RegisterReaderServer(server, rpcreader.NewServer(readWriter))
|
||||
writerpb.RegisterWriterServer(server, rpcwriter.NewServer(readWriter))
|
||||
|
||||
go grpcutils.Serve(serverListener, server)
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package gwriter
|
||||
package rpcwriter
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
||||
// See the file LICENSE for licensing terms.
|
||||
|
||||
package gwriter
|
||||
package rpcwriter
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -18,7 +18,7 @@ It works by starting the VM's as a subprocess of Lux Node by `os.Exec`.
|
||||
|
||||
- `VMRegistry` calls the RPC Chain VM `Factory`.
|
||||
- Factory Starts an instance of a `VMRE` server that consumes a `runtime.Initializer` interface implementation.
|
||||
- The address of this server is passed as a ENV variable `LUX_VM_RUNTIME_ENGINE_ADDR` via `os.Exec` which starts the VM binary.
|
||||
- The address of this server is passed as a ENV variable `VM_RUNTIME_ENGINE_ADDR` via `os.Exec` which starts the VM binary.
|
||||
- The VM uses the address of the `VMRE` server to create a client.
|
||||
- Client sends a `Initialize` RPC informing the server of the `Protocol Version` and future `Address` of the RPC Chain VM server allowing it to perform a validation `Handshake`.
|
||||
- After the `Handshake` is complete the RPC Chain VM server is started which serves the `ChainVM` implementation.
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
const (
|
||||
// Address of the runtime engine server.
|
||||
EngineAddressKey = "LUX_VM_RUNTIME_ENGINE_ADDR"
|
||||
EngineAddressKey = "VM_RUNTIME_ENGINE_ADDR"
|
||||
|
||||
// Duration before handshake timeout during bootstrap.
|
||||
DefaultHandshakeTimeout = 5 * time.Second
|
||||
|
||||
Reference in New Issue
Block a user