mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-23 06:44:35 +00:00
Add validator_node, restructure binaries, gRPC.
This is a massive commit which restructures the workspace, adds a very basic, untested, validator client and some very basic, non-functioning gRPC endpoints to the beacon-node.
This commit is contained in:
2
protos/src/lib.rs
Normal file
2
protos/src/lib.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod services;
|
||||
pub mod services_grpc;
|
||||
46
protos/src/services.proto
Normal file
46
protos/src/services.proto
Normal file
@@ -0,0 +1,46 @@
|
||||
// TODO: This setup requires that the BN (beacon node) holds the block in state
|
||||
// during the interval between the `GenerateProposalRequest` and the
|
||||
// `SubmitProposalRequest`.
|
||||
//
|
||||
// This is sub-optimal as if a validator client switches BN during this process
|
||||
// the block will be lost.
|
||||
//
|
||||
// This "stateful" method is being used presently because it's easier and
|
||||
// requires less maintainence as the `BeaconBlock` definition changes.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package ethereum.beacon.rpc.v1;
|
||||
|
||||
service BeaconBlockService {
|
||||
rpc ProduceBeaconBlock(ProduceBeaconBlockRequest) returns (ProduceBeaconBlockResponse);
|
||||
rpc PublishBeaconBlock(PublishBeaconBlockRequest) returns (PublishBeaconBlockResponse);
|
||||
}
|
||||
|
||||
message BeaconBlock {
|
||||
uint64 slot = 1;
|
||||
bytes block_root = 2;
|
||||
bytes randao_reveal = 3;
|
||||
bytes signature = 4;
|
||||
}
|
||||
|
||||
// Validator requests an unsigned proposal.
|
||||
message ProduceBeaconBlockRequest {
|
||||
uint64 slot = 1;
|
||||
}
|
||||
|
||||
// Beacon node returns an unsigned proposal.
|
||||
message ProduceBeaconBlockResponse {
|
||||
BeaconBlock block = 1;
|
||||
}
|
||||
|
||||
// Validator submits a signed proposal.
|
||||
message PublishBeaconBlockRequest {
|
||||
BeaconBlock block = 1;
|
||||
}
|
||||
|
||||
// Beacon node indicates a sucessfully submitted proposal.
|
||||
message PublishBeaconBlockResponse {
|
||||
bool success = 1;
|
||||
bytes msg = 2;
|
||||
}
|
||||
1049
protos/src/services.rs
Normal file
1049
protos/src/services.rs
Normal file
File diff suppressed because it is too large
Load Diff
99
protos/src/services_grpc.rs
Normal file
99
protos/src/services_grpc.rs
Normal file
@@ -0,0 +1,99 @@
|
||||
// This file is generated. Do not edit
|
||||
// @generated
|
||||
|
||||
// https://github.com/Manishearth/rust-clippy/issues/702
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(clippy)]
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
|
||||
#![allow(box_pointers)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(missing_docs)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(trivial_casts)]
|
||||
#![allow(unsafe_code)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_results)]
|
||||
|
||||
const METHOD_BEACON_BLOCK_SERVICE_PRODUCE_BEACON_BLOCK: ::grpcio::Method<super::services::ProduceBeaconBlockRequest, super::services::ProduceBeaconBlockResponse> = ::grpcio::Method {
|
||||
ty: ::grpcio::MethodType::Unary,
|
||||
name: "/ethereum.beacon.rpc.v1.BeaconBlockService/ProduceBeaconBlock",
|
||||
req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de },
|
||||
resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de },
|
||||
};
|
||||
|
||||
const METHOD_BEACON_BLOCK_SERVICE_PUBLISH_BEACON_BLOCK: ::grpcio::Method<super::services::PublishBeaconBlockRequest, super::services::PublishBeaconBlockResponse> = ::grpcio::Method {
|
||||
ty: ::grpcio::MethodType::Unary,
|
||||
name: "/ethereum.beacon.rpc.v1.BeaconBlockService/PublishBeaconBlock",
|
||||
req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de },
|
||||
resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de },
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct BeaconBlockServiceClient {
|
||||
client: ::grpcio::Client,
|
||||
}
|
||||
|
||||
impl BeaconBlockServiceClient {
|
||||
pub fn new(channel: ::grpcio::Channel) -> Self {
|
||||
BeaconBlockServiceClient {
|
||||
client: ::grpcio::Client::new(channel),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn produce_beacon_block_opt(&self, req: &super::services::ProduceBeaconBlockRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<super::services::ProduceBeaconBlockResponse> {
|
||||
self.client.unary_call(&METHOD_BEACON_BLOCK_SERVICE_PRODUCE_BEACON_BLOCK, req, opt)
|
||||
}
|
||||
|
||||
pub fn produce_beacon_block(&self, req: &super::services::ProduceBeaconBlockRequest) -> ::grpcio::Result<super::services::ProduceBeaconBlockResponse> {
|
||||
self.produce_beacon_block_opt(req, ::grpcio::CallOption::default())
|
||||
}
|
||||
|
||||
pub fn produce_beacon_block_async_opt(&self, req: &super::services::ProduceBeaconBlockRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::services::ProduceBeaconBlockResponse>> {
|
||||
self.client.unary_call_async(&METHOD_BEACON_BLOCK_SERVICE_PRODUCE_BEACON_BLOCK, req, opt)
|
||||
}
|
||||
|
||||
pub fn produce_beacon_block_async(&self, req: &super::services::ProduceBeaconBlockRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::services::ProduceBeaconBlockResponse>> {
|
||||
self.produce_beacon_block_async_opt(req, ::grpcio::CallOption::default())
|
||||
}
|
||||
|
||||
pub fn publish_beacon_block_opt(&self, req: &super::services::PublishBeaconBlockRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<super::services::PublishBeaconBlockResponse> {
|
||||
self.client.unary_call(&METHOD_BEACON_BLOCK_SERVICE_PUBLISH_BEACON_BLOCK, req, opt)
|
||||
}
|
||||
|
||||
pub fn publish_beacon_block(&self, req: &super::services::PublishBeaconBlockRequest) -> ::grpcio::Result<super::services::PublishBeaconBlockResponse> {
|
||||
self.publish_beacon_block_opt(req, ::grpcio::CallOption::default())
|
||||
}
|
||||
|
||||
pub fn publish_beacon_block_async_opt(&self, req: &super::services::PublishBeaconBlockRequest, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::services::PublishBeaconBlockResponse>> {
|
||||
self.client.unary_call_async(&METHOD_BEACON_BLOCK_SERVICE_PUBLISH_BEACON_BLOCK, req, opt)
|
||||
}
|
||||
|
||||
pub fn publish_beacon_block_async(&self, req: &super::services::PublishBeaconBlockRequest) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver<super::services::PublishBeaconBlockResponse>> {
|
||||
self.publish_beacon_block_async_opt(req, ::grpcio::CallOption::default())
|
||||
}
|
||||
pub fn spawn<F>(&self, f: F) where F: ::futures::Future<Item = (), Error = ()> + Send + 'static {
|
||||
self.client.spawn(f)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BeaconBlockService {
|
||||
fn produce_beacon_block(&mut self, ctx: ::grpcio::RpcContext, req: super::services::ProduceBeaconBlockRequest, sink: ::grpcio::UnarySink<super::services::ProduceBeaconBlockResponse>);
|
||||
fn publish_beacon_block(&mut self, ctx: ::grpcio::RpcContext, req: super::services::PublishBeaconBlockRequest, sink: ::grpcio::UnarySink<super::services::PublishBeaconBlockResponse>);
|
||||
}
|
||||
|
||||
pub fn create_beacon_block_service<S: BeaconBlockService + Send + Clone + 'static>(s: S) -> ::grpcio::Service {
|
||||
let mut builder = ::grpcio::ServiceBuilder::new();
|
||||
let mut instance = s.clone();
|
||||
builder = builder.add_unary_handler(&METHOD_BEACON_BLOCK_SERVICE_PRODUCE_BEACON_BLOCK, move |ctx, req, resp| {
|
||||
instance.produce_beacon_block(ctx, req, resp)
|
||||
});
|
||||
let mut instance = s.clone();
|
||||
builder = builder.add_unary_handler(&METHOD_BEACON_BLOCK_SERVICE_PUBLISH_BEACON_BLOCK, move |ctx, req, resp| {
|
||||
instance.publish_beacon_block(ctx, req, resp)
|
||||
});
|
||||
builder.build()
|
||||
}
|
||||
Reference in New Issue
Block a user