Skip to content

Commit

Permalink
Revert "Revert "Create a debugRoutingConfig param and a UnicornSecret (
Browse files Browse the repository at this point in the history
…#290)" - see more details in descriptions (#301)"

This reverts commit b7f0630.
  • Loading branch information
jsy1218 committed Aug 20, 2023
1 parent b7f0630 commit 5c1a006
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bin/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class RoutingAPIStage extends Stage {
tenderlyUser: string
tenderlyProject: string
tenderlyAccessKey: string
unicornSecret: string
}
) {
super(scope, id, props)
Expand All @@ -51,6 +52,7 @@ export class RoutingAPIStage extends Stage {
tenderlyUser,
tenderlyProject,
tenderlyAccessKey,
unicornSecret,
} = props

const { url } = new RoutingAPIStack(this, 'RoutingAPI', {
Expand All @@ -67,6 +69,7 @@ export class RoutingAPIStage extends Stage {
tenderlyUser,
tenderlyProject,
tenderlyAccessKey,
unicornSecret,
})
this.url = url
}
Expand Down Expand Up @@ -123,6 +126,11 @@ export class RoutingAPIPipeline extends Stack {
//secretCompleteArn: arn:aws:secretsmanager:us-east-2:644039819003:secret:routing-api-rpc-urls-json-backup-D2sWoe
})

// Secret that controls the access to the debugging query string params
const unicornSecrets = sm.Secret.fromSecretAttributes(this, 'DebugConfigUnicornSecrets', {
secretCompleteArn: 'arn:aws:secretsmanager:us-east-2:644039819003:secret:debug-config-unicornsecrets-jvmCsq',
})

const tenderlyCreds = sm.Secret.fromSecretAttributes(this, 'TenderlyCreds', {
secretCompleteArn: 'arn:aws:secretsmanager:us-east-2:644039819003:secret:tenderly-api-wQaI2R',
})
Expand Down Expand Up @@ -173,6 +181,7 @@ export class RoutingAPIPipeline extends Stack {
tenderlyUser: tenderlyCreds.secretValueFromJson('tenderly-user').toString(),
tenderlyProject: tenderlyCreds.secretValueFromJson('tenderly-project').toString(),
tenderlyAccessKey: tenderlyCreds.secretValueFromJson('tenderly-access-key').toString(),
unicornSecret: unicornSecrets.secretValueFromJson('debug-config-unicorn-key').toString(),
})

const betaUsEast2AppStage = pipeline.addStage(betaUsEast2Stage)
Expand All @@ -195,6 +204,7 @@ export class RoutingAPIPipeline extends Stack {
tenderlyUser: tenderlyCreds.secretValueFromJson('tenderly-user').toString(),
tenderlyProject: tenderlyCreds.secretValueFromJson('tenderly-project').toString(),
tenderlyAccessKey: tenderlyCreds.secretValueFromJson('tenderly-access-key').toString(),
unicornSecret: unicornSecrets.secretValueFromJson('debug-config-unicornsecrets').toString(),
})

const prodUsEast2AppStage = pipeline.addStage(prodUsEast2Stage)
Expand Down Expand Up @@ -289,6 +299,7 @@ new RoutingAPIStack(app, 'RoutingAPIStack', {
tenderlyUser: process.env.TENDERLY_USER!,
tenderlyProject: process.env.TENDERLY_PROJECT!,
tenderlyAccessKey: process.env.TENDERLY_ACCESS_KEY!,
unicornSecret: process.env.UNICORN_SECRET!,
})

