Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev to staging #67

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions cmd/blockchain/main.go

This file was deleted.

13 changes: 0 additions & 13 deletions pkg/api/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,6 @@ func WorkerLoginController(c *gin.Context) {
func CreateTasksController(c *gin.Context) {
log.Info().Msg("Creating Tasks")

// Log the headers of the request
headers := c.Request.Header
log.Info().Interface("headers", headers).Msg("Request headers")

// Log the size of the request
requestSize := c.Request.ContentLength
log.Info().Int64("requestSize", requestSize).Msg("Request size")

log.Debug().Interface("request body", c.Request.Body).Msg("Creating tasks with request body")

minerUserInterface, exists := c.Get("minerUser")
Expand Down Expand Up @@ -157,8 +149,6 @@ func CreateTasksController(c *gin.Context) {
return
}

log.Info().Str("minerUser", fmt.Sprintf("%+v", minerUser)).Msg("Miner user found")

// Here we will handle file upload
// Parse files from the form
form, err := c.MultipartForm()
Expand Down Expand Up @@ -476,9 +466,6 @@ func GetTaskByIdController(c *gin.Context) {
taskID := c.Param("task-id")
taskService := task.NewTaskService()

// TODO: Remove this after testing
log.Info().Interface("Headers", c.Request.Header).Msg("Request Headers")

task, err := taskService.GetTaskResponseById(c.Request.Context(), taskID)
if err != nil {
c.JSON(http.StatusInternalServerError, defaultErrorResponse("Internal server error"))
Expand Down
1 change: 1 addition & 0 deletions pkg/api/middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ func MinerAuthMiddleware() gin.HandlerFunc {

subnetState := blockchain.GetSubnetStateSubscriberInstance()
_, isFound := subnetState.FindMinerHotkeyIndex(foundApiKey.MinerUser().Hotkey)

if !isFound {
log.Error().Msg("Miner hotkey is deregistered")
c.AbortWithStatusJSON(http.StatusUnauthorized, defaultErrorResponse("Unauthorized"))
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ func LoginRoutes(router *gin.Engine) {
tasks := apiV1.Group("/tasks")
{
tasks.PUT("/submit-result/:task-id", WriteTaskRateLimiter(), WorkerAuthMiddleware(), SubmitTaskResultController)
tasks.POST("/create-tasks", InMetagraphOnly(), WriteTaskRateLimiter(), MinerAuthMiddleware(), CreateTasksController)
// TODO: re-enable InMetagraphOnly() in future
tasks.POST("/create-tasks", WriteTaskRateLimiter(), MinerAuthMiddleware(), CreateTasksController)
tasks.GET("/task-result/:task-id", ReadTaskRateLimiter(), GetTaskResultsController)
tasks.GET("/:task-id", ReadTaskRateLimiter(), GetTaskByIdController)
tasks.GET("/next-task/:task-id", ReadTaskRateLimiter(), WorkerAuthMiddleware(), GetNextInProgressTaskController)
Expand Down
14 changes: 10 additions & 4 deletions pkg/api/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,20 @@ func CustomGinLogger(logger *zerolog.Logger) gin.HandlerFunc {

logger := log.With().Logger().Output(consoleWriter)

// Log main request info
logger.Info().
Int("status_code", param.StatusCode).
Str("latency", param.Latency.String()).
Str("ip", param.ClientIP).
Str("method", param.Method).
Str("path", param.Path).
Int("resp_size", param.BodySize).
Int("status_code", param.StatusCode).
Str("latency", param.Latency.String()).
Int("req_size", len(body)).
Int("resp_size", param.BodySize).
Str("ip", param.ClientIP).
Msg("")

// Log headers separately
logger.Info().
Interface("headers", c.Request.Header).
Msg("")
}
}
Loading
Loading