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

Introduce the use of path aliases in @dendreth/relay #365

Merged
merged 13 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions beacon-light-client/plonky2/input_fetchers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"devDependencies": {
"@types/circomlibjs": "^0",
"@types/json-bigint": "^1",
"@types/node": "^18.0.0",
"@types/yargs": "^17.0.32",
"tsx": "^4.7.1"
},
Expand Down
6 changes: 5 additions & 1 deletion beacon-light-client/plonky2/input_fetchers/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": "../../../tsconfig.json"
"extends": "../../../tsconfig.json",
"references": [
{
"path":"../../../relay"
}],
}
7 changes: 7 additions & 0 deletions beacon-light-client/solidity/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
require('dotenv').config();

require('tsconfig-paths').register({
baseUrl: './',
paths: {
'@/*': ['../../relay/*'],
},
});

// Disabled due to compatibility issues with pnpapi
// TODO: Replace with modern alternative
// import 'hardhat-gas-reporter';
Expand Down
1 change: 1 addition & 0 deletions beacon-light-client/solidity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"chai-as-promised": "^7.1.2",
"dotenv": "^16.4.4",
"env-paths": "^3.0.0",
"tsconfig-paths": "^4.2.0",
"typescript": "5.2.2"
},
"exports": {
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
"clean:normal": "yarn clean:jest && EXCL_NM='-e node_modules' yarn clean:untracked_artifacts",
"clean:jest": "jest --clear-cache",
"clean:untracked_artifacts": "git clean -fdx -e .env -e .direnv -e .yarn -e .vscode $EXCL_NM -- $(git rev-parse --show-toplevel)",
"check:build": "cd beacon-light-client/solidity/ && yarn build:sol && cd ../../ && yarn tsc",
"check:build": "cd beacon-light-client/solidity/ && yarn build:sol && cd ../../ && yarn tsc -b ./tsconfig.json",
"format:check": "prettier --check . && alejandra --exclude ./.yarn --exclude ./node_modules --exclude ./yarn-project.nix --check .",
"format:write": "prettier --write . && alejandra --exclude ./.yarn --exclude ./node_modules --exclude ./yarn-project.nix .",
"test": "jest --verbose --silent -i",
"test-emcc": "USE_EMCC=1 jest --verbose --silent",
"ts": "yarn node --import tsx",
"build-plonky-2": "tsc -p beacon-light-client/plonky2/input_fetchers/tsconfig.json"
"build-plonky-2": "yarn tsc -b beacon-light-client/plonky2/input_fetchers/tsconfig.json"
smanilov marked this conversation as resolved.
Show resolved Hide resolved
},
"dependencies": {
"@chainsafe/bls": "^6.0.3",
Expand Down Expand Up @@ -109,6 +109,9 @@
"get-changed-validators": "dist/beacon-light-client/plonky2/validators_commitment_mapper_tree/get_changed_validators.js"
},
"dependenciesMeta": {
"@lodestar/[email protected]": {
"unplugged": true
smanilov marked this conversation as resolved.
Show resolved Hide resolved
},
"@openzeppelin/[email protected]": {
"unplugged": true
},
Expand Down
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
4 changes: 1 addition & 3 deletions relay/implementations/eos-contract.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
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';
import { getDataFromPrintHeaderResult } from '@dendreth/utils/cosmos-utils/cosmos-utils';
import { formatHex } from '@dendreth/utils/ts-utils/bls';
import { getGenericLogger } from '@dendreth/utils/ts-utils/logger';

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
8 changes: 4 additions & 4 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,17 +7,17 @@ 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';
//

import { Redis as RedisClient, Result } from 'ioredis';
import chalk from 'chalk';
import {
getDepthByGindex,
splitIntoBatches,
} from '@dendreth/utils/ts-utils/common-utils';
import { validatorFromValidatorJSON } from '../utils/converters';
import { validatorFromValidatorJSON } from '@/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
9 changes: 8 additions & 1 deletion relay/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{
"extends": "../tsconfig.json"
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./*"],
"@/lodestar-types": ["../.yarn/unplugged/@lodestar-types-npm-1.17.0-1607a25762/node_modules/@lodestar/types/lib/utils/executionAddress"]
EmilIvanichkovv marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
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
8 changes: 4 additions & 4 deletions relay/utils/orchestrator.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Queue } from 'bullmq';
import { GetUpdate } from '../types/types';
import { Config } from '../constants/constants';
import { GetUpdate } from '@/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 { findClosestValidBlock } from '../workers/poll-updates/get_light_client_input_from_to';
import { IBeaconApi } from '@/abstraction/beacon-api-interface';
import { findClosestValidBlock } from '@/workers/poll-updates/get_light_client_input_from_to';
import { getGenericLogger } from '@dendreth/utils/ts-utils/logger';

const logger = getGenericLogger();
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
Loading