Skip to content

Commit

Permalink
refactor(relay): Use @ for paths within /relay
Browse files Browse the repository at this point in the history
  • Loading branch information
kkirkov committed Jul 1, 2024
1 parent 8a1d795 commit b284d3d
Show file tree
Hide file tree
Showing 26 changed files with 66 additions and 63 deletions.
2 changes: 1 addition & 1 deletion relay/abstraction/beacon-api-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ExecutionPayloadHeader,
SyncAggregate,
SyncCommittee,
} from '../types/types';
} from '@/types/types';

export interface IBeaconApi {
getBeaconRestApis(): string[];
Expand Down
2 changes: 1 addition & 1 deletion relay/abstraction/prover-interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Proof, ProofInputType } from '../types/types';
import { Proof, ProofInputType } from '@/types/types';

export interface IProver {
genProof(proofInput: ProofInputType): Promise<Proof>;
Expand Down
2 changes: 1 addition & 1 deletion relay/abstraction/redis-interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ProofResultType, WitnessGeneratorInput } from '../types/types';
import { ProofResultType, WitnessGeneratorInput } from '@/types/types';

export interface IRedis {
getNextProof(slot: number): Promise<ProofResultType | null>;
Expand Down
4 changes: 2 additions & 2 deletions relay/implementations/beacon-api.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { UintNumberType, ByteVectorType } from '@chainsafe/ssz';
import { ValueOfFields } from '@chainsafe/ssz/lib/view/container';
import { IBeaconApi } from '../abstraction/beacon-api-interface';
import { IBeaconApi } from '@/abstraction/beacon-api-interface';
import {
BeaconBlockHeader,
ExecutionPayloadHeader,
SyncAggregate,
SyncCommittee,
Validator,
} from '../types/types';
} from '@/types/types';
import { Tree } from '@chainsafe/persistent-merkle-tree';
import { bytesToHex } from '@dendreth/utils/ts-utils/bls';
import {
Expand Down
2 changes: 1 addition & 1 deletion relay/implementations/cosmos-contract.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ISmartContract } from '../abstraction/smart-contract-abstraction';
import { ISmartContract } from '@/abstraction/smart-contract-abstraction';
import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate';
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
import { promisify } from 'node:util';
Expand Down
2 changes: 1 addition & 1 deletion relay/implementations/eos-contract.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ISmartContract } from '../abstraction/smart-contract-abstraction';
import { ISmartContract } from '@/abstraction/smart-contract-abstraction';
import { promisify } from 'node:util';
import { exec as exec_ } from 'node:child_process';
import { compileVerifierParseDataTool } from '../../tests/helpers/helpers';
Expand Down
4 changes: 2 additions & 2 deletions relay/implementations/prover.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IProver } from '../abstraction/prover-interface';
import { ProofInputType, Proof, WitnessGeneratorInput } from '../types/types';
import { IProver } from '@/abstraction/prover-interface';
import { ProofInputType, Proof, WitnessGeneratorInput } from '@/types/types';
import { getGenericLogger } from '@dendreth/utils/ts-utils/logger';

const logger = getGenericLogger();
Expand Down
6 changes: 3 additions & 3 deletions relay/implementations/redis.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IRedis } from '../abstraction/redis-interface';
import { IRedis } from '@/abstraction/redis-interface';
import {
BalanceProof,
ProofResultType,
Expand All @@ -7,7 +7,7 @@ import {
BlsDepositData,
BalancesAccumulatorInput,
CommitmentMapperInput,
} from '../types/types';
} from '@/types/types';
import { RedisClientType, createClient } from 'redis';
import CONSTANTS from '../../beacon-light-client/plonky2/kv_db_constants.json';
//
Expand All @@ -17,7 +17,7 @@ import {
getDepthByGindex,
splitIntoBatches,
} from '@dendreth/utils/ts-utils/common-utils';
import { validatorFromValidatorJSON } from '../utils/converters';
import { validatorFromValidatorJSON } from '@dendreth/relay/utils/converters';
import JSONbig from 'json-bigint';

declare module 'ioredis' {
Expand Down
4 changes: 2 additions & 2 deletions relay/implementations/solidity-contract.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Contract } from 'ethers';
import { ISmartContract } from '../abstraction/smart-contract-abstraction';
import { ISmartContract } from '@/abstraction/smart-contract-abstraction';
import Web3 from 'web3';
import {
TransactionSpeed,
getSolidityProof,
publishTransaction,
} from './publish_evm_transaction';
} from '@/implementations/publish_evm_transaction';

