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

Update get execution #48

Merged
merged 7 commits into from
Jan 7, 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
3 changes: 2 additions & 1 deletion .github/workflows/dev-test-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
ENDPOINT: "localhost:2206"
# TODO: remove this before merge
# Pin to this branch to have all the fix
AVS_BUILD_VERSION: passing-result-to-subsequent-steps
AVS_BUILD_VERSION: update-sdk

steps:
- name: Checkout repository
Expand Down Expand Up @@ -53,4 +53,5 @@ jobs:
run: |
export TEST_API_KEY="$(docker compose exec aggregator /ava create-api-key --role=admin --subject=apikey)"
export ENDPOINT="localhost:2206"
yarn run build
yarn test
5 changes: 5 additions & 0 deletions .github/workflows/staging-test-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ jobs:
- name: Install dependencies
run: yarn install

- name: Build typescript
run: |
npm run
npm run build
- name: Run tests againts staging AVS
run: |
yarn test
35 changes: 27 additions & 8 deletions grpc_codegen/avs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,27 @@ enum Error {
// Error occurs when we failed to migrate task data and it cannot be decode
TaskDataCorrupted = 7000;
TaskDataMissingError = 7001;
// Trigger Task failed
TaskTriggerError = 7003;
}


// TaskStatus represents status of the task. The transition is as follow
enum TaskStatus {
Active = 0;
// Task is completd when it's reaching its max_execution or its expiration time
Completed = 1;
Failed = 2;
Canceled = 3;
Executing = 4;
}

// Execution Status re-present a run of the task
enum ExecutionStatus {
Queued = 0;
Finished = 2;
}

