Feat: support for engine api over ipc (#7428)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Nil Medvedev
2024-04-10 21:31:53 +01:00
committed by GitHub
parent 69355affb8
commit dd83c9c4f8
6 changed files with 211 additions and 10 deletions

View File

@ -176,6 +176,14 @@ pub struct RpcServerArgs {
/// Gas price oracle configuration.
#[command(flatten)]
pub gas_price_oracle: GasPriceOracleArgs,
/// Enable auth engine api over IPC
#[arg(long)]
pub auth_ipc: bool,
/// Filename for auth IPC socket/pipe within the datadir
#[arg(long = "auth-ipc.path", default_value_t = constants::DEFAULT_ENGINE_API_IPC_ENDPOINT.to_string())]
pub auth_ipc_path: String,
}
impl RpcServerArgs {
@ -191,6 +199,12 @@ impl RpcServerArgs {
self
}
/// Enables the Auth IPC
pub fn with_auth_ipc(mut self) -> Self {
self.auth_ipc = true;
self
}
/// Change rpc port numbers based on the instance number.
/// * The `auth_port` is scaled by a factor of `instance * 100`
/// * The `http_port` is scaled by a factor of `-instance`
@ -458,7 +472,11 @@ impl RethRpcConfig for RpcServerArgs {
fn auth_server_config(&self, jwt_secret: JwtSecret) -> Result<AuthServerConfig, RpcError> {
let address = SocketAddr::new(self.auth_addr, self.auth_port);
Ok(AuthServerConfig::builder(jwt_secret).socket_addr(address).build())
let mut builder = AuthServerConfig::builder(jwt_secret).socket_addr(address);
if self.auth_ipc {
builder = builder.ipc_endpoint(self.auth_ipc_path.clone());
}
Ok(builder.build())
}
fn auth_jwt_secret(&self, default_jwt_path: PathBuf) -> Result<JwtSecret, JwtError> {
@ -494,6 +512,8 @@ impl Default for RpcServerArgs {
auth_addr: Ipv4Addr::LOCALHOST.into(),
auth_port: constants::DEFAULT_AUTH_PORT,
auth_jwtsecret: None,
auth_ipc: false,
auth_ipc_path: constants::DEFAULT_ENGINE_API_IPC_ENDPOINT.to_string(),
rpc_jwtsecret: None,
rpc_max_request_size: RPC_DEFAULT_MAX_REQUEST_SIZE_MB.into(),
rpc_max_response_size: RPC_DEFAULT_MAX_RESPONSE_SIZE_MB.into(),