Skip to content

Commit

Permalink
Merge pull request #2399 from AztecProtocol/stage
Browse files Browse the repository at this point in the history
Pw/logging and optimisations (#2398)
  • Loading branch information
PhilWindle authored Feb 17, 2023
2 parents d0de04e + 6b9b68f commit 5160615
Show file tree
Hide file tree
Showing 24 changed files with 740 additions and 186 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,9 @@ jobs:
- run:
name: 'Build sidecar'
command: build metrics-sidecar
- run:
name: 'Build fluent-bit'
command: build fluent-bit
- run:
name: 'Build prometheus'
command: build prometheus
Expand Down Expand Up @@ -814,6 +817,9 @@ jobs:
- run:
name: 'sidecar'
command: deploy_ecr metrics-sidecar
- run:
name: 'fluent-bit'
command: deploy_ecr fluent-bit
- run:
name: 'prometheus'
command: deploy_global prometheus
Expand Down
12 changes: 6 additions & 6 deletions yarn-project/barretenberg.js/src/blockchain/blockchain_status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type BlockchainAssetJson = Jsonify<BlockchainAsset>;

export const blockchainAssetToJson = ({ address, ...asset }: BlockchainAsset): BlockchainAssetJson => ({
...asset,
address: address.toString(),
address: address.toLowerCaseAddress(),
});

export const blockchainAssetFromJson = ({ address, ...asset }: BlockchainAssetJson): BlockchainAsset => ({
Expand All @@ -55,7 +55,7 @@ export type BlockchainBridgeJson = Jsonify<BlockchainBridge>;

export const blockchainBridgeToJson = ({ address, ...bridge }: BlockchainBridge): BlockchainBridgeJson => ({
...bridge,
address: address.toString(),
address: address.toLowerCaseAddress(),
});

export const blockchainBridgeFromJson = ({ address, ...bridge }: BlockchainBridgeJson): BlockchainBridge => ({
Expand Down Expand Up @@ -88,10 +88,10 @@ export type BlockchainStatusJson = Jsonify<BlockchainStatus>;
export function blockchainStatusToJson(status: BlockchainStatus): BlockchainStatusJson {
return {
...status,
rollupContractAddress: status.rollupContractAddress.toString(),
permitHelperContractAddress: status.permitHelperContractAddress.toString(),
verifierContractAddress: status.verifierContractAddress.toString(),
bridgeDataProvider: status.bridgeDataProvider.toString(),
rollupContractAddress: status.rollupContractAddress.toLowerCaseAddress(),
permitHelperContractAddress: status.permitHelperContractAddress.toLowerCaseAddress(),
verifierContractAddress: status.verifierContractAddress.toLowerCaseAddress(),
bridgeDataProvider: status.bridgeDataProvider.toLowerCaseAddress(),
dataRoot: status.dataRoot.toString('hex'),
nullRoot: status.nullRoot.toString('hex'),
rootRoot: status.rootRoot.toString('hex'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export const runtimeConfigToJson = ({
maxFeePerGas: maxFeePerGas.toString(),
maxPriorityFeePerGas: maxPriorityFeePerGas.toString(),
privacySets: privacySetsToJson(privacySets),
rollupBeneficiary: rollupBeneficiary ? rollupBeneficiary.toString() : undefined,
blacklist: blacklist ? blacklist.map(x => x.toString()) : undefined,
rollupBeneficiary: rollupBeneficiary ? rollupBeneficiary.toLowerCaseAddress() : undefined,
blacklist: blacklist ? blacklist.map(x => x.toLowerCaseAddress()) : undefined,
});

export const runtimeConfigFromJson = ({
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/block-server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export function appFactory(server: Server, prefix: string) {
});

const app = new Koa();
app.on('error', error => {
console.log(`KOA app-level error. ${JSON.stringify({ error })}`);
});
app.proxy = true;
app.use(compress({ br: false } as any));
app.use(cors());
Expand Down
52 changes: 48 additions & 4 deletions yarn-project/block-server/terraform/dev/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ resource "aws_ecs_task_definition" "block-server" {
cpu = "2048"
memory = "4096"
execution_role_arn = data.terraform_remote_state.setup_iac.outputs.ecs_task_execution_role_arn
task_role_arn = data.terraform_remote_state.aztec2_iac.outputs.cloudwatch_logging_ecs_role_arn

container_definitions = <<DEFINITIONS
[
Expand Down Expand Up @@ -104,11 +105,14 @@ resource "aws_ecs_task_definition" "block-server" {
}
],
"logConfiguration": {
"logDriver": "awslogs",
"logDriver":"awsfirelens",
"options": {
"awslogs-group": "/fargate/service/${var.DEPLOY_TAG}/block-server",
"awslogs-region": "eu-west-2",
"awslogs-stream-prefix": "ecs"
"Name": "cloudwatch",
"region": "eu-west-2",
"log_key": "log",
"log_stream_name": "/ecs/$(container_name)/$(ecs_task_id)",
"log_group_name": "/fargate/service/${var.DEPLOY_TAG}/block-server",
"auto_create_group": "false"
}
}
},
Expand Down Expand Up @@ -136,6 +140,46 @@ resource "aws_ecs_task_definition" "block-server" {
"awslogs-stream-prefix": "ecs"
}
}
},
{
"essential": true,
"image": "278380418400.dkr.ecr.eu-west-2.amazonaws.com/fluent-bit:latest",
"name": "log_router",
"firelensConfiguration": {
"type": "fluentbit",
"options": {
"enable-ecs-log-metadata": "true",
"config-file-type":"file",
"config-file-value":"/etc/fluent-bit/fluent-bit.conf"
}
},
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/fargate/service/${var.DEPLOY_TAG}/block-server",
"awslogs-region": "eu-west-2",
"awslogs-stream-prefix": "ecs"
}
},
"environment": [
{
"name": "DEPLOY_TAG",
"value": "${var.DEPLOY_TAG}"
},
{
"name": "SERVICE",
"value": "block-server"
},
{
"name": "LOKI_HOST",
"value": "loki.local"
},
{
"name": "LOKI_PORT",
"value": "3100"
}
],
"memoryReservation": 64
}
]
DEFINITIONS
Expand Down
51 changes: 40 additions & 11 deletions yarn-project/block-server/terraform/prod/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ resource "aws_ecs_task_definition" "block-server" {
cpu = "2048"
memory = "4096"
execution_role_arn = data.terraform_remote_state.setup_iac.outputs.ecs_task_execution_role_arn
task_role_arn = data.terraform_remote_state.aztec2_iac.outputs.cloudwatch_logging_ecs_role_arn

container_definitions = <<DEFINITIONS
[
Expand Down Expand Up @@ -104,15 +105,15 @@ resource "aws_ecs_task_definition" "block-server" {
}
],
"logConfiguration": {
"logDriver": "awsfirelens",
"options": {
"Name": "grafana-loki",
"Url": "http://loki.local:3100/loki/api/v1/push",
"Labels": "{environment=\"${var.DEPLOY_TAG}\", service=\"block-server\"}",
"RemoveKeys": "container_id,ecs_task_arn",
"LabelKeys": "container_name,ecs_task_definition,source,ecs_cluster",
"LineFormat": "key_value"
}
"logDriver":"awsfirelens",
"options": {
"Name": "cloudwatch",
"region": "eu-west-2",
"log_key": "log",
"log_stream_name": "/ecs/$(container_name)/$(ecs_task_id)",
"log_group_name": "/fargate/service/${var.DEPLOY_TAG}/block-server",
"auto_create_group": "false"
}
}
},
{
Expand Down Expand Up @@ -142,14 +143,42 @@ resource "aws_ecs_task_definition" "block-server" {
},
{
"essential": true,
"image": "grafana/fluent-bit-plugin-loki:2.7.0-amd64",
"image": "278380418400.dkr.ecr.eu-west-2.amazonaws.com/fluent-bit:latest",
"name": "log_router",
"firelensConfiguration": {
"type": "fluentbit",
"options": {
"enable-ecs-log-metadata": "true"
"enable-ecs-log-metadata": "true",
"config-file-type":"file",
"config-file-value":"/etc/fluent-bit/fluent-bit.conf"
}
},
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/fargate/service/${var.DEPLOY_TAG}/block-server",
"awslogs-region": "eu-west-2",
"awslogs-stream-prefix": "ecs"
}
},
"environment": [
{
"name": "DEPLOY_TAG",
"value": "${var.DEPLOY_TAG}"
},
{
"name": "SERVICE",
"value": "block-server"
},
{
"name": "LOKI_HOST",
"value": "loki.local"
},
{
"name": "LOKI_PORT",
"value": "3100"
}
],
"memoryReservation": 64
}
]
Expand Down
51 changes: 40 additions & 11 deletions yarn-project/block-server/terraform/stage/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ resource "aws_ecs_task_definition" "block-server" {
cpu = "2048"
memory = "4096"
execution_role_arn = data.terraform_remote_state.setup_iac.outputs.ecs_task_execution_role_arn
task_role_arn = data.terraform_remote_state.aztec2_iac.outputs.cloudwatch_logging_ecs_role_arn

container_definitions = <<DEFINITIONS
[
Expand Down Expand Up @@ -106,15 +107,15 @@ resource "aws_ecs_task_definition" "block-server" {
}
],
"logConfiguration": {
"logDriver": "awsfirelens",
"options": {
"Name": "grafana-loki",
"Url": "http://loki.local:3100/loki/api/v1/push",
"Labels": "{environment=\"${var.DEPLOY_TAG}\", service=\"block-server\"}",
"RemoveKeys": "container_id,ecs_task_arn",
"LabelKeys": "container_name,ecs_task_definition,source,ecs_cluster",
"LineFormat": "key_value"
}
"logDriver":"awsfirelens",
"options": {
"Name": "cloudwatch",
"region": "eu-west-2",
"log_key": "log",
"log_stream_name": "/ecs/$(container_name)/$(ecs_task_id)",
"log_group_name": "/fargate/service/${var.DEPLOY_TAG}/block-server",
"auto_create_group": "false"
}
}
},
{
Expand Down Expand Up @@ -144,14 +145,42 @@ resource "aws_ecs_task_definition" "block-server" {
},
{
"essential": true,
"image": "grafana/fluent-bit-plugin-loki:2.7.0-amd64",
"image": "278380418400.dkr.ecr.eu-west-2.amazonaws.com/fluent-bit:latest",
"name": "log_router",
"firelensConfiguration": {
"type": "fluentbit",
"options": {
"enable-ecs-log-metadata": "true"
"enable-ecs-log-metadata": "true",
"config-file-type":"file",
"config-file-value":"/etc/fluent-bit/fluent-bit.conf"
}
},
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/fargate/service/${var.DEPLOY_TAG}/block-server",
"awslogs-region": "eu-west-2",
"awslogs-stream-prefix": "ecs"
}
},
"environment": [
{
"name": "DEPLOY_TAG",
"value": "${var.DEPLOY_TAG}"
},
{
"name": "SERVICE",
"value": "block-server"
},
{
"name": "LOKI_HOST",
"value": "loki.local"
},
{
"name": "LOKI_PORT",
"value": "3100"
}
],
"memoryReservation": 64
}
]
Expand Down
51 changes: 40 additions & 11 deletions yarn-project/block-server/terraform/testnet/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ resource "aws_ecs_task_definition" "block-server" {
cpu = "2048"
memory = "4096"
execution_role_arn = data.terraform_remote_state.setup_iac.outputs.ecs_task_execution_role_arn
task_role_arn = data.terraform_remote_state.aztec2_iac.outputs.cloudwatch_logging_ecs_role_arn

container_definitions = <<DEFINITIONS
[
Expand Down Expand Up @@ -104,15 +105,15 @@ resource "aws_ecs_task_definition" "block-server" {
}
],
"logConfiguration": {
"logDriver": "awsfirelens",
"options": {
"Name": "grafana-loki",
"Url": "http://loki.local:3100/loki/api/v1/push",
"Labels": "{environment=\"${var.DEPLOY_TAG}\", service=\"block-server\"}",
"RemoveKeys": "container_id,ecs_task_arn",
"LabelKeys": "container_name,ecs_task_definition,source,ecs_cluster",
"LineFormat": "key_value"
}
"logDriver":"awsfirelens",
"options": {
"Name": "cloudwatch",
"region": "eu-west-2",
"log_key": "log",
"log_stream_name": "/ecs/$(container_name)/$(ecs_task_id)",
"log_group_name": "/fargate/service/${var.DEPLOY_TAG}/block-server",
"auto_create_group": "false"
}
}
},
{
Expand Down Expand Up @@ -142,14 +143,42 @@ resource "aws_ecs_task_definition" "block-server" {
},
{
"essential": true,
"image": "grafana/fluent-bit-plugin-loki:2.7.0-amd64",
"image": "278380418400.dkr.ecr.eu-west-2.amazonaws.com/fluent-bit:latest",
"name": "log_router",
"firelensConfiguration": {
"type": "fluentbit",
"options": {
"enable-ecs-log-metadata": "true"
"enable-ecs-log-metadata": "true",
"config-file-type":"file",
"config-file-value":"/etc/fluent-bit/fluent-bit.conf"
}
},
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/fargate/service/${var.DEPLOY_TAG}/block-server",
"awslogs-region": "eu-west-2",
"awslogs-stream-prefix": "ecs"
}
},
"environment": [
{
"name": "DEPLOY_TAG",
"value": "${var.DEPLOY_TAG}"
},
{
"name": "SERVICE",
"value": "block-server"
},
{
"name": "LOKI_HOST",
"value": "loki.local"
},
{
"name": "LOKI_PORT",
"value": "3100"
}
],
"memoryReservation": 64
}
]
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/falafel/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ export function appFactory(server: Server, prefix: string, metrics: Metrics, ser
});

const app = new Koa();
app.on('error', error => {
console.log(`KOA app-level error. ${JSON.stringify({ error })}`);
});
app.proxy = true;
app.use(compress({ br: false } as any));
app.use(cors());
Expand Down
Loading

0 comments on commit 5160615

Please sign in to comment.