Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerd77 committed Apr 22, 2024
2 parents e025e0d + 9631d98 commit 6278715
Show file tree
Hide file tree
Showing 25 changed files with 97 additions and 175 deletions.
8 changes: 4 additions & 4 deletions packages/blockchain/test/customConsensus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,19 @@ describe('consensus transition checks', () => {
const blockchain = await Blockchain.create({ common, consensus })

try {
await (blockchain as any).checkAndTransitionHardForkByNumber(5n)
await blockchain.checkAndTransitionHardForkByNumber(5n)
assert.ok('checkAndTransitionHardForkByNumber does not throw with custom consensus')
} catch (err: any) {
assert.fail(
`checkAndTransitionHardForkByNumber should not throw with custom consensus, error=${err.message}`
)
}

;(blockchain as any).consensus = new EthashConsensus()
;(blockchain.common as any).consensusAlgorithm = () => 'fibonacci'
blockchain.consensus = new EthashConsensus()
blockchain.common.consensusAlgorithm = () => 'fibonacci'

try {
await (blockchain as any).checkAndTransitionHardForkByNumber(5n)
await blockchain.checkAndTransitionHardForkByNumber(5n)
assert.fail(
'checkAndTransitionHardForkByNumber should throw when using standard consensus (ethash, clique, casper) but consensus algorithm defined in common is different'
)
Expand Down
3 changes: 1 addition & 2 deletions packages/client/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -995,8 +995,7 @@ async function run() {
chain: chainName,
mergeForkIdPostMerge: args.mergeForkIdPostMerge,
})
//@ts-ignore
common.customCrypto = cryptoFunctions
;(common.customCrypto as any) = cryptoFunctions
customGenesisState = parseGethGenesisState(genesisFile)
}

Expand Down
10 changes: 3 additions & 7 deletions packages/client/src/net/server/rlpxserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,10 @@ export class RlpxServer extends Server {
let peer: RlpxPeer | null = new RlpxPeer({
config: this.config,
id: bytesToUnprefixedHex(rlpxPeer.getId()!),
// @ts-ignore
host: rlpxPeer._socket.remoteAddress!,
// @ts-ignore
port: rlpxPeer._socket.remotePort!,
host: rlpxPeer['_socket'].remoteAddress!,
port: rlpxPeer['_socket'].remotePort!,
protocols: Array.from(this.protocols),
// @ts-ignore: Property 'server' does not exist on type 'Socket'.
// TODO: check this error
inbound: rlpxPeer._socket.server !== undefined,
inbound: (rlpxPeer['_socket'] as any).server !== undefined,
})
try {
await peer.accept(rlpxPeer, this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ type PayloadToPayloadStats = {
}

const logCLStatus = (logger: winston.Logger, logMsg: string, logLevel: logLevel) => {
//@ts-ignore
logger[logLevel](enginePrefix + logMsg)
}
export class CLConnectionManager {
Expand Down
6 changes: 1 addition & 5 deletions packages/client/test/net/server/rlpxserver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ describe('should return rlpx server info with ip4 as default', async () => {
}
;(server as any).rlpx = { destroy: vi.fn() }

// @ts-ignore
server.rlpx!.id = hexToBytes('0x' + mockId)
await server.start()
const nodeInfo = server.getRlpxInfo()
Expand Down Expand Up @@ -209,7 +208,6 @@ describe('should return rlpx server info with ip6', async () => {
}
;(server as any).rlpx = { destroy: vi.fn() }

// @ts-ignore
server.rlpx!.id = hexToBytes('0x' + mockId)

config.events.on(Event.SERVER_ERROR, (err) => {
Expand Down Expand Up @@ -346,8 +344,6 @@ describe('should init rlpx', async () => {
;(server as any).peers.set('01', { id: '01' } as any)
server.rlpx!.events.emit('peer:removed', rlpxPeer)
server.rlpx!.events.emit('peer:error', rlpxPeer, new Error('err0'))

// @ts-ignore
server.rlpx!.id = hexToBytes('0xff')
;(server.rlpx!.id as any) = hexToBytes('0xff')
server.rlpx!.events.emit('listening')
})
6 changes: 2 additions & 4 deletions packages/client/test/rpc/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,9 @@ export async function createClient(clientOpts: Partial<createClientArgs> = {}) {
savePreimages: clientOpts.savePreimages,
logger: getLogger({}),
})
const blockchain = clientOpts.blockchain ?? mockBlockchain()
const blockchain = clientOpts.blockchain ?? (mockBlockchain() as unknown as Blockchain)

const chain =
// @ts-ignore TODO Move to async Chain.create() initialization
clientOpts.chain ?? new Chain({ config, blockchain: blockchain as any, genesisState })
const chain = clientOpts.chain ?? (await Chain.create({ config, blockchain, genesisState }))
chain.opened = true

// if blockchain has not been bundled with chain, add the mock blockchain
Expand Down
7 changes: 4 additions & 3 deletions packages/client/test/sync/fetcher/headerfetcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ describe('[HeaderFetcher]', async () => {
const fetcher = new HeaderFetcher({ config, pool, flow })
const headers = [{ number: 1 }, { number: 2 }]
assert.deepEqual(
//@ts-ignore
fetcher.process({ task: { count: 2 }, peer: 'peer0' }, { headers, bv: BigInt(1) }),
fetcher.process(
{ task: { count: 2 }, peer: 'peer0' } as any,
{ headers, bv: BigInt(1) } as any
),
headers as any,
'got results'
)
//@ts-ignore
assert.notOk(
fetcher.process({ task: { count: 2 } } as any, { headers: [], bv: BigInt(1) } as any),
'bad results'
Expand Down
2 changes: 0 additions & 2 deletions packages/client/test/sync/fetcher/storagefetcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ describe('[StorageFetcher]', async () => {
JSON.stringify(utf8ToBytes(highestReceivedhash)),
'should set new highest known hash'
)

// @ts-ignore
;(job.task.storageRequests[0] as any).first = BigInt(3)
;(job.task.storageRequests[0] as any).count = BigInt(4)
const result = (await fetcher.request(job as any)) as any
Expand Down
5 changes: 2 additions & 3 deletions packages/common/test/customChains.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as testnet from './data/testnet.json'
import * as testnet2 from './data/testnet2.json'
import * as testnet3 from './data/testnet3.json'

import type { ChainConfig } from '../src/index.js'
import type { ChainConfig, HardforkTransitionConfig } from '../src/index.js'

describe('[Common]: Custom chains', () => {
it('chain -> object: should provide correct access to private network chain parameters', () => {
Expand Down Expand Up @@ -221,8 +221,7 @@ describe('custom chain setup with hardforks with undefined/null block numbers',
]

assert.throws(
//@ts-expect-error -- Disabling type check to verify that error is thrown
() => Common.custom({ hardforks: undefinedHardforks }),
() => Common.custom({ hardforks: undefinedHardforks as HardforkTransitionConfig[] }),
undefined,
undefined,
'throws when a hardfork with an undefined block number is passed'
Expand Down
9 changes: 3 additions & 6 deletions packages/devp2p/examples/peer-communication-les.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ const REMOTE_CLIENTID_FILTER = [
'prichain',
]

// @ts-ignore
const getPeerAddr = (peer: Peer) => `${peer._socket.remoteAddress}:${peer._socket.remotePort}`
const getPeerAddr = (peer: Peer) => `${peer['_socket'].remoteAddress}:${peer['_socket'].remotePort}`

// DPT
const dpt = new devp2p.DPT(PRIVATE_KEY, {
Expand Down Expand Up @@ -224,11 +223,9 @@ setInterval(() => {
const peersCount = dpt.getPeers().length
const openSlots = rlpx._getOpenSlots()

// @ts-ignore
const queueLength = rlpx._peersQueue.length
const queueLength = rlpx['_peersQueue'].length

// @ts-ignore
const queueLength2 = rlpx._peersQueue.filter((o) => o.ts <= Date.now()).length
const queueLength2 = rlpx['_peersQueue'].filter((o) => o.ts <= Date.now()).length

console.log(
chalk.yellow(
Expand Down
9 changes: 3 additions & 6 deletions packages/devp2p/examples/peer-communication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ const CHECK_BLOCK_HEADER = RLP.decode(
'0xf90219a0d44a4d33e28d7ea9edd12b69bd32b394587eee498b0e2543ce2bad1877ffbeaca01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347941ad91ee08f21be3de0ba2ba6918e714da6b45836a0fdec060ee45e55da9e36060fc95dddd0bdc47e447224666a895d9f0dc9adaa0ca0092d9fcc02ca9b372daec726704ce720d3aa366739868f4820ecaabadb9ac309a0974fee017515a46303f467b6fd50872994db1b0ea64d3455bad93ff9678aced9b90100356050004c5c89691add79838a01d4c302419252a4d3c96e9273908b7ee84660886c070607b4928c416a1800746a0d1dbb442d0baf06eea321422263726748600cc200e82aec08336863514d12d665718016989189c116bc0947046cc6718110586c11464a189000a11a41cc96991970153d88840768170244197e164c6204249b9091a0052ac85088c8108a4418dd2903690a036722623888ea14e90458a390a305a2342cb02766094f68c4100036330719848b48411614686717ab6068a46318204232429dc42020608802ceecd66c3c33a3a1fc6e82522049470328a4a81ba07c6604228ba94f008476005087a6804463696b41002650c0fdf548448a90408717ca31b6d618e883bad42083be153b83bdfbb1846078104798307834383639373636353666366532303530366636663663a0ae1de0acd35a98e211c7e276ad7524bb84a5e1b8d33dd7d1c052b095b564e8b888cca66773148b6e12'
)

// @ts-ignore
const getPeerAddr = (peer: Peer) => `${peer._socket.remoteAddress}:${peer._socket.remotePort}`
const getPeerAddr = (peer: Peer) => `${peer['_socket'].remoteAddress}:${peer['_socket'].remotePort}`

// DPT
const dpt = new devp2p.DPT(PRIVATE_KEY, {
Expand Down Expand Up @@ -373,11 +372,9 @@ setInterval(() => {
const peersCount = dpt.getPeers().length
const openSlots = rlpx._getOpenSlots()

// @ts-ignore
const queueLength = rlpx._peersQueue.length
const queueLength = rlpx['_peersQueue'].length

// @ts-ignore
const queueLength2 = rlpx._peersQueue.filter((o) => o.ts <= Date.now()).length
const queueLength2 = rlpx['_peersQueue'].filter((o) => o.ts <= Date.now()).length

console.log(
chalk.yellow(
Expand Down
31 changes: 10 additions & 21 deletions packages/devp2p/src/protocol/eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ export class ETH extends Protocol {

if (code !== ETH.MESSAGE_CODES.STATUS && this.DEBUG) {
const debugMsg = this.DEBUG
? // @ts-ignore
`Received ${this.getMsgPrefix(code)} message from ${this._peer._socket.remoteAddress}:${
// @ts-ignore
this._peer._socket.remotePort
}`
? `Received ${this.getMsgPrefix(code)} message from ${
this._peer['_socket'].remoteAddress
}:${this._peer['_socket'].remotePort}`
: undefined
const logData = formatLogData(bytesToHex(data), this._verbose)
this.debug(this.getMsgPrefix(code), `${debugMsg}: ${logData}`)
Expand All @@ -89,12 +87,8 @@ export class ETH extends Protocol {
if (this.DEBUG) {
const debugMsg = this.DEBUG
? `Received ${this.getMsgPrefix(code)} message from ${
// @ts-ignore
this._peer._socket.remoteAddress
}:${
// @ts-ignore
this._peer._socket.remotePort
}`
this._peer['_socket'].remoteAddress
}:${this._peer['_socket'].remotePort}`
: undefined
this.debug(this.getMsgPrefix(code), `${debugMsg}: ${peerStatusMsg}`)
}
Expand Down Expand Up @@ -305,19 +299,16 @@ export class ETH extends Protocol {
this.debug(
'STATUS',

// @ts-ignore
`Send STATUS message to ${this._peer._socket.remoteAddress}:${
// @ts-ignore
this._peer._socket.remotePort
`Send STATUS message to ${this._peer['_socket'].remoteAddress}:${
this._peer['_socket'].remotePort
} (eth${this._version}): ${this._getStatusString(this._status)}`
)
}

let payload = RLP.encode(this._status)

// Use snappy compression if peer supports DevP2P >=v5
// @ts-ignore
if (this._peer._hello !== null && this._peer._hello.protocolVersion >= 5) {
if (this._peer['_hello'] !== null && this._peer['_hello'].protocolVersion >= 5) {
payload = snappy.compress(payload)
}

Expand All @@ -329,8 +320,7 @@ export class ETH extends Protocol {
if (this.DEBUG) {
const logData = formatLogData(bytesToHex(RLP.encode(payload)), this._verbose)
const messageName = this.getMsgPrefix(code)
// @ts-ignore
const debugMsg = `Send ${messageName} message to ${this._peer._socket.remoteAddress}:${this._peer._socket.remotePort}: ${logData}`
const debugMsg = `Send ${messageName} message to ${this._peer['_socket'].remoteAddress}:${this._peer['_socket'].remotePort}: ${logData}`

this.debug(messageName, debugMsg)
}
Expand Down Expand Up @@ -372,8 +362,7 @@ export class ETH extends Protocol {
payload = RLP.encode(payload)

// Use snappy compression if peer supports DevP2P >=v5
// @ts-ignore
if (this._peer._hello !== null && this._peer._hello.protocolVersion >= 5) {
if (this._peer['_hello'] !== null && this._peer['_hello'].protocolVersion >= 5) {
payload = snappy.compress(payload)
}

Expand Down
31 changes: 10 additions & 21 deletions packages/devp2p/src/protocol/les.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ export class LES extends Protocol {
this.debug(
this.getMsgPrefix(code),
`${`Received ${this.getMsgPrefix(code)} message from ${
(<any>this._peer)._socket.remoteAddress
}:${
// @ts-ignore
this._peer._socket.remotePort
}`}: ${logData}`
this._peer['_socket'].remoteAddress
}:${this._peer['_socket'].remotePort}`}: ${logData}`
)
}
}
Expand All @@ -75,10 +72,8 @@ export class LES extends Protocol {
this.debug(
this.getMsgPrefix(code),
`${`Received ${this.getMsgPrefix(code)} message from ${
// @ts-ignore
this._peer._socket.remoteAddress
// @ts-ignore
}:${this._peer._socket.remotePort}`}: ${this._getStatusString(this._peerStatus)}`
this._peer['_socket'].remoteAddress
}:${this._peer['_socket'].remotePort}`}: ${this._getStatusString(this._peerStatus)}`
)
}
this._handleStatus()
Expand Down Expand Up @@ -201,19 +196,16 @@ export class LES extends Protocol {
if (this.DEBUG) {
this.debug(
'STATUS',
// @ts-ignore
`Send STATUS message to ${this._peer._socket.remoteAddress}:${
// @ts-ignore
this._peer._socket.remotePort
`Send STATUS message to ${this._peer['_socket'].remoteAddress}:${
this._peer['_socket'].remotePort
} (les${this._version}): ${this._getStatusString(this._status)}`
)
}

let payload = RLP.encode(statusList)

// Use snappy compression if peer supports DevP2P >=v5
// @ts-ignore
if (this._peer._hello !== null && this._peer._hello.protocolVersion >= 5) {
if (this._peer['_hello'] !== null && this._peer['_hello'].protocolVersion >= 5) {
payload = snappy.compress(payload)
}

Expand All @@ -230,10 +222,8 @@ export class LES extends Protocol {
if (this.DEBUG) {
this.debug(
this.getMsgPrefix(code),
// @ts-ignore
`Send ${this.getMsgPrefix(code)} message to ${this._peer._socket.remoteAddress}:${
// @ts-ignore
this._peer._socket.remotePort
`Send ${this.getMsgPrefix(code)} message to ${this._peer['_socket'].remoteAddress}:${
this._peer['_socket'].remotePort
}: ${formatLogData(bytesToHex(RLP.encode(payload)), this._verbose)}`
)
}
Expand Down Expand Up @@ -278,8 +268,7 @@ export class LES extends Protocol {
payload = RLP.encode(payload)

// Use snappy compression if peer supports DevP2P >=v5
// @ts-ignore
if (this._peer._hello !== null && this._peer._hello.protocolVersion >= 5) {
if (this._peer['_hello'] !== null && this._peer['_hello'].protocolVersion >= 5) {
payload = snappy.compress(payload)
}

Expand Down
10 changes: 4 additions & 6 deletions packages/devp2p/src/protocol/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export abstract class Protocol {
}

// Remote Peer IP logger
// @ts-ignore
const ip = this._peer._socket.remoteAddress

const ip = this._peer['_socket'].remoteAddress
if (typeof ip === 'string') {
this.msgDebuggers[ip] = devp2pDebug.extend(ip)
}
Expand All @@ -77,8 +77,7 @@ export abstract class Protocol {
* Can be used together with the `devp2p:FIRST_PEER` debugger.
*/
_addFirstPeerDebugger() {
// @ts-ignore
const ip = this._peer._socket.remoteAddress
const ip = this._peer['_socket'].remoteAddress
if (typeof ip === 'string') {
this.msgDebuggers[ip] = devp2pDebug.extend('FIRST_PEER')
this._peer._addFirstPeerDebugger()
Expand All @@ -98,8 +97,7 @@ export abstract class Protocol {
this.msgDebuggers[messageName](msg)
}

// @ts-ignore
const ip = this._peer._socket.remoteAddress
const ip = this._peer['_socket'].remoteAddress
if (typeof ip === 'string' && this.msgDebuggers[ip] !== undefined) {
this.msgDebuggers[ip](msg)
}
Expand Down
Loading

0 comments on commit 6278715

Please sign in to comment.