export class SolidityContract implements ISmartContract {
private lightClientContract: Contract;
Expand Down
16 changes: 8 additions & 8 deletions relay/on_chain_publisher.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { GetUpdate, ProofResultType } from './types/types';
import { IBeaconApi } from './abstraction/beacon-api-interface';
import { IRedis } from './abstraction/redis-interface';
import { ISmartContract } from './abstraction/smart-contract-abstraction';
import { GetUpdate, ProofResultType } from '@/types/types';
import { IBeaconApi } from '@/abstraction/beacon-api-interface';
import { IRedis } from '@/abstraction/redis-interface';
import { ISmartContract } from '@/abstraction/smart-contract-abstraction';
import { Contract } from 'ethers';
import {
TransactionSpeed,
getSolidityProof,
publishTransaction,
} from './implementations/publish_evm_transaction';
} from '@/implementations/publish_evm_transaction';
import Web3 from 'web3';
import { checkConfig, sleep } from '@dendreth/utils/ts-utils/common-utils';
import { Queue } from 'bullmq';
import { Config, UPDATE_POLING_QUEUE } from './constants/constants';
import { getSlotOnChain } from './utils/smart_contract_utils';
import { addUpdate } from './utils/orchestrator';
import { Config, UPDATE_POLING_QUEUE } from '@/constants/constants';
import { getSlotOnChain } from '@/utils/smart_contract_utils';
import { addUpdate } from '@/utils/orchestrator';
import { getGenericLogger } from '@dendreth/utils/ts-utils/logger';

const logger = getGenericLogger();
Expand Down
2 changes: 1 addition & 1 deletion relay/relayer_logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { checkConfig } from '@dendreth/utils/ts-utils/common-utils';
import {
PROOF_GENERATOR_QUEUE,
UPDATE_POLING_QUEUE,
} from './constants/constants';
} from '@/constants/constants';
import { getGenericLogger } from '@dendreth/utils/ts-utils/logger';

const logger = getGenericLogger();
Expand Down
2 changes: 1 addition & 1 deletion relay/save_proof_inputs_from_redis.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { writeFile, writeFileSync } from 'fs';
import { Redis } from './implementations/redis';
import { Redis } from '@/implementations/redis';

