-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Move winston NodeJS transports to cli package #4509
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d6a7074
Move winston NodeJS transports to cli package
dapplion 1d9c4c0
Remove old profile test
dapplion 05c9927
Fix types in beacon-node test
dapplion 7015955
Remove logger.important usage
dapplion 8daf7b4
Use function constructor
dapplion d515e94
Enable customization of logLevel per module
dapplion c164d45
Don't mutate module on print
dapplion f6ed549
Update logger options
dapplion 99be395
Update logger cli tests
dapplion f2bb891
Remove dynamic log level test
dapplion 7bb31b3
Check-types
dapplion c844ba9
Remove legacy item
dapplion 5c80c02
Use LoggerModule for vmon
dapplion File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import {expect} from "chai"; | ||
import {config} from "@lodestar/config/default"; | ||
import {fromHexString} from "@chainsafe/ssz"; | ||
import {allForks, phase0, ssz} from "@lodestar/types"; | ||
import {ssz} from "@lodestar/types"; | ||
import {BeaconDb} from "../../../../../../src/db/index.js"; | ||
import {generateSignedBlock} from "../../../../../utils/block.js"; | ||
import {testLogger} from "../../../../../utils/logger.js"; | ||
import {BlockArchiveBatchPutBinaryItem} from "../../../../../../src/db/repositories/index.js"; | ||
import {startTmpBeaconDb} from "../../../../../utils/db.js"; | ||
|
||
describe("BlockArchiveRepository", function () { | ||
|
@@ -70,49 +69,4 @@ describe("BlockArchiveRepository", function () { | |
savedBlock2.message.slot = sampleBlock.message.slot; | ||
expect(ssz.phase0.SignedBeaconBlock.equals(savedBlock1, savedBlock2)).to.equal(true); | ||
}); | ||
|
||
it("batchPutBinary should be faster than batchPut", async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a test but a very old performance test with winston profiler. Removed as it's not even tracked |
||
// increase length to test performance | ||
const signedBlocks = Array.from({length: 1000}, (_, i) => { | ||
const signedBlock = sampleBlock; | ||
signedBlock.message.slot = i; | ||
return signedBlock; | ||
}); | ||
// persist to block db | ||
await Promise.all(signedBlocks.map((signedBlock: phase0.SignedBeaconBlock) => db.block.add(signedBlock))); | ||
const blockSummaries = signedBlocks.map(toBatchPutBinaryItem); | ||
// old way | ||
logger.profile("batchPut"); | ||
const savedBlocks = notNull( | ||
await Promise.all(blockSummaries.map((summary) => db.block.get(summary.blockRoot as Uint8Array))) | ||
); | ||
await db.blockArchive.batchPut(savedBlocks.map((block) => ({key: block.message.slot, value: block}))); | ||
logger.profile("batchPut"); | ||
logger.profile("batchPutBinary"); | ||
const blockBinaries = notNull( | ||
await Promise.all(blockSummaries.map((summary) => db.block.getBinary(summary.blockRoot as Uint8Array))) | ||
); | ||
await db.blockArchive.batchPutBinary( | ||
blockSummaries.map((summary, i) => ({ | ||
...summary, | ||
value: blockBinaries[i], | ||
})) | ||
); | ||
logger.profile("batchPutBinary"); | ||
}); | ||
}); | ||
|
||
function notNull<T>(arr: (T | null)[]): T[] { | ||
for (const item of arr) if (item === null) throw Error("null item"); | ||
return arr as T[]; | ||
} | ||
|
||
function toBatchPutBinaryItem(signedBlock: allForks.SignedBeaconBlock): BlockArchiveBatchPutBinaryItem { | ||
return { | ||
key: signedBlock.message.slot, | ||
value: ssz.phase0.SignedBeaconBlock.serialize(signedBlock) as Buffer, | ||
slot: signedBlock.message.slot, | ||
blockRoot: config.getForkTypes(signedBlock.message.slot).BeaconBlock.hashTreeRoot(signedBlock.message), | ||
parentRoot: signedBlock.message.parentRoot, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import {config} from "@lodestar/config/default"; | ||
import {ssz} from "@lodestar/types"; | ||
import {WinstonLogger} from "@lodestar/utils"; | ||
import {createMetrics, IMetrics} from "../../../src/metrics/index.js"; | ||
import {testLogger} from "../../utils/logger.js"; | ||
|
||
export function createMetricsTest(): IMetrics { | ||
const state = ssz.phase0.BeaconState.defaultViewDU(); | ||
const logger = new WinstonLogger(); | ||
const logger = testLogger(); | ||
return createMetrics({enabled: true, port: 0}, config, state, logger); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.important API is not used anymore in production and forces creators of custom loggers to add it