message ETHTransferNode {
string destination = 1;
string amount = 2;
Expand Down Expand Up @@ -208,7 +217,7 @@ message TaskNode {
}

message Execution {
string id = 1;
string id = 1;
int64 start_at = 2;
int64 end_at = 3;
bool success = 4;
Expand All @@ -232,6 +241,7 @@ message Execution {
repeated Step steps = 8;
}


message Task {
string id = 1;
string owner = 2;
Expand Down Expand Up @@ -291,8 +301,8 @@ message NonceResp {
message ListWalletReq {
// filter out by factory address or salt
// otherwise return all the wallet
string factory = 1;
string salt = 2;
string factory_address = 1;
string salt = 2;
}

message SmartWallet {
Expand Down Expand Up @@ -355,11 +365,15 @@ message ListExecutionsResp {
bool has_more = 4;
}

message GetExecutionReq {
message ExecutionReq {
string task_id = 1;
string execution_id = 2;
}

message ExecutionStatusResp {
ExecutionStatus status = 1;
}

message GetKeyReq {
string owner = 1;
int64 expired_at = 2;
Expand Down Expand Up @@ -422,9 +436,12 @@ message UserTriggerTaskReq {
}

message UserTriggerTaskResp {
bool result = 1;
// if trigger inline, the execution id will be returned
string execution_id = 2;
// Regardless whether it is a block or async, we always get back the same kind of id for this trigger.
// The caller then make a second request to GetExecution to check for the execution status and data.
// In the blocking mode, the execution_id is materialized and has been created, we can then call GetExecution on it immediately to receive result
// In async mode, the execution_id is created ahead of time and not materialized, calling GetExecutionStatus on it will return Status=Pending for example. Once Status=Completed you can call GetExecution to get all log and detail. Call GetExecution before it is completed will result in "Execution Not Found"
string execution_id = 1;
ExecutionStatus status = 2;
}

service Aggregator {
Expand All @@ -441,7 +458,9 @@ service Aggregator {
rpc ListTasks(ListTasksReq) returns (ListTasksResp) {};
rpc GetTask(IdReq) returns (Task) {};
rpc ListExecutions(ListExecutionsReq) returns (ListExecutionsResp) {};
rpc GetExecution(GetExecutionReq) returns (Execution) {};

rpc GetExecution(ExecutionReq) returns (Execution) {};
rpc GetExecutionStatus(ExecutionReq) returns (ExecutionStatusResp) {};

rpc CancelTask(IdReq) returns (google.protobuf.BoolValue) {};
rpc DeleteTask(IdReq) returns (google.protobuf.BoolValue) {};
Expand Down
37 changes: 27 additions & 10 deletions grpc_codegen/avs_grpc_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface IAggregatorService extends grpc.ServiceDefinition<grpc.UntypedServiceI
getTask: IAggregatorService_IGetTask;
listExecutions: IAggregatorService_IListExecutions;
getExecution: IAggregatorService_IGetExecution;
getExecutionStatus: IAggregatorService_IGetExecutionStatus;
cancelTask: IAggregatorService_ICancelTask;
deleteTask: IAggregatorService_IDeleteTask;
triggerTask: IAggregatorService_ITriggerTask;
Expand Down Expand Up @@ -95,15 +96,24 @@ interface IAggregatorService_IListExecutions extends grpc.MethodDefinition<avs_p
responseSerialize: grpc.serialize<avs_pb.ListExecutionsResp>;
responseDeserialize: grpc.deserialize<avs_pb.ListExecutionsResp>;
}
interface IAggregatorService_IGetExecution extends grpc.MethodDefinition<avs_pb.GetExecutionReq, avs_pb.Execution> {
interface IAggregatorService_IGetExecution extends grpc.MethodDefinition<avs_pb.ExecutionReq, avs_pb.Execution> {
path: "/aggregator.Aggregator/GetExecution";
requestStream: false;
responseStream: false;
requestSerialize: grpc.serialize<avs_pb.GetExecutionReq>;
requestDeserialize: grpc.deserialize<avs_pb.GetExecutionReq>;
requestSerialize: grpc.serialize<avs_pb.ExecutionReq>;
requestDeserialize: grpc.deserialize<avs_pb.ExecutionReq>;
responseSerialize: grpc.serialize<avs_pb.Execution>;
responseDeserialize: grpc.deserialize<avs_pb.Execution>;
}
interface IAggregatorService_IGetExecutionStatus extends grpc.MethodDefinition<avs_pb.ExecutionReq, avs_pb.ExecutionStatusResp> {
path: "/aggregator.Aggregator/GetExecutionStatus";
requestStream: false;
responseStream: false;
requestSerialize: grpc.serialize<avs_pb.ExecutionReq>;
requestDeserialize: grpc.deserialize<avs_pb.ExecutionReq>;
responseSerialize: grpc.serialize<avs_pb.ExecutionStatusResp>;
responseDeserialize: grpc.deserialize<avs_pb.ExecutionStatusResp>;
}
interface IAggregatorService_ICancelTask extends grpc.MethodDefinition<avs_pb.IdReq, google_protobuf_wrappers_pb.BoolValue> {
path: "/aggregator.Aggregator/CancelTask";
requestStream: false;
Expand Down Expand Up @@ -143,7 +153,8 @@ export interface IAggregatorServer extends grpc.UntypedServiceImplementation {
listTasks: grpc.handleUnaryCall<avs_pb.ListTasksReq, avs_pb.ListTasksResp>;
getTask: grpc.handleUnaryCall<avs_pb.IdReq, avs_pb.Task>;
listExecutions: grpc.handleUnaryCall<avs_pb.ListExecutionsReq, avs_pb.ListExecutionsResp>;
getExecution: grpc.handleUnaryCall<avs_pb.GetExecutionReq, avs_pb.Execution>;
getExecution: grpc.handleUnaryCall<avs_pb.ExecutionReq, avs_pb.Execution>;
getExecutionStatus: grpc.handleUnaryCall<avs_pb.ExecutionReq, avs_pb.ExecutionStatusResp>;
cancelTask: grpc.handleUnaryCall<avs_pb.IdReq, google_protobuf_wrappers_pb.BoolValue>;
deleteTask: grpc.handleUnaryCall<avs_pb.IdReq, google_protobuf_wrappers_pb.BoolValue>;
triggerTask: grpc.handleUnaryCall<avs_pb.UserTriggerTaskReq, avs_pb.UserTriggerTaskResp>;
Expand Down Expand Up @@ -174,9 +185,12 @@ export interface IAggregatorClient {
listExecutions(request: avs_pb.ListExecutionsReq, callback: (error: grpc.ServiceError | null, response: avs_pb.ListExecutionsResp) => void): grpc.ClientUnaryCall;
listExecutions(request: avs_pb.ListExecutionsReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: avs_pb.ListExecutionsResp) => void): grpc.ClientUnaryCall;
listExecutions(request: avs_pb.ListExecutionsReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: avs_pb.ListExecutionsResp) => void): grpc.ClientUnaryCall;
getExecution(request: avs_pb.GetExecutionReq, callback: (error: grpc.ServiceError | null, response: avs_pb.Execution) => void): grpc.ClientUnaryCall;
getExecution(request: avs_pb.GetExecutionReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: avs_pb.Execution) => void): grpc.ClientUnaryCall;
getExecution(request: avs_pb.GetExecutionReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: avs_pb.Execution) => void): grpc.ClientUnaryCall;
getExecution(request: avs_pb.ExecutionReq, callback: (error: grpc.ServiceError | null, response: avs_pb.Execution) => void): grpc.ClientUnaryCall;
getExecution(request: avs_pb.ExecutionReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: avs_pb.Execution) => void): grpc.ClientUnaryCall;
getExecution(request: avs_pb.ExecutionReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: avs_pb.Execution) => void): grpc.ClientUnaryCall;
getExecutionStatus(request: avs_pb.ExecutionReq, callback: (error: grpc.ServiceError | null, response: avs_pb.ExecutionStatusResp) => void): grpc.ClientUnaryCall;
getExecutionStatus(request: avs_pb.ExecutionReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: avs_pb.ExecutionStatusResp) => void): grpc.ClientUnaryCall;
getExecutionStatus(request: avs_pb.ExecutionReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: avs_pb.ExecutionStatusResp) => void): grpc.ClientUnaryCall;
cancelTask(request: avs_pb.IdReq, callback: (error: grpc.ServiceError | null, response: google_protobuf_wrappers_pb.BoolValue) => void): grpc.ClientUnaryCall;
cancelTask(request: avs_pb.IdReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_wrappers_pb.BoolValue) => void): grpc.ClientUnaryCall;
cancelTask(request: avs_pb.IdReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: google_protobuf_wrappers_pb.BoolValue) => void): grpc.ClientUnaryCall;
Expand Down Expand Up @@ -214,9 +228,12 @@ export class AggregatorClient extends grpc.Client implements IAggregatorClient {
public listExecutions(request: avs_pb.ListExecutionsReq, callback: (error: grpc.ServiceError | null, response: avs_pb.ListExecutionsResp) => void): grpc.ClientUnaryCall;
public listExecutions(request: avs_pb.ListExecutionsReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: avs_pb.ListExecutionsResp) => void): grpc.ClientUnaryCall;
public listExecutions(request: avs_pb.ListExecutionsReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: avs_pb.ListExecutionsResp) => void): grpc.ClientUnaryCall;
public getExecution(request: avs_pb.GetExecutionReq, callback: (error: grpc.ServiceError | null, response: avs_pb.Execution) => void): grpc.ClientUnaryCall;
public getExecution(request: avs_pb.GetExecutionReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: avs_pb.Execution) => void): grpc.ClientUnaryCall;
public getExecution(request: avs_pb.GetExecutionReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: avs_pb.Execution) => void): grpc.ClientUnaryCall;
public getExecution(request: avs_pb.ExecutionReq, callback: (error: grpc.ServiceError | null, response: avs_pb.Execution) => void): grpc.ClientUnaryCall;
public getExecution(request: avs_pb.ExecutionReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: avs_pb.Execution) => void): grpc.ClientUnaryCall;
public getExecution(request: avs_pb.ExecutionReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: avs_pb.Execution) => void): grpc.ClientUnaryCall;
public getExecutionStatus(request: avs_pb.ExecutionReq, callback: (error: grpc.ServiceError | null, response: avs_pb.ExecutionStatusResp) => void): grpc.ClientUnaryCall;
public getExecutionStatus(request: avs_pb.ExecutionReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: avs_pb.ExecutionStatusResp) => void): grpc.ClientUnaryCall;
public getExecutionStatus(request: avs_pb.ExecutionReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: avs_pb.ExecutionStatusResp) => void): grpc.ClientUnaryCall;
public cancelTask(request: avs_pb.IdReq, callback: (error: grpc.ServiceError | null, response: google_protobuf_wrappers_pb.BoolValue) => void): grpc.ClientUnaryCall;
public cancelTask(request: avs_pb.IdReq, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: google_protobuf_wrappers_pb.BoolValue) => void): grpc.ClientUnaryCall;
public cancelTask(request: avs_pb.IdReq, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: google_protobuf_wrappers_pb.BoolValue) => void): grpc.ClientUnaryCall;
Expand Down
38 changes: 30 additions & 8 deletions grpc_codegen/avs_grpc_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,26 @@ function deserialize_aggregator_Execution(buffer_arg) {
return avs_pb.Execution.deserializeBinary(new Uint8Array(buffer_arg));
}

