Skip to content

Commit

Permalink
don't write router contract when movement not move
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzhiran committed Jan 22, 2025
1 parent dfa7984 commit 2e1cc01
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions task/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ func (r *processor) process(taskID common.Hash) error {
slog.Error("failed to handle task", "error", err)
return err
}
if len(proof) == 0 {
return nil
}
processTime := time.Since(startTime)
slog.Info("process task success", "project_id", t.ProjectID.String(), "task_id", t.ID, "process_time", processTime)
metrics.TaskDurationMtc.WithLabelValues(t.ProjectID.String(), t.ProjectVersion, t.ID.String()).Set(processTime.Seconds())
Expand Down
4 changes: 4 additions & 0 deletions vm/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ func encodeMovementPayload(task *task.Task, projectConfig *project.Config) ([]by
slog.Info("------", "lastPayload", string(task.PrevTask.Payload))
slog.Info("------", "curPayload", string(task.Payload))

if isMove == 0 {
return nil, nil
}

assignment := ProofofMovementCircuit{
LastPayloadHash: uints.NewU8Array(lastPayloadHash[:]),
LastTimestamp: lastTimestamp,
Expand Down
3 changes: 3 additions & 0 deletions vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ func (r *Handler) Handle(task *task.Task, projectConfig *project.Config) ([]byte
if err != nil {
return nil, errors.Wrap(err, "failed to load payload")
}
if len(taskPayload) == 0 {
return nil, nil
}
conn, ok := r.vmClients[projectConfig.VMTypeID]
if !ok {
return nil, errors.Errorf("unsupported vm type id %d", projectConfig.VMTypeID)
Expand Down

0 comments on commit 2e1cc01

Please sign in to comment.