(async () => {
const redis = new Redis('localhost', 6379);
Expand Down
8 changes: 7 additions & 1 deletion relay/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"extends": "../tsconfig.json"
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./*"]
}
}
}
2 changes: 1 addition & 1 deletion relay/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
UintBigintType,
} from '@chainsafe/ssz';
import { ValueOfFields } from '@chainsafe/ssz/lib/view/container';
import { Config } from '../constants/constants';
import { Config } from '@/constants/constants';

export type BeaconBlockHeader = ValueOfFields<{
slot: UintNumberType;
Expand Down
2 changes: 1 addition & 1 deletion relay/utils/converters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { hexToBytes } from '@dendreth/utils/ts-utils/bls';
import { Validator } from '../types/types';
import { Validator } from '@/types/types';

function stringToNumber(str: string): number {
return str == BigInt(2n ** 64n - 1n).toString() ? Infinity : Number(str);
Expand Down
7 changes: 2 additions & 5 deletions relay/utils/discord_monitor.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { SolidityContract } from '@dendreth/relay/implementations/solidity-contract';
import {
getBeaconApi,
BeaconApi,
} from '@dendreth/relay/implementations/beacon-api';
import { SolidityContract } from '@/implementations/solidity-contract';
import { getBeaconApi, BeaconApi } from '@/implementations/beacon-api';
import { ethers } from 'ethers';
import { sleep } from '@dendreth/utils/ts-utils/common-utils';
import { GatewayIntentBits, Events, Partials } from 'discord.js';
Expand Down
4 changes: 2 additions & 2 deletions relay/utils/get_current_network_config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { checkConfig } from '@dendreth/utils/ts-utils/common-utils';
import { Config } from '../constants/constants';
import * as network_config from '../constants/network_config.json';
import { Config } from '@/constants/constants';
import * as network_config from '@/constants/network_config.json';

export function getNetworkConfig(network: 'pratter' | 'mainnet'): Config {
const config = {
Expand Down
6 changes: 3 additions & 3 deletions relay/utils/orchestrator.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Queue } from 'bullmq';
import { GetUpdate } from '../types/types';
import { Config } from '../constants/constants';
import { GetUpdate } from '@dendreth/relay/types/types';
import { Config } from '@/constants/constants';
import {
SLOTS_PER_PERIOD,
computeSyncCommitteePeriodAt,
} from '@dendreth/utils/ts-utils/ssz-utils';
import { IBeaconApi } from '../abstraction/beacon-api-interface';
import { IBeaconApi } from '@dendreth/relay/abstraction/beacon-api-interface';
import { findClosestValidBlock } from '../workers/poll-updates/get_light_client_input_from_to';
import { getGenericLogger } from '@dendreth/utils/ts-utils/logger';

Expand Down
4 changes: 2 additions & 2 deletions relay/utils/smart_contract_utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IBeaconApi } from '../abstraction/beacon-api-interface';
import { ISmartContract } from '../abstraction/smart-contract-abstraction';
import { IBeaconApi } from '@/abstraction/beacon-api-interface';
import { ISmartContract } from '@/abstraction/smart-contract-abstraction';
import { getGenericLogger } from '@dendreth/utils/ts-utils/logger';

const logger = getGenericLogger();
Expand Down
4 changes: 2 additions & 2 deletions relay/workers/cleaner.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Queue } from 'bullmq';
import { checkConfig, sleep } from '@dendreth/utils/ts-utils/common-utils';
import { getGenericLogger } from '@dendreth/utils/ts-utils/logger';
import { GetUpdate } from '../types/types';
import { UPDATE_POLING_QUEUE } from '../constants/constants';
import { GetUpdate } from '@/types/types';
import { UPDATE_POLING_QUEUE } from '@/constants/constants';

const logger = getGenericLogger();

Expand Down
8 changes: 4 additions & 4 deletions relay/workers/poll-updates/do_update.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Queue } from 'bullmq';
import { IBeaconApi } from '../../abstraction/beacon-api-interface';
import { getInputFromTo } from './get_light_client_input_from_to';
import { ProofInputType } from '../../types/types';
import { Config } from '../../constants/constants';
import { IBeaconApi } from '@/abstraction/beacon-api-interface';
import { getInputFromTo } from '@/workers/poll-updates/get_light_client_input_from_to';
import { ProofInputType } from '@/types/types';
import { Config } from '@/constants/constants';
import { getGenericLogger } from '@dendreth/utils/ts-utils/logger';

const logger = getGenericLogger();
Expand Down
8 changes: 4 additions & 4 deletions relay/workers/poll-updates/get_light_client_input_from_to.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Config } from '../../constants/constants';
import { getProofInput } from './get_ligth_client_input';
import { IBeaconApi } from '../../abstraction/beacon-api-interface';
import { BeaconBlockHeader, SyncAggregate } from '../../types/types';
import { Config } from '@/constants/constants';
import { getProofInput } from '@/workers/poll-updates/get_ligth_client_input';
import { IBeaconApi } from '@/abstraction/beacon-api-interface';
import { BeaconBlockHeader, SyncAggregate } from '@/types/types';
import { getGenericLogger } from '@dendreth/utils/ts-utils/logger';
import { prometheusTiming } from '@dendreth/utils/ts-utils/prometheus-utils';

Expand Down
4 changes: 2 additions & 2 deletions relay/workers/poll-updates/get_ligth_client_input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import {
formatHex,
} from '@dendreth/utils/ts-utils/bls';
import { Tree } from '@chainsafe/persistent-merkle-tree';
import { Config } from '../../constants/constants';
import { Config } from '@/constants/constants';
import {
BeaconBlockHeader,
ExecutionPayloadHeader,
SyncAggregate,
SyncCommittee,
WitnessGeneratorInput,
} from '../../types/types';
} from '@/types/types';
import { computeSyncCommitteePeriodAt } from '@dendreth/utils/ts-utils/ssz-utils';

const ExecutionPayload = new ContainerType({
Expand Down
8 changes: 4 additions & 4 deletions relay/workers/poll-updates/poll-updates-worker.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Worker, Queue } from 'bullmq';
import { exec as _exec } from 'child_process';
import { GetUpdate, ProofInputType } from '../../types/types';
import { GetUpdate, ProofInputType } from '@/types/types';
import {
PROOF_GENERATOR_QUEUE,
UPDATE_POLING_QUEUE,
} from '../../constants/constants';
import doUpdate from './do_update';
import { getBeaconApi } from '@dendreth/relay/implementations/beacon-api';
} from '@/constants/constants';
import doUpdate from '@/workers/poll-updates/do_update';
import { getBeaconApi } from '@/implementations/beacon-api';
import { checkConfig } from '@dendreth/utils/ts-utils/common-utils';
import { getGenericLogger } from '@dendreth/utils/ts-utils/logger';
import { initPrometheusSetup } from '@dendreth/utils/ts-utils/prometheus-utils';
Expand Down
6 changes: 3 additions & 3 deletions relay/workers/prover/gen_proof.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IProver } from '../../abstraction/prover-interface';
import { IRedis } from '../../abstraction/redis-interface';
import { ProofInputType } from '../../types/types';
import { IProver } from '@/abstraction/prover-interface';
import { IRedis } from '@/abstraction/redis-interface';
import { ProofInputType } from '@/types/types';

export default async function genProof(
redis: IRedis,
Expand Down
10 changes: 5 additions & 5 deletions relay/workers/prover/prover-worker.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Worker } from 'bullmq';
import { exec as _exec } from 'child_process';
import { ProofInputType } from '../../types/types';
import genProof from './gen_proof';
import { Redis } from '@dendreth/relay/implementations/redis';
import { Prover } from '@dendreth/relay/implementations/prover';
import { PROOF_GENERATOR_QUEUE } from '../../constants/constants';
import { ProofInputType } from '@/types/types';
import genProof from '@/workers/prover/gen_proof';
import { Redis } from '@/implementations/redis';
import { Prover } from '@/implementations/prover';
import { PROOF_GENERATOR_QUEUE } from '@/constants/constants';
import { checkConfig } from '@dendreth/utils/ts-utils/common-utils';
import yargs from 'yargs';

Expand Down

0 comments on commit b284d3d

Please sign in to comment.