Skip to content

Commit

Permalink
rebase and some linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mssabr01 committed Apr 22, 2024
1 parent f81382b commit 788984f
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,7 @@ export const queryFromArchivers = async (
const randomArchivers = Utils.getRandomItemFromArr(filteredArchivers, 0, maxNumberofArchiversToRetry)
let retry = 0
while (retry < maxNumberofArchiversToRetry) {
// eslint-disable-next-line security/detect-object-injection
let randomArchiver = randomArchivers[retry]
if (!randomArchiver) randomArchiver = randomArchivers[0]
try {
Expand Down
13 changes: 2 additions & 11 deletions src/Data/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,21 +542,12 @@ export function addDataSender(sender: DataSender): void {
dataSenders.set(sender.nodeInfo.publicKey, sender)
}

interface configConsensusResponse {
config?: {
sharding?: {
nodesPerConsensusGroup?: number
nodesPerEdge?: number
}
}
}

async function getConsensusRadius(): Promise<number> {
// If there is no node, return existing currentConsensusRadius
if (NodeList.getList().length === 0) return currentConsensusRadius

// Define the query function to get the network config from a node
const queryFn = async (node) => {
const queryFn = async (node): Promise<object> => {
const REQUEST_NETCONFIG_TIMEOUT_SECOND = 2 // 2s timeout
try {
const response = await P2P.getJson(
Expand All @@ -571,7 +562,7 @@ async function getConsensusRadius(): Promise<number> {
}

// Define the equality function to compare two responses
const equalityFn = (responseA, responseB) => {
const equalityFn = (responseA, responseB): boolean => {
return (
responseA.config.sharding.nodesPerConsensusGroup === responseB.config.sharding.nodesPerConsensusGroup
)
Expand Down
1 change: 1 addition & 0 deletions src/GlobalAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const syncGlobalAccount = async (): Promise<void> => {
)
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const equalFn = (info1: any, info2: any): boolean => {
const cm1 = deepCopy(info1)
const cm2 = deepCopy(info2)
Expand Down
4 changes: 3 additions & 1 deletion src/shardeum/calculateAccountHash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export enum AccountType {
}

export const accountSpecificHash = (account: any): string => {
let hash
let hash: string
delete account.hash
if (
account.accountType === AccountType.NetworkAccount ||
Expand Down Expand Up @@ -58,6 +58,7 @@ export const accountSpecificHash = (account: any): string => {
}

// Converting the correct account data format to get the correct hash
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const fixAccountUint8Arrays = (account: any): void => {
if (!account) return // if account is null, return
if (account.storageRoot) account.storageRoot = Uint8Array.from(Object.values(account.storageRoot)) // Account
Expand Down Expand Up @@ -93,6 +94,7 @@ export const verifyAccountHash = (receipt: ArchiverReceipt): boolean => {
)
return false
}
// eslint-disable-next-line security/detect-object-injection
const expectedAccountHash = receipt.appliedReceipt.appliedVote.account_state_hash_after[indexOfAccount]
if (calculatedAccountHash !== expectedAccountHash) {
Logger.mainLogger.error(
Expand Down
2 changes: 1 addition & 1 deletion src/shardeum/verifyAppReceiptData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const verifyAppReceiptData = async (
}

// Converting the correct appReceipt data format to get the correct hash
const calculateAppReceiptDataHash = (appReceiptData: any): string => {
const calculateAppReceiptDataHash = (appReceiptData): string => {
try {
if (appReceiptData.data && appReceiptData.data.receipt) {
if (appReceiptData.data.receipt.bitvector)
Expand Down
2 changes: 1 addition & 1 deletion src/sync-v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { ArchiverNodeInfo } from '../State'
import { getActiveNodeListFromArchiver } from '../NodeList'
import * as NodeList from '../NodeList'
import { verifyCycleRecord, verifyStandbyList, verifyValidatorList } from './verify'
import { verifyCycleRecord, verifyValidatorList } from './verify'
import * as Logger from '../Logger'

/**
Expand Down
1 change: 1 addition & 0 deletions src/utils/stringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const defaultStringifierOptions: stringifierOptions = {
bufferEncoding: 'base64',
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function stringify(val: any, options: stringifierOptions = defaultStringifierOptions): string {
const returnVal = stringifier(val, false, options)
if (returnVal !== undefined) {
Expand Down

0 comments on commit 788984f

Please sign in to comment.