---
# System prepended metadata

title: Remote debugging

---

# Client-Server Library for Log Uploads to S3

## Overview

This document outlines the development of a client-server library designed for secure and efficient uploading of customer logs to S3. The library will be integrated into tools such as SSV nodes and DKG, allowing for easy log uploads via a CLI command.

## Uploading Flow

### Client-Side Implementation

#### 1. Create Upload Command
- Implement a CLI command or API, `uploadLogs`, to package and prepare logs for uploading.

#### 2. Sign Request
- Sign the upload request with the operator's private key, including metadata like file name, size, and timestamp.

#### 3. Send Signed Request to Server
- Send the signed request and metadata to the server via a secure HTTP request.

#### 4. Upload to S3 Using Presigned URL
- Upon receiving a presigned URL from the server, upload the logs directly to S3 using an HTTP PUT request.

### Server-Side Implementation

#### 1. Verify Signature
- Verify the request's signature against the operators' public keys, possibly via an SSV API.

#### 2. Rate Limiting and Request Validation
- Check the request against predefined limits, such as requests per second, to prevent abuse. Possibily check against blacklist 

#### 3. Generate Presigned URL for S3 Upload
- Generate a presigned URL that allows the client temporary access to upload files directly to a specific S3 bucket.

#### 4. Send Presigned URL to Client
- Send the presigned URL back to the client, along with any necessary instructions for the upload process.

## Integration with SSV Node and DKG

- Design the library as a standalone module for easy integration into various tools.


---

# SSV logs uploader proposal



# Functional requirements




## Architecture 


![image](https://hackmd.io/_uploads/Bk-G5MCpa.png)



# Sequence diagram 

![image](https://hackmd.io/_uploads/HyuQcfRTp.png)


## e2m changes

### processBlock
[processBlock](https://github.com/bloxapp/ethereum2-monitor/blob/a16d98bfebf9b6a52325f819b9225614c38aad38/monitor/monitor.go#L260) method of monitord should be changed to trigger SSE event emitting for the missed duties. Method has a list of successfully handled duties here:
```go
for _, duty := range resolved {  
    if duty.Successful() {  
       successful = append(successful, duty)  
    }  
}
```
Ones with `!duty.Successful()` we should collect and sent to consumers of SSE, 
the **ssv-log-collector**

## ssv-logs-collector 
##### Important ⚠️
This service should be placed to the same docker container as the ssv node itself to have access:
- ssv node logs 
- operator private key
##### Description
Service stands with ssv node in the same docker container, sharing the file system with logs and private key. 

On start it connects to e2m opening the SSE connection. Listens to the events.

When `e2m` produces an event "duty missed":
- service extracts the logs
- compresses it according to the _configured strategy_
- calculates a hash checksum of logs zipped file
- signs the hash
- sends the hash, signature, address (or pubkey) to get an one-time upload `access token`
- uploads the zipped logs to `ssv-logs-uploader` service authorizing with the access-token
##### On-start health checking
- Checks access to the logs directory, checks some files presence and read permissions
- Checks access to the private key, validating the key 
- SSE connection to `/health` of `e2m`
- HTTP request to `ssv-logs-uploader` to `/health`


## ssv-logs-uploader
##### Description
Stand alone centralized service of Blox infra. Accepts logs from operators and securely uploads the logs to the S3 bucket
Authenticates `ssv-logs-collector` to push the logs before accepting any incoming data











