Skip to content

Commit

Permalink
Merge branch 'master' into devnet8-engine
Browse files Browse the repository at this point in the history
  • Loading branch information
acolytec3 committed Jul 21, 2023
2 parents 7e8beec + d19ee0e commit b3e6df3
Show file tree
Hide file tree
Showing 41 changed files with 991 additions and 1,126 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/client-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ jobs:
with:
timeout_minutes: 10
max_attempts: 3
command: cd ${{github.workspace}}/packages/client && npx vitest run test/integration/cli.spec.ts
command: cd ${{github.workspace}}/packages/client && npx vitest run test/cli/cli
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/client/src/net/peer/rlpxpeer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ export class RlpxPeer extends Peer {
this.rlpxPeer = null
this.connected = false
this.config.events.emit(Event.PEER_DISCONNECTED, this)
this.rlpx?.removeListener('peer:error', peerErrorHandlerBound)
this.rlpx?.events.removeListener('peer:error', peerErrorHandlerBound)
}
this.rlpx.on('peer:error', peerErrorHandlerBound)
this.rlpx.once('peer:added', peerAddedHandler.bind(this))
this.rlpx.once('peer:removed', peerRemovedHandler.bind(this))
this.rlpx.events.on('peer:error', peerErrorHandlerBound)
this.rlpx.events.once('peer:added', peerAddedHandler.bind(this))
this.rlpx.events.once('peer:removed', peerRemovedHandler.bind(this))
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/net/protocol/rlpxsender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export class RlpxSender extends Sender {
super()

this.sender = rlpxProtocol
this.sender.on('status', (status: any) => {
this.sender.events.on('status', (status: any) => {
this.status = status
})
this.sender.on('message', (code: number, payload: any) => {
this.sender.events.on('message', (code: number, payload: any) => {
this.emit('message', { code, payload })
})
}
Expand Down
16 changes: 9 additions & 7 deletions packages/client/src/net/server/rlpxserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ export class RlpxServer extends Server {
dnsAddr: this.config.dnsAddr,
})

this.dpt.on('error', (e: Error) => this.error(e))
this.dpt.events.on('error', (e: Error) => this.error(e))

this.dpt.on('listening', () => {
this.dpt.events.on('listening', () => {
resolve()
})

Expand All @@ -250,7 +250,7 @@ export class RlpxServer extends Server {
common: this.config.chainCommon,
})

this.rlpx.on('peer:added', async (rlpxPeer: Devp2pRLPxPeer) => {
this.rlpx.events.on('peer:added', async (rlpxPeer: Devp2pRLPxPeer) => {
let peer: RlpxPeer | null = new RlpxPeer({
config: this.config,
id: bytesToUnprefixedHex(rlpxPeer.getId()!),
Expand All @@ -276,7 +276,7 @@ export class RlpxServer extends Server {
}
})

this.rlpx.on('peer:removed', (rlpxPeer: Devp2pRLPxPeer, reason: any) => {
this.rlpx.events.on('peer:removed', (rlpxPeer: Devp2pRLPxPeer, reason: any) => {
const id = bytesToUnprefixedHex(rlpxPeer.getId() as Uint8Array)
const peer = this.peers.get(id)
if (peer) {
Expand All @@ -288,11 +288,13 @@ export class RlpxServer extends Server {
}
})

this.rlpx.on('peer:error', (rlpxPeer: Devp2pRLPxPeer, error: Error) => this.error(error))
this.rlpx.events.on('peer:error', (rlpxPeer: Devp2pRLPxPeer, error: Error) =>
this.error(error)
)

this.rlpx.on('error', (e: Error) => this.error(e))
this.rlpx.events.on('error', (e: Error) => this.error(e))

this.rlpx.on('listening', () => {
this.rlpx.events.on('listening', () => {
this.config.events.emit(Event.SERVER_LISTENING, {
transport: this.name,
url: this.getRlpxInfo().enode ?? '',
Expand Down
9 changes: 5 additions & 4 deletions packages/client/src/util/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { json as jsonParser } from 'body-parser'
import Connect from 'connect'
import cors from 'cors'
import { createServer } from 'http'
import { Server as RPCServer } from 'jayson/promise'
import { decode } from 'jwt-simple'
Expand All @@ -12,6 +10,9 @@ import type { IncomingMessage } from 'connect'
import type { HttpServer } from 'jayson/promise'
import type { TAlgorithm } from 'jwt-simple'

const Connect = require('connect')
const cors = require('cors')

const algorithm: TAlgorithm = 'HS256'

type CreateRPCServerOpts = {
Expand Down Expand Up @@ -164,14 +165,14 @@ function checkHeaderAuth(req: any, jwtSecret: Uint8Array): void {
export function createRPCServerListener(opts: CreateRPCServerListenerOpts): HttpServer {
const { server, withEngineMiddleware, rpcCors } = opts

const app = Connect()
const app = Connect() as any
if (typeof rpcCors === 'string') app.use(cors({ origin: rpcCors }))
// GOSSIP_MAX_SIZE_BELLATRIX is proposed to be 10MiB
app.use(jsonParser({ limit: '11mb' }))

if (withEngineMiddleware) {
const { jwtSecret, unlessFn } = withEngineMiddleware
app.use((req, res, next) => {
app.use((req: any, res: any, next: any) => {
try {
if (unlessFn && unlessFn(req)) return next()
checkHeaderAuth(req, jwtSecret)
Expand Down
92 changes: 0 additions & 92 deletions packages/client/test/cli/cli-rpc.spec.ts

This file was deleted.

61 changes: 0 additions & 61 deletions packages/client/test/cli/cli-sync.spec.ts

This file was deleted.

Loading

0 comments on commit b3e6df3

Please sign in to comment.