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 the new auth method and trigger matcher array #56

Merged
merged 15 commits into from
Jan 23, 2025
8 changes: 8 additions & 0 deletions .github/workflows/staging-test-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ jobs:
ORACLE_CONTRACT: ${{ vars.ORACLE_CONTRACT }}
ENDPOINT: ${{ vars.ENDPOINT }}
CHAIN_ENDPOINT: ${{ secrets.CHAIN_ENDPOINT }}
# On staging env, when test run it may not cleanup data properly for multiple reasons.
# In the next run, especially on pagination test, the assumption about data is wrong.
# For those kind of particular test, we want to ensure a 100% unique salt across run
# One way to do so, is get this run_id from github action and use it as salt
# On local dev, we just default to a hard code number in the test to isolate its. data
# on local test is continously wipe out on every run so it isn't a problem like staging
# We may want to sweep and delete task data on those test account
RUN_ID: ${{ github.run_id }}

steps:
- name: Checkout repository
Expand Down
3 changes: 2 additions & 1 deletion config/aggregator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ smart_wallet:
controller_private_key: e0502ddd5a0d05ec7b5c22614a01c8ce783810edaa98e44cc82f5fa5a819aaa9

macros:
notify_bot_token: "<telegram-bot-token-if-using-telebot>"
secrets:
notify_bot_token: "<telegram-bot-token-if-using-telebot>"
58 changes: 41 additions & 17 deletions grpc_codegen/avs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package aggregator;
option go_package = "./avsproto";

import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";

message IdReq {
string id = 1;
Expand All @@ -21,18 +22,37 @@ message BlockCondition {
int64 interval = 1;
}

// An arbitrary expression to express the condition.
// People can define condition example
// chainlinkPrice("address-of-eth-usd-pair") > 2644500 && queryContract("contractaddress", "callmsg")[2] < = 5
// By allow arbitrary expression, people can mix and match to create conplex
// condition that match their workload
//
// The function to be used need to be pre-defined on our task egnine runtime.
// When a new block is build, our engine will execute these check
//
// The expression language is re-present by https://expr-lang.org/
// EventCondition is a filter to match on an event. It's adhoc logic expression re-present in an array to match an ethereum event
message EventCondition {
string expression = 1;
message Matcher {
// the type of Filter we support, right now, we support below value for
// - topics:
// - address:
string type = 1;

// the payload of the type data to be mached. Each type will have different semantic meaning on how to match
// Given type=topics`. This value is the topic array, for every non null element of the array we perform an equal check
// If all are equal, the filter resolve to true
//
// Example:
// To find all ERC20 transfer event into or out to wallet 0x5DD596C901987A2b28C38A9C1DfBf86fFFc15d77 we can do
// value = [
// [
// "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
// "0x5DD596C901987A2b28C38A9C1DfBf86fFFc15d77", // tx out
// ],
// [
// "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
// null,
// "0x5DD596C901987A2b28C38A9C1DfBf86fFFc15d77" // tx in
// ],
// ]
repeated string value = 2;
}

// an array of filter to be mach, as soon as any element of the array mach, the trigger is fired.
repeated Matcher matcher = 1;
string expression = 2;
}


Expand All @@ -53,6 +73,7 @@ message TaskTrigger {
// support filter by event expression such as topic0, topic1, topoc2 and event_data and contract_address
EventCondition event = 6;
}
string id = 7;
}