function serialize_aggregator_GetExecutionReq(arg) {
if (!(arg instanceof avs_pb.GetExecutionReq)) {
throw new Error('Expected argument of type aggregator.GetExecutionReq');
function serialize_aggregator_ExecutionReq(arg) {
if (!(arg instanceof avs_pb.ExecutionReq)) {
throw new Error('Expected argument of type aggregator.ExecutionReq');
}
return Buffer.from(arg.serializeBinary());
}

function deserialize_aggregator_GetExecutionReq(buffer_arg) {
return avs_pb.GetExecutionReq.deserializeBinary(new Uint8Array(buffer_arg));
function deserialize_aggregator_ExecutionReq(buffer_arg) {
return avs_pb.ExecutionReq.deserializeBinary(new Uint8Array(buffer_arg));
}

function serialize_aggregator_ExecutionStatusResp(arg) {
if (!(arg instanceof avs_pb.ExecutionStatusResp)) {
throw new Error('Expected argument of type aggregator.ExecutionStatusResp');
}
return Buffer.from(arg.serializeBinary());
}

function deserialize_aggregator_ExecutionStatusResp(buffer_arg) {
return avs_pb.ExecutionStatusResp.deserializeBinary(new Uint8Array(buffer_arg));
}

function serialize_aggregator_GetKeyReq(arg) {
Expand Down Expand Up @@ -333,13 +344,24 @@ createTask: {
path: '/aggregator.Aggregator/GetExecution',
requestStream: false,
responseStream: false,
requestType: avs_pb.GetExecutionReq,
requestType: avs_pb.ExecutionReq,
responseType: avs_pb.Execution,
requestSerialize: serialize_aggregator_GetExecutionReq,
requestDeserialize: deserialize_aggregator_GetExecutionReq,
requestSerialize: serialize_aggregator_ExecutionReq,
requestDeserialize: deserialize_aggregator_ExecutionReq,
responseSerialize: serialize_aggregator_Execution,
responseDeserialize: deserialize_aggregator_Execution,
},
getExecutionStatus: {
path: '/aggregator.Aggregator/GetExecutionStatus',
requestStream: false,
responseStream: false,
requestType: avs_pb.ExecutionReq,
responseType: avs_pb.ExecutionStatusResp,
requestSerialize: serialize_aggregator_ExecutionReq,
requestDeserialize: deserialize_aggregator_ExecutionReq,
responseSerialize: serialize_aggregator_ExecutionStatusResp,
responseDeserialize: deserialize_aggregator_ExecutionStatusResp,
},
cancelTask: {
path: '/aggregator.Aggregator/CancelTask',
requestStream: false,
Expand Down
56 changes: 41 additions & 15 deletions grpc_codegen/avs_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,8 @@ export namespace NonceResp {
}

export class ListWalletReq extends jspb.Message {
getFactory(): string;
setFactory(value: string): ListWalletReq;
getFactoryAddress(): string;
setFactoryAddress(value: string): ListWalletReq;
getSalt(): string;
setSalt(value: string): ListWalletReq;

Expand All @@ -873,7 +873,7 @@ export class ListWalletReq extends jspb.Message {

export namespace ListWalletReq {
export type AsObject = {
factory: string,
factoryAddress: string,
salt: string,
}
}
Expand Down Expand Up @@ -1096,29 +1096,49 @@ export namespace ListExecutionsResp {
}
}

export class GetExecutionReq extends jspb.Message {
export class ExecutionReq extends jspb.Message {
getTaskId(): string;
setTaskId(value: string): GetExecutionReq;
setTaskId(value: string): ExecutionReq;
getExecutionId(): string;
setExecutionId(value: string): GetExecutionReq;
setExecutionId(value: string): ExecutionReq;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): GetExecutionReq.AsObject;
static toObject(includeInstance: boolean, msg: GetExecutionReq): GetExecutionReq.AsObject;
toObject(includeInstance?: boolean): ExecutionReq.AsObject;
static toObject(includeInstance: boolean, msg: ExecutionReq): ExecutionReq.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: GetExecutionReq, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): GetExecutionReq;
static deserializeBinaryFromReader(message: GetExecutionReq, reader: jspb.BinaryReader): GetExecutionReq;
static serializeBinaryToWriter(message: ExecutionReq, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): ExecutionReq;
static deserializeBinaryFromReader(message: ExecutionReq, reader: jspb.BinaryReader): ExecutionReq;
}

export namespace GetExecutionReq {
export namespace ExecutionReq {
export type AsObject = {
taskId: string,
executionId: string,
}
}

export class ExecutionStatusResp extends jspb.Message {
getStatus(): ExecutionStatus;
setStatus(value: ExecutionStatus): ExecutionStatusResp;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): ExecutionStatusResp.AsObject;
static toObject(includeInstance: boolean, msg: ExecutionStatusResp): ExecutionStatusResp.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: ExecutionStatusResp, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): ExecutionStatusResp;
static deserializeBinaryFromReader(message: ExecutionStatusResp, reader: jspb.BinaryReader): ExecutionStatusResp;
}

export namespace ExecutionStatusResp {
export type AsObject = {
status: ExecutionStatus,
}
}

export class GetKeyReq extends jspb.Message {
getOwner(): string;
setOwner(value: string): GetKeyReq;
Expand Down Expand Up @@ -1286,10 +1306,10 @@ export namespace UserTriggerTaskReq {
}

export class UserTriggerTaskResp extends jspb.Message {
getResult(): boolean;
setResult(value: boolean): UserTriggerTaskResp;
getExecutionId(): string;
setExecutionId(value: string): UserTriggerTaskResp;
getStatus(): ExecutionStatus;
setStatus(value: ExecutionStatus): UserTriggerTaskResp;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): UserTriggerTaskResp.AsObject;
Expand All @@ -1303,8 +1323,8 @@ export class UserTriggerTaskResp extends jspb.Message {

export namespace UserTriggerTaskResp {
export type AsObject = {
result: boolean,
executionId: string,
status: ExecutionStatus,
}
}

Expand All @@ -1317,6 +1337,7 @@ export enum Error {
SMARTWALLETNOTFOUNDERROR = 6001,
TASKDATACORRUPTED = 7000,
TASKDATAMISSINGERROR = 7001,
TASKTRIGGERERROR = 7003,
}

export enum TaskStatus {
Expand All @@ -1327,6 +1348,11 @@ export enum TaskStatus {
EXECUTING = 4,
}

export enum ExecutionStatus {
QUEUED = 0,
FINISHED = 2,
}

export enum CustomCodeLang {
JAVASCRIPT = 0,
}
Loading
Loading