Skip to content

use timestamp in rpc request #107

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

Merged
merged 1 commit into from
Jan 22, 2025
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
11 changes: 4 additions & 7 deletions aggregator/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"strings"
"time"

"github.com/AvaProtocol/ap-avs/core/auth"
"github.com/AvaProtocol/ap-avs/model"
Expand Down Expand Up @@ -52,7 +51,7 @@ func (r *RpcServer) GetKey(ctx context.Context, payload *avsproto.GetKeyReq) (*a
}
} else {
// We need to have 3 things to verify the signature: the signature, the hash of the original data, and the public key of the signer. With this information we can determine if the private key holder of the public key pair did indeed sign the message
text := fmt.Sprintf(authTemplate, payload.ChainId, payload.IssuedAt, payload.ExpiredAt, payload.Owner)
text := fmt.Sprintf(authTemplate, payload.ChainId, payload.IssuedAt.AsTime().UTC().Format("2006-01-02T15:04:05.000Z"), payload.ExpiredAt.AsTime().UTC().Format("2006-01-02T15:04:05.000Z"), payload.Owner)
data := []byte(text)
hash := accounts.TextHash(data)

Expand All @@ -78,14 +77,12 @@ func (r *RpcServer) GetKey(ctx context.Context, payload *avsproto.GetKeyReq) (*a
}
}

expiredAt, err := time.Parse(time.RFC3339, payload.ExpiredAt)

if err != nil {
return nil, status.Error(codes.InvalidArgument, auth.MalformedExpirationTime)
if err := payload.ExpiredAt.CheckValid(); err != nil {
return nil, status.Errorf(codes.Unauthenticated, auth.MalformedExpirationTime)
}

claims := &jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(expiredAt),
ExpiresAt: jwt.NewNumericDate(payload.ExpiredAt.AsTime()),
Issuer: auth.Issuer,
Subject: payload.Owner,
}
Expand Down
6 changes: 4 additions & 2 deletions core/taskengine/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ func (x *TaskExecutor) RunTask(task *model.Task, queueData *QueueExecutionData)
task.TotalExecution += 1
task.LastRanAt = t0.Unix()

vm.Compile()
if err = vm.Compile(); err != nil {
x.logger.Error("error compile task", "error", err, "edges", task.Edges, "node", task.Nodes, "task trigger data", task.Trigger, "task trigger metadata", triggerMetadata)
}
runTaskErr := vm.Run()

t1 := time.Now()
Expand All @@ -121,7 +123,7 @@ func (x *TaskExecutor) RunTask(task *model.Task, queueData *QueueExecutionData)
}

if runTaskErr != nil {
x.logger.Error("error executing task", "error", err, "task_id", task.Id, "triggermark", triggerMetadata)
x.logger.Error("error executing task", "error", err, "runError", runTaskErr, "task_id", task.Id, "triggermark", triggerMetadata)
execution.Error = runTaskErr.Error()
}

Expand Down
Loading
Loading