new RoutingAPIPipeline(app, 'RoutingAPIPipelineStack', {
Expand Down
3 changes: 3 additions & 0 deletions bin/stacks/routing-api-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class RoutingAPIStack extends cdk.Stack {
tenderlyUser: string
tenderlyProject: string
tenderlyAccessKey: string
unicornSecret: string
}
) {
super(parent, name, props)
Expand All @@ -59,6 +60,7 @@ export class RoutingAPIStack extends cdk.Stack {
tenderlyUser,
tenderlyProject,
tenderlyAccessKey,
unicornSecret,
} = props

const {
Expand Down Expand Up @@ -98,6 +100,7 @@ export class RoutingAPIStack extends cdk.Stack {
cachedRoutesDynamoDb,
cachingRequestFlagDynamoDb,
cachedV3PoolsDynamoDb,
unicornSecret,
})

const accessLogGroup = new aws_logs.LogGroup(this, 'RoutingAPIGAccessLogs')
Expand Down
3 changes: 3 additions & 0 deletions bin/stacks/routing-lambda-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface RoutingLambdaStackProps extends cdk.NestedStackProps {
cachedRoutesDynamoDb?: aws_dynamodb.Table
cachingRequestFlagDynamoDb?: aws_dynamodb.Table
cachedV3PoolsDynamoDb?: aws_dynamodb.Table
unicornSecret: string
}
export class RoutingLambdaStack extends cdk.NestedStack {
public readonly routingLambda: aws_lambda_nodejs.NodejsFunction
Expand All @@ -51,6 +52,7 @@ export class RoutingLambdaStack extends cdk.NestedStack {
cachedRoutesDynamoDb,
cachingRequestFlagDynamoDb,
cachedV3PoolsDynamoDb,
unicornSecret,
} = props

const lambdaRole = new aws_iam.Role(this, 'RoutingLambdaRole', {
Expand Down Expand Up @@ -97,6 +99,7 @@ export class RoutingLambdaStack extends cdk.NestedStack {
CACHED_ROUTES_TABLE_NAME: DynamoDBTableProps.CacheRouteDynamoDbTable.Name,
CACHING_REQUEST_FLAG_TABLE_NAME: DynamoDBTableProps.CachingRequestFlagDynamoDbTable.Name,
CACHED_V3_POOLS_TABLE_NAME: DynamoDBTableProps.V3PoolsDynamoDbTable.Name,
UNICORN_SECRET: unicornSecret,
...jsonRpcProviders,
},
layers: [
Expand Down
8 changes: 8 additions & 0 deletions lib/handlers/quote/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ export class QuoteHandler extends APIGLambdaHandler<
permitSigDeadline,
enableUniversalRouter,
quoteSpeed,
debugRoutingConfig,
unicornSecret,
intent,
},
requestInjected: {
Expand Down Expand Up @@ -212,13 +214,19 @@ export class QuoteHandler extends APIGLambdaHandler<
protocols = [Protocol.V3]
}

let parsedDebugRoutingConfig = {}
if (debugRoutingConfig && unicornSecret && unicornSecret === process.env.UNICORN_SECRET) {
parsedDebugRoutingConfig = JSON.parse(debugRoutingConfig)
}

const routingConfig: AlphaRouterConfig = {
...DEFAULT_ROUTING_CONFIG_BY_CHAIN(chainId),
...(minSplits ? { minSplits } : {}),
...(forceCrossProtocol ? { forceCrossProtocol } : {}),
...(forceMixedRoutes ? { forceMixedRoutes } : {}),
protocols,
...(quoteSpeed ? QUOTE_SPEED_CONFIG[quoteSpeed] : {}),
...parsedDebugRoutingConfig,
...(intent ? INTENT_SPECIFIC_CONFIG[intent] : {}),
}

Expand Down
4 changes: 4 additions & 0 deletions lib/handlers/quote/schema/quote-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export const QuoteQueryParamsJoi = Joi.object({
// TODO: Remove once universal router is no longer behind a feature flag.
enableUniversalRouter: Joi.boolean().optional().default(false),
quoteSpeed: Joi.string().valid('fast', 'standard').optional().default('standard'),
debugRoutingConfig: Joi.string().optional(),
unicornSecret: Joi.string().optional(),
intent: Joi.string().valid('quote', 'swap', 'caching').optional().default('quote'),
}).and('recipient', 'slippageTolerance', 'deadline')

Expand Down Expand Up @@ -85,5 +87,7 @@ export type QuoteQueryParams = {
permitSigDeadline?: string
enableUniversalRouter?: boolean
quoteSpeed?: string
debugRoutingConfig?: string
unicornSecret?: string
intent?: string
}

0 comments on commit 5c1a006

Please sign in to comment.