// gRPC internal error code use up to 17, we extend and start from 1000 to avoid any conflict
Expand Down Expand Up @@ -153,6 +174,8 @@ message BranchNode {
message FilterNode {
// Filter node acts like .select or .filter to pluck out element in an array that evaluate the expression to true
string expression = 1;
// input is the id of the node that
string input = 2;
}

// LoopNode currently not support, but we pre-defined to reverse the field id
Expand All @@ -164,7 +187,6 @@ message LoopNode {
string iter_val = 2;
string iter_key = 3;


// inside the runner, it can access to the current value of the loop iteration through the iter_val/iter_key above
oneof runner {
// Transfer eth require no calldata etc, just a destination address and an eth amount to be sent
Expand All @@ -174,7 +196,7 @@ message LoopNode {
// multicall to wrap many calls. in a contract write, we need to generate signature and send as userops.
ContractWriteNode contract_write = 11;
// read data fron a target contract
ContractReadNode contract_read = 12;
ContractReadNode contract_read = 12;
// Make call to a graphql endpoint
GraphQLQueryNode graphql_data_query = 13 ;
// Make call to a HTTP endpoint
Expand Down Expand Up @@ -376,8 +398,10 @@ message ExecutionStatusResp {

message GetKeyReq {
string owner = 1;
int64 expired_at = 2;
string signature = 3;
int64 chain_id = 2;
google.protobuf.Timestamp issued_at = 3;
google.protobuf.Timestamp expired_at = 4;
string signature = 5;
}

message KeyResp {
Expand All @@ -390,8 +414,8 @@ message KeyResp {
// In an event trigger, we will have the log_index, tx_hash and the block_number
// In a time based trigger(cron/fixed time) we will have the epoch.
//
// TriggerMetadata is used to populate the `trigger.data` variable. Example, if this is a transfer
// event, then you will have access to trigger1.data.from_address trigger1.data.value
// TriggerMetadata is used to populate the `<trigger-name>.data` variable. Example, if this is a transfer
// event, then you will have access to <trigger-name>.data.from_address or <trigger-name>.data.value
message TriggerMetadata {
uint64 block_number = 1;
uint64 log_index = 2;
Expand Down
1 change: 1 addition & 0 deletions grpc_codegen/avs_grpc_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import * as grpc from "@grpc/grpc-js";
import * as avs_pb from "./avs_pb";
import * as google_protobuf_wrappers_pb from "google-protobuf/google/protobuf/wrappers_pb";
import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb";

interface IAggregatorService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
getKey: IAggregatorService_IGetKey;
Expand Down
1 change: 1 addition & 0 deletions grpc_codegen/avs_grpc_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
var grpc = require('@grpc/grpc-js');
var avs_pb = require('./avs_pb.js');
var google_protobuf_wrappers_pb = require('google-protobuf/google/protobuf/wrappers_pb.js');
var google_protobuf_timestamp_pb = require('google-protobuf/google/protobuf/timestamp_pb.js');

function serialize_aggregator_CreateTaskReq(arg) {
if (!(arg instanceof avs_pb.CreateTaskReq)) {
Expand Down
57 changes: 54 additions & 3 deletions grpc_codegen/avs_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import * as jspb from "google-protobuf";
import * as google_protobuf_wrappers_pb from "google-protobuf/google/protobuf/wrappers_pb";
import * as google_protobuf_timestamp_pb from "google-protobuf/google/protobuf/timestamp_pb";

export class IdReq extends jspb.Message {
getId(): string;
Expand Down Expand Up @@ -92,6 +93,10 @@ export namespace BlockCondition {
}

export class EventCondition extends jspb.Message {
clearMatcherList(): void;
getMatcherList(): Array<EventCondition.Matcher>;
setMatcherList(value: Array<EventCondition.Matcher>): EventCondition;
addMatcher(value?: EventCondition.Matcher, index?: number): EventCondition.Matcher;
getExpression(): string;
setExpression(value: string): EventCondition;

Expand All @@ -107,8 +112,36 @@ export class EventCondition extends jspb.Message {

export namespace EventCondition {
export type AsObject = {
matcherList: Array<EventCondition.Matcher.AsObject>,
expression: string,
}


export class Matcher extends jspb.Message {
getType(): string;
setType(value: string): Matcher;
clearValueList(): void;
getValueList(): Array<string>;
setValueList(value: Array<string>): Matcher;
addValue(value: string, index?: number): string;

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

export namespace Matcher {
export type AsObject = {
type: string,
valueList: Array<string>,
}
}

}

export class TaskTrigger extends jspb.Message {
Expand Down Expand Up @@ -139,6 +172,8 @@ export class TaskTrigger extends jspb.Message {
clearEvent(): void;
getEvent(): EventCondition | undefined;
setEvent(value?: EventCondition): TaskTrigger;
getId(): string;
setId(value: string): TaskTrigger;

getTriggerTypeCase(): TaskTrigger.TriggerTypeCase;

Expand All @@ -160,6 +195,7 @@ export namespace TaskTrigger {
cron?: CronCondition.AsObject,
block?: BlockCondition.AsObject,
event?: EventCondition.AsObject,
id: string,
}

export enum TriggerTypeCase {
Expand Down Expand Up @@ -384,6 +420,8 @@ export namespace BranchNode {
export class FilterNode extends jspb.Message {
getExpression(): string;
setExpression(value: string): FilterNode;
getInput(): string;
setInput(value: string): FilterNode;

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): FilterNode.AsObject;
Expand All @@ -398,6 +436,7 @@ export class FilterNode extends jspb.Message {
export namespace FilterNode {
export type AsObject = {
expression: string,
input: string,
}
}

Expand Down Expand Up @@ -1142,8 +1181,18 @@ export namespace ExecutionStatusResp {
export class GetKeyReq extends jspb.Message {
getOwner(): string;
setOwner(value: string): GetKeyReq;
getExpiredAt(): number;
setExpiredAt(value: number): GetKeyReq;
getChainId(): number;
setChainId(value: number): GetKeyReq;

hasIssuedAt(): boolean;
clearIssuedAt(): void;
getIssuedAt(): google_protobuf_timestamp_pb.Timestamp | undefined;
setIssuedAt(value?: google_protobuf_timestamp_pb.Timestamp): GetKeyReq;

hasExpiredAt(): boolean;
clearExpiredAt(): void;
getExpiredAt(): google_protobuf_timestamp_pb.Timestamp | undefined;
setExpiredAt(value?: google_protobuf_timestamp_pb.Timestamp): GetKeyReq;
getSignature(): string;
setSignature(value: string): GetKeyReq;

Expand All @@ -1160,7 +1209,9 @@ export class GetKeyReq extends jspb.Message {
export namespace GetKeyReq {
export type AsObject = {
owner: string,
expiredAt: number,
chainId: number,
issuedAt?: google_protobuf_timestamp_pb.Timestamp.AsObject,
expiredAt?: google_protobuf_timestamp_pb.Timestamp.AsObject,
signature: string,
}
}
Expand Down
Loading
Loading