Skip to content

Commit

Permalink
Cleanup the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Oct 10, 2023
1 parent 5c85157 commit 274cc19
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 230 deletions.
1 change: 1 addition & 0 deletions packages/beacon-node/.mocharc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ require:
- ./test/setupPreset.ts
- ./test/setup.ts
timeout: 5000
exit: true
extension: ["ts"]
node-option:
- "loader=ts-node/esm"
3 changes: 0 additions & 3 deletions packages/beacon-node/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,13 @@ export function getValidatorApi({
produceBlindedBlock,

async produceAttestationData(committeeIndex, slot) {
console.log("%%%%%% produceAttestationData");
notWhileSyncing();
console.log("%%%%%% produceAttestationData 2");

await waitForSlot(slot); // Must never request for a future slot > currentSlot

// This needs a state in the same epoch as `slot` such that state.currentJustifiedCheckpoint is correct.
// Note: This may trigger an epoch transition if there skipped slots at the beginning of the epoch.
const headState = chain.getHeadState();
console.log({chain, headState});
const headSlot = headState.slot;
const attEpoch = computeEpochAtSlot(slot);
const headBlockRootHex = chain.forkChoice.getHead().blockRoot;
Expand Down
4 changes: 0 additions & 4 deletions packages/beacon-node/src/network/peers/peerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,17 +639,14 @@ export class PeerManager {

private async disconnect(peer: PeerId): Promise<void> {
try {
this.logger.info("Disconnecting peer", {peer: prettyPrintPeerId(peer)});
await this.libp2p.hangUp(peer);
this.logger.info("Disconnected", {peer: prettyPrintPeerId(peer)});
} catch (e) {
this.logger.debug("Unclean disconnect", {peer: prettyPrintPeerId(peer)}, e as Error);
}
}

private async goodbyeAndDisconnect(peer: PeerId, goodbye: GoodByeReasonCode): Promise<void> {
try {
this.logger.info("Sending goodbye", {peer: prettyPrintPeerId(peer), goodbye});
const reason = GOODBYE_KNOWN_CODES[goodbye.toString()] || "";
this.metrics?.peerGoodbyeSent.inc({reason});

Expand All @@ -660,7 +657,6 @@ export class PeerManager {

// Wrap with shorter timeout than regular ReqResp requests to speed up shutdown
await withTimeout(() => this.reqResp.sendGoodbye(peer, BigInt(goodbye)), 1_000);
this.logger.info("Sent goodbye", {peer: prettyPrintPeerId(peer), goodbye});
} catch (e) {
this.logger.verbose("Failed to send goodbye", {peer: prettyPrintPeerId(peer)}, e as Error);
} finally {
Expand Down
69 changes: 0 additions & 69 deletions packages/beacon-node/test/e2e/network/gossipsub-without-mocha.ts

This file was deleted.

11 changes: 0 additions & 11 deletions packages/beacon-node/test/e2e/network/test-libp2p.js

This file was deleted.

51 changes: 0 additions & 51 deletions packages/beacon-node/test/e2e/network/test-main-process.js

This file was deleted.

31 changes: 0 additions & 31 deletions packages/beacon-node/test/e2e/network/test-server.js

This file was deleted.

45 changes: 0 additions & 45 deletions packages/beacon-node/test/e2e/network/test-theads.js

This file was deleted.

32 changes: 16 additions & 16 deletions packages/logger/src/utils/consoleTransport.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Logger, transports} from "winston";
// import {LEVEL, LogLevel, WinstonLogInfo} from "../interface.js";
import {LEVEL, LogLevel, WinstonLogInfo} from "../interface.js";
import {LogLevel} from "../interface.js";

export class ConsoleDynamicLevel extends transports.Console {
Expand All @@ -16,7 +16,7 @@ export class ConsoleDynamicLevel extends transports.Console {
this.defaultLevel = opts.defaultLevel;

// Set level and parent to undefined so that underlying transport logs everything
// this.level = undefined;
this.level = undefined;
}

setModuleLevel(module: string, level: LogLevel): void {
Expand All @@ -27,21 +27,21 @@ export class ConsoleDynamicLevel extends transports.Console {
return this.levelByModule.delete(module);
}

// _write(info: WinstonLogInfo, enc: BufferEncoding, callback: (error?: Error | null | undefined) => void): void {
// const moduleLevel = this.levelByModule.get(info.module) ?? this.defaultLevel;
_write(info: WinstonLogInfo, enc: BufferEncoding, callback: (error?: Error | null | undefined) => void): void {
const moduleLevel = this.levelByModule.get(info.module) ?? this.defaultLevel;

// // Min number is highest prio log level
// // levels = {error: 0, warn: 1, info: 2, ...}
// Min number is highest prio log level
// levels = {error: 0, warn: 1, info: 2, ...}

// if (this.levels[moduleLevel] >= this.levels[info[LEVEL]]) {
// // Set level and parent to undefined so that underlying transport logs everything
// if (this.parent) {
// this.parent = undefined;
// }
if (this.levels[moduleLevel] >= this.levels[info[LEVEL]]) {
// Set level and parent to undefined so that underlying transport logs everything
if (this.parent) {
this.parent = undefined;
}

// super._write(info, enc, callback);
// } else {
// callback(null);
// }
// }
super._write(info, enc, callback);
} else {
callback(null);
}
}
}

0 comments on commit 274cc19

Please sign in to comment.