Skip to content

Commit

Permalink
make rr use nonce manager and increase concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
Intizar-T committed Aug 19, 2024
1 parent 52c5d93 commit b131f51
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 15 deletions.
3 changes: 2 additions & 1 deletion core/src/reporter/request-response.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Logger } from 'pino'
import type { RedisClientType } from 'redis'
import {
CONCURRENCY,
NONCE_MANAGER_REQUEST_RESPONSE_QUEUE_NAME,
REPORTER_REQUEST_RESPONSE_QUEUE_NAME,
REQUEST_RESPONSE_REPORTER_STATE_NAME,
Expand All @@ -15,7 +16,7 @@ export async function buildReporter(redisClient: RedisClientType, logger: Logger
service: REQUEST_RESPONSE_SERVICE_NAME,
nonceManagerQueueName: NONCE_MANAGER_REQUEST_RESPONSE_QUEUE_NAME,
reporterQueueName: REPORTER_REQUEST_RESPONSE_QUEUE_NAME,
concurrency: 1,
concurrency: CONCURRENCY,
delegatedFee: false,
_logger: logger,
})
Expand Down
8 changes: 4 additions & 4 deletions core/src/worker/request-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const FILE_NAME = import.meta.url

export async function worker(redisClient: RedisClientType, _logger: Logger) {
const logger = _logger.child({ name: 'worker', file: FILE_NAME })
const queue = new Queue(NONCE_MANAGER_REQUEST_RESPONSE_QUEUE_NAME, BULLMQ_CONNECTION)
const nonceManagerQueue = new Queue(NONCE_MANAGER_REQUEST_RESPONSE_QUEUE_NAME, BULLMQ_CONNECTION)
const worker = new Worker(
WORKER_REQUEST_RESPONSE_QUEUE_NAME,
await job(queue, _logger),
await job(nonceManagerQueue, _logger),
BULLMQ_CONNECTION,
)

Expand All @@ -45,7 +45,7 @@ export async function worker(redisClient: RedisClientType, _logger: Logger) {
process.on('SIGTERM', handleExit)
}

export async function job(reporterQueue: QueueType, _logger: Logger) {
export async function job(nonceManagerQueue: QueueType, _logger: Logger) {
const logger = _logger.child({ name: 'job', file: FILE_NAME })
const iface = new ethers.utils.Interface(RequestResponseCoordinator__factory.abi)

Expand Down Expand Up @@ -78,7 +78,7 @@ export async function job(reporterQueue: QueueType, _logger: Logger) {
)
logger.debug(tx, 'tx')

await reporterQueue.add('request-response', tx, {
await nonceManagerQueue.add('request-response', tx, {
jobId: inData.requestId,
...WORKER_JOB_SETTINGS,
})
Expand Down
7 changes: 3 additions & 4 deletions docker-compose.local-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ services:
json-rpc:
build:
context: .
dockerfile: dockerfiles/local-data-feed/contracts.Dockerfile
dockerfile: dockerfiles/local-vrf-rr/json-rpc.Dockerfile
image: json-rpc
expose:
- "8545"
Expand All @@ -88,11 +88,10 @@ services:
build:
context: .
dockerfile: dockerfiles/local-vrf-rr/core-cli-contracts.Dockerfile
args:
SERVICE: ${SERVICE}
image: core-cli-contracts
volumes:
- ./dockerfiles/local-vrf-rr/scripts/setup-${SERVICE}.sh:/setup.sh
depends_on:
api:
condition: service_healthy
env_file: dockerfiles/local-vrf-rr/envs/.core-cli-contracts.env
command: /bin/sh -c "/setup.sh"
13 changes: 12 additions & 1 deletion dockerfiles/local-vrf-rr/core-cli-contracts.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# node:20.10.0-slim
FROM node@sha256:18aacc7993a16f1d766c21e3bff922e830bcdc7b549bbb789ceb7374a6138480 AS build

ARG SERVICE

RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*

WORKDIR /app
Expand Down Expand Up @@ -29,6 +31,9 @@ COPY core core

COPY cli cli

COPY dockerfiles/local-vrf-rr/scripts/setup-${SERVICE}.sh setup.sh
RUN chmod +x setup.sh

RUN yarn core install \
&& yarn core build \
&& yarn cli install \
Expand Down Expand Up @@ -68,4 +73,10 @@ COPY --from=build /app/util /app/util

COPY --from=build /app/core /app/core

COPY --from=build /app/cli /app/cli
COPY --from=build /app/cli /app/cli

COPY --from=build /app/setup.sh /app/setup.sh

RUN chmod +x setup.sh

CMD [ "/app/setup.sh" ]
1 change: 1 addition & 0 deletions dockerfiles/local-vrf-rr/envs/.api.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
DATABASE_URL=postgresql://testuser@postgres:5432/test?search_path=public
APP_PORT=3000
ENCRYPT_PASSWORD=anything
POST_TO_LOGSCRIBE=false

REDIS_HOST=redis
REDIS_PORT=6379
6 changes: 6 additions & 0 deletions dockerfiles/local-vrf-rr/json-rpc.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:20

WORKDIR /app
COPY contracts/v0.1/hardhat.config.cjs /app/hardhat.config.cjs
COPY contracts/v0.1/package.json /app/package.json
RUN yarn
2 changes: 1 addition & 1 deletion dockerfiles/local-vrf-rr/scripts/setup-rr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fi

ORACLE_ADDRESS=0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
if [ "$CHAIN" == "baobab" ]; then
ORACLE_ADDRESS=0x71F4d40dFe60349E67105E02AE5a1Db41fD5AF0e
ORACLE_ADDRESS=0x5fe8a7445bFDB2Cd6d9f1DcfB3B33D8c365FFdB0
elif [ "$CHAIN" == "cypress" ]; then
ORACLE_ADDRESS=0x159F3BB6609B4C709F15823F3544032942106042
fi
Expand Down
6 changes: 3 additions & 3 deletions dockerfiles/local-vrf-rr/scripts/update-hardhat-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const providerUrl = process.argv[2];

const dir = "contracts/v0.1/hardhat.config.cjs";
let fileContent = fs.readFileSync(dir, "utf8");
const pattern = /(localhost: {\n\s*gasPrice: 250_000_000_000\n\s*},)/g;
const pattern = /(localhost:\s*{\s*gasPrice:\s*250_000_000_000\s*,?\s*})/g;
const replacement = `localhost: {
gasPrice: 250_000_000_000,
url: ${providerUrl}
},`;
url: "${providerUrl}"
}`;
fileContent = fileContent.replace(pattern, replacement);
fs.writeFileSync(dir, fileContent);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
"monitor": "yarn workspace @bisonai/orakl-monitor",
"vrf": "yarn workspace @bisonai/orakl-vrf",
"util": "yarn workspace @bisonai/orakl-util",
"prepare": "husky install && chmod +x .husky/pre-commit"
"prepare": "husky && chmod +x .husky/pre-commit"
}
}

0 comments on commit b131f51

Please sign in to comment.