This package provides a gRPC-based implementation of the Evolve execution interface. It allows Evolve to communicate with remote execution clients via gRPC using the Connect-RPC framework.
The gRPC execution client enables separation between the consensus layer (Evolve) and the execution layer by providing a network interface for communication. This allows execution clients to run in separate processes or even on different machines.
To connect to a remote execution service:
import (
"github.com/evstack/ev-node/execution/grpc"
)
// Create a new gRPC client
client := grpc.NewClient("http://localhost:50051")
// Use the client as an execution.Executor
ctx := context.Background()
stateRoot, maxBytes, err := client.InitChain(ctx, time.Now(), 1, "my-chain")To serve an execution implementation via gRPC:
import (
"net/http"
"github.com/evstack/ev-node/execution/grpc"
)
// Wrap your executor implementation
handler := grpc.NewExecutorServiceHandler(myExecutor)
// Start the HTTP server
http.ListenAndServe(":50051", handler)The gRPC service is defined in proto/evnode/v1/execution.proto and provides the following methods:
InitChain: Initialize the blockchain with genesis parametersGetTxs: Fetch transactions from the mempoolExecuteTxs: Execute transactions and update stateSetFinal: Mark a block as finalized
- Full implementation of the
execution.Executorinterface - Support for HTTP/1.1 and HTTP/2 (via h2c)
- gRPC reflection for debugging and service discovery
- Compression for efficient data transfer
- Comprehensive error handling and validation
Run the tests with:
go test ./execution/grpc/...The package includes comprehensive unit tests for both client and